… | |
… | |
666 | unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); |
666 | unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); |
667 | } |
667 | } |
668 | |
668 | |
669 | if (unpaid_price > player_wealth) |
669 | if (unpaid_price > player_wealth) |
670 | { |
670 | { |
671 | char buf[MAX_BUF]; |
671 | dynbuf_text buf; |
672 | char cost[MAX_BUF]; |
|
|
673 | char missing[MAX_BUF]; |
|
|
674 | |
672 | |
675 | snprintf (cost, MAX_BUF, "%s", cost_string_from_value (unpaid_price, 0)); |
673 | buf << "You have " << unpaid_count |
676 | snprintf (missing, MAX_BUF, "%s", cost_string_from_value (unpaid_price - player_wealth, 0)); |
674 | << " unpaid item(s) that would cost you " << cost_string_from_value (unpaid_price, 0) |
|
|
675 | << ". You need another " << cost_string_from_value (unpaid_price - player_wealth, 0) |
|
|
676 | << " to be able to afford that."; |
677 | |
677 | |
678 | snprintf (buf, MAX_BUF, "You have %d unpaid items that would cost you %s. You need another %s to be able to afford that.", |
678 | pl->failmsg (buf); |
679 | unpaid_count, cost, missing); |
|
|
680 | new_draw_info (NDI_UNIQUE, 0, pl, buf); |
|
|
681 | |
679 | |
682 | return 0; |
680 | return 0; |
683 | } |
681 | } |
684 | else |
682 | else |
685 | return 1; |
683 | return 1; |
… | |
… | |
797 | |
795 | |
798 | /* elmex: this is for the bank plugin :( */ |
796 | /* elmex: this is for the bank plugin :( */ |
799 | sint64 |
797 | sint64 |
800 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
798 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
801 | { |
799 | { |
802 | archetype *at = archetype::find (arch); |
|
|
803 | |
|
|
804 | if (!at) |
|
|
805 | return 0; |
|
|
806 | |
|
|
807 | if (amount > 0) |
800 | if (amount) |
808 | { |
801 | { |
809 | object *tmp = arch_to_object (at); |
802 | object *ob = archetype::get (arch); |
|
|
803 | |
|
|
804 | if (!ob) |
|
|
805 | return 0; |
|
|
806 | |
810 | tmp->nrof = amount; |
807 | ob->nrof = amount; |
811 | insert_ob_in_ob (tmp, pl); |
808 | pl->insert (ob); |
812 | } |
809 | } |
813 | |
810 | |
814 | return 1; |
811 | return 1; |
815 | } |
812 | } |
816 | |
813 | |
… | |
… | |
1068 | { |
1065 | { |
1069 | shopinv *s1 = (shopinv *) a1, *s2 = (shopinv *) a2; |
1066 | shopinv *s1 = (shopinv *) a1, *s2 = (shopinv *) a2; |
1070 | |
1067 | |
1071 | if (s1->type < s2->type) |
1068 | if (s1->type < s2->type) |
1072 | return -1; |
1069 | return -1; |
|
|
1070 | |
1073 | if (s1->type > s2->type) |
1071 | if (s1->type > s2->type) |
1074 | return 1; |
1072 | return 1; |
1075 | |
1073 | |
1076 | /* the type is the same (what atoi gets), so do a strcasecmp to sort |
1074 | /* the type is the same (what atoi gets), so do a strcasecmp to sort |
1077 | * via alphabetical order |
1075 | * via alphabetical order |
… | |
… | |
1127 | |
1125 | |
1128 | void |
1126 | void |
1129 | shop_listing (object *sign, object *op) |
1127 | shop_listing (object *sign, object *op) |
1130 | { |
1128 | { |
1131 | int i, j, numitems = 0, numallocated = 0, x1, x2, y1, y2; |
1129 | int i, j, numitems = 0, numallocated = 0, x1, x2, y1, y2; |
1132 | const char *shop_coords = get_ob_key_value (sign, "shop_coords"); |
1130 | const char *shop_coords = sign->kv (shstr_shop_coords); |
1133 | object *stack; |
1131 | object *stack; |
1134 | shopinv *items; |
1132 | shopinv *items; |
1135 | |
1133 | |
1136 | /* Should never happen, but just in case a monster does apply a sign */ |
1134 | /* Should never happen, but just in case a monster does apply a sign */ |
1137 | if (op->type != PLAYER) |
1135 | if (op->type != PLAYER) |
… | |
… | |
1210 | |
1208 | |
1211 | /* elmex: this function checks whether the object is in a shop */ |
1209 | /* elmex: this function checks whether the object is in a shop */ |
1212 | bool |
1210 | bool |
1213 | is_in_shop (object *o) |
1211 | is_in_shop (object *o) |
1214 | { |
1212 | { |
1215 | if (!o->map) |
1213 | if (!o->is_on_map ()) |
1216 | return false; |
1214 | return false; |
1217 | |
1215 | |
1218 | return is_in_shop (o->map, o->x, o->y); |
1216 | return is_in_shop (o->map, o->x, o->y); |
1219 | } |
1217 | } |
1220 | |
1218 | |
… | |
… | |
1228 | is_in_shop (maptile *map, int x, int y) |
1226 | is_in_shop (maptile *map, int x, int y) |
1229 | { |
1227 | { |
1230 | for (object *floor = GET_MAP_OB (map, x, y); floor; floor = floor->above) |
1228 | for (object *floor = GET_MAP_OB (map, x, y); floor; floor = floor->above) |
1231 | if (QUERY_FLAG (floor, FLAG_IS_FLOOR)) |
1229 | if (QUERY_FLAG (floor, FLAG_IS_FLOOR)) |
1232 | return floor->type == SHOP_FLOOR; |
1230 | return floor->type == SHOP_FLOOR; |
|
|
1231 | |
1233 | return false; |
1232 | return false; |
1234 | } |
1233 | } |
1235 | |
1234 | |