comparison arogue7/pack.c @ 219:f9ef86cf22b2

Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents 1cd604c827a3
children e1cd27c5464f
comparison
equal deleted inserted replaced
218:56e748983fa8 219:f9ef86cf22b2
18 #include "rogue.h" 18 #include "rogue.h"
19 #ifdef PC7300 19 #ifdef PC7300
20 #include "menu.h" 20 #include "menu.h"
21 #endif 21 #endif
22 22
23 bool is_type (struct object *obj, int type);
24
23 /* 25 /*
24 * Routines to deal with the pack 26 * Routines to deal with the pack
25 */ 27 */
26 28
27 /* 29 /*
28 * add_pack: 30 * add_pack:
29 * Pick up an object and add it to the pack. If the argument is non-null 31 * Pick up an object and add it to the pack. If the argument is non-null
30 * use it as the linked_list pointer instead of gettting it off the ground. 32 * use it as the linked_list pointer instead of gettting it off the ground.
31 */ 33 */
32 bool 34 bool
33 add_pack(item, silent, packret) 35 add_pack(struct linked_list *item, bool silent, struct linked_list **packret)
34 register struct linked_list *item, **packret;
35 bool silent;
36 { 36 {
37 register struct linked_list *ip, *lp = NULL, *ap; 37 register struct linked_list *ip, *lp = NULL, *ap;
38 register struct object *obj, *op = NULL; 38 register struct object *obj, *op = NULL;
39 register bool exact, from_floor; 39 register bool exact, from_floor;
40 40
370 370
371 /* 371 /*
372 * inventory: 372 * inventory:
373 * list what is in the pack 373 * list what is in the pack
374 */ 374 */
375 inventory(list, type) 375 bool
376 register struct linked_list *list; 376 inventory(struct linked_list *list, int type)
377 register int type;
378 { 377 {
379 register struct object *obj; 378 register struct object *obj;
380 register char ch; 379 register char ch;
381 register int n_objs, cnt, maxx, curx; 380 register int n_objs, cnt, maxx, curx;
382 char inv_temp[2*LINELEN+1]; 381 char inv_temp[2*LINELEN+1];
509 /* 508 /*
510 * picky_inven: 509 * picky_inven:
511 * Allow player to inventory a single item 510 * Allow player to inventory a single item
512 */ 511 */
513 void 512 void
514 picky_inven() 513 picky_inven(void)
515 { 514 {
516 register struct linked_list *item; 515 register struct linked_list *item;
517 register char ch, mch; 516 register char ch, mch;
518 517
519 if (pack == NULL) 518 if (pack == NULL)
563 562
564 563
565 /* 564 /*
566 * get_item: 565 * get_item:
567 * pick something out of a pack for a purpose 566 * pick something out of a pack for a purpose
567 * purpose: NULL if we should be silent (no prompts)
568 */ 568 */
569 struct linked_list * 569 struct linked_list *
570 get_item(list, purpose, type, askfirst, showcost) 570 get_item(struct linked_list *list, char *purpose, int type, bool askfirst,
571 reg struct linked_list *list; 571 bool showcost)
572 char *purpose; /* NULL if we should be silent (no prompts) */
573 int type;
574 bool askfirst, showcost;
575 { 572 {
576 reg struct linked_list *item; 573 reg struct linked_list *item;
577 reg struct object *obj; 574 reg struct object *obj;
578 reg int cnt, pagecnt, ch, och, maxx, curx, confused; 575 reg int cnt, pagecnt, ch, och, maxx, curx, confused;
579 struct linked_list *saveitem = NULL; 576 struct linked_list *saveitem = NULL;
752 } 749 }
753 } 750 }
754 #endif 751 #endif
755 /* Write the screen */ 752 /* Write the screen */
756 if ((menu_overlay && cnt < lines / 2 + 2) || cnt == 1) { 753 if ((menu_overlay && cnt < lines / 2 + 2) || cnt == 1) {
757 over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, NULL); 754 over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, '\0');
758 cnt = -1; /* Indicate we used over_win */ 755 cnt = -1; /* Indicate we used over_win */
759 } 756 }
760 else draw(hw); 757 else draw(hw);
761 758
762 if (purpose) { 759 if (purpose) {
810 else 807 else
811 msg ("You can't %s that!", purpose); 808 msg ("You can't %s that!", purpose);
812 } 809 }
813 } 810 }
814 811
815 pack_char(list, obj) 812 char
816 register struct object *obj; 813 pack_char(struct linked_list *list, struct object *obj)
817 struct linked_list *list;
818 { 814 {
819 register struct linked_list *item; 815 register struct linked_list *item;
820 register char c; 816 register char c;
821 817
822 c = 'a'; 818 c = 'a';
834 830
835 /* 831 /*
836 * cur_null: 832 * cur_null:
837 * This updates cur_weapon etc for dropping things 833 * This updates cur_weapon etc for dropping things
838 */ 834 */
839 cur_null(op) 835 void
840 reg struct object *op; 836 cur_null(struct object *op)
841 { 837 {
842 if (op == cur_weapon) cur_weapon = NULL; 838 if (op == cur_weapon) cur_weapon = NULL;
843 else if (op == cur_armor) cur_armor = NULL; 839 else if (op == cur_armor) cur_armor = NULL;
844 else if (op == cur_ring[LEFT_1]) cur_ring[LEFT_1] = NULL; 840 else if (op == cur_ring[LEFT_1]) cur_ring[LEFT_1] = NULL;
845 else if (op == cur_ring[LEFT_2]) cur_ring[LEFT_2] = NULL; 841 else if (op == cur_ring[LEFT_2]) cur_ring[LEFT_2] = NULL;
859 855
860 /* 856 /*
861 * idenpack: 857 * idenpack:
862 * Identify all the items in the pack 858 * Identify all the items in the pack
863 */ 859 */
864 idenpack() 860 void
861 idenpack(void)
865 { 862 {
866 reg struct linked_list *pc; 863 reg struct linked_list *pc;
867 864
868 for (pc = pack ; pc != NULL ; pc = next(pc)) 865 for (pc = pack ; pc != NULL ; pc = next(pc))
869 whatis(pc); 866 whatis(pc);
870 } 867 }
871 868
872 is_type (obj, type) 869 bool
873 register struct object *obj; 870 is_type (struct object *obj, int type)
874 register int type;
875 { 871 {
876 register bool current; 872 register bool current;
877 873
878 if (type == obj->o_type) 874 if (type == obj->o_type)
879 return (TRUE); 875 return (TRUE);
1022 } 1018 }
1023 } 1019 }
1024 return(FALSE); 1020 return(FALSE);
1025 } 1021 }
1026 1022
1027 del_pack(item) 1023 void
1028 register struct linked_list *item; 1024 del_pack(struct linked_list *item)
1029 { 1025 {
1030 register struct object *obj; 1026 register struct object *obj;
1031 1027
1032 obj = OBJPTR(item); 1028 obj = OBJPTR(item);
1033 if (obj->o_count > 1) { 1029 if (obj->o_count > 1) {
1045 * carry_obj: 1041 * carry_obj:
1046 * Check to see if a monster is carrying something and, if so, give 1042 * Check to see if a monster is carrying something and, if so, give
1047 * it to him. 1043 * it to him.
1048 */ 1044 */
1049 1045
1050 carry_obj(mp, chance) 1046 void
1051 register struct thing *mp; 1047 carry_obj(struct thing *mp, int chance)
1052 int chance;
1053 { 1048 {
1054 reg struct linked_list *item; 1049 reg struct linked_list *item;
1055 reg struct object *obj; 1050 reg struct object *obj;
1056 1051
1057 /* 1052 /*
1070 * floor and so the hero will know where it is if he's trying to 1065 * floor and so the hero will know where it is if he's trying to
1071 * avoid it. Note that only UNIQUEs carry relics. 1066 * avoid it. Note that only UNIQUEs carry relics.
1072 */ 1067 */
1073 if (on(*mp, ISUNIQUE)) { 1068 if (on(*mp, ISUNIQUE)) {
1074 if (on(*mp, CARRYMDAGGER)) { 1069 if (on(*mp, CARRYMDAGGER)) {
1075 item = spec_item(RELIC, MUSTY_DAGGER, NULL, NULL); 1070 item = spec_item(RELIC, MUSTY_DAGGER, 0, 0);
1076 obj = OBJPTR(item); 1071 obj = OBJPTR(item);
1077 obj->o_pos = mp->t_pos; 1072 obj->o_pos = mp->t_pos;
1078 attach(mp->t_pack, item); 1073 attach(mp->t_pack, item);
1079 } 1074 }
1080 1075
1081 if (on(*mp, CARRYCLOAK)) { 1076 if (on(*mp, CARRYCLOAK)) {
1082 item = spec_item(RELIC, EMORI_CLOAK, NULL, NULL); 1077 item = spec_item(RELIC, EMORI_CLOAK, 0, 0);
1083 obj = OBJPTR(item); 1078 obj = OBJPTR(item);
1084 obj->o_pos = mp->t_pos; 1079 obj->o_pos = mp->t_pos;
1085 attach(mp->t_pack, item); 1080 attach(mp->t_pack, item);
1086 } 1081 }
1087 1082
1088 if (on(*mp, CARRYANKH)) { 1083 if (on(*mp, CARRYANKH)) {
1089 item = spec_item(RELIC, HEIL_ANKH, NULL, NULL); 1084 item = spec_item(RELIC, HEIL_ANKH, 0, 0);
1090 obj = OBJPTR(item); 1085 obj = OBJPTR(item);
1091 obj->o_pos = mp->t_pos; 1086 obj->o_pos = mp->t_pos;
1092 attach(mp->t_pack, item); 1087 attach(mp->t_pack, item);
1093 } 1088 }
1094 1089
1095 if (on(*mp, CARRYSTAFF)) { 1090 if (on(*mp, CARRYSTAFF)) {
1096 item = spec_item(RELIC, MING_STAFF, NULL, NULL); 1091 item = spec_item(RELIC, MING_STAFF, 0, 0);
1097 obj = OBJPTR(item); 1092 obj = OBJPTR(item);
1098 obj->o_pos = mp->t_pos; 1093 obj->o_pos = mp->t_pos;
1099 attach(mp->t_pack, item); 1094 attach(mp->t_pack, item);
1100 } 1095 }
1101 1096
1102 if (on(*mp, CARRYWAND)) { 1097 if (on(*mp, CARRYWAND)) {
1103 item = spec_item(RELIC, ORCUS_WAND, NULL, NULL); 1098 item = spec_item(RELIC, ORCUS_WAND, 0, 0);
1104 obj = OBJPTR(item); 1099 obj = OBJPTR(item);
1105 obj->o_pos = mp->t_pos; 1100 obj->o_pos = mp->t_pos;
1106 attach(mp->t_pack, item); 1101 attach(mp->t_pack, item);
1107 } 1102 }
1108 1103
1109 if (on(*mp, CARRYROD)) { 1104 if (on(*mp, CARRYROD)) {
1110 item = spec_item(RELIC, ASMO_ROD, NULL, NULL); 1105 item = spec_item(RELIC, ASMO_ROD, 0, 0);
1111 obj = OBJPTR(item); 1106 obj = OBJPTR(item);
1112 obj->o_pos = mp->t_pos; 1107 obj->o_pos = mp->t_pos;
1113 attach(mp->t_pack, item); 1108 attach(mp->t_pack, item);
1114 } 1109 }
1115 1110
1116 if (on(*mp, CARRYYAMULET)) { 1111 if (on(*mp, CARRYYAMULET)) {
1117 item = spec_item(RELIC, YENDOR_AMULET, NULL, NULL); 1112 item = spec_item(RELIC, YENDOR_AMULET, 0, 0);
1118 obj = OBJPTR(item); 1113 obj = OBJPTR(item);
1119 obj->o_pos = mp->t_pos; 1114 obj->o_pos = mp->t_pos;
1120 attach(mp->t_pack, item); 1115 attach(mp->t_pack, item);
1121 } 1116 }
1122 1117
1123 if (on(*mp, CARRYBAMULET)) { 1118 if (on(*mp, CARRYBAMULET)) {
1124 item = spec_item(RELIC, STONEBONES_AMULET, NULL, NULL); 1119 item = spec_item(RELIC, STONEBONES_AMULET, 0, 0);
1125 obj = OBJPTR(item); 1120 obj = OBJPTR(item);
1126 obj->o_pos = mp->t_pos; 1121 obj->o_pos = mp->t_pos;
1127 attach(mp->t_pack, item); 1122 attach(mp->t_pack, item);
1128 } 1123 }
1129 1124
1130 if (on(*mp, CARRYMANDOLIN)) { 1125 if (on(*mp, CARRYMANDOLIN)) {
1131 item = spec_item(RELIC, BRIAN_MANDOLIN, NULL, NULL); 1126 item = spec_item(RELIC, BRIAN_MANDOLIN, 0, 0);
1132 obj = OBJPTR(item); 1127 obj = OBJPTR(item);
1133 obj->o_pos = mp->t_pos; 1128 obj->o_pos = mp->t_pos;
1134 attach(mp->t_pack, item); 1129 attach(mp->t_pack, item);
1135 } 1130 }
1136 if (on(*mp, CARRYEYE)) { 1131 if (on(*mp, CARRYEYE)) {
1137 item = spec_item(RELIC, EYE_VECNA, NULL, NULL); 1132 item = spec_item(RELIC, EYE_VECNA, 0, 0);
1138 obj = OBJPTR(item); 1133 obj = OBJPTR(item);
1139 obj->o_pos = mp->t_pos; 1134 obj->o_pos = mp->t_pos;
1140 attach(mp->t_pack, item); 1135 attach(mp->t_pack, item);
1141 } 1136 }
1142 if (on(*mp, CARRYAXE)) { 1137 if (on(*mp, CARRYAXE)) {
1143 item = spec_item(RELIC, AXE_AKLAD, NULL, NULL); 1138 item = spec_item(RELIC, AXE_AKLAD, 0, 0);
1144 obj = OBJPTR(item); 1139 obj = OBJPTR(item);
1145 obj->o_pos = mp->t_pos; 1140 obj->o_pos = mp->t_pos;
1146 attach(mp->t_pack, item); 1141 attach(mp->t_pack, item);
1147 } 1142 }
1148 if (on(*mp, CARRYQUILL)) { 1143 if (on(*mp, CARRYQUILL)) {
1149 register int i, howmany; 1144 register int i, howmany;
1150 1145
1151 item = spec_item(RELIC, QUILL_NAGROM, NULL, NULL); 1146 item = spec_item(RELIC, QUILL_NAGROM, 0, 0);
1152 obj = OBJPTR(item); 1147 obj = OBJPTR(item);
1153 obj->o_pos = mp->t_pos; 1148 obj->o_pos = mp->t_pos;
1154 obj->o_charges = rnd(QUILLCHARGES); 1149 obj->o_charges = rnd(QUILLCHARGES);
1155 attach(mp->t_pack, item); 1150 attach(mp->t_pack, item);
1156 howmany = roll(4,3); 1151 howmany = roll(4,3);
1163 obj->o_pos = mp->t_pos; 1158 obj->o_pos = mp->t_pos;
1164 attach(mp->t_pack, item); 1159 attach(mp->t_pack, item);
1165 } 1160 }
1166 } 1161 }
1167 if (on(*mp, CARRYMSTAR)) { 1162 if (on(*mp, CARRYMSTAR)) {
1168 item = spec_item(RELIC, HRUGGEK_MSTAR, NULL, NULL); 1163 item = spec_item(RELIC, HRUGGEK_MSTAR, 0, 0);
1169 obj = OBJPTR(item); 1164 obj = OBJPTR(item);
1170 obj->o_pos = mp->t_pos; 1165 obj->o_pos = mp->t_pos;
1171 attach(mp->t_pack, item); 1166 attach(mp->t_pack, item);
1172 } 1167 }
1173 if (on(*mp, CARRYFLAIL)) { 1168 if (on(*mp, CARRYFLAIL)) {
1174 item = spec_item(RELIC, YEENOGHU_FLAIL, NULL, NULL); 1169 item = spec_item(RELIC, YEENOGHU_FLAIL, 0, 0);
1175 obj = OBJPTR(item); 1170 obj = OBJPTR(item);
1176 obj->o_pos = mp->t_pos; 1171 obj->o_pos = mp->t_pos;
1177 attach(mp->t_pack, item); 1172 attach(mp->t_pack, item);
1178 } 1173 }
1179 if (on(*mp, CARRYHORN)) { 1174 if (on(*mp, CARRYHORN)) {
1180 item = spec_item(RELIC, GERYON_HORN, NULL, NULL); 1175 item = spec_item(RELIC, GERYON_HORN, 0, 0);
1181 obj = OBJPTR(item); 1176 obj = OBJPTR(item);
1182 obj->o_pos = mp->t_pos; 1177 obj->o_pos = mp->t_pos;
1183 attach(mp->t_pack, item); 1178 attach(mp->t_pack, item);
1184 } 1179 }
1185 if (on(*mp, CARRYSURTURRING)) { 1180 if (on(*mp, CARRYSURTURRING)) {
1186 item = spec_item(RELIC, SURTUR_RING, NULL, NULL); 1181 item = spec_item(RELIC, SURTUR_RING, 0, 0);
1187 obj = OBJPTR(item); 1182 obj = OBJPTR(item);
1188 obj->o_pos = mp->t_pos; 1183 obj->o_pos = mp->t_pos;
1189 attach(mp->t_pack, item); 1184 attach(mp->t_pack, item);
1190 } 1185 }
1191 } 1186 }
1192 /* 1187 /*
1193 * If it carries gold, give it some 1188 * If it carries gold, give it some
1194 */ 1189 */
1195 if (on(*mp, CARRYGOLD) && rnd(100) < chance) { 1190 if (on(*mp, CARRYGOLD) && rnd(100) < chance) {
1196 item = spec_item(GOLD, NULL, NULL, NULL); 1191 item = spec_item(GOLD, 0, 0, 0);
1197 obj = OBJPTR(item); 1192 obj = OBJPTR(item);
1198 obj->o_count = GOLDCALC + GOLDCALC; 1193 obj->o_count = GOLDCALC + GOLDCALC;
1199 obj->o_pos = mp->t_pos; 1194 obj->o_pos = mp->t_pos;
1200 attach(mp->t_pack, item); 1195 attach(mp->t_pack, item);
1201 } 1196 }
1202 1197
1203 /* 1198 /*
1204 * If it carries food, give it some 1199 * If it carries food, give it some
1205 */ 1200 */
1206 if (on(*mp, CARRYFOOD) && rnd(100) < chance) { 1201 if (on(*mp, CARRYFOOD) && rnd(100) < chance) {
1207 item = spec_item(FOOD, NULL, NULL, NULL); 1202 item = spec_item(FOOD, 0, 0, 0);
1208 obj = OBJPTR(item); 1203 obj = OBJPTR(item);
1209 obj->o_weight = things[TYP_FOOD].mi_wght; 1204 obj->o_weight = things[TYP_FOOD].mi_wght;
1210 obj->o_pos = mp->t_pos; 1205 obj->o_pos = mp->t_pos;
1211 attach(mp->t_pack, item); 1206 attach(mp->t_pack, item);
1212 } 1207 }
1326 * nothing is there, do nothing. If there is one thing, pick it 1321 * nothing is there, do nothing. If there is one thing, pick it
1327 * up. If there are multiple things, prompt the player for what 1322 * up. If there are multiple things, prompt the player for what
1328 * he wants (* means everything). 1323 * he wants (* means everything).
1329 */ 1324 */
1330 1325
1331 grab(y, x) 1326 int
1332 register y, x; 1327 grab(int y, int x)
1333 { 1328 {
1334 register struct linked_list *next_item, *item; 1329 register struct linked_list *next_item, *item;
1335 register struct object *obj; 1330 register struct object *obj;
1336 register int cnt, pagecnt; 1331 register int cnt, pagecnt;
1337 int num_there = 0, ch, och; 1332 int num_there = 0, ch, och;
1396 * If we have fewer than half a screenful, don't clear the screen. 1391 * If we have fewer than half a screenful, don't clear the screen.
1397 * Leave an extra blank line at the bottom and 3 blank columns 1392 * Leave an extra blank line at the bottom and 3 blank columns
1398 * to he right. 1393 * to he right.
1399 */ 1394 */
1400 if (menu_overlay && num_there < lines / 2 + 2) { 1395 if (menu_overlay && num_there < lines / 2 + 2) {
1401 over_win(cw, hw, num_there + 2, maxlen + 3, num_there, curlen, NULL); 1396 over_win(cw, hw, num_there + 2, maxlen + 3, num_there, curlen, '\0');
1402 pagecnt = -1; /* Indicate we used over_win */ 1397 pagecnt = -1; /* Indicate we used over_win */
1403 } 1398 }
1404 else draw(hw); /* write screen */ 1399 else draw(hw); /* write screen */
1405 1400
1406 for (;;) { 1401 for (;;) {
1444 * screen. Leave an extra blank line at the bottom and 1439 * screen. Leave an extra blank line at the bottom and
1445 * 3 blank columns to he right. 1440 * 3 blank columns to he right.
1446 */ 1441 */
1447 if (menu_overlay && num_there < lines / 2 + 2) { 1442 if (menu_overlay && num_there < lines / 2 + 2) {
1448 over_win(cw, hw, num_there + 2, maxlen + 3, 1443 over_win(cw, hw, num_there + 2, maxlen + 3,
1449 num_there, 49, NULL); 1444 num_there, 49, '\0');
1450 cnt = -1; /* Indicate we used over_win */ 1445 cnt = -1; /* Indicate we used over_win */
1451 } 1446 }
1452 else draw(hw); /* write screen */ 1447 else draw(hw); /* write screen */
1453 continue; 1448 continue;
1454 } 1449 }
1483 * make_sell_pack: 1478 * make_sell_pack:
1484 * 1479 *
1485 * Create a pack for sellers (a la quartermaster) 1480 * Create a pack for sellers (a la quartermaster)
1486 */ 1481 */
1487 1482
1488 make_sell_pack(tp) 1483 void
1489 struct thing *tp; 1484 make_sell_pack(struct thing *tp)
1490 { 1485 {
1491 reg struct linked_list *item; 1486 reg struct linked_list *item;
1492 reg struct object *obj; 1487 reg struct object *obj;
1493 reg int sell_type, nitems, i; 1488 reg int sell_type, nitems, i;
1494 1489