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.51 by root, Fri Apr 25 11:40:34 2008 UTC vs.
Revision 1.54 by root, Sat Aug 30 02:26:46 2008 UTC

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 :( */
799sint64 797sint64
800pay_player_arch (object *pl, const char *arch, sint64 amount) 798pay_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
1128void 1126void
1129shop_listing (object *sign, object *op) 1127shop_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 */
1212bool 1210bool
1213is_in_shop (object *o) 1211is_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
1228is_in_shop (maptile *map, int x, int y) 1226is_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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines