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,2013,2014,2015,2016 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> |
… | |
… | |
29 | #include <sproto.h> |
29 | #include <sproto.h> |
30 | |
30 | |
31 | /* this is a measure of how effective store specialisation is. A general store |
31 | /* this is a measure of how effective store specialisation is. A general store |
32 | * will offer this proportion of the 'maximum' price, a specialised store will |
32 | * will offer this proportion of the 'maximum' price, a specialised store will |
33 | * offer a range of prices around it such that the maximum price is always one |
33 | * offer a range of prices around it such that the maximum price is always one |
34 | * therefore making this number higher, makes specialisation less effective. |
34 | * therefore making this number higher, makes specialisation less effective. |
35 | * setting this value above 1 or to a negative value would have interesting, |
35 | * setting this value above 1 or to a negative value would have interesting, |
36 | * (though not useful) effects. |
36 | * (though not useful) effects. |
37 | */ |
37 | */ |
38 | #define SPECIALISATION_EFFECT .5 |
38 | #define SPECIALISATION_EFFECT .5 |
39 | |
39 | |
… | |
… | |
55 | * would not be done. |
55 | * would not be done. |
56 | * |
56 | * |
57 | * Added F_APPROX flag, which means that the price returned should be wrong by |
57 | * Added F_APPROX flag, which means that the price returned should be wrong by |
58 | * an amount related to the player's bargaining skill. |
58 | * an amount related to the player's bargaining skill. |
59 | * |
59 | * |
60 | * Added F_SHOP flag to mean that the specialisation of the shop on the player's |
60 | * Added F_SHOP flag to mean that the specialisation of the shop on the player's |
61 | * current map should be taken into account when determining the price. Shops that |
61 | * current map should be taken into account when determining the price. Shops that |
62 | * specialise in what is being traded will give better prices than those that do not. |
62 | * specialise in what is being traded will give better prices than those that do not. |
63 | * |
63 | * |
64 | * CF 0.91.4 - This function got changed around a bit. Now the |
64 | * CF 0.91.4 - This function got changed around a bit. Now the |
65 | * number of object is multiplied by the value early on. This fixes problems |
65 | * number of object is multiplied by the value early on. This fixes problems |
66 | * with items worth very little. What happened before is that various |
66 | * with items worth very little. What happened before is that various |
67 | * divisions took place, the value got rounded to 0 (Being an int), and |
67 | * divisions took place, the value got rounded to 0 (Being an int), and |
… | |
… | |
169 | /* Value of the wand is multiplied by the number of |
169 | /* Value of the wand is multiplied by the number of |
170 | * charges. the treasure code already sets up the value |
170 | * charges. the treasure code already sets up the value |
171 | * 50 charges is used as the baseline. |
171 | * 50 charges is used as the baseline. |
172 | */ |
172 | */ |
173 | if (tmp->flag [FLAG_IDENTIFIED] || !tmp->need_identify () || identified) |
173 | if (tmp->flag [FLAG_IDENTIFIED] || !tmp->need_identify () || identified) |
174 | val *= tmp->stats.food / 50; |
174 | val *= tmp->stats.food; |
175 | else /* if not identified, presume one charge */ |
175 | /* if not identified, presume one charge */ |
176 | val /= 50; |
176 | val /= 50; |
177 | } |
177 | } |
178 | |
178 | |
179 | /* Limit amount of money you can get for really great items. */ |
179 | /* Limit amount of money you can get for really great items. */ |
180 | if (flag == F_SELL) |
180 | if (flag == F_SELL) |
181 | val = value_limit (val, number, who, shop); |
181 | val = value_limit (val, number, who, shop); |
… | |
… | |
189 | * AND Cha = 30 will get optimal price. |
189 | * AND Cha = 30 will get optimal price. |
190 | * Thus charisma will never get useless. |
190 | * Thus charisma will never get useless. |
191 | * -b.e. edler@heydernet.de |
191 | * -b.e. edler@heydernet.de |
192 | */ |
192 | */ |
193 | |
193 | |
194 | if (who && who->type == PLAYER) |
194 | if (who && who->is_player ()) |
195 | { |
195 | { |
196 | int lev_bargain = 0; |
196 | int lev_bargain = 0; |
197 | int lev_identify = 0; |
197 | int lev_identify = 0; |
198 | |
198 | |
199 | if (!no_bargain) |
199 | if (!no_bargain) |
… | |
… | |
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 | double bargaining = min (0., 1. - powf (lev_bargain / MAXLEVEL_TREASURE, 0.25)); |
222 | double bargaining = max (0., 1. - powf (double (lev_bargain) / MAXLEVEL_TREASURE, 0.25)); |
223 | double charisma = (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.); |
224 | |
224 | |
225 | double factor = (1. - cha_ratio) * bargaining + cha_ratio * charisma; |
225 | double factor = (1. - cha_ratio) * bargaining + cha_ratio * charisma; |
226 | |
226 | |
227 | // scale 0..1 to 2 .. 80% |
227 | // scale 0..1 to 2 .. 80% |
… | |
… | |
255 | { |
255 | { |
256 | if (flag == F_SELL) |
256 | if (flag == F_SELL) |
257 | val *= shop_specialisation_ratio (tmp, who->map) * shopkeeper_approval (who->map, who) / shop_greed (who->map); |
257 | val *= shop_specialisation_ratio (tmp, who->map) * shopkeeper_approval (who->map, who) / shop_greed (who->map); |
258 | else if (flag == F_BUY) |
258 | else if (flag == F_BUY) |
259 | { |
259 | { |
260 | /* |
260 | /* |
261 | * when buying, if the item was sold by another player, it is ok to |
261 | * when buying, if the item was sold by another player, it is ok to |
262 | * let the item be sold cheaper, according to the specialisation of |
262 | * let the item be sold cheaper, according to the specialisation of |
263 | * the shop. If a player sold an item here, then his sale price was |
263 | * the shop. If a player sold an item here, then his sale price was |
264 | * multiplied by the specialisation ratio, to do the same to the buy |
264 | * multiplied by the specialisation ratio, to do the same to the buy |
265 | * price will not generate extra money. However, the |
265 | * price will not generate extra money. However, the |
266 | * same is not true of generated items, these have to /divide/ by the |
266 | * same is not true of generated items, these have to /divide/ by the |
267 | * specialisation, so that the price is never less than what they could |
267 | * specialisation, so that the price is never less than what they could |
268 | * be sold for (otherwise players could camp map resets to make money). |
268 | * be sold for (otherwise players could camp map resets to make money). |
269 | * In game terms, a non-specialist shop, might not recognise the true |
269 | * In game terms, a non-specialist shop, might not recognise the true |
270 | * value of the items they sell (much like how people sometimes find |
270 | * value of the items they sell (much like how people sometimes find |
271 | * antiques in a junk shop in real life). |
271 | * antiques in a junk shop in real life). |
272 | */ |
272 | */ |
273 | if (tmp->flag [FLAG_PLAYER_SOLD]) |
273 | if (tmp->flag [FLAG_PLAYER_SOLD]) |
274 | val *= shop_specialisation_ratio (tmp, who->map); |
274 | val *= shop_specialisation_ratio (tmp, who->map); |
275 | else |
275 | else |
276 | val /= shop_specialisation_ratio (tmp, who->map); |
276 | val /= shop_specialisation_ratio (tmp, who->map); |
277 | |
277 | |
278 | val *= shop_greed (who->map) / shopkeeper_approval (who->map, who); |
278 | val *= shop_greed (who->map) / shopkeeper_approval (who->map, who); |
279 | } |
279 | } |
280 | |
280 | |
281 | /* we will also have an extra 0-5% variation between shops of the same type |
281 | /* we will also have an extra 0-5% variation between shops of the same type |
282 | * for valuable items (below a value of 50 this effect wouldn't be very |
282 | * for valuable items (below a value of 50 this effect wouldn't be very |
283 | * pointful, and could give fun with rounding. |
283 | * pointful, and could give fun with rounding. |
284 | */ |
284 | */ |
285 | //TODO: why use cosf at all, just % and scale linearly, gives more even distribution |
285 | //TODO: why use cosf at all, just % and scale linearly, gives more even distribution |
286 | if (val > 50) |
286 | if (val > 50) |
287 | val *= 1 + .05f * cosf ((tmp->uuid.seq & 0xffff) * M_PI * 2. / 0x10000); |
287 | val *= 1 + .05f * cosf ((tmp->uuid.seq & 0xffff) * M_PI * 2. / 0x10000); |
… | |
… | |
443 | } |
443 | } |
444 | |
444 | |
445 | for (tmp = op->inv; tmp; tmp = tmp->below) |
445 | for (tmp = op->inv; tmp; tmp = tmp->below) |
446 | if (tmp->type == MONEY) |
446 | if (tmp->type == MONEY) |
447 | total += tmp->nrof * (sint64)tmp->value; |
447 | total += tmp->nrof * (sint64)tmp->value; |
448 | 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))) |
449 | total += query_money (tmp); |
449 | total += query_money (tmp); |
450 | |
450 | |
451 | return total; |
451 | return total; |
452 | } |
452 | } |
453 | |
453 | |
… | |
… | |
468 | return 0; |
468 | return 0; |
469 | |
469 | |
470 | pay_from_container (pl, pl, to_pay); |
470 | pay_from_container (pl, pl, to_pay); |
471 | |
471 | |
472 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
472 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
473 | 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))) |
474 | pay_from_container (pl, pouch, to_pay); |
474 | pay_from_container (pl, pouch, to_pay); |
475 | |
475 | |
476 | pl->update_stats (); |
476 | pl->update_stats (); |
477 | return 1; |
477 | return 1; |
478 | } |
478 | } |
… | |
… | |
505 | change_exp (pl, saved_money, shstr_bargaining, SK_EXP_NONE); |
505 | change_exp (pl, saved_money, shstr_bargaining, SK_EXP_NONE); |
506 | |
506 | |
507 | pay_from_container (pl, pl, to_pay); |
507 | pay_from_container (pl, pl, to_pay); |
508 | |
508 | |
509 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
509 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
510 | 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))) |
511 | pay_from_container (pl, pouch, to_pay); |
511 | pay_from_container (pl, pouch, to_pay); |
512 | |
512 | |
513 | pl->update_stats (); |
513 | pl->update_stats (); |
514 | |
514 | |
515 | return 1; |
515 | return 1; |
… | |
… | |
617 | coin_objs[i]->destroy (); |
617 | coin_objs[i]->destroy (); |
618 | } |
618 | } |
619 | |
619 | |
620 | /* Checks all unpaid items in op's inventory, adds up all the money they |
620 | /* Checks all unpaid items in op's inventory, adds up all the money they |
621 | * have, and checks that they can actually afford what they want to buy. |
621 | * have, and checks that they can actually afford what they want to buy. |
622 | * Returns 1 if they can, and 0 if they can't. also prints an appropriate message |
622 | * Returns 1 if they can, and 0 if they can't. also prints an appropriate message |
623 | * to the player |
623 | * to the player |
624 | */ |
624 | */ |
625 | int |
625 | int |
626 | can_pay (object *pl) |
626 | can_pay (object *pl) |
627 | { |
627 | { |
… | |
… | |
720 | void |
720 | void |
721 | pay_player (object *pl, sint64 amount) |
721 | pay_player (object *pl, sint64 amount) |
722 | { |
722 | { |
723 | int count = 0; |
723 | int count = 0; |
724 | archetype *at = 0; |
724 | archetype *at = 0; |
725 | object *pouch = 0, *tmp = 0; |
725 | object *pouch = 0; |
726 | |
726 | |
727 | for (count = 0; coins[count]; count++) |
727 | for (count = 0; coins[count]; count++) |
728 | { |
728 | { |
729 | at = archetype::find (coins[count]); |
729 | at = archetype::find (coins[count]); |
730 | |
730 | |
… | |
… | |
732 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
732 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
733 | else if ((amount / at->value) > 0) |
733 | else if ((amount / at->value) > 0) |
734 | { |
734 | { |
735 | for (pouch = pl->inv; pouch; pouch = pouch->below) |
735 | for (pouch = pl->inv; pouch; pouch = pouch->below) |
736 | { |
736 | { |
737 | 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)) |
738 | { |
738 | { |
739 | int w = at->weight * (100 - pouch->stats.Str) / 100; |
739 | int w = at->weight * (100 - pouch->stats.Str) / 100; |
740 | int n = amount / at->value; |
740 | int n = amount / at->value; |
741 | |
741 | |
742 | if (w == 0) |
742 | if (w == 0) |
… | |
… | |
837 | |
837 | |
838 | return true; |
838 | return true; |
839 | } |
839 | } |
840 | |
840 | |
841 | /* returns a double that is the ratio of the price that a shop will offer for |
841 | /* returns a double that is the ratio of the price that a shop will offer for |
842 | * item based on the shops specialisation. Does not take account of greed, |
842 | * item based on the shops specialisation. Does not take account of greed, |
843 | * returned value is between SPECIALISATION_EFFECT and 1. |
843 | * returned value is between SPECIALISATION_EFFECT and 1. |
844 | */ |
844 | */ |
845 | static double |
845 | static double |
846 | shop_specialisation_ratio (const object *item, const maptile *map) |
846 | shop_specialisation_ratio (const object *item, const maptile *map) |
847 | { |
847 | { |
… | |
… | |
855 | return 0; |
855 | return 0; |
856 | } |
856 | } |
857 | |
857 | |
858 | if (!item->type) |
858 | if (!item->type) |
859 | { |
859 | { |
860 | 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 ()); |
861 | /* |
861 | /* |
862 | * 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 |
863 | * 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.." |
864 | */ |
864 | */ |
865 | return SPECIALISATION_EFFECT; |
865 | return SPECIALISATION_EFFECT; |
866 | } |
866 | } |
867 | |
867 | |
868 | if (map->shopitems) |
868 | if (map->shopitems) |
… | |
… | |
870 | if (items[i].typenum == item->type || (!items[i].typenum && !likedness)) |
870 | if (items[i].typenum == item->type || (!items[i].typenum && !likedness)) |
871 | likedness = items[i].strength; |
871 | likedness = items[i].strength; |
872 | |
872 | |
873 | if (likedness > 100) |
873 | if (likedness > 100) |
874 | { /* someone has been rather silly with the map headers. */ |
874 | { /* someone has been rather silly with the map headers. */ |
875 | 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); |
876 | likedness = 100; |
876 | likedness = 100; |
877 | } |
877 | } |
878 | |
878 | |
879 | if (likedness < -100) |
879 | if (likedness < -100) |
880 | { |
880 | { |
881 | 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); |
882 | likedness = -100; |
882 | likedness = -100; |
883 | } |
883 | } |
884 | |
884 | |
885 | return lerp (double (likedness), -100., 100., SPECIALISATION_EFFECT, 1.); |
885 | return lerp (double (likedness), -100., 100., SPECIALISATION_EFFECT, 1.); |
886 | } |
886 | } |
… | |
… | |
904 | ? DISLIKE_RATIO |
904 | ? DISLIKE_RATIO |
905 | : 1.; |
905 | : 1.; |
906 | } |
906 | } |
907 | |
907 | |
908 | /* 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 |
909 | * 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 |
910 | * 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 |
911 | * 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 |
912 | * value reduction. |
912 | * value reduction. |
913 | * |
913 | * |
914 | */ |
914 | */ |
915 | static sint64 |
915 | static sint64 |
916 | value_limit (sint64 val, int quantity, const object *who, int isshop) |
916 | value_limit (sint64 val, int quantity, const object *who, int isshop) |
917 | { |
917 | { |
918 | sint64 newval, unit_price, tmpshopmax; |
918 | sint64 newval, unit_price, tmpshopmax; |
… | |
… | |
958 | { |
958 | { |
959 | dynbuf_text buf; |
959 | dynbuf_text buf; |
960 | maptile *map = op->map; |
960 | maptile *map = op->map; |
961 | |
961 | |
962 | /*shopitems *items=map->shopitems; */ |
962 | /*shopitems *items=map->shopitems; */ |
963 | int pos = 0, i; |
963 | int i; |
964 | double opinion = 0; |
964 | double opinion = 0; |
965 | |
965 | |
966 | if (op->type != PLAYER) |
966 | if (op->type != PLAYER) |
967 | return 0; |
967 | return 0; |
968 | |
968 | |
… | |
… | |
1034 | |
1034 | |
1035 | struct shopinv |
1035 | struct shopinv |
1036 | { |
1036 | { |
1037 | char *item_sort; |
1037 | char *item_sort; |
1038 | char *item_real; |
1038 | char *item_real; |
|
|
1039 | sint64 value; |
1039 | uint16 type; |
1040 | uint16 type; |
1040 | uint32 nrof; |
1041 | uint32 nrof; |
1041 | }; |
1042 | }; |
1042 | |
1043 | |
1043 | /* 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 |
… | |
… | |
1076 | * so the display is properly. |
1077 | * so the display is properly. |
1077 | */ |
1078 | */ |
1078 | if (tmp->nrof == 0) |
1079 | if (tmp->nrof == 0) |
1079 | items[*numitems].nrof++; |
1080 | items[*numitems].nrof++; |
1080 | items[*numitems].type = tmp->type; |
1081 | items[*numitems].type = tmp->type; |
|
|
1082 | |
|
|
1083 | items[*numitems].value = tmp->value; |
1081 | |
1084 | |
1082 | switch (tmp->type) |
1085 | switch (tmp->type) |
1083 | { |
1086 | { |
1084 | #if 0 |
1087 | #if 0 |
1085 | case BOOTS: |
1088 | case BOOTS: |
… | |
… | |
1097 | #endif |
1100 | #endif |
1098 | |
1101 | |
1099 | default: |
1102 | default: |
1100 | items[*numitems].item_sort = strdup (query_base_name (tmp, 0)); |
1103 | items[*numitems].item_sort = strdup (query_base_name (tmp, 0)); |
1101 | 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; |
1102 | (*numitems)++; |
1106 | (*numitems)++; |
1103 | break; |
1107 | break; |
1104 | } |
1108 | } |
1105 | |
1109 | |
1106 | tmp->set_flag (FLAG_UNPAID); |
1110 | tmp->set_flag (FLAG_UNPAID); |
… | |
… | |
1108 | |
1112 | |
1109 | void |
1113 | void |
1110 | shop_listing (object *sign, object *op) |
1114 | shop_listing (object *sign, object *op) |
1111 | { |
1115 | { |
1112 | int i, j, x1, x2, y1, y2; |
1116 | int i, j, x1, x2, y1, y2; |
1113 | const char *shop_coords = sign->kv (shstr_shop_coords); |
1117 | const char *shop_coords = sign->kv [shstr_shop_coords]; |
1114 | object *stack; |
1118 | object *stack; |
1115 | shopinv *items; |
1119 | shopinv *items; |
1116 | |
1120 | |
1117 | /* 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 */ |
1118 | if (!op->is_player ()) |
1122 | if (!op->is_player ()) |
… | |
… | |
1162 | { |
1166 | { |
1163 | /* Collapse items of the same name together */ |
1167 | /* Collapse items of the same name together */ |
1164 | 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)) |
1165 | items[i + 1].nrof += items[i].nrof; |
1169 | items[i + 1].nrof += items[i].nrof; |
1166 | else |
1170 | else |
1167 | 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 | } |
1168 | |
1178 | |
1169 | free (items[i].item_sort); |
1179 | free (items[i].item_sort); |
1170 | free (items[i].item_real); |
1180 | free (items[i].item_real); |
1171 | } |
1181 | } |
1172 | |
1182 | |