Mercurial > hg > early-roguelike
comparison arogue7/util.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 | 
|---|---|
| 33 | 33 | 
| 34 /* | 34 /* | 
| 35 * this routine computes the players current AC without dex bonus's | 35 * this routine computes the players current AC without dex bonus's | 
| 36 */ | 36 */ | 
| 37 int | 37 int | 
| 38 ac_compute(ignoremetal) | 38 ac_compute(bool ignoremetal) | 
| 39 bool ignoremetal; | |
| 40 { | 39 { | 
| 41 register int ac; | 40 register int ac; | 
| 42 | 41 | 
| 43 ac = pstats.s_arm; /* base armor of "skin" */ | 42 ac = pstats.s_arm; /* base armor of "skin" */ | 
| 44 if (cur_armor) { | 43 if (cur_armor) { | 
| 67 /* | 66 /* | 
| 68 * aggravate: | 67 * aggravate: | 
| 69 * aggravate all the monsters on this level | 68 * aggravate all the monsters on this level | 
| 70 */ | 69 */ | 
| 71 | 70 | 
| 72 aggravate(do_uniques, do_good) | 71 void | 
| 73 bool do_uniques, do_good; | 72 aggravate(bool do_uniques, bool do_good) | 
| 74 { | 73 { | 
| 75 register struct linked_list *mi; | 74 register struct linked_list *mi; | 
| 76 register struct thing *thingptr; | 75 register struct thing *thingptr; | 
| 77 | 76 | 
| 78 for (mi = mlist; mi != NULL; mi = next(mi)) { | 77 for (mi = mlist; mi != NULL; mi = next(mi)) { | 
| 85 /* | 84 /* | 
| 86 * cansee: | 85 * cansee: | 
| 87 * returns true if the hero can see a certain coordinate. | 86 * returns true if the hero can see a certain coordinate. | 
| 88 */ | 87 */ | 
| 89 | 88 | 
| 90 cansee(y, x) | 89 bool | 
| 91 register int y, x; | 90 cansee(int y, int x) | 
| 92 { | 91 { | 
| 93 register struct room *rer; | 92 register struct room *rer; | 
| 94 register int radius; | 93 register int radius; | 
| 95 coord tp; | 94 coord tp; | 
| 96 | 95 | 
| 132 * All further experience levels are computed by muliplying by 2 | 131 * All further experience levels are computed by muliplying by 2 | 
| 133 * up through MAXDOUBLE. Then the cap is added in to compute | 132 * up through MAXDOUBLE. Then the cap is added in to compute | 
| 134 * further levels | 133 * further levels | 
| 135 */ | 134 */ | 
| 136 long | 135 long | 
| 137 check_level() | 136 check_level(void) | 
| 138 { | 137 { | 
| 139 register int i, j, add = 0; | 138 register int i, j, add = 0; | 
| 140 register unsigned long exp; | 139 register unsigned long exp; | 
| 141 long retval; /* Return value */ | 140 long retval; /* Return value */ | 
| 142 int nsides; | 141 int nsides; | 
| 176 /* | 175 /* | 
| 177 * Used to modify the players strength | 176 * Used to modify the players strength | 
| 178 * it keeps track of the highest it has been, just in case | 177 * it keeps track of the highest it has been, just in case | 
| 179 */ | 178 */ | 
| 180 | 179 | 
| 181 chg_str(amt) | 180 void | 
| 182 register int amt; | 181 chg_str(int amt) | 
| 183 { | 182 { | 
| 184 register int ring_str; /* ring strengths */ | 183 register int ring_str; /* ring strengths */ | 
| 185 register struct stats *ptr; /* for speed */ | 184 register struct stats *ptr; /* for speed */ | 
| 186 | 185 | 
| 187 ptr = &pstats; | 186 ptr = &pstats; | 
| 199 } | 198 } | 
| 200 | 199 | 
| 201 /* | 200 /* | 
| 202 * let's confuse the player | 201 * let's confuse the player | 
| 203 */ | 202 */ | 
| 204 confus_player() | 203 void | 
| 204 confus_player(void) | |
| 205 { | 205 { | 
| 206 if (off(player, ISCLEAR)) | 206 if (off(player, ISCLEAR)) | 
| 207 { | 207 { | 
| 208 msg("Wait, what's going on here. Huh? What? Who?"); | 208 msg("Wait, what's going on here. Huh? What? Who?"); | 
| 209 if (find_slot(unconfuse)) | 209 if (find_slot(unconfuse)) | 
| 216 } | 216 } | 
| 217 | 217 | 
| 218 /* | 218 /* | 
| 219 * this routine computes the players current dexterity | 219 * this routine computes the players current dexterity | 
| 220 */ | 220 */ | 
| 221 dex_compute() | 221 int | 
| 222 dex_compute(void) | |
| 222 { | 223 { | 
| 223 if (cur_misc[WEAR_GAUNTLET] != NULL && | 224 if (cur_misc[WEAR_GAUNTLET] != NULL && | 
| 224 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { | 225 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { | 
| 225 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) | 226 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) | 
| 226 return (3); | 227 return (3); | 
| 234 /* | 235 /* | 
| 235 * diag_ok: | 236 * diag_ok: | 
| 236 * Check to see if the move is legal if it is diagonal | 237 * Check to see if the move is legal if it is diagonal | 
| 237 */ | 238 */ | 
| 238 | 239 | 
| 239 diag_ok(sp, ep, flgptr) | 240 bool | 
| 240 register coord *sp, *ep; | 241 diag_ok(coord *sp, coord *ep, struct thing *flgptr) | 
| 241 struct thing *flgptr; | |
| 242 { | 242 { | 
| 243 register int numpaths = 0; | 243 register int numpaths = 0; | 
| 244 | 244 | 
| 245 /* Horizontal and vertical moves are always ok */ | 245 /* Horizontal and vertical moves are always ok */ | 
| 246 if (ep->x == sp->x || ep->y == sp->y) | 246 if (ep->x == sp->x || ep->y == sp->y) | 
| 256 | 256 | 
| 257 /* | 257 /* | 
| 258 * pick a random position around the give (y, x) coordinates | 258 * pick a random position around the give (y, x) coordinates | 
| 259 */ | 259 */ | 
| 260 coord * | 260 coord * | 
| 261 fallpos(pos, be_clear, range) | 261 fallpos(coord *pos, bool be_clear, int range) | 
| 262 register coord *pos; | |
| 263 bool be_clear; | |
| 264 int range; | |
| 265 { | 262 { | 
| 266 register int tried, i, j; | 263 register int tried, i, j; | 
| 267 register char ch; | 264 register char ch; | 
| 268 static coord ret; | 265 static coord ret; | 
| 269 static short masks[] = { | 266 static short masks[] = { | 
| 337 /* | 334 /* | 
| 338 * findmindex: | 335 * findmindex: | 
| 339 * Find the index into the monster table of a monster given its name. | 336 * Find the index into the monster table of a monster given its name. | 
| 340 */ | 337 */ | 
| 341 | 338 | 
| 342 findmindex(name) | 339 int | 
| 343 char *name; | 340 findmindex(char *name) | 
| 344 { | 341 { | 
| 345 int which; | 342 int which; | 
| 346 | 343 | 
| 347 for (which=1; which<NUMMONST; which++) { | 344 for (which=1; which<NUMMONST; which++) { | 
| 348 if (strcmp(name, monsters[which].m_name) == 0) | 345 if (strcmp(name, monsters[which].m_name) == 0) | 
| 359 * find_mons: | 356 * find_mons: | 
| 360 * Find the monster from his coordinates | 357 * Find the monster from his coordinates | 
| 361 */ | 358 */ | 
| 362 | 359 | 
| 363 struct linked_list * | 360 struct linked_list * | 
| 364 find_mons(y, x) | 361 find_mons(int y, int x) | 
| 365 register int y; | |
| 366 register int x; | |
| 367 { | 362 { | 
| 368 register struct linked_list *item; | 363 register struct linked_list *item; | 
| 369 register struct thing *th; | 364 register struct thing *th; | 
| 370 | 365 | 
| 371 for (item = mlist; item != NULL; item = next(item)) | 366 for (item = mlist; item != NULL; item = next(item)) | 
| 381 * find_obj: | 376 * find_obj: | 
| 382 * find the unclaimed object at y, x | 377 * find the unclaimed object at y, x | 
| 383 */ | 378 */ | 
| 384 | 379 | 
| 385 struct linked_list * | 380 struct linked_list * | 
| 386 find_obj(y, x) | 381 find_obj(int y, int x) | 
| 387 register int y; | |
| 388 register int x; | |
| 389 { | 382 { | 
| 390 register struct linked_list *obj; | 383 register struct linked_list *obj; | 
| 391 register struct object *op; | 384 register struct object *op; | 
| 392 | 385 | 
| 393 for (obj = lvl_obj; obj != NULL; obj = next(obj)) | 386 for (obj = lvl_obj; obj != NULL; obj = next(obj)) | 
| 401 | 394 | 
| 402 /* | 395 /* | 
| 403 * get coordinates from the player using the cursor keys (or mouse) | 396 * get coordinates from the player using the cursor keys (or mouse) | 
| 404 */ | 397 */ | 
| 405 coord | 398 coord | 
| 406 get_coordinates() | 399 get_coordinates(void) | 
| 407 { | 400 { | 
| 408 register int which; | 401 register int which; | 
| 409 coord c; | 402 coord c; | 
| 410 #ifdef PC7300 | 403 #ifdef PC7300 | 
| 411 struct umdata startmouse, listenmouse; /* Mouse parameters */ | 404 struct umdata startmouse, listenmouse; /* Mouse parameters */ | 
| 548 | 541 | 
| 549 /* | 542 /* | 
| 550 * set up the direction co_ordinate for use in various "prefix" commands | 543 * set up the direction co_ordinate for use in various "prefix" commands | 
| 551 */ | 544 */ | 
| 552 bool | 545 bool | 
| 553 get_dir(direction) | 546 get_dir(coord *direction) | 
| 554 coord *direction; | |
| 555 { | 547 { | 
| 556 register char *prompt; | 548 register char *prompt; | 
| 557 register bool gotit; | 549 register bool gotit; | 
| 558 int x,y; | 550 int x,y; | 
| 559 | 551 | 
| 608 } | 600 } | 
| 609 | 601 | 
| 610 /* | 602 /* | 
| 611 * see if the object is one of the currently used items | 603 * see if the object is one of the currently used items | 
| 612 */ | 604 */ | 
| 613 is_current(obj) | 605 bool | 
| 614 register struct object *obj; | 606 is_current(struct object *obj) | 
| 615 { | 607 { | 
| 616 if (obj == NULL) | 608 if (obj == NULL) | 
| 617 return FALSE; | 609 return FALSE; | 
| 618 if (obj == cur_armor || obj == cur_weapon || | 610 if (obj == cur_armor || obj == cur_weapon || | 
| 619 obj == cur_ring[LEFT_1] || obj == cur_ring[LEFT_2] || | 611 obj == cur_ring[LEFT_1] || obj == cur_ring[LEFT_2] || | 
| 648 | 640 | 
| 649 | 641 | 
| 650 /* | 642 /* | 
| 651 * Look: | 643 * Look: | 
| 652 * A quick glance all around the player | 644 * A quick glance all around the player | 
| 653 */ | 645 * wakeup: Should we wake up monsters | 
| 654 | 646 * runend: At end of a run -- for mazes | 
| 655 look(wakeup, runend) | 647 */ | 
| 656 bool wakeup; /* Should we wake up monsters */ | 648 | 
| 657 bool runend; /* At end of a run -- for mazes */ | 649 void | 
| 650 look(bool wakeup, bool runend) | |
| 658 { | 651 { | 
| 659 register int x, y, radius; | 652 register int x, y, radius; | 
| 660 register char ch, och; | 653 register char ch, och; | 
| 661 register int oldx, oldy; | 654 register int oldx, oldy; | 
| 662 register bool inpass, horiz, vert, do_light = FALSE, do_blank = FALSE; | 655 register bool inpass, horiz, vert, do_light = FALSE, do_blank = FALSE; | 
| 936 | 929 | 
| 937 /* | 930 /* | 
| 938 * Lower a level of experience | 931 * Lower a level of experience | 
| 939 */ | 932 */ | 
| 940 | 933 | 
| 941 lower_level(who) | 934 void | 
| 942 short who; | 935 lower_level(short who) | 
| 943 { | 936 { | 
| 944 int fewer, nsides; | 937 int fewer, nsides; | 
| 945 unsigned int exp; | 938 unsigned int exp; | 
| 946 | 939 | 
| 947 msg("You suddenly feel less skillful."); | 940 msg("You suddenly feel less skillful."); | 
| 969 | 962 | 
| 970 /* | 963 /* | 
| 971 * print out the name of a monster | 964 * print out the name of a monster | 
| 972 */ | 965 */ | 
| 973 char * | 966 char * | 
| 974 monster_name(tp) | 967 monster_name(struct thing *tp) | 
| 975 register struct thing *tp; | |
| 976 { | 968 { | 
| 977 prbuf[0] = '\0'; | 969 prbuf[0] = '\0'; | 
| 978 if (on(*tp, ISFLEE) || on(*tp, WASTURNED)) | 970 if (on(*tp, ISFLEE) || on(*tp, WASTURNED)) | 
| 979 strcat(prbuf, "terrified "); | 971 strcat(prbuf, "terrified "); | 
| 980 if (on(*tp, ISHUH)) | 972 if (on(*tp, ISHUH)) | 
| 1001 * Try to move the hero somplace besides next to where he is. We ask him | 993 * Try to move the hero somplace besides next to where he is. We ask him | 
| 1002 * where. There can be restrictions based on why he is moving. | 994 * where. There can be restrictions based on why he is moving. | 
| 1003 */ | 995 */ | 
| 1004 | 996 | 
| 1005 bool | 997 bool | 
| 1006 move_hero(why) | 998 move_hero(int why) | 
| 1007 int why; | |
| 1008 { | 999 { | 
| 1009 char *action = ""; | 1000 char *action = ""; | 
| 1010 char which; | 1001 char which; | 
| 1011 coord c; | 1002 coord c; | 
| 1012 | 1003 | 
| 1047 /* | 1038 /* | 
| 1048 * raise_level: | 1039 * raise_level: | 
| 1049 * The guy just magically went up a level. | 1040 * The guy just magically went up a level. | 
| 1050 */ | 1041 */ | 
| 1051 | 1042 | 
| 1052 raise_level() | 1043 void | 
| 1044 raise_level(void) | |
| 1053 { | 1045 { | 
| 1054 unsigned long test; /* Next level -- be sure it is not an overflow */ | 1046 unsigned long test; /* Next level -- be sure it is not an overflow */ | 
| 1055 | 1047 | 
| 1056 test = check_level(); /* Get next boundary */ | 1048 test = check_level(); /* Get next boundary */ | 
| 1057 | 1049 | 
| 1079 }; | 1071 }; | 
| 1080 | 1072 | 
| 1081 /* | 1073 /* | 
| 1082 * save: | 1074 * save: | 
| 1083 * See if a creature saves against something | 1075 * See if a creature saves against something | 
| 1084 */ | 1076 * which: which type of save | 
| 1085 save(which, who, adj) | 1077 * who: who is saving | 
| 1086 int which; /* which type of save */ | 1078 * adj: saving throw adjustment | 
| 1087 struct thing *who; /* who is saving */ | 1079 */ | 
| 1088 int adj; /* saving throw adjustment */ | 1080 bool | 
| 1081 save(int which, struct thing *who, int adj) | |
| 1089 { | 1082 { | 
| 1090 register int need, level, protect; | 1083 register int need, level, protect; | 
| 1091 | 1084 | 
| 1092 protect = 0; | 1085 protect = 0; | 
| 1093 level = who->t_stats.s_lvl; | 1086 level = who->t_stats.s_lvl; | 
| 1142 /* | 1135 /* | 
| 1143 * secret_door: | 1136 * secret_door: | 
| 1144 * Figure out what a secret door looks like. | 1137 * Figure out what a secret door looks like. | 
| 1145 */ | 1138 */ | 
| 1146 | 1139 | 
| 1147 secretdoor(y, x) | 1140 char | 
| 1148 register int y, x; | 1141 secretdoor(int y, int x) | 
| 1149 { | 1142 { | 
| 1150 register int i; | 1143 register int i; | 
| 1151 register struct room *rp; | 1144 register struct room *rp; | 
| 1152 register coord *cpp; | 1145 register coord *cpp; | 
| 1153 static coord cp; | 1146 static coord cp; | 
| 1166 } | 1159 } | 
| 1167 | 1160 | 
| 1168 /* | 1161 /* | 
| 1169 * this routine computes the players current strength | 1162 * this routine computes the players current strength | 
| 1170 */ | 1163 */ | 
| 1171 str_compute() | 1164 int | 
| 1165 str_compute(void) | |
| 1172 { | 1166 { | 
| 1173 if (cur_misc[WEAR_GAUNTLET] != NULL && | 1167 if (cur_misc[WEAR_GAUNTLET] != NULL && | 
| 1174 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { | 1168 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { | 
| 1175 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) | 1169 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) | 
| 1176 return (3); | 1170 return (3); | 
| 1182 } | 1176 } | 
| 1183 | 1177 | 
| 1184 /* | 1178 /* | 
| 1185 * copy string using unctrl for things | 1179 * copy string using unctrl for things | 
| 1186 */ | 1180 */ | 
| 1187 strucpy(s1, s2, len) | 1181 void | 
| 1188 register char *s1, *s2; | 1182 strucpy(char *s1, char *s2, int len) | 
| 1189 register int len; | |
| 1190 { | 1183 { | 
| 1191 register char *sp; | 1184 register char *sp; | 
| 1192 | 1185 | 
| 1193 while (len--) | 1186 while (len--) | 
| 1194 { | 1187 { | 
| 1202 * tr_name: | 1195 * tr_name: | 
| 1203 * print the name of a trap | 1196 * print the name of a trap | 
| 1204 */ | 1197 */ | 
| 1205 | 1198 | 
| 1206 char * | 1199 char * | 
| 1207 tr_name(ch) | 1200 tr_name(char ch) | 
| 1208 char ch; | |
| 1209 { | 1201 { | 
| 1210 register char *s = ""; | 1202 register char *s = ""; | 
| 1211 | 1203 | 
| 1212 switch (ch) | 1204 switch (ch) | 
| 1213 { | 1205 { | 
| 1233 | 1225 | 
| 1234 /* | 1226 /* | 
| 1235 * for printfs: if string starts with a vowel, return "n" for an "an" | 1227 * for printfs: if string starts with a vowel, return "n" for an "an" | 
| 1236 */ | 1228 */ | 
| 1237 char * | 1229 char * | 
| 1238 vowelstr(str) | 1230 vowelstr(char *str) | 
| 1239 register char *str; | |
| 1240 { | 1231 { | 
| 1241 switch (*str) | 1232 switch (*str) | 
| 1242 { | 1233 { | 
| 1243 case 'a': | 1234 case 'a': | 
| 1244 case 'e': | 1235 case 'e': | 
| 1252 } | 
