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.80 by root, Wed Apr 28 19:01:01 2010 UTC vs.
Revision 1.92 by root, Mon Oct 29 23:55:55 2012 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <spells.h> 26#include <spells.h>
79 int no_bargain; 79 int no_bargain;
80 int identified; 80 int identified;
81 int not_cursed; 81 int not_cursed;
82 int approximate; 82 int approximate;
83 int shop; 83 int shop;
84 double diff;
85 84
86 approx_range = 0; 85 approx_range = 0;
87 86
88 no_bargain = flag & F_NO_BARGAIN; 87 no_bargain = flag & F_NO_BARGAIN;
89 identified = flag & F_IDENTIFIED; 88 identified = flag & F_IDENTIFIED;
170 /* Value of the wand is multiplied by the number of 169 /* Value of the wand is multiplied by the number of
171 * charges. the treasure code already sets up the value 170 * charges. the treasure code already sets up the value
172 * 50 charges is used as the baseline. 171 * 50 charges is used as the baseline.
173 */ 172 */
174 if (tmp->flag [FLAG_IDENTIFIED] || !tmp->need_identify () || identified) 173 if (tmp->flag [FLAG_IDENTIFIED] || !tmp->need_identify () || identified)
175 val *= tmp->stats.food / 50; 174 val *= tmp->stats.food;
176 else /* if not identified, presume one charge */ 175 /* if not identified, presume one charge */
177 val /= 50; 176 val /= 50;
178 } 177 }
179 178
180 /* Limit amount of money you can get for really great items. */ 179 /* Limit amount of money you can get for really great items. */
181 if (flag == F_SELL) 180 if (flag == F_SELL)
182 val = value_limit (val, number, who, shop); 181 val = value_limit (val, number, who, shop);
190 * AND Cha = 30 will get optimal price. 189 * AND Cha = 30 will get optimal price.
191 * Thus charisma will never get useless. 190 * Thus charisma will never get useless.
192 * -b.e. edler@heydernet.de 191 * -b.e. edler@heydernet.de
193 */ 192 */
194 193
195 if (who && who->type == PLAYER) 194 if (who && who->is_player ())
196 { 195 {
197 int lev_bargain = 0; 196 int lev_bargain = 0;
198 int lev_identify = 0; 197 int lev_identify = 0;
199 198
200 if (find_skill_by_number (who, SK_BARGAINING)) 199 if (!no_bargain)
201 lev_bargain = find_skill_by_number (who, SK_BARGAINING)->level; 200 if (object *skill = find_skill_by_name (who, shstr_bargaining))
201 lev_bargain = skill->level;
202 202
203 if (const typedata *tmptype = get_typedata (tmp->type)) 203 if (const typedata *tmptype = get_typedata (tmp->type))
204 { 204 {
205 if (int idskill1 = tmptype->identifyskill) 205 if (int idskill1 = tmptype->identifyskill)
206 { 206 {
217 /* ratio determines how much of the price modification 217 /* ratio determines how much of the price modification
218 * will come from the basic stat charisma 218 * will come from the basic stat charisma
219 * the rest will come from the level in bargaining skill 219 * the rest will come from the level in bargaining skill
220 */ 220 */
221 const double cha_ratio = 0.40; 221 const double cha_ratio = 0.40;
222 222 double bargaining = max (0., 1. - powf (double (lev_bargain) / MAXLEVEL_TREASURE, 0.25));
223 diff = no_bargain ? 1.0 : 1. - pow (lev_bargain / MAXLEVEL_TREASURE, 0.25);
224 diff = (1. - cha_ratio) * diff + cha_ratio * (cha_bonus[who->stats.Cha] - 1.) / (cha_bonus[who->stats.Cha] + 1.); 223 double charisma = (cha_bonus[who->stats.Cha] - 1.) / (cha_bonus[who->stats.Cha] + 1.);
225 diff = .02 + (.80 - .02) * diff; 224
225 double factor = (1. - cha_ratio) * bargaining + cha_ratio * charisma;
226
227 // scale 0..1 to 2 .. 80%
228 factor = lerp (factor, 0., 1., 0.02, 0.80);
226 229
227 if (flag == F_BUY) 230 if (flag == F_BUY)
228 val += val * diff; 231 val += val * factor;
229 else if (flag == F_SELL) 232 else if (flag == F_SELL)
230 val -= val * diff; 233 val -= val * factor;
231 234
232 // now find a price range. the less good we can judge, the larger the range is 235 // now find a price range. the less good we can judge, the larger the range is
233 // then the range is adjusted randomly around the correct value 236 // then the range is adjusted randomly around the correct value
234 if (approximate) 237 if (approximate)
235 approx_range = val / sqrt (lev_identify * 3 + 1); 238 approx_range = val / sqrt (lev_identify * 3 + 1);
324 * 10,000 silver or something) 327 * 10,000 silver or something)
325 */ 328 */
326const char * 329const char *
327cost_string_from_value (sint64 cost, int approx) 330cost_string_from_value (sint64 cost, int approx)
328{ 331{
329 static char buf[MAX_BUF];
330 archetype *coin, *next_coin; 332 archetype *coin, *next_coin;
331 int num, cointype = 0; 333 int num, cointype = 0;
332 334
333 coin = find_next_coin (cost, &cointype); 335 coin = find_next_coin (cost, &cointype);
334 if (coin == NULL) 336 if (!coin)
335 return "nothing"; 337 return "nothing";
336 338
337 num = cost / coin->value; 339 num = cost / coin->value;
338 /* so long as nrof is 32 bit, this is true. 340 /* so long as nrof is 32 bit, this is true.
339 * If it takes more coins than a person can possibly carry, this 341 * If it takes more coins than a person can possibly carry, this
340 * is basically true. 342 * is basically true.
341 */ 343 */
342 if ((cost / coin->value) > UINT32_MAX) 344 if (cost / coin->value > UINT32_MAX)
343 {
344 strcpy (buf, "an unimaginable sum of money"); 345 return "an unimaginable sum of money";
345 return buf;
346 }
347 346
348 cost -= num * (sint64)coin->value; 347 cost -= num * (sint64)coin->value;
349 348
350 sprintf (buf, "%d %s", num, num > 1 ? &coin->object::name_pl : &coin->object::name); 349 char *buf = format ("%d %s", num, num > 1 ? &coin->object::name_pl : &coin->object::name);
351 350
352 next_coin = find_next_coin (cost, &cointype); 351 next_coin = find_next_coin (cost, &cointype);
353 if (next_coin == NULL || approx) 352 if (!next_coin || approx)
354 return buf; 353 return buf;
355 354
356 coin = next_coin; 355 coin = next_coin;
357 num = cost / coin->value; 356 num = cost / coin->value;
358 cost -= num * (sint64)coin->value; 357 cost -= num * (sint64)coin->value;
359 358
360 sprintf (buf + strlen (buf), " and %d %s", num, num > 1 ? &coin->object::name_pl : &coin->object::name); 359 return format ("%s and %d %s", buf, num, num > 1 ? &coin->object::name_pl : &coin->object::name);
361
362 return buf;
363} 360}
364 361
365const char * 362const char *
366query_cost_string (const object *tmp, object *who, int flag) 363query_cost_string (const object *tmp, object *who, int flag)
367{ 364{
386 { 383 {
387 if (!idskill1 || !find_skill_by_number (who, idskill1)) 384 if (!idskill1 || !find_skill_by_number (who, idskill1))
388 { 385 {
389 if (!idskill2 || !find_skill_by_number (who, idskill2)) 386 if (!idskill2 || !find_skill_by_number (who, idskill2))
390 { 387 {
391 if (!find_skill_by_number (who, SK_BARGAINING)) 388 if (!find_skill_by_name (who, shstr_bargaining))
392 { 389 {
393 static char buf[MAX_BUF];
394 int num, cointype = 0; 390 int num, cointype = 0;
395 archetype *coin = find_next_coin (real_value, &cointype); 391 archetype *coin = find_next_coin (real_value, &cointype);
396 392
397 if (coin == NULL) 393 if (!coin)
398 return "nothing"; 394 return "nothing";
399 395
400 num = real_value / coin->value; 396 num = real_value / coin->value;
401 397
402 if (num == 1) 398 if (num == 1)
403 sprintf (buf, "about one %s", &coin->object::name); 399 return format ("about one %s", &coin->object::name);
404 else if (num < 5) 400 else if (num < 5)
405 sprintf (buf, "a few %s", &coin->object::name_pl); 401 return format ("a few %s", &coin->object::name_pl);
406 else if (num < 10) 402 else if (num < 10)
407 sprintf (buf, "several %s", &coin->object::name_pl); 403 return format ("several %s", &coin->object::name_pl);
408 else if (num < 25) 404 else if (num < 25)
409 sprintf (buf, "a moderate amount of %s", &coin->object::name_pl); 405 return format ("a moderate amount of %s", &coin->object::name_pl);
410 else if (num < 100) 406 else if (num < 100)
411 sprintf (buf, "lots of %s", &coin->object::name_pl); 407 return format ("lots of %s", &coin->object::name_pl);
412 else if (num < 1000) 408 else if (num < 1000)
413 sprintf (buf, "a great many %s", &coin->object::name_pl); 409 return format ("a great many %s", &coin->object::name_pl);
414 else 410 else
415 sprintf (buf, "a vast quantity of %s", &coin->object::name_pl); 411 return format ("a vast quantity of %s", &coin->object::name_pl);
416
417 return buf;
418 } 412 }
419 } 413 }
420 } 414 }
421 415
422 int hash = ((unsigned int) tmp->count * 174364621) & 1023;
423
424 if (approx_range) 416 if (approx_range)
425 { 417 {
418 int hash = tmp->random_seed () & 1023;
426 sint64 lo = (sint64) real_value - (approx_range * hash >> 10); 419 sint64 lo = real_value - (approx_range * hash >> 10);
427 static char buf[MAX_BUF];
428 420
429 sprintf (buf, "between %s", cost_string_from_value (lo, 1)); 421 return format ("between %s and %s",
430 sprintf (buf + strlen (buf), " and %s", cost_string_from_value (lo + approx_range, 1)); 422 cost_string_from_value (lo, 1),
431 423 cost_string_from_value (lo + approx_range, 1));
432 return buf;
433 } 424 }
434 } 425 }
435 426
436 return cost_string_from_value (real_value, 0); 427 return cost_string_from_value (real_value, 0);
437} 428}
452 } 443 }
453 444
454 for (tmp = op->inv; tmp; tmp = tmp->below) 445 for (tmp = op->inv; tmp; tmp = tmp->below)
455 if (tmp->type == MONEY) 446 if (tmp->type == MONEY)
456 total += tmp->nrof * (sint64)tmp->value; 447 total += tmp->nrof * (sint64)tmp->value;
457 else if (tmp->type == CONTAINER && tmp->flag [FLAG_APPLIED] && (!tmp->race || tmp->race.contains ("gold"))) 448 else if (tmp->type == CONTAINER && tmp->flag [FLAG_APPLIED] && (!tmp->race || tmp->race.contains (shstr_gold)))
458 total += query_money (tmp); 449 total += query_money (tmp);
459 450
460 return total; 451 return total;
461} 452}
462 453
477 return 0; 468 return 0;
478 469
479 pay_from_container (pl, pl, to_pay); 470 pay_from_container (pl, pl, to_pay);
480 471
481 for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) 472 for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below)
482 if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains ("gold"))) 473 if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains (shstr_gold)))
483 pay_from_container (pl, pouch, to_pay); 474 pay_from_container (pl, pouch, to_pay);
484 475
485 pl->update_stats (); 476 pl->update_stats ();
486 return 1; 477 return 1;
487} 478}
509 * This determins the amount of exp (if any) gained for bargaining. 500 * This determins the amount of exp (if any) gained for bargaining.
510 */ 501 */
511 saved_money = query_cost (op, pl, F_BUY | F_NO_BARGAIN | F_SHOP) - to_pay; 502 saved_money = query_cost (op, pl, F_BUY | F_NO_BARGAIN | F_SHOP) - to_pay;
512 503
513 if (saved_money > 0) 504 if (saved_money > 0)
514 change_exp (pl, saved_money, "bargaining", SK_EXP_NONE); 505 change_exp (pl, saved_money, shstr_bargaining, SK_EXP_NONE);
515 506
516 pay_from_container (pl, pl, to_pay); 507 pay_from_container (pl, pl, to_pay);
517 508
518 for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) 509 for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below)
519 if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains ("gold"))) 510 if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains (shstr_gold)))
520 pay_from_container (pl, pouch, to_pay); 511 pay_from_container (pl, pouch, to_pay);
521 512
522 pl->update_stats (); 513 pl->update_stats ();
523 514
524 return 1; 515 return 1;
684 675
685 for (object::depth_iterator op = pl->begin (); op != pl->end (); ++op) 676 for (object::depth_iterator op = pl->begin (); op != pl->end (); ++op)
686 { 677 {
687 if (op->flag [FLAG_UNPAID]) 678 if (op->flag [FLAG_UNPAID])
688 { 679 {
689 char buf[MAX_BUF];
690 snprintf (buf, MAX_BUF, "%s", query_cost_string (op, pl, F_BUY | F_SHOP)); 680 const char *buf = query_cost_string (op, pl, F_BUY | F_SHOP);
691 681
692 if (!pay_for_item (op, pl)) 682 if (!pay_for_item (op, pl))
693 { 683 {
694 sint64 i = query_cost (op, pl, F_BUY | F_SHOP) - query_money (pl); 684 sint64 i = query_cost (op, pl, F_BUY | F_SHOP) - query_money (pl);
695 685
700 } 690 }
701 else 691 else
702 { 692 {
703 op->clr_flag (FLAG_UNPAID); 693 op->clr_flag (FLAG_UNPAID);
704 op->clr_flag (FLAG_PLAYER_SOLD); 694 op->clr_flag (FLAG_PLAYER_SOLD);
705 new_draw_info_format (NDI_UNIQUE, 0, op, "You paid %s for %s.", buf, query_name (op)); 695 new_draw_info_format (NDI_UNIQUE, 0, pl, "You paid %s for %s.", buf, query_name (op));
706 696
707 if (!merge_ob (op, op->env->inv)) 697 if (!merge_ob (op, op->env->inv))
708 esrv_update_item (UPD_FLAGS, pl, op); 698 esrv_update_item (UPD_FLAGS, pl, op);
709 699
710 goto next_item; 700 goto next_item;
730void 720void
731pay_player (object *pl, sint64 amount) 721pay_player (object *pl, sint64 amount)
732{ 722{
733 int count = 0; 723 int count = 0;
734 archetype *at = 0; 724 archetype *at = 0;
735 object *pouch = 0, *tmp = 0; 725 object *pouch = 0;
736 726
737 for (count = 0; coins[count]; count++) 727 for (count = 0; coins[count]; count++)
738 { 728 {
739 at = archetype::find (coins[count]); 729 at = archetype::find (coins[count]);
740 730
742 LOG (llevError, "Could not find %s archetype\n", coins[count]); 732 LOG (llevError, "Could not find %s archetype\n", coins[count]);
743 else if ((amount / at->value) > 0) 733 else if ((amount / at->value) > 0)
744 { 734 {
745 for (pouch = pl->inv; pouch; pouch = pouch->below) 735 for (pouch = pl->inv; pouch; pouch = pouch->below)
746 { 736 {
747 if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && pouch->race.contains ("gold")) 737 if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && pouch->race.contains (shstr_gold))
748 { 738 {
749 int w = at->weight * (100 - pouch->stats.Str) / 100; 739 int w = at->weight * (100 - pouch->stats.Str) / 100;
750 int n = amount / at->value; 740 int n = amount / at->value;
751 741
752 if (w == 0) 742 if (w == 0)
832 * exp/10 -> 1 for each gold coin 822 * exp/10 -> 1 for each gold coin
833 */ 823 */
834 extra_gain = amount - query_cost (op, pl, F_SELL | F_NO_BARGAIN | F_SHOP); 824 extra_gain = amount - query_cost (op, pl, F_SELL | F_NO_BARGAIN | F_SHOP);
835 825
836 if (extra_gain > 0) 826 if (extra_gain > 0)
837 change_exp (pl, extra_gain / 10, "bargaining", SK_EXP_NONE); 827 change_exp (pl, extra_gain / 10, shstr_bargaining, SK_EXP_NONE);
838 828
839 pay_player (pl, amount); 829 pay_player (pl, amount);
840 830
841 new_draw_info_format (NDI_UNIQUE, 0, pl, "You receive %s for %s.", 831 new_draw_info_format (NDI_UNIQUE, 0, pl, "You receive %s for %s.",
842 query_cost_string (op, pl, F_SELL | F_SHOP), query_name (op)); 832 query_cost_string (op, pl, F_SELL | F_SHOP), query_name (op));
865 return 0; 855 return 0;
866 } 856 }
867 857
868 if (!item->type) 858 if (!item->type)
869 { 859 {
870 LOG (llevError, "shop_specialisation_ratio: passed an item with an invalid type\n"); 860 LOG (llevError, "shop_specialisation_ratio: passed an item with an invalid type: %s\n", item->debug_desc ());
871 /* 861 /*
872 * I'm not really sure what the /right/ thing to do here is, these types of 862 * I'm not really sure what the /right/ thing to do here is, these types of
873 * item shouldn't exist anyway, but returning the ratio is probably the best bet.." 863 * item shouldn't exist anyway, but returning the ratio is probably the best bet.."
874 */ 864 */
875 return SPECIALISATION_EFFECT; 865 return SPECIALISATION_EFFECT;
880 if (items[i].typenum == item->type || (!items[i].typenum && !likedness)) 870 if (items[i].typenum == item->type || (!items[i].typenum && !likedness))
881 likedness = items[i].strength; 871 likedness = items[i].strength;
882 872
883 if (likedness > 100) 873 if (likedness > 100)
884 { /* someone has been rather silly with the map headers. */ 874 { /* someone has been rather silly with the map headers. */
885 LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is above 100%%\n", item->type, &map->path); 875 LOG (llevDebug, "shop_specialisation ratio: item %s on map %s is above 100%%\n", item->debug_desc (), &map->path);
886 likedness = 100; 876 likedness = 100;
887 } 877 }
888 878
889 if (likedness < -100) 879 if (likedness < -100)
890 { 880 {
891 LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, &map->path); 881 LOG (llevDebug, "shop_specialisation ratio: item %s on map %s is below -100%%\n", item->debug_desc (), &map->path);
892 likedness = -100; 882 likedness = -100;
893 } 883 }
894 884
895 return lerp (double (likedness), -100., 100., SPECIALISATION_EFFECT, 1.); 885 return lerp (double (likedness), -100., 100., SPECIALISATION_EFFECT, 1.);
896} 886}
918/* limit the value of items based on the wealth of the shop. If the item is close 908/* limit the value of items based on the wealth of the shop. If the item is close
919 * to the maximum value a shop will offer, we start to reduce it, if the item is 909 * to the maximum value a shop will offer, we start to reduce it, if the item is
920 * below the minimum value the shop is prepared to trade in, then we don't 910 * below the minimum value the shop is prepared to trade in, then we don't
921 * want it and offer nothing. If it isn't a shop, check whether we should do generic 911 * want it and offer nothing. If it isn't a shop, check whether we should do generic
922 * value reduction. 912 * value reduction.
923 * 913 *
924 */ 914 */
925static sint64 915static sint64
926value_limit (sint64 val, int quantity, const object *who, int isshop) 916value_limit (sint64 val, int quantity, const object *who, int isshop)
927{ 917{
928 sint64 newval, unit_price, tmpshopmax; 918 sint64 newval, unit_price, tmpshopmax;
968{ 958{
969 dynbuf_text buf; 959 dynbuf_text buf;
970 maptile *map = op->map; 960 maptile *map = op->map;
971 961
972 /*shopitems *items=map->shopitems; */ 962 /*shopitems *items=map->shopitems; */
973 int pos = 0, i; 963 int i;
974 double opinion = 0; 964 double opinion = 0;
975 965
976 if (op->type != PLAYER) 966 if (op->type != PLAYER)
977 return 0; 967 return 0;
978 968
1044 1034
1045struct shopinv 1035struct shopinv
1046{ 1036{
1047 char *item_sort; 1037 char *item_sort;
1048 char *item_real; 1038 char *item_real;
1039 sint64 value;
1049 uint16 type; 1040 uint16 type;
1050 uint32 nrof; 1041 uint32 nrof;
1051}; 1042};
1052 1043
1053/* There are a lot fo extra casts in here just to suppress warnings - it 1044/* There are a lot fo extra casts in here just to suppress warnings - it
1073} 1064}
1074 1065
1075static void 1066static void
1076add_shop_item (object *tmp, shopinv * items, int *numitems, int *numallocated) 1067add_shop_item (object *tmp, shopinv * items, int *numitems, int *numallocated)
1077{ 1068{
1078#if 0
1079 char buf[MAX_BUF];
1080#endif
1081 /* clear unpaid flag so that doesn't come up in query 1069 /* clear unpaid flag so that doesn't come up in query
1082 * string. We clear nrof so that we can better sort 1070 * string. We clear nrof so that we can better sort
1083 * the object names. 1071 * the object names.
1084 */ 1072 */
1085 1073
1089 * so the display is properly. 1077 * so the display is properly.
1090 */ 1078 */
1091 if (tmp->nrof == 0) 1079 if (tmp->nrof == 0)
1092 items[*numitems].nrof++; 1080 items[*numitems].nrof++;
1093 items[*numitems].type = tmp->type; 1081 items[*numitems].type = tmp->type;
1082
1083 items[*numitems].value = tmp->value;
1094 1084
1095 switch (tmp->type) 1085 switch (tmp->type)
1096 { 1086 {
1097#if 0 1087#if 0
1098 case BOOTS: 1088 case BOOTS:
1110#endif 1100#endif
1111 1101
1112 default: 1102 default:
1113 items[*numitems].item_sort = strdup (query_base_name (tmp, 0)); 1103 items[*numitems].item_sort = strdup (query_base_name (tmp, 0));
1114 items[*numitems].item_real = strdup (query_base_name (tmp, 1)); 1104 items[*numitems].item_real = strdup (query_base_name (tmp, 1));
1105 items[*numitems].value += tmp->value;
1115 (*numitems)++; 1106 (*numitems)++;
1116 break; 1107 break;
1117 } 1108 }
1118 1109
1119 tmp->set_flag (FLAG_UNPAID); 1110 tmp->set_flag (FLAG_UNPAID);
1121 1112
1122void 1113void
1123shop_listing (object *sign, object *op) 1114shop_listing (object *sign, object *op)
1124{ 1115{
1125 int i, j, x1, x2, y1, y2; 1116 int i, j, x1, x2, y1, y2;
1126 const char *shop_coords = sign->kv (shstr_shop_coords); 1117 const char *shop_coords = sign->kv [shstr_shop_coords];
1127 object *stack; 1118 object *stack;
1128 shopinv *items; 1119 shopinv *items;
1129 1120
1130 /* Should never happen, but just in case a monster does apply a sign */ 1121 /* Should never happen, but just in case a monster does apply a sign */
1131 if (!op->is_player ()) 1122 if (!op->is_player ())
1175 { 1166 {
1176 /* Collapse items of the same name together */ 1167 /* Collapse items of the same name together */
1177 if ((i + 1) < numitems && !strcmp (items[i].item_real, items[i + 1].item_real)) 1168 if ((i + 1) < numitems && !strcmp (items[i].item_real, items[i + 1].item_real))
1178 items[i + 1].nrof += items[i].nrof; 1169 items[i + 1].nrof += items[i].nrof;
1179 else 1170 else
1180 buf.printf (" %4d %s\n", items[i].nrof ? items[i].nrof : 1, items[i].nrof == 1 ? items[i].item_sort : items[i].item_real); 1171 {
1172 buf.printf (
1173 " %4d %s\n for %s\n",
1174 items[i].nrof ? items[i].nrof : 1,
1175 items[i].nrof == 1 ? items[i].item_sort : items[i].item_real,
1176 cost_string_from_value (items[i].value, op->flag [FLAG_WIZ] ? 0 : 1));
1177 }
1181 1178
1182 free (items[i].item_sort); 1179 free (items[i].item_sort);
1183 free (items[i].item_real); 1180 free (items[i].item_real);
1184 } 1181 }
1185 1182

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines