Changeset 36
- Timestamp:
- 04/09/07 10:03:24 (2 years ago)
- Files:
-
- trunk/src/birth.c (modified) (5 diffs)
- trunk/src/defines.h (modified) (1 diff)
- trunk/src/externs.h (modified) (3 diffs)
- trunk/src/init2.c (modified) (2 diffs)
- trunk/src/store.c (modified) (68 diffs)
- trunk/src/tables.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/birth.c
r33 r36 745 745 { 746 746 return handler_aux(cmd, oid, &p_ptr->prace, z_info->p_max, 747 0xffffffff, p_name +p_info[oid].name);747 0xffffffff, p_name + p_info[oid].name); 748 748 } 749 749 … … 759 759 { 760 760 return handler_aux(cmd, oid, &p_ptr->pclass, z_info->c_max, 761 (rp_ptr->choice), c_name+c_info[oid].name);761 (rp_ptr->choice), c_name + c_info[oid].name); 762 762 } 763 763 764 764 765 765 static const menu_iter menu_defs[] = { 766 { 0, 0, 0, display_gender, gender_handler },767 { 0, 0, 0, display_race, race_handler },768 { 0, 0, 0, display_class, class_handler },766 { 0, 0, 0, display_gender, gender_handler }, 767 { 0, 0, 0, display_race, race_handler }, 768 { 0, 0, 0, display_class, class_handler }, 769 769 }; 770 770 … … 773 773 static bool choose_character() 774 774 { 775 int i; 776 777 const region *regions [] = {&gender_region, &race_region, &class_region}; 778 byte *values [] = {&p_ptr->psex, &p_ptr->prace, &p_ptr->pclass}; 779 int limits [] = {SEX_MALE+1, z_info->p_max, z_info->c_max}; 780 const char *hints [] = { 775 int i = 0; 776 777 const region *regions[] = { &gender_region, &race_region, &class_region }; 778 byte *values[] = { &p_ptr->psex, &p_ptr->prace, &p_ptr->pclass }; 779 int limits[] = { SEX_MALE + 1, z_info->p_max, z_info->c_max }; 780 781 menu_type menu; 782 783 const char *hints[] = 784 { 781 785 "Your 'sex' does not have any significant gameplay effects.", 782 786 "Your 'race' determines various intrinsic factors and bonuses.", 783 "Your 'class' determines various intrinsic abilities and bonuses" }; 787 "Your 'class' determines various intrinsic abilities and bonuses" 788 }; 784 789 785 790 typedef void (*browse_f) (int oid, void *, const region *loc); 786 browse_f browse [] = {NULL, race_aux_hook, class_aux_hook }; 787 menu_type menu; 791 browse_f browse[] = {NULL, race_aux_hook, class_aux_hook }; 792 793 788 794 WIPE(&menu, menu); 789 795 menu.cmd_keys = "?=*\r\n\x18"; /* ?, ,= *, \n, <ctl-X> */ 790 796 791 i = 0; 792 while(i < N_ELEMENTS(menu_defs)) 797 while (i < (int)N_ELEMENTS(menu_defs)) 793 798 { 794 799 event_type cx; 795 800 int cursor = *values[i]; 801 796 802 menu.flags = MN_NO_TAGS | MN_DBL_TAP; 797 803 menu.count = limits[i]; 798 804 menu.browse_hook = browse[i]; 799 805 menu_init2(&menu, find_menu_skin(MN_SCROLL), &menu_defs[i], regions[i]); 806 800 807 clear_question(); 801 802 808 Term_putstr(QUESTION_COL, QUESTION_ROW, -1, TERM_YELLOW, hints[i]); 809 803 810 cx = menu_select(&menu, &cursor, 0); 804 if(cx.key == ESCAPE) { 805 return FALSE; /* restart */ 806 } 807 else if(cx.type == EVT_BACK) { 811 812 if (cx.key == ESCAPE) 813 { 814 /* Restart */ 815 return FALSE; 816 } 817 else if (cx.type == EVT_BACK) 818 { 819 /* Move back one menu */ 808 820 *values[i] = cursor; 809 821 region_erase(regions[i]); 810 822 i--; 811 823 } 812 else if(cx.key == '*') { 824 else if (cx.key == '*') 825 { 813 826 /* Force refresh */ 814 827 Term_key_push('6'); 815 828 continue; 816 829 } 830 817 831 else i++; 818 832 } 833 819 834 return TRUE; 820 835 } … … 1500 1515 void player_birth(void) 1501 1516 { 1502 int i, n;1503 1504 1505 1517 /* Create a new character */ 1506 1518 while (1) … … 1526 1538 1527 1539 1528 /* Shops */ 1529 for (n = 0; n < MAX_STORES; n++) 1530 { 1531 /* Initialize */ 1532 store_init(n); 1533 1534 /* Ignore home */ 1535 if (n == STORE_HOME) continue; 1536 1537 /* Maintain the shop (ten times) */ 1538 for (i = 0; i < 10; i++) store_maint(n); 1539 } 1540 } 1540 /* Initialise the stores */ 1541 store_init(); 1542 } trunk/src/defines.h
r34 r36 252 252 /* 253 253 * Store constants 254 * 255 * Special note about STORE_MAX_KEEP; not only must it be below 256 * STORE_INVEN_MAX, it must actually be below (STORE_INVEN_MAX - maximum 257 * staple items across all stores); i.e. if the General Store has three 258 * staple items (and no other store has more than three staple items), 259 * then STORE_MAX_KEEP > (STORE_INVEN_MAX - 3), or > 21 (in this case). 254 260 */ 255 261 #define STORE_INVEN_MAX 24 /* Max number of discrete objs in inven */ 256 262 #define STORE_OBJ_LEVEL 5 /* Magic Level for normal stores */ 257 263 #define STORE_TURNOVER 9 /* Normal shop turnover, per day */ 258 #define STORE_MIN_KEEP 6 /* Min slots to "always" keep full */ 264 #define STORE_MIN_KEEP 6 /* Min slots to "always" keep full - 265 must be above 0 */ 259 266 #define STORE_MAX_KEEP 18 /* Max slots to "always" keep full */ 260 267 #define STORE_SHUFFLE 25 /* 1/Chance (per day) of an owner changing */ 261 268 #define STORE_TURNS 1000 /* Number of turns between turnovers */ 269 #define STORE_CHOICES 32 /* Number of choices in the store selection table */ 262 270 263 271 trunk/src/externs.h
r33 r36 71 71 extern cptr inscrip_text[MAX_INSCRIP]; 72 72 extern const grouper object_text_order[]; 73 extern const byte store_choices[MAX_STORES-2][STORE_CHOICES][2]; 73 74 74 75 /* variable.c */ … … 670 671 extern void store_shuffle(int which); 671 672 extern void store_maint(int which); 672 extern void store_init( int which);673 extern void store_init(void); 673 674 674 675 /* util.c */ … … 682 683 extern void flush(void); 683 684 extern void flush_fail(void); 684 extern char anykey(void);685 685 extern char inkey(void); 686 686 extern event_type inkey_ex(void); 687 extern char anykey(void); 687 688 extern void bell(cptr reason); 688 689 extern void sound(int val); trunk/src/init2.c
r27 r36 1123 1123 /*** Initialize others ***/ 1124 1124 1125 #define STORE_CHOICES 32 /* Number of items to choose stock from */1126 1127 1128 /*1129 * Hack -- Objects sold in the stores -- by tval/sval pair.1130 */1131 static const byte store_table[MAX_STORES-2][STORE_CHOICES][2] =1132 {1133 {1134 /* General Store */1135 1136 { TV_FOOD, SV_FOOD_RATION },1137 { TV_FOOD, SV_FOOD_RATION },1138 { TV_FOOD, SV_FOOD_RATION },1139 { TV_FOOD, SV_FOOD_RATION },1140 { TV_FOOD, SV_FOOD_RATION },1141 { TV_FOOD, SV_FOOD_BISCUIT },1142 { TV_FOOD, SV_FOOD_JERKY },1143 { TV_FOOD, SV_FOOD_JERKY },1144 1145 { TV_FOOD, SV_FOOD_PINT_OF_WINE },1146 { TV_FOOD, SV_FOOD_PINT_OF_ALE },1147 { TV_LITE, SV_LITE_TORCH },1148 { TV_LITE, SV_LITE_TORCH },1149 { TV_LITE, SV_LITE_TORCH },1150 { TV_LITE, SV_LITE_TORCH },1151 { TV_LITE, SV_LITE_LANTERN },1152 { TV_LITE, SV_LITE_LANTERN },1153 1154 { TV_FLASK, 0 },1155 { TV_FLASK, 0 },1156 { TV_FLASK, 0 },1157 { TV_FLASK, 0 },1158 { TV_FLASK, 0 },1159 { TV_FLASK, 0 },1160 { TV_SPIKE, 0 },1161 { TV_SPIKE, 0 },1162 1163 { TV_SHOT, SV_AMMO_NORMAL },1164 { TV_ARROW, SV_AMMO_NORMAL },1165 { TV_BOLT, SV_AMMO_NORMAL },1166 { TV_DIGGING, SV_SHOVEL },1167 { TV_DIGGING, SV_PICK },1168 { TV_CLOAK, SV_CLOAK },1169 { TV_CLOAK, SV_CLOAK },1170 { TV_CLOAK, SV_CLOAK }1171 },1172 1173 {1174 /* Armoury */1175 1176 { TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS },1177 { TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS },1178 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },1179 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },1180 { TV_HELM, SV_HARD_LEATHER_CAP },1181 { TV_HELM, SV_HARD_LEATHER_CAP },1182 { TV_HELM, SV_METAL_CAP },1183 { TV_HELM, SV_IRON_HELM },1184 1185 { TV_SOFT_ARMOR, SV_ROBE },1186 { TV_SOFT_ARMOR, SV_ROBE },1187 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },1188 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },1189 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },1190 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },1191 { TV_SOFT_ARMOR, SV_HARD_STUDDED_LEATHER },1192 { TV_SOFT_ARMOR, SV_HARD_STUDDED_LEATHER },1193 1194 { TV_SOFT_ARMOR, SV_LEATHER_SCALE_MAIL },1195 { TV_SOFT_ARMOR, SV_LEATHER_SCALE_MAIL },1196 { TV_HARD_ARMOR, SV_METAL_SCALE_MAIL },1197 { TV_HARD_ARMOR, SV_CHAIN_MAIL },1198 { TV_HARD_ARMOR, SV_CHAIN_MAIL },1199 { TV_HARD_ARMOR, SV_AUGMENTED_CHAIN_MAIL },1200 { TV_HARD_ARMOR, SV_BAR_CHAIN_MAIL },1201 { TV_HARD_ARMOR, SV_DOUBLE_CHAIN_MAIL },1202 1203 { TV_HARD_ARMOR, SV_METAL_BRIGANDINE_ARMOUR },1204 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },1205 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },1206 { TV_GLOVES, SV_SET_OF_GAUNTLETS },1207 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD },1208 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD },1209 { TV_SHIELD, SV_LARGE_LEATHER_SHIELD },1210 { TV_SHIELD, SV_SMALL_METAL_SHIELD }1211 },1212 1213 {1214 /* Weaponsmith */1215 1216 { TV_SWORD, SV_DAGGER },1217 { TV_SWORD, SV_MAIN_GAUCHE },1218 { TV_SWORD, SV_RAPIER },1219 { TV_SWORD, SV_SMALL_SWORD },1220 { TV_SWORD, SV_SHORT_SWORD },1221 { TV_SWORD, SV_SABRE },1222 { TV_SWORD, SV_CUTLASS },1223 { TV_SWORD, SV_TULWAR },1224 1225 { TV_SWORD, SV_BROAD_SWORD },1226 { TV_SWORD, SV_LONG_SWORD },1227 { TV_SWORD, SV_SCIMITAR },1228 { TV_SWORD, SV_KATANA },1229 { TV_SWORD, SV_BASTARD_SWORD },1230 { TV_POLEARM, SV_SPEAR },1231 { TV_POLEARM, SV_AWL_PIKE },1232 { TV_POLEARM, SV_TRIDENT },1233 1234 { TV_POLEARM, SV_PIKE },1235 { TV_POLEARM, SV_BEAKED_AXE },1236 { TV_POLEARM, SV_BROAD_AXE },1237 { TV_POLEARM, SV_LANCE },1238 { TV_POLEARM, SV_BATTLE_AXE },1239 { TV_HAFTED, SV_WHIP },1240 { TV_BOW, SV_SLING },1241 { TV_BOW, SV_SHORT_BOW },1242 1243 { TV_BOW, SV_LONG_BOW },1244 { TV_BOW, SV_LIGHT_XBOW },1245 { TV_SHOT, SV_AMMO_NORMAL },1246 { TV_SHOT, SV_AMMO_NORMAL },1247 { TV_ARROW, SV_AMMO_NORMAL },1248 { TV_ARROW, SV_AMMO_NORMAL },1249 { TV_BOLT, SV_AMMO_NORMAL },1250 { TV_BOLT, SV_AMMO_NORMAL },1251 },1252 1253 {1254 /* Temple */1255 1256 { TV_HAFTED, SV_WHIP },1257 { TV_HAFTED, SV_QUARTERSTAFF },1258 { TV_HAFTED, SV_MACE },1259 { TV_HAFTED, SV_MACE },1260 { TV_HAFTED, SV_BALL_AND_CHAIN },1261 { TV_HAFTED, SV_WAR_HAMMER },1262 { TV_HAFTED, SV_LUCERN_HAMMER },1263 { TV_HAFTED, SV_MORNING_STAR },1264 1265 { TV_HAFTED, SV_FLAIL },1266 { TV_HAFTED, SV_FLAIL },1267 { TV_HAFTED, SV_LEAD_FILLED_MACE },1268 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },1269 { TV_SCROLL, SV_SCROLL_BLESSING },1270 { TV_SCROLL, SV_SCROLL_HOLY_CHANT },1271 { TV_POTION, SV_POTION_BOLDNESS },1272 { TV_POTION, SV_POTION_HEROISM },1273 1274 { TV_POTION, SV_POTION_CURE_LIGHT },1275 { TV_POTION, SV_POTION_CURE_SERIOUS },1276 { TV_POTION, SV_POTION_CURE_SERIOUS },1277 { TV_POTION, SV_POTION_CURE_CRITICAL },1278 { TV_POTION, SV_POTION_CURE_CRITICAL },1279 { TV_POTION, SV_POTION_RESTORE_EXP },1280 { TV_POTION, SV_POTION_RESTORE_EXP },1281 { TV_POTION, SV_POTION_RESTORE_EXP },1282 1283 { TV_PRAYER_BOOK, 0 },1284 { TV_PRAYER_BOOK, 0 },1285 { TV_PRAYER_BOOK, 0 },1286 { TV_PRAYER_BOOK, 1 },1287 { TV_PRAYER_BOOK, 1 },1288 { TV_PRAYER_BOOK, 2 },1289 { TV_PRAYER_BOOK, 2 },1290 { TV_PRAYER_BOOK, 3 }1291 },1292 1293 {1294 /* Alchemy shop */1295 1296 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_HIT },1297 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_DAM },1298 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },1299 { TV_SCROLL, SV_SCROLL_IDENTIFY },1300 { TV_SCROLL, SV_SCROLL_IDENTIFY },1301 { TV_SCROLL, SV_SCROLL_IDENTIFY },1302 { TV_SCROLL, SV_SCROLL_IDENTIFY },1303 { TV_SCROLL, SV_SCROLL_LIGHT },1304 1305 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },1306 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },1307 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },1308 { TV_SCROLL, SV_SCROLL_MONSTER_CONFUSION },1309 { TV_SCROLL, SV_SCROLL_MAPPING },1310 { TV_SCROLL, SV_SCROLL_DETECT_GOLD },1311 { TV_SCROLL, SV_SCROLL_DETECT_ITEM },1312 { TV_SCROLL, SV_SCROLL_DETECT_TRAP },1313 1314 { TV_SCROLL, SV_SCROLL_DETECT_DOOR },1315 { TV_SCROLL, SV_SCROLL_DETECT_INVIS },1316 { TV_SCROLL, SV_SCROLL_RECHARGING },1317 { TV_SCROLL, SV_SCROLL_SATISFY_HUNGER },1318 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },1319 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },1320 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },1321 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },1322 1323 { TV_POTION, SV_POTION_RESIST_HEAT },1324 { TV_POTION, SV_POTION_RESIST_COLD },1325 { TV_POTION, SV_POTION_RES_STR },1326 { TV_POTION, SV_POTION_RES_INT },1327 { TV_POTION, SV_POTION_RES_WIS },1328 { TV_POTION, SV_POTION_RES_DEX },1329 { TV_POTION, SV_POTION_RES_CON },1330 { TV_POTION, SV_POTION_RES_CHR }1331 },1332 1333 {1334 /* Magic-User store */1335 1336 { TV_RING, SV_RING_SEARCHING },1337 { TV_RING, SV_RING_FEATHER_FALL },1338 { TV_RING, SV_RING_PROTECTION },1339 { TV_AMULET, SV_AMULET_CHARISMA },1340 { TV_AMULET, SV_AMULET_SLOW_DIGEST },1341 { TV_AMULET, SV_AMULET_RESIST_ACID },1342 { TV_WAND, SV_WAND_SLOW_MONSTER },1343 { TV_WAND, SV_WAND_CONFUSE_MONSTER },1344 1345 { TV_WAND, SV_WAND_SLEEP_MONSTER },1346 { TV_WAND, SV_WAND_MAGIC_MISSILE },1347 { TV_WAND, SV_WAND_STINKING_CLOUD },1348 { TV_WAND, SV_WAND_WONDER },1349 { TV_STAFF, SV_STAFF_LITE },1350 { TV_STAFF, SV_STAFF_MAPPING },1351 { TV_STAFF, SV_STAFF_DETECT_TRAP },1352 { TV_STAFF, SV_STAFF_DETECT_DOOR },1353 1354 { TV_STAFF, SV_STAFF_DETECT_GOLD },1355 { TV_STAFF, SV_STAFF_DETECT_ITEM },1356 { TV_STAFF, SV_STAFF_DETECT_INVIS },1357 { TV_STAFF, SV_STAFF_DETECT_EVIL },1358 { TV_STAFF, SV_STAFF_TELEPORTATION },1359 { TV_STAFF, SV_STAFF_TELEPORTATION },1360 { TV_STAFF, SV_STAFF_IDENTIFY },1361 { TV_STAFF, SV_STAFF_IDENTIFY },1362 1363 { TV_MAGIC_BOOK, 0 },1364 { TV_MAGIC_BOOK, 0 },1365 { TV_MAGIC_BOOK, 0 },1366 { TV_MAGIC_BOOK, 1 },1367 { TV_MAGIC_BOOK, 1 },1368 { TV_MAGIC_BOOK, 2 },1369 { TV_MAGIC_BOOK, 2 },1370 { TV_MAGIC_BOOK, 3 }1371 }1372 };1373 1374 1375 1376 1125 static void autoinscribe_init(void) 1377 1126 { … … 1508 1257 1509 1258 /* Extract the tval/sval codes */ 1510 int tv = store_ table[i][k][0];1511 int sv = store_ table[i][k][1];1259 int tv = store_choices[i][k][0]; 1260 int sv = store_choices[i][k][1]; 1512 1261 1513 1262 /* Look for it */ trunk/src/store.c
r1 r36 2 2 3 3 /* 4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke 4 * Copyright (c) 1997-2005 Andrew Sidwell, Ben Harrison, James E. Wilson, 5 * Robert A. Koeneke 5 6 * 6 7 * This software may be copied and distributed for educational, research, … … 10 11 11 12 #include "angband.h" 12 13 13 #include "script.h" 14 14 15 16 #define MAX_COMMENT_ACCEPT 6 17 18 static cptr comment_accept[MAX_COMMENT_ACCEPT] = 15 /*** Various file-wide definitions ***/ 16 17 /** Store display stuff **/ 18 19 /* Easy names for the elements of the 'scr_places' arrays. */ 20 enum 21 { 22 LOC_PRICE = 0, 23 LOC_OWNER, 24 LOC_HEADER, 25 LOC_ITEMS_START, 26 LOC_ITEMS_END, 27 LOC_MORE, 28 LOC_HELP_CLEAR, 29 LOC_HELP_PROMPT, 30 LOC_AU, 31 32 LOC_MAX 33 }; 34 35 /* Places for the various things displayed onscreen */ 36 static unsigned int scr_places_x[LOC_MAX]; 37 static unsigned int scr_places_y[LOC_MAX]; 38 39 /* State flags */ 40 #define STORE_HELP 0x000001 41 #define STORE_INVEN_CHANGE 0x000002 42 #define STORE_GOLD_CHANGE 0x000004 43 #define STORE_HELP_CHANGE 0x000008 44 #define STORE_FRAME_CHANGE 0x000010 45 #define STORE_MORE_CHANGE 0x000020 46 #define STORE_SIZE_CHANGE 0x000040 47 48 /* Compound flag for the initial display of a store */ 49 #define STORE_INIT_CHANGE \ 50 (STORE_INVEN_CHANGE | STORE_FRAME_CHANGE | STORE_GOLD_CHANGE | \ 51 STORE_HELP_CHANGE | STORE_SIZE_CHANGE) 52 53 54 /** Variables to maintain state -- these shouldn't really exist ***/ 55 56 /* Current store number */ 57 static int store_current; 58 59 /* Item at the top of the current store display */ 60 static int store_top; 61 62 /* Flags for the display */ 63 static u32b store_flags; 64 65 66 67 68 /*** Utility function ***/ 69 70 /* 71 * Return the owner struct for the given store. 72 */ 73 owner_type *store_owner(int st) 74 { 75 store_type *st_ptr = &store[st]; 76 return &b_info[(st * z_info->b_max) + st_ptr->owner]; 77 } 78 79 80 81 /*** Flavour text stuff ***/ 82 83 /* 84 * Messages for reacting to purchase prices. 85 */ 86 static const char *comment_worthless[] = 87 { 88 "Arrgghh!", 89 "You bastard!", 90 "You hear someone sobbing...", 91 "The shopkeeper howls in agony!" 92 }; 93 94 static const char *comment_bad[] = 95 { 96 "Damn!", 97 "You fiend!", 98 "The shopkeeper curses at you.", 99 "The shopkeeper glares at you." 100 }; 101 102 static const char *comment_accept[] = 19 103 { 20 104 "Okay.", … … 26 110 }; 27 111 28 29 #define MAX_COMMENT_INSULT 8 30 31 static cptr comment_insult[MAX_COMMENT_INSULT] = 32 { 33 "Try again.", 34 "Ridiculous!", 35 "You will have to do better than that!", 36 "Do you wish to do business or not?", 37 "You've got to be kidding!", 38 "You'd better be kidding!", 39 "You try my patience.", 40 "Hmmm, nice weather we're having." 41 }; 42 43 44 #define MAX_COMMENT_NONSENSE 4 45 46 static cptr comment_nonsense[MAX_COMMENT_NONSENSE] = 47 { 48 "I must have heard you wrong.", 49 "I'm sorry, I missed that.", 50 "I'm sorry, what was that?", 51 "Sorry, what was that again?" 52 }; 53 54 55 56 /* 57 * Successful haggle. 58 */ 59 static void say_comment_accept(void) 60 { 61 message(MSG_STORE5, 0, comment_accept[rand_int(MAX_COMMENT_ACCEPT)]); 62 } 63 64 65 /* 66 * You are insulting me 67 */ 68 static void say_comment_insult(void) 69 { 70 msg_print(comment_insult[rand_int(MAX_COMMENT_INSULT)]); 71 } 72 73 74 /* 75 * You are making no sense. 76 */ 77 static void say_comment_nonsense(void) 78 { 79 msg_print(comment_nonsense[rand_int(MAX_COMMENT_NONSENSE)]); 80 } 81 82 83 84 /* 85 * Messages for reacting to purchase prices. 86 */ 87 88 #define MAX_COMMENT_WORTHLESS 4 89 90 static cptr comment_worthless[MAX_COMMENT_WORTHLESS] = 91 { 92 "Arrgghh!", 93 "You bastard!", 94 "You hear someone sobbing...", 95 "The shopkeeper howls in agony!" 96 }; 97 98 #define MAX_COMMENT_BAD 4 99 100 static cptr comment_bad[MAX_COMMENT_BAD] = 101 { 102 "Damn!", 103 "You fiend!", 104 "The shopkeeper curses at you.", 105 "The shopkeeper glares at you." 106 }; 107 108 #define MAX_COMMENT_GOOD 4 109 110 static cptr comment_good[MAX_COMMENT_GOOD] = 112 static const char *comment_good[] = 111 113 { 112 114 "Cool!", … … 116 118 }; 117 119 118 #define MAX_COMMENT_GREAT 4 119 120 static cptr comment_great[MAX_COMMENT_GREAT] = 120 static const char *comment_great[] = 121 121 { 122 122 "Yipee!", … … 126 126 }; 127 127 128 /* Randomly select one of the entries in an array */ 129 #define ONE_OF(x) x[rand_int(N_ELEMENTS(x))] 130 128 131 129 132 /* … … 136 139 /* Item was worthless, but we bought it */ 137 140 if ((value <= 0) && (price > value)) 138 { 139 /* Comment */ 140 message(MSG_STORE1, 0, comment_worthless[rand_int(MAX_COMMENT_WORTHLESS)]); 141 } 141 message(MSG_STORE1, 0, ONE_OF(comment_worthless)); 142 142 143 143 /* Item was cheaper than we thought, and we paid more than necessary */ 144 144 else if ((value < guess) && (price > value)) 145 { 146 /* Comment */ 147 message(MSG_STORE2, 0, comment_bad[rand_int(MAX_COMMENT_BAD)]); 148 } 145 message(MSG_STORE2, 0, ONE_OF(comment_bad)); 149 146 150 147 /* Item was a good bargain, and we got away with it */ 151 148 else if ((value > guess) && (value < (4 * guess)) && (price < value)) 152 { 153 /* Comment */ 154 message(MSG_STORE3, 0, comment_good[rand_int(MAX_COMMENT_GOOD)]); 155 } 149 message(MSG_STORE3, 0, ONE_OF(comment_good)); 156 150 157 151 /* Item was a great bargain, and we got away with it */ 158 152 else if ((value > guess) && (price < value)) 159 { 160 /* Comment */ 161 message(MSG_STORE4, 0, comment_great[rand_int(MAX_COMMENT_GREAT)]); 162 } 163 } 164 165 166 static int get_store_choice(int store_num) 167 { 168 return store[store_num].table[rand_int(store[store_num].table_num)]; 153 message(MSG_STORE4, 0, ONE_OF(comment_great)); 169 154 } 170 155 … … 319 304 320 305 321 /* 322 * We store the current "store number" here so everyone can access it 323 */ 324 static int store_num = 7; 325 326 /* 327 * We store the current "store page" here so everyone can access it 328 */ 329 static int store_top = 0; 330 331 /* 332 * We store the current "store pointer" here so everyone can access it 333 */ 334 static store_type *st_ptr = NULL; 335 336 /* 337 * We store the current "owner type" here so everyone can access it 338 */ 339 static owner_type *ot_ptr = NULL; 340 341 342 343 344 306 /*** Basics: pricing, generation, etc. ***/ 345 307 346 308 /* 347 309 * Determine the price of an object (qty one) in a store. 310 * 311 * `flip` == TRUE means the shop is buying, player selling 312 * == FALSE means the shop is selling, player buying 348 313 * 349 314 * This function takes into account the player's charisma, and the … … 363 328 * "greed" value is always something (?). 364 329 */ 365 static s32b price_item(const object_type *o_ptr, int greed,bool flip)330 static s32b price_item(const object_type *o_ptr, bool flip) 366 331 { 367 332 int factor; … … 369 334 s32b price; 370 335 336 owner_type *ot_ptr = store_owner(store_current); 337 338 /* The greed value is always of the current store's owner */ 339 int greed = ot_ptr->inflate; 340 371 341 372 342 /* Get the value of one of the items */ … … 394 364 395 365 /* Mega-Hack -- Black market sucks */ 396 if (store_ num== STORE_B_MARKET) price = price / 2;366 if (store_current == STORE_B_MARKET) price = price / 2; 397 367 } 398 368 … … 407 377 408 378 /* Mega-Hack -- Black market sucks */ 409 if (store_ num== STORE_B_MARKET) price = price * 2;379 if (store_current == STORE_B_MARKET) price = price * 2; 410 380 } 411 381 … … 556 526 557 527 /* 558 * Convert a store item index into a one character label559 *560 * We use labels "a"-"l" for page 1, and labels "m"-"x" for page 2.561 */562 static s16b store_to_label(int i)563 {564 /* Assume legal */565 return (I2A(i));566 }567 568 569 /*570 * Convert a one character label into a store item index.571 *572 * Return "-1" if the label does not indicate a real store item.573 */574 static s16b label_to_store(int c)575 {576 int i;577 578 /* Convert */579 i = (islower((unsigned char)c) ? A2I(c) : -1);580 581 /* Verify the index */582 if ((i < 0) || (i >= st_ptr->stock_num)) return (-1);583 584 /* Return the index */585 return (i);586 }587 588 589 590 /*591 528 * Determine if a store object can "absorb" another object. 592 529 * … … 679 616 * adding them to a pile which was already full. 680 617 */ 681 static bool store_check_num( const object_type *o_ptr)618 static bool store_check_num(int st, const object_type *o_ptr) 682 619 { 683 620 int i; 684 621 object_type *j_ptr; 685 622 623 store_type *st_ptr = &store[st]; 624 686 625 /* Free space is always usable */ 687 626 if (st_ptr->stock_num < st_ptr->stock_size) return TRUE; 688 627 689 628 /* The "home" acts like the player */ 690 if (st ore_num== STORE_HOME)629 if (st == STORE_HOME) 691 630 { 692 631 /* Check all the objects */ … … 725 664 static bool store_will_buy_tester(const object_type *o_ptr) 726 665 { 727 return store_will_buy(store_ num, o_ptr);728 } 729 730 731 /* 732 * Add an object to the inventory of the "Home"666 return store_will_buy(store_current, o_ptr); 667 } 668 669 670 /* 671 * Add an object to the inventory of the Home. 733 672 * 734 673 * In all cases, return the slot (or -1) where the object was placed. … … 736 675 * Note that this is a hacked up version of "inven_carry()". 737 676 * 738 * Also note that it may not correctly "adapt" to "knowledge" b acoming739 * known ,the player may have to pick stuff up and drop it again.677 * Also note that it may not correctly "adapt" to "knowledge" becoming 678 * known: the player may have to pick stuff up and drop it again. 740 679 */ 741 680 static int home_carry(object_type *o_ptr) 742 681 { 743 682 int i, slot; 744 s32b value, j_value;683 u32b value, j_value; 745 684 object_type *j_ptr; 746 685 686 store_type *st_ptr = &store[STORE_HOME]; 747 687 748 688 /* Check each existing object (try to combine) */ … … 834 774 * In all cases, return the slot (or -1) where the object was placed 835 775 */ 836 static int store_carry( object_type *o_ptr)776 static int store_carry(int st, object_type *o_ptr) 837 777 { 838 778 int i, slot; 839 s32b value, j_value;779 u32b value, j_value; 840 780 object_type *j_ptr; 841 781 782 store_type *st_ptr = &store[st]; 842 783 843 784 /* Evaluate the object */ … … 916 857 917 858 /* 918 * Increase, by a given amount, the number of a certain item919 * in a certain store.This can result in zero items.920 */ 921 static void store_item_increase(int item, int num)859 * Increase, by a 'num', the number of an item 'item' in store 'st'. 860 * This can result in zero items. 861 */ 862 static void store_item_increase(int st, int item, int num) 922 863 { 923 864 int cnt; 924 865 object_type *o_ptr; 866 867 store_type *st_ptr = &store[st]; 925 868 926 869 /* Get the object */ … … 931 874 if (cnt > 255) cnt = 255; 932 875 else if (cnt < 0) cnt = 0; 933 num = cnt - o_ptr->number;934 876 935 877 /* Save the new number */ 936 o_ptr->number += num;937 } 938 939 940 /* 941 * Remove a slot if it is empty 942 */ 943 static void store_item_optimize(int item)878 o_ptr->number = cnt; 879 } 880 881 882 /* 883 * Remove a slot if it is empty, in store 'st'. 884 */ 885 static void store_item_optimize(int st, int item) 944 886 { 945 887 int j; 946 888 object_type *o_ptr; 947 889 890 store_type *st_ptr = &store[st]; 891 948 892 /* Get the object */ 949 893 o_ptr = &st_ptr->stock[item]; … … 969 913 970 914 971 /* 972 * This function will keep 'crap' out of the black market. 973 * Crap is defined as any object that is "available" elsewhere 974 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com> 975 */ 976 static bool black_market_crap(const object_type *o_ptr) 915 916 /* 917 * Delete a random object from store 'st', or, if it is a stack, perhaps only 918 * partially delete it. 919 * 920 * This function is used when store maintainance occurs, and is designed to 921 * imitate non-PC purchasers making purchases from the store. 922 */ 923 static void store_delete_item(int st) 924 { 925 int what, num; 926 object_type *o_ptr; 927 928 store_type *st_ptr = &store[st]; 929 930 /* Paranoia */ 931 if (st_ptr->stock_num <= 0) return; 932 933 /* Pick a random slot */ 934 what = rand_int(st_ptr->stock_num); 935 936 /* Get the object */ 937 o_ptr = &st_ptr->stock[what]; 938 939 /* Determine how many objects are in the slot */ 940 num = o_ptr->number; 941 942 /* Deal with stacks */ 943 if (num > 1) 944 { 945 /* Sometimes destroy a single object */ 946 if (rand_int(100) < 50) num = 1; 947 948 /* Sometimes destroy half the objects */ 949 else if (rand_int(100) < 50) num = (num + 1) / 2; 950 951 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. */ 952 if ((o_ptr->tval == TV_ROD) || 953 (o_ptr->tval == TV_STAFF) || 954 (o_ptr->tval == TV_WAND)) 955 { 956 o_ptr->pval -= num * o_ptr->pval / o_ptr->number; 957 } 958 } 959 960 /* Delete the item */ 961 store_item_increase(st, what, -num); 962 store_item_optimize(st, what); 963 } 964 965 966 967 /* 968 * This makes sure that the black market doesn't stock any object that other 969 * stores have, unless it is an ego-item or has various bonuses. 970 * 971 * Based on a suggestion by Lee Vogt <lvogt@cig.mcel.mot.com>. 972 * 973 * If the stores ever become truly externalised, i.e. if Lua becomes more 974 * integrated, then there should be some way to get this out of the compiled 975 * code, as it is a little hacky. XXX 976 */ 977 static bool black_market_ok(const object_type *o_ptr) 977 978 { 978 979 int i, j; 979 980 980 /* Ego items are never crap */ 981 if (o_ptr->name2) return (FALSE); 982 983 /* Good items are never crap */ 984 if (o_ptr->to_a > 0) return (FALSE); 985 if (o_ptr->to_h > 0) return (FALSE); 986 if (o_ptr->to_d > 0) return (FALSE); 981 /* Ego items are always fine */ 982 if (o_ptr->name2) return (TRUE); 983 984 /* Good items are normally fine */ 985 if (o_ptr->to_a > 2) return (TRUE); 986 if (o_ptr->to_h > 1) return (TRUE); 987 if (o_ptr->to_d > 2) return (TRUE); 988 989 990 /* No cheap items */ 991 if (object_value(o_ptr) < 10) return (FALSE); 987 992 988 993 /* Check the other stores */ … … 991 996 /* Skip home and black market */ 992 997 if (i == STORE_B_MARKET || i == STORE_HOME)
