ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/shop.C
(Generate patch)

Comparing deliantra/server/server/shop.C (file contents):
Revision 1.38 by root, Mon Jun 4 12:19:09 2007 UTC vs.
Revision 1.39 by root, Mon Jun 4 13:04:00 2007 UTC

131 if (tmp->arch != NULL) 131 if (tmp->arch != NULL)
132 { 132 {
133 if (flag == F_BUY) 133 if (flag == F_BUY)
134 { 134 {
135 LOG (llevError, "Asking for buy-value of unidentified object.\n"); 135 LOG (llevError, "Asking for buy-value of unidentified object.\n");
136 val = tmp->arch->clone.value * 50 * number; 136 val = tmp->arch->value * 50 * number;
137 } 137 }
138 else 138 else
139 { /* Trying to sell something, or get true value */ 139 { /* Trying to sell something, or get true value */
140 if (tmp->type == POTION) 140 if (tmp->type == POTION)
141 val = number * 40; /* Don't want to give anything away */ 141 val = number * 40; /* Don't want to give anything away */
143 { 143 {
144 /* Get 2/3'rd value for applied objects, 1/3'rd for totally 144 /* Get 2/3'rd value for applied objects, 1/3'rd for totally
145 * unknown objects 145 * unknown objects
146 */ 146 */
147 if (QUERY_FLAG (tmp, FLAG_BEEN_APPLIED)) 147 if (QUERY_FLAG (tmp, FLAG_BEEN_APPLIED))
148 val = number * tmp->arch->clone.value * 2 / 3; 148 val = number * tmp->arch->value * 2 / 3;
149 else 149 else
150 val = number * tmp->arch->clone.value / 3; 150 val = number * tmp->arch->value / 3;
151 } 151 }
152 } 152 }
153 } 153 }
154 else 154 else
155 { /* No archetype with this object */ 155 { /* No archetype with this object */
166 166
167 /* If the item has been applied or identifed or does not need to be 167 /* If the item has been applied or identifed or does not need to be
168 * identified, AND the object is magical and the archetype is non 168 * identified, AND the object is magical and the archetype is non
169 * magical, then change values accordingly. The tmp->arch==NULL is 169 * magical, then change values accordingly. The tmp->arch==NULL is
170 * really just a check to prevent core dumps for when it checks 170 * really just a check to prevent core dumps for when it checks
171 * tmp->arch->clone.magic for any magic. The check for archetype 171 * tmp->arch->magic for any magic. The check for archetype
172 * magic is to not give extra money for archetypes that are by 172 * magic is to not give extra money for archetypes that are by
173 * default magical. This is because the archetype value should have 173 * default magical. This is because the archetype value should have
174 * already figured in that value. 174 * already figured in that value.
175 */ 175 */
176 if ((QUERY_FLAG (tmp, FLAG_IDENTIFIED) || !need_identify (tmp) || identified || 176 if ((QUERY_FLAG (tmp, FLAG_IDENTIFIED) || !need_identify (tmp) || identified ||
177 QUERY_FLAG (tmp, FLAG_BEEN_APPLIED)) && tmp->magic && (tmp->arch == NULL || !tmp->arch->clone.magic)) 177 QUERY_FLAG (tmp, FLAG_BEEN_APPLIED)) && tmp->magic && (tmp->arch == NULL || !tmp->arch->magic))
178 { 178 {
179 if (tmp->magic > 0) 179 if (tmp->magic > 0)
180 val *= (3 * tmp->magic * tmp->magic * tmp->magic); 180 val *= (3 * tmp->magic * tmp->magic * tmp->magic);
181 else 181 else
182 /* Note that tmp->magic is negative, so that this 182 /* Note that tmp->magic is negative, so that this
332 coin = archetype::find (coins[*cointype]); 332 coin = archetype::find (coins[*cointype]);
333 if (coin == NULL) 333 if (coin == NULL)
334 return NULL; 334 return NULL;
335 *cointype += 1; 335 *cointype += 1;
336 } 336 }
337 while (coin->clone.value > c); 337 while (coin->value > c);
338 338
339 return coin; 339 return coin;
340} 340}
341 341
342/* This returns a string of how much something is worth based on 342/* This returns a string of how much something is worth based on
358 358
359 coin = find_next_coin (cost, &cointype); 359 coin = find_next_coin (cost, &cointype);
360 if (coin == NULL) 360 if (coin == NULL)
361 return "nothing"; 361 return "nothing";
362 362
363 num = cost / coin->clone.value; 363 num = cost / coin->value;
364 /* so long as nrof is 32 bit, this is true. 364 /* so long as nrof is 32 bit, this is true.
365 * If it takes more coins than a person can possibly carry, this 365 * If it takes more coins than a person can possibly carry, this
366 * is basically true. 366 * is basically true.
367 */ 367 */
368 if ((cost / coin->clone.value) > UINT32_MAX) 368 if ((cost / coin->value) > UINT32_MAX)
369 { 369 {
370 strcpy (buf, "an unimaginable sum of money"); 370 strcpy (buf, "an unimaginable sum of money");
371 return buf; 371 return buf;
372 } 372 }
373 373
374 cost -= num * (sint64)coin->clone.value; 374 cost -= num * (sint64)coin->value;
375 375
376 sprintf (buf, "%d %s", num, num > 1 ? &coin->clone.name_pl : &coin->clone.name); 376 sprintf (buf, "%d %s", num, num > 1 ? &coin->object::name_pl : &coin->object::name);
377 377
378 next_coin = find_next_coin (cost, &cointype); 378 next_coin = find_next_coin (cost, &cointype);
379 if (next_coin == NULL || approx) 379 if (next_coin == NULL || approx)
380 return buf; 380 return buf;
381 381
382 coin = next_coin; 382 coin = next_coin;
383 num = cost / coin->clone.value; 383 num = cost / coin->value;
384 cost -= num * (sint64)coin->clone.value; 384 cost -= num * (sint64)coin->value;
385 385
386 sprintf (buf + strlen (buf), " and %d %s", num, num > 1 ? &coin->clone.name_pl : &coin->clone.name); 386 sprintf (buf + strlen (buf), " and %d %s", num, num > 1 ? &coin->object::name_pl : &coin->object::name);
387 387
388 return buf; 388 return buf;
389} 389}
390 390
391const char * 391const char *
421 archetype *coin = find_next_coin (real_value, &cointype); 421 archetype *coin = find_next_coin (real_value, &cointype);
422 422
423 if (coin == NULL) 423 if (coin == NULL)
424 return "nothing"; 424 return "nothing";
425 425
426 num = real_value / coin->clone.value; 426 num = real_value / coin->value;
427 if (num == 1) 427 if (num == 1)
428 sprintf (buf, "about one %s", &coin->clone.name); 428 sprintf (buf, "about one %s", &coin->object::name);
429 else if (num < 5) 429 else if (num < 5)
430 sprintf (buf, "a few %s", &coin->clone.name_pl); 430 sprintf (buf, "a few %s", &coin->object::name_pl);
431 else if (num < 10) 431 else if (num < 10)
432 sprintf (buf, "several %s", &coin->clone.name_pl); 432 sprintf (buf, "several %s", &coin->object::name_pl);
433 else if (num < 25) 433 else if (num < 25)
434 sprintf (buf, "a moderate amount of %s", &coin->clone.name_pl); 434 sprintf (buf, "a moderate amount of %s", &coin->object::name_pl);
435 else if (num < 100) 435 else if (num < 100)
436 sprintf (buf, "lots of %s", &coin->clone.name_pl); 436 sprintf (buf, "lots of %s", &coin->object::name_pl);
437 else if (num < 1000) 437 else if (num < 1000)
438 sprintf (buf, "a great many %s", &coin->clone.name_pl); 438 sprintf (buf, "a great many %s", &coin->object::name_pl);
439 else 439 else
440 sprintf (buf, "a vast quantity of %s", &coin->clone.name_pl); 440 sprintf (buf, "a vast quantity of %s", &coin->object::name_pl);
441 return buf; 441 return buf;
442 } 442 }
443 } 443 }
444 } 444 }
445 445
581 581
582 if (tmp->type == MONEY) 582 if (tmp->type == MONEY)
583 { 583 {
584 for (i = 0; i < NUM_COINS; i++) 584 for (i = 0; i < NUM_COINS; i++)
585 { 585 {
586 if (tmp->value == tmp->arch->clone.value && !strcmp (coins[NUM_COINS - 1 - i], tmp->arch->archname)) 586 if (tmp->value == tmp->arch->value && !strcmp (coins[NUM_COINS - 1 - i], tmp->arch->archname))
587 { 587 {
588 // This should not happen, but if it does, just merge the two. 588 // This should not happen, but if it does, just merge the two.
589 if (coin_objs [i]) 589 if (coin_objs [i])
590 { 590 {
591 LOG (llevError, "%s has two money entries of (%s)\n", &pouch->name, coins[NUM_COINS - 1 - i]); 591 LOG (llevError, "%s has two money entries of (%s)\n", &pouch->name, coins[NUM_COINS - 1 - i]);
793 { 793 {
794 at = archetype::find (coins[count]); 794 at = archetype::find (coins[count]);
795 795
796 if (at == NULL) 796 if (at == NULL)
797 LOG (llevError, "Could not find %s archetype\n", coins[count]); 797 LOG (llevError, "Could not find %s archetype\n", coins[count]);
798 else if ((amount / at->clone.value) > 0) 798 else if ((amount / at->value) > 0)
799 { 799 {
800 for (pouch = pl->inv; pouch; pouch = pouch->below) 800 for (pouch = pl->inv; pouch; pouch = pouch->below)
801 { 801 {
802 if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && pouch->race && strstr (pouch->race, "gold")) 802 if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && pouch->race && strstr (pouch->race, "gold"))
803 { 803 {
804 int w = at->clone.weight * (100 - pouch->stats.Str) / 100; 804 int w = at->weight * (100 - pouch->stats.Str) / 100;
805 int n = amount / at->clone.value; 805 int n = amount / at->value;
806 806
807 if (w == 0) 807 if (w == 0)
808 w = 1; /* Prevent divide by zero */ 808 w = 1; /* Prevent divide by zero */
809 809
810 if (n > 0 && (!pouch->weight_limit || pouch->carrying + w <= pouch->weight_limit)) 810 if (n > 0 && (!pouch->weight_limit || pouch->carrying + w <= pouch->weight_limit))
822 esrv_send_item (pl, pl); 822 esrv_send_item (pl, pl);
823 } 823 }
824 } 824 }
825 } 825 }
826 826
827 if (amount / at->clone.value > 0) 827 if (amount / at->value > 0)
828 { 828 {
829 tmp = arch_to_object (at); 829 tmp = arch_to_object (at);
830 tmp->nrof = amount / tmp->value; 830 tmp->nrof = amount / tmp->value;
831 amount -= tmp->nrof * tmp->value; 831 amount -= tmp->nrof * tmp->value;
832 tmp = insert_ob_in_ob (tmp, pl); 832 tmp = insert_ob_in_ob (tmp, pl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines