Mercurial > hg > early-roguelike
comparison arogue5/util.c @ 218:56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
This still leaves over a thousand lines of warning messages, mostly
related to the return types of daemons and fuses.
author | John "Elwin" Edwards |
---|---|
date | Sun, 07 Feb 2016 14:39:21 -0500 |
parents | c49f7927b0fa |
children | d71e5e1f49cf |
comparison
equal
deleted
inserted
replaced
217:94a0d9dd5ce1 | 218:56e748983fa8 |
---|---|
20 /* | 20 /* |
21 * aggravate: | 21 * aggravate: |
22 * aggravate all the monsters on this level | 22 * aggravate all the monsters on this level |
23 */ | 23 */ |
24 | 24 |
25 aggravate() | 25 void |
26 aggravate(void) | |
26 { | 27 { |
27 register struct linked_list *mi; | 28 register struct linked_list *mi; |
28 | 29 |
29 for (mi = mlist; mi != NULL; mi = next(mi)) | 30 for (mi = mlist; mi != NULL; mi = next(mi)) |
30 runto(THINGPTR(mi), &hero); | 31 runto(THINGPTR(mi), &hero); |
33 /* | 34 /* |
34 * cansee: | 35 * cansee: |
35 * returns true if the hero can see a certain coordinate. | 36 * returns true if the hero can see a certain coordinate. |
36 */ | 37 */ |
37 | 38 |
38 cansee(y, x) | 39 bool |
39 register int y, x; | 40 cansee(int y, int x) |
40 { | 41 { |
41 register struct room *rer; | 42 register struct room *rer; |
42 register int radius; | 43 register int radius; |
43 coord tp; | 44 coord tp; |
44 | 45 |
91 { 110L, 1802240L }, /* cleric */ | 92 { 110L, 1802240L }, /* cleric */ |
92 { 75L, 1228800L } /* Thief */ | 93 { 75L, 1228800L } /* Thief */ |
93 }; | 94 }; |
94 | 95 |
95 long | 96 long |
96 check_level(get_spells) | 97 check_level(bool get_spells) |
97 bool get_spells; | |
98 { | 98 { |
99 register int i, j, add = 0; | 99 register int i, j, add = 0; |
100 register unsigned long exp; | 100 register unsigned long exp; |
101 long retval; /* Return value */ | 101 long retval; /* Return value */ |
102 int nsides = 0; | 102 int nsides = 0; |
146 /* | 146 /* |
147 * Used to modify the playes strength | 147 * Used to modify the playes strength |
148 * it keeps track of the highest it has been, just in case | 148 * it keeps track of the highest it has been, just in case |
149 */ | 149 */ |
150 | 150 |
151 chg_str(amt) | 151 void |
152 register int amt; | 152 chg_str(int amt) |
153 { | 153 { |
154 register int ring_str; /* ring strengths */ | 154 register int ring_str; /* ring strengths */ |
155 register struct stats *ptr; /* for speed */ | 155 register struct stats *ptr; /* for speed */ |
156 | 156 |
157 ptr = &pstats; | 157 ptr = &pstats; |
170 | 170 |
171 /* | 171 /* |
172 * this routine computes the players current AC without dex bonus's | 172 * this routine computes the players current AC without dex bonus's |
173 */ | 173 */ |
174 int | 174 int |
175 ac_compute() | 175 ac_compute(void) |
176 { | 176 { |
177 register int ac; | 177 register int ac; |
178 | 178 |
179 ac = cur_armor != NULL ? cur_armor->o_ac : pstats.s_arm; | 179 ac = cur_armor != NULL ? cur_armor->o_ac : pstats.s_arm; |
180 ac -= ring_value(R_PROTECT); | 180 ac -= ring_value(R_PROTECT); |
192 } | 192 } |
193 | 193 |
194 /* | 194 /* |
195 * this routine computes the players current strength | 195 * this routine computes the players current strength |
196 */ | 196 */ |
197 str_compute() | 197 int |
198 str_compute(void) | |
198 { | 199 { |
199 if (cur_misc[WEAR_GAUNTLET] != NULL && | 200 if (cur_misc[WEAR_GAUNTLET] != NULL && |
200 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { | 201 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { |
201 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) | 202 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) |
202 return (3); | 203 return (3); |
208 } | 209 } |
209 | 210 |
210 /* | 211 /* |
211 * this routine computes the players current dexterity | 212 * this routine computes the players current dexterity |
212 */ | 213 */ |
213 dex_compute() | 214 int |
215 dex_compute(void) | |
214 { | 216 { |
215 if (cur_misc[WEAR_GAUNTLET] != NULL && | 217 if (cur_misc[WEAR_GAUNTLET] != NULL && |
216 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { | 218 cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { |
217 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) | 219 if (cur_misc[WEAR_GAUNTLET]->o_flags & ISCURSED) |
218 return (3); | 220 return (3); |
227 /* | 229 /* |
228 * diag_ok: | 230 * diag_ok: |
229 * Check to see if the move is legal if it is diagonal | 231 * Check to see if the move is legal if it is diagonal |
230 */ | 232 */ |
231 | 233 |
232 diag_ok(sp, ep, flgptr) | 234 bool |
233 register coord *sp, *ep; | 235 diag_ok(coord *sp, coord *ep, struct thing *flgptr) |
234 struct thing *flgptr; | |
235 { | 236 { |
236 register int numpaths = 0; | 237 register int numpaths = 0; |
237 | 238 |
238 /* Horizontal and vertical moves are always ok */ | 239 /* Horizontal and vertical moves are always ok */ |
239 if (ep->x == sp->x || ep->y == sp->y) | 240 if (ep->x == sp->x || ep->y == sp->y) |
250 /* | 251 /* |
251 * eat: | 252 * eat: |
252 * He wants to eat something, so let him try | 253 * He wants to eat something, so let him try |
253 */ | 254 */ |
254 | 255 |
255 eat() | 256 void |
257 eat(void) | |
256 { | 258 { |
257 register struct linked_list *item; | 259 register struct linked_list *item; |
258 | 260 |
259 if ((item = get_item(pack, "eat", FOOD)) == NULL) | 261 if ((item = get_item(pack, "eat", FOOD)) == NULL) |
260 return; | 262 return; |
280 | 282 |
281 /* | 283 /* |
282 * pick a random position around the give (y, x) coordinates | 284 * pick a random position around the give (y, x) coordinates |
283 */ | 285 */ |
284 coord * | 286 coord * |
285 fallpos(pos, be_clear, range) | 287 fallpos(coord *pos, bool be_clear, int range) |
286 register coord *pos; | |
287 bool be_clear; | |
288 int range; | |
289 { | 288 { |
290 register int tried, i, j; | 289 register int tried, i, j; |
291 register char ch; | 290 register char ch; |
292 static coord ret; | 291 static coord ret; |
293 static short masks[] = { | 292 static short masks[] = { |
362 * find_mons: | 361 * find_mons: |
363 * Find the monster from his corrdinates | 362 * Find the monster from his corrdinates |
364 */ | 363 */ |
365 | 364 |
366 struct linked_list * | 365 struct linked_list * |
367 find_mons(y, x) | 366 find_mons(int y, int x) |
368 register int y; | |
369 register int x; | |
370 { | 367 { |
371 register struct linked_list *item; | 368 register struct linked_list *item; |
372 register struct thing *th; | 369 register struct thing *th; |
373 | 370 |
374 for (item = mlist; item != NULL; item = next(item)) | 371 for (item = mlist; item != NULL; item = next(item)) |
384 * find_obj: | 381 * find_obj: |
385 * find the unclaimed object at y, x | 382 * find the unclaimed object at y, x |
386 */ | 383 */ |
387 | 384 |
388 struct linked_list * | 385 struct linked_list * |
389 find_obj(y, x) | 386 find_obj(int y, int x) |
390 register int y; | |
391 register int x; | |
392 { | 387 { |
393 register struct linked_list *obj; | 388 register struct linked_list *obj; |
394 register struct object *op; | 389 register struct object *op; |
395 | 390 |
396 for (obj = lvl_obj; obj != NULL; obj = next(obj)) | 391 for (obj = lvl_obj; obj != NULL; obj = next(obj)) |
404 | 399 |
405 | 400 |
406 /* | 401 /* |
407 * set up the direction co_ordinate for use in varios "prefix" commands | 402 * set up the direction co_ordinate for use in varios "prefix" commands |
408 */ | 403 */ |
409 get_dir() | 404 bool |
405 get_dir(void) | |
410 { | 406 { |
411 register char *prompt; | 407 register char *prompt; |
412 register bool gotit; | 408 register bool gotit; |
413 | 409 |
414 prompt = terse ? "Direction?" : "Which direction? "; | 410 prompt = terse ? "Direction?" : "Which direction? "; |
444 } | 440 } |
445 | 441 |
446 /* | 442 /* |
447 * see if the object is one of the currently used items | 443 * see if the object is one of the currently used items |
448 */ | 444 */ |
449 is_current(obj) | 445 bool |
450 register struct object *obj; | 446 is_current(struct object *obj) |
451 { | 447 { |
452 if (obj == NULL) | 448 if (obj == NULL) |
453 return FALSE; | 449 return FALSE; |
454 if (obj == cur_armor || obj == cur_weapon || | 450 if (obj == cur_armor || obj == cur_weapon || |
455 obj == cur_ring[LEFT_1] || obj == cur_ring[LEFT_2] || | 451 obj == cur_ring[LEFT_1] || obj == cur_ring[LEFT_2] || |
481 | 477 |
482 | 478 |
483 /* | 479 /* |
484 * Look: | 480 * Look: |
485 * A quick glance all around the player | 481 * A quick glance all around the player |
486 */ | 482 * wakeup: Should we wake up monsters |
487 | 483 * runend: At end of a run -- for mazes |
488 look(wakeup, runend) | 484 */ |
489 bool wakeup; /* Should we wake up monsters */ | 485 |
490 bool runend; /* At end of a run -- for mazes */ | 486 void |
487 look(bool wakeup, bool runend) | |
491 { | 488 { |
492 register int x, y, radius; | 489 register int x, y, radius; |
493 register char ch, och; | 490 register char ch, och; |
494 register int oldx, oldy; | 491 register int oldx, oldy; |
495 register bool inpass, horiz, vert, do_light = FALSE, do_blank = FALSE; | 492 register bool inpass, horiz, vert, do_light = FALSE, do_blank = FALSE; |
736 /* | 733 /* |
737 * raise_level: | 734 * raise_level: |
738 * The guy just magically went up a level. | 735 * The guy just magically went up a level. |
739 */ | 736 */ |
740 | 737 |
741 raise_level(get_spells) | 738 void |
742 bool get_spells; | 739 raise_level(bool get_spells) |
743 { | 740 { |
744 unsigned long test; /* Next level -- be sure it is not an overflow */ | 741 unsigned long test; /* Next level -- be sure it is not an overflow */ |
745 | 742 |
746 test = check_level(FALSE); /* Get next boundary */ | 743 test = check_level(FALSE); /* Get next boundary */ |
747 | 744 |
764 }; | 761 }; |
765 | 762 |
766 /* | 763 /* |
767 * save: | 764 * save: |
768 * See if a creature saves against something | 765 * See if a creature saves against something |
769 */ | 766 * which: which type of save |
770 save(which, who, adj) | 767 * who: who is saving |
771 int which; /* which type of save */ | 768 * adj: saving throw adjustment |
772 struct thing *who; /* who is saving */ | 769 */ |
773 int adj; /* saving throw adjustment */ | 770 bool |
771 save(int which, struct thing *who, int adj) | |
774 { | 772 { |
775 register int need, level; | 773 register int need, level; |
776 | 774 |
777 level = who->t_stats.s_lvl; | 775 level = who->t_stats.s_lvl; |
778 need = st_matrix[who->t_ctype][which]; | 776 need = st_matrix[who->t_ctype][which]; |
812 /* | 810 /* |
813 * secret_door: | 811 * secret_door: |
814 * Figure out what a secret door looks like. | 812 * Figure out what a secret door looks like. |
815 */ | 813 */ |
816 | 814 |
817 secretdoor(y, x) | 815 char |
818 register int y, x; | 816 secretdoor(int y, int x) |
819 { | 817 { |
820 register int i; | 818 register int i; |
821 register struct room *rp; | 819 register struct room *rp; |
822 register coord *cpp; | 820 register coord *cpp; |
823 static coord cp; | 821 static coord cp; |
836 } | 834 } |
837 | 835 |
838 /* | 836 /* |
839 * copy string using unctrl for things | 837 * copy string using unctrl for things |
840 */ | 838 */ |
841 strucpy(s1, s2, len) | 839 void |
842 register char *s1, *s2; | 840 strucpy(char *s1, char *s2, int len) |
843 register int len; | |
844 { | 841 { |
845 register char *sp; | 842 register char *sp; |
846 | 843 |
847 while (len--) | 844 while (len--) |
848 { | 845 { |
857 * tr_name: | 854 * tr_name: |
858 * print the name of a trap | 855 * print the name of a trap |
859 */ | 856 */ |
860 | 857 |
861 char * | 858 char * |
862 tr_name(ch) | 859 tr_name(char ch) |
863 char ch; | |
864 { | 860 { |
865 register char *s = NULL; | 861 register char *s = NULL; |
866 | 862 |
867 switch (ch) | 863 switch (ch) |
868 { | 864 { |
888 | 884 |
889 /* | 885 /* |
890 * for printfs: if string starts with a vowel, return "n" for an "an" | 886 * for printfs: if string starts with a vowel, return "n" for an "an" |
891 */ | 887 */ |
892 char * | 888 char * |
893 vowelstr(str) | 889 vowelstr(char *str) |
894 register char *str; | |
895 { | 890 { |
896 switch (*str) | 891 switch (*str) |
897 { | 892 { |
898 case 'a': | 893 case 'a': |
899 case 'e': | 894 case 'e': |
909 /* | 904 /* |
910 * waste_time: | 905 * waste_time: |
911 * Do nothing but let other things happen | 906 * Do nothing but let other things happen |
912 */ | 907 */ |
913 | 908 |
914 waste_time() | 909 void |
910 waste_time(void) | |
915 { | 911 { |
916 if (inwhgt) /* if from wghtchk then done */ | 912 if (inwhgt) /* if from wghtchk then done */ |
917 return; | 913 return; |
918 do_daemons(BEFORE); | 914 do_daemons(BEFORE); |
919 do_fuses(BEFORE); | 915 do_fuses(BEFORE); |