Mercurial > hg > early-roguelike
comparison xrogue/pack.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
| author | John "Elwin" Edwards |
|---|---|
| date | Wed, 02 Mar 2016 21:13:26 -0500 |
| parents | cadff8f047a1 |
| children | 7c1cb43f346e |
comparison
equal
deleted
inserted
replaced
| 219:f9ef86cf22b2 | 220:f54901b9c39b |
|---|---|
| 19 #include <curses.h> | 19 #include <curses.h> |
| 20 #include <ctype.h> | 20 #include <ctype.h> |
| 21 #include <string.h> | 21 #include <string.h> |
| 22 #include "rogue.h" | 22 #include "rogue.h" |
| 23 | 23 |
| 24 bool is_type(struct object *obj, int type); | |
| 25 | |
| 24 /* | 26 /* |
| 25 * add_pack: | 27 * add_pack: |
| 26 * Pick up an object and add it to the pack. If the argument is non-null | 28 * Pick up an object and add it to the pack. If the argument is non-null |
| 27 * use it as the linked_list pointer instead of gettting it off the ground. | 29 * use it as the linked_list pointer instead of gettting it off the ground. |
| 28 */ | 30 */ |
| 29 | 31 |
| 30 bool | 32 bool |
| 31 add_pack(item, silent) | 33 add_pack(struct linked_list *item, bool silent) |
| 32 register struct linked_list *item; | |
| 33 bool silent; | |
| 34 { | 34 { |
| 35 register struct linked_list *ip, *lp = NULL, *ap; | 35 register struct linked_list *ip, *lp = NULL, *ap; |
| 36 register struct object *obj, *op = NULL; | 36 register struct object *obj, *op = NULL; |
| 37 register bool exact, from_floor; | 37 register bool exact, from_floor; |
| 38 bool giveflag = 0; | 38 bool giveflag = 0; |
| 460 /* | 460 /* |
| 461 * inventory: | 461 * inventory: |
| 462 * list what is in the pack | 462 * list what is in the pack |
| 463 */ | 463 */ |
| 464 | 464 |
| 465 inventory(list, type) | 465 bool |
| 466 register struct linked_list *list; | 466 inventory(struct linked_list *list, int type) |
| 467 register int type; | |
| 468 { | 467 { |
| 469 register struct object *obj; | 468 register struct object *obj; |
| 470 register char ch; | 469 register char ch; |
| 471 register int n_objs, cnt, maxx = 0, curx; | 470 register int n_objs, cnt, maxx = 0, curx; |
| 472 char inv_temp[2*LINELEN+1]; | 471 char inv_temp[2*LINELEN+1]; |
| 561 * picky_inven: | 560 * picky_inven: |
| 562 * Allow player to inventory a single item | 561 * Allow player to inventory a single item |
| 563 */ | 562 */ |
| 564 | 563 |
| 565 void | 564 void |
| 566 picky_inven() | 565 picky_inven(void) |
| 567 { | 566 { |
| 568 register struct linked_list *item; | 567 register struct linked_list *item; |
| 569 register char ch, mch; | 568 register char ch, mch; |
| 570 | 569 |
| 571 if (pack == NULL) | 570 if (pack == NULL) |
| 614 } | 613 } |
| 615 | 614 |
| 616 /* | 615 /* |
| 617 * get_item: | 616 * get_item: |
| 618 * pick something out of a pack for a purpose | 617 * pick something out of a pack for a purpose |
| 618 * purpose: NULL if we should be silent (no prompts) | |
| 619 */ | 619 */ |
| 620 | 620 |
| 621 struct linked_list * | 621 struct linked_list * |
| 622 get_item(list, purpose, type, askfirst, showcost) | 622 get_item(struct linked_list *list, char *purpose, int type, bool askfirst, |
| 623 reg struct linked_list *list; | 623 bool showcost) |
| 624 char *purpose; /* NULL if we should be silent (no prompts) */ | |
| 625 int type; | |
| 626 bool askfirst, showcost; | |
| 627 { | 624 { |
| 628 reg struct linked_list *item; | 625 reg struct linked_list *item; |
| 629 reg struct object *obj; | 626 reg struct object *obj; |
| 630 reg int cnt, pagecnt, ch, och, maxx, curx, confused; | 627 reg int cnt, pagecnt, ch, och, maxx, curx, confused; |
| 631 struct linked_list *saveitem = NULL; | 628 struct linked_list *saveitem = NULL; |
| 753 curx = strlen(description); | 750 curx = strlen(description); |
| 754 if (maxx < curx) maxx = curx; | 751 if (maxx < curx) maxx = curx; |
| 755 | 752 |
| 756 /* Write the screen */ | 753 /* Write the screen */ |
| 757 if ((menu_overlay && cnt < lines - 3) || cnt == 1) { | 754 if ((menu_overlay && cnt < lines - 3) || cnt == 1) { |
| 758 over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, NULL); | 755 over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, '\0'); |
| 759 cnt = -1; /* Indicate we used over_win */ | 756 cnt = -1; /* Indicate we used over_win */ |
| 760 } | 757 } |
| 761 else draw(hw); | 758 else draw(hw); |
| 762 | 759 |
| 763 if (purpose) { | 760 if (purpose) { |
| 812 else | 809 else |
| 813 msg ("You can't %s that!", purpose); | 810 msg ("You can't %s that!", purpose); |
| 814 } | 811 } |
| 815 } | 812 } |
| 816 | 813 |
| 817 pack_char(list, obj) | 814 char |
| 818 register struct object *obj; | 815 pack_char(struct linked_list *list, struct object *obj) |
| 819 struct linked_list *list; | |
| 820 { | 816 { |
| 821 register struct linked_list *item; | 817 register struct linked_list *item; |
| 822 register char c; | 818 register char c; |
| 823 | 819 |
| 824 c = 'a'; | 820 c = 'a'; |
| 836 /* | 832 /* |
| 837 * cur_null: | 833 * cur_null: |
| 838 * This updates cur_weapon etc for dropping things | 834 * This updates cur_weapon etc for dropping things |
| 839 */ | 835 */ |
| 840 | 836 |
| 841 cur_null(op) | 837 void |
| 842 reg struct object *op; | 838 cur_null(struct object *op) |
| 843 { | 839 { |
| 844 if (op == cur_weapon) cur_weapon = NULL; | 840 if (op == cur_weapon) cur_weapon = NULL; |
| 845 else if (op == cur_armor) cur_armor = NULL; | 841 else if (op == cur_armor) cur_armor = NULL; |
| 846 else if (op == cur_ring[LEFT_1]) cur_ring[LEFT_1] = NULL; | 842 else if (op == cur_ring[LEFT_1]) cur_ring[LEFT_1] = NULL; |
| 847 else if (op == cur_ring[LEFT_2]) cur_ring[LEFT_2] = NULL; | 843 else if (op == cur_ring[LEFT_2]) cur_ring[LEFT_2] = NULL; |
| 862 /* | 858 /* |
| 863 * idenpack: | 859 * idenpack: |
| 864 * Identify all the items in the pack | 860 * Identify all the items in the pack |
| 865 */ | 861 */ |
| 866 | 862 |
| 867 idenpack() | 863 void |
| 864 idenpack(void) | |
| 868 { | 865 { |
| 869 reg struct linked_list *pc; | 866 reg struct linked_list *pc; |
| 870 | 867 |
| 871 for (pc = pack ; pc != NULL ; pc = next(pc)) | 868 for (pc = pack ; pc != NULL ; pc = next(pc)) |
| 872 whatis(pc); | 869 whatis(pc); |
| 873 } | 870 } |
| 874 | 871 |
| 875 is_type (obj, type) | 872 bool |
| 876 register struct object *obj; | 873 is_type(struct object *obj, int type) |
| 877 register int type; | |
| 878 { | 874 { |
| 879 register bool current; | 875 register bool current; |
| 880 | 876 |
| 881 if (type == obj->o_type) | 877 if (type == obj->o_type) |
| 882 return (TRUE); | 878 return (TRUE); |
| 1027 } | 1023 } |
| 1028 } | 1024 } |
| 1029 return(FALSE); | 1025 return(FALSE); |
| 1030 } | 1026 } |
| 1031 | 1027 |
| 1032 del_pack(item) | 1028 void |
| 1033 register struct linked_list *item; | 1029 del_pack(struct linked_list *item) |
| 1034 { | 1030 { |
| 1035 register struct object *obj; | 1031 register struct object *obj; |
| 1036 | 1032 |
| 1037 obj = OBJPTR(item); | 1033 obj = OBJPTR(item); |
| 1038 if (obj->o_count > 1) { | 1034 if (obj->o_count > 1) { |
| 1050 * carry_obj: | 1046 * carry_obj: |
| 1051 * Check to see if a monster is carrying something and, if so, give | 1047 * Check to see if a monster is carrying something and, if so, give |
| 1052 * it to him. | 1048 * it to him. |
| 1053 */ | 1049 */ |
| 1054 | 1050 |
| 1055 carry_obj(mp, chance) | 1051 void |
| 1056 register struct thing *mp; | 1052 carry_obj(struct thing *mp, int chance) |
| 1057 int chance; | |
| 1058 { | 1053 { |
| 1059 reg struct linked_list *item; | 1054 reg struct linked_list *item; |
| 1060 reg struct object *obj; | 1055 reg struct object *obj; |
| 1061 | 1056 |
| 1062 /* | 1057 /* |
| 1075 * floor and so the hero will know where it is if he's trying to | 1070 * floor and so the hero will know where it is if he's trying to |
| 1076 * avoid it. Note that only UNIQUEs carry relics. | 1071 * avoid it. Note that only UNIQUEs carry relics. |
| 1077 */ | 1072 */ |
| 1078 if (on(*mp, ISUNIQUE)) { | 1073 if (on(*mp, ISUNIQUE)) { |
| 1079 if (on(*mp, CARRYMDAGGER)) { | 1074 if (on(*mp, CARRYMDAGGER)) { |
| 1080 item = spec_item(RELIC, MUSTY_DAGGER, NULL, NULL); | 1075 item = spec_item(RELIC, MUSTY_DAGGER, 0, 0); |
| 1081 obj = OBJPTR(item); | 1076 obj = OBJPTR(item); |
| 1082 obj->o_pos = mp->t_pos; | 1077 obj->o_pos = mp->t_pos; |
| 1083 attach(mp->t_pack, item); | 1078 attach(mp->t_pack, item); |
| 1084 } | 1079 } |
| 1085 | 1080 |
| 1086 if (on(*mp, CARRYCLOAK)) { | 1081 if (on(*mp, CARRYCLOAK)) { |
| 1087 item = spec_item(RELIC, EMORI_CLOAK, NULL, NULL); | 1082 item = spec_item(RELIC, EMORI_CLOAK, 0, 0); |
| 1088 obj = OBJPTR(item); | 1083 obj = OBJPTR(item); |
| 1089 obj->o_pos = mp->t_pos; | 1084 obj->o_pos = mp->t_pos; |
| 1090 attach(mp->t_pack, item); | 1085 attach(mp->t_pack, item); |
| 1091 } | 1086 } |
| 1092 | 1087 |
| 1093 if (on(*mp, CARRYANKH)) { | 1088 if (on(*mp, CARRYANKH)) { |
| 1094 item = spec_item(RELIC, HEIL_ANKH, NULL, NULL); | 1089 item = spec_item(RELIC, HEIL_ANKH, 0, 0); |
| 1095 obj = OBJPTR(item); | 1090 obj = OBJPTR(item); |
| 1096 obj->o_pos = mp->t_pos; | 1091 obj->o_pos = mp->t_pos; |
| 1097 attach(mp->t_pack, item); | 1092 attach(mp->t_pack, item); |
| 1098 } | 1093 } |
| 1099 | 1094 |
| 1100 if (on(*mp, CARRYSTAFF)) { | 1095 if (on(*mp, CARRYSTAFF)) { |
| 1101 item = spec_item(RELIC, MING_STAFF, NULL, NULL); | 1096 item = spec_item(RELIC, MING_STAFF, 0, 0); |
| 1102 obj = OBJPTR(item); | 1097 obj = OBJPTR(item); |
| 1103 obj->o_pos = mp->t_pos; | 1098 obj->o_pos = mp->t_pos; |
| 1104 attach(mp->t_pack, item); | 1099 attach(mp->t_pack, item); |
| 1105 } | 1100 } |
| 1106 | 1101 |
| 1107 if (on(*mp, CARRYWAND)) { | 1102 if (on(*mp, CARRYWAND)) { |
| 1108 item = spec_item(RELIC, ORCUS_WAND, NULL, NULL); | 1103 item = spec_item(RELIC, ORCUS_WAND, 0, 0); |
| 1109 obj = OBJPTR(item); | 1104 obj = OBJPTR(item); |
| 1110 obj->o_pos = mp->t_pos; | 1105 obj->o_pos = mp->t_pos; |
| 1111 attach(mp->t_pack, item); | 1106 attach(mp->t_pack, item); |
| 1112 } | 1107 } |
| 1113 | 1108 |
| 1114 if (on(*mp, CARRYROD)) { | 1109 if (on(*mp, CARRYROD)) { |
| 1115 item = spec_item(RELIC, ASMO_ROD, NULL, NULL); | 1110 item = spec_item(RELIC, ASMO_ROD, 0, 0); |
| 1116 obj = OBJPTR(item); | 1111 obj = OBJPTR(item); |
| 1117 obj->o_pos = mp->t_pos; | 1112 obj->o_pos = mp->t_pos; |
| 1118 attach(mp->t_pack, item); | 1113 attach(mp->t_pack, item); |
| 1119 } | 1114 } |
| 1120 | 1115 |
| 1121 if (on(*mp, CARRYYAMULET)) { | 1116 if (on(*mp, CARRYYAMULET)) { |
| 1122 item = spec_item(RELIC, YENDOR_AMULET, NULL, NULL); | 1117 item = spec_item(RELIC, YENDOR_AMULET, 0, 0); |
| 1123 obj = OBJPTR(item); | 1118 obj = OBJPTR(item); |
| 1124 obj->o_pos = mp->t_pos; | 1119 obj->o_pos = mp->t_pos; |
| 1125 attach(mp->t_pack, item); | 1120 attach(mp->t_pack, item); |
| 1126 } | 1121 } |
| 1127 | 1122 |
| 1128 if (on(*mp, CARRYBAMULET)) { | 1123 if (on(*mp, CARRYBAMULET)) { |
| 1129 item = spec_item(RELIC, STONEBONES_AMULET, NULL, NULL); | 1124 item = spec_item(RELIC, STONEBONES_AMULET, 0, 0); |
| 1130 obj = OBJPTR(item); | 1125 obj = OBJPTR(item); |
| 1131 obj->o_pos = mp->t_pos; | 1126 obj->o_pos = mp->t_pos; |
| 1132 attach(mp->t_pack, item); | 1127 attach(mp->t_pack, item); |
| 1133 } | 1128 } |
| 1134 | 1129 |
| 1135 if (on(*mp, CARRYMANDOLIN)) { | 1130 if (on(*mp, CARRYMANDOLIN)) { |
| 1136 item = spec_item(RELIC, BRIAN_MANDOLIN, NULL, NULL); | 1131 item = spec_item(RELIC, BRIAN_MANDOLIN, 0, 0); |
| 1137 obj = OBJPTR(item); | 1132 obj = OBJPTR(item); |
| 1138 obj->o_pos = mp->t_pos; | 1133 obj->o_pos = mp->t_pos; |
| 1139 attach(mp->t_pack, item); | 1134 attach(mp->t_pack, item); |
| 1140 } | 1135 } |
| 1141 if (on(*mp, CARRYEYE)) { | 1136 if (on(*mp, CARRYEYE)) { |
| 1142 item = spec_item(RELIC, EYE_VECNA, NULL, NULL); | 1137 item = spec_item(RELIC, EYE_VECNA, 0, 0); |
| 1143 obj = OBJPTR(item); | 1138 obj = OBJPTR(item); |
| 1144 obj->o_pos = mp->t_pos; | 1139 obj->o_pos = mp->t_pos; |
| 1145 attach(mp->t_pack, item); | 1140 attach(mp->t_pack, item); |
| 1146 } | 1141 } |
| 1147 if (on(*mp, CARRYAXE)) { | 1142 if (on(*mp, CARRYAXE)) { |
| 1148 item = spec_item(RELIC, AXE_AKLAD, NULL, NULL); | 1143 item = spec_item(RELIC, AXE_AKLAD, 0, 0); |
| 1149 obj = OBJPTR(item); | 1144 obj = OBJPTR(item); |
| 1150 obj->o_pos = mp->t_pos; | 1145 obj->o_pos = mp->t_pos; |
| 1151 attach(mp->t_pack, item); | 1146 attach(mp->t_pack, item); |
| 1152 } | 1147 } |
| 1153 if (on(*mp, CARRYQUILL)) { | 1148 if (on(*mp, CARRYQUILL)) { |
| 1154 register int i, howmany; | 1149 register int i, howmany; |
| 1155 | 1150 |
| 1156 item = spec_item(RELIC, QUILL_NAGROM, NULL, NULL); | 1151 item = spec_item(RELIC, QUILL_NAGROM, 0, 0); |
| 1157 obj = OBJPTR(item); | 1152 obj = OBJPTR(item); |
| 1158 obj->o_pos = mp->t_pos; | 1153 obj->o_pos = mp->t_pos; |
| 1159 obj->o_charges = rnd(QUILLCHARGES); | 1154 obj->o_charges = rnd(QUILLCHARGES); |
| 1160 attach(mp->t_pack, item); | 1155 attach(mp->t_pack, item); |
| 1161 howmany = roll(4,3); | 1156 howmany = roll(4,3); |
| 1168 obj->o_pos = mp->t_pos; | 1163 obj->o_pos = mp->t_pos; |
| 1169 attach(mp->t_pack, item); | 1164 attach(mp->t_pack, item); |
| 1170 } | 1165 } |
| 1171 } | 1166 } |
| 1172 if (on(*mp, CARRYMSTAR)) { | 1167 if (on(*mp, CARRYMSTAR)) { |
| 1173 item = spec_item(RELIC, HRUGGEK_MSTAR, NULL, NULL); | 1168 item = spec_item(RELIC, HRUGGEK_MSTAR, 0, 0); |
| 1174 obj = OBJPTR(item); | 1169 obj = OBJPTR(item); |
| 1175 obj->o_pos = mp->t_pos; | 1170 obj->o_pos = mp->t_pos; |
| 1176 attach(mp->t_pack, item); | 1171 attach(mp->t_pack, item); |
| 1177 } | 1172 } |
| 1178 if (on(*mp, CARRYFLAIL)) { | 1173 if (on(*mp, CARRYFLAIL)) { |
| 1179 item = spec_item(RELIC, YEENOGHU_FLAIL, NULL, NULL); | 1174 item = spec_item(RELIC, YEENOGHU_FLAIL, 0, 0); |
| 1180 obj = OBJPTR(item); | 1175 obj = OBJPTR(item); |
| 1181 obj->o_pos = mp->t_pos; | 1176 obj->o_pos = mp->t_pos; |
| 1182 attach(mp->t_pack, item); | 1177 attach(mp->t_pack, item); |
| 1183 } | 1178 } |
| 1184 if (on(*mp, CARRYHORN)) { | 1179 if (on(*mp, CARRYHORN)) { |
| 1185 item = spec_item(RELIC, GERYON_HORN, NULL, NULL); | 1180 item = spec_item(RELIC, GERYON_HORN, 0, 0); |
| 1186 obj = OBJPTR(item); | 1181 obj = OBJPTR(item); |
| 1187 obj->o_pos = mp->t_pos; | 1182 obj->o_pos = mp->t_pos; |
| 1188 attach(mp->t_pack, item); | 1183 attach(mp->t_pack, item); |
| 1189 } | 1184 } |
| 1190 if (on(*mp, CARRYSURTURRING)) { | 1185 if (on(*mp, CARRYSURTURRING)) { |
| 1191 item = spec_item(RELIC, SURTUR_RING, NULL, NULL); | 1186 item = spec_item(RELIC, SURTUR_RING, 0, 0); |
| 1192 obj = OBJPTR(item); | 1187 obj = OBJPTR(item); |
| 1193 obj->o_pos = mp->t_pos; | 1188 obj->o_pos = mp->t_pos; |
| 1194 attach(mp->t_pack, item); | 1189 attach(mp->t_pack, item); |
| 1195 } | 1190 } |
| 1196 if (on(*mp, CARRYCARD)) { | 1191 if (on(*mp, CARRYCARD)) { |
| 1197 item = spec_item(RELIC, ALTERAN_CARD, NULL, NULL); | 1192 item = spec_item(RELIC, ALTERAN_CARD, 0, 0); |
| 1198 obj = OBJPTR(item); | 1193 obj = OBJPTR(item); |
| 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 gold, give it some | 1199 * If it carries gold, give it some |
| 1205 */ | 1200 */ |
| 1206 if (on(*mp, CARRYGOLD) && rnd(100) < chance) { | 1201 if (on(*mp, CARRYGOLD) && rnd(100) < chance) { |
| 1207 item = spec_item(GOLD, NULL, NULL, NULL); | 1202 item = spec_item(GOLD, 0, 0, 0); |
| 1208 obj = OBJPTR(item); | 1203 obj = OBJPTR(item); |
| 1209 obj->o_count = GOLDCALC + GOLDCALC; | 1204 obj->o_count = GOLDCALC + GOLDCALC; |
| 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 } |
| 1230 when 33: type = E_ELDERBERRY; | 1225 when 33: type = E_ELDERBERRY; |
| 1231 when 36: type = E_BLUEBERRY; | 1226 when 36: type = E_BLUEBERRY; |
| 1232 when 40: type = E_SLIMEMOLD; /* monster food */ | 1227 when 40: type = E_SLIMEMOLD; /* monster food */ |
| 1233 otherwise: type = E_RATION; | 1228 otherwise: type = E_RATION; |
| 1234 } | 1229 } |
| 1235 item = spec_item(FOOD, type, NULL, NULL); | 1230 item = spec_item(FOOD, type, 0, 0); |
| 1236 obj = OBJPTR(item); | 1231 obj = OBJPTR(item); |
| 1237 obj->o_weight = things[TYP_FOOD].mi_wght; | 1232 obj->o_weight = things[TYP_FOOD].mi_wght; |
| 1238 obj->o_pos = mp->t_pos; | 1233 obj->o_pos = mp->t_pos; |
| 1239 attach(mp->t_pack, item); | 1234 attach(mp->t_pack, item); |
| 1240 } | 1235 } |
| 1354 * nothing is there, do nothing. If there is one thing, pick it | 1349 * nothing is there, do nothing. If there is one thing, pick it |
| 1355 * up. If there are multiple things, prompt the player for what | 1350 * up. If there are multiple things, prompt the player for what |
| 1356 * he wants (* means everything). | 1351 * he wants (* means everything). |
| 1357 */ | 1352 */ |
| 1358 | 1353 |
| 1359 grab(y, x) |
