comparison arogue5/chase.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 0ed67132cf10
children e52a8a7ad4c5
comparison
equal deleted inserted replaced
217:94a0d9dd5ce1 218:56e748983fa8
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * See the file LICENSE.TXT for full copyright and licensing information. 12 * See the file LICENSE.TXT for full copyright and licensing information.
13 */ 13 */
14 14
15 #include <stdlib.h>
15 #include <ctype.h> 16 #include <ctype.h>
16 #include <limits.h> 17 #include <limits.h>
17 #include "curses.h" 18 #include "curses.h"
18 #include "rogue.h" 19 #include "rogue.h"
19 #define MAXINT INT_MAX 20 #define MAXINT INT_MAX
20 #define MININT INT_MIN 21 #define MININT INT_MIN
21 22
22 coord ch_ret; /* Where chasing takes you */ 23 coord ch_ret; /* Where chasing takes you */
23 24
24 25 struct linked_list *get_hurl(struct thing *tp);
25 26 bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting);
26 27
27 28
28 /* 29 /*
29 * Canblink checks if the monster can teleport (blink). If so, it will 30 * Canblink checks if the monster can teleport (blink). If so, it will
30 * try to blink the monster next to the player. 31 * try to blink the monster next to the player.
31 */ 32 */
32 33
33 bool 34 bool
34 can_blink(tp) 35 can_blink(struct thing *tp)
35 register struct thing *tp;
36 { 36 {
37 register int y, x, index=9; 37 register int y, x, index=9;
38 coord tryp; /* To hold the coordinates for use in diag_ok */ 38 coord tryp; /* To hold the coordinates for use in diag_ok */
39 bool spots[9], found_one=FALSE; 39 bool spots[9], found_one=FALSE;
40 40
126 * Can_shoot determines if the monster (er) has a direct line of shot 126 * Can_shoot determines if the monster (er) has a direct line of shot
127 * at the player (ee). If so, it returns the direction in which to shoot. 127 * at the player (ee). If so, it returns the direction in which to shoot.
128 */ 128 */
129 129
130 coord * 130 coord *
131 can_shoot(er, ee) 131 can_shoot(coord *er, coord *ee)
132 register coord *er, *ee;
133 { 132 {
134 static coord shoot_dir; 133 static coord shoot_dir;
135 134
136 /* Make sure we are chasing the player */ 135 /* Make sure we are chasing the player */
137 if (!ce((*ee), hero)) return(NULL); 136 if (!ce((*ee), hero)) return(NULL);
152 * Find the spot for the chaser(er) to move closer to the 151 * Find the spot for the chaser(er) to move closer to the
153 * chasee(ee). Returns TRUE if we want to keep on chasing later 152 * chasee(ee). Returns TRUE if we want to keep on chasing later
154 * FALSE if we reach the goal. 153 * FALSE if we reach the goal.
155 */ 154 */
156 155
157 chase(tp, ee, flee, mdead) 156 /* flee: True if destination (ee) is player and monster is running
158 register struct thing *tp; 157 * away or the player is in a wall and the monster can't get to it
159 register coord *ee; 158 */
160 bool flee; /* True if destination (ee) is player and monster is running away 159 bool
161 * or the player is in a wall and the monster can't get to it 160 chase(struct thing *tp, coord *ee, bool flee, bool *mdead)
162 */
163 bool *mdead;
164 { 161 {
165 int damage, dist, thisdist, monst_dist = MAXINT; 162 int damage, dist, thisdist, monst_dist = MAXINT;
166 struct linked_list *weapon; 163 struct linked_list *weapon;
167 register coord *er = &tp->t_pos; 164 register coord *er = &tp->t_pos;
168 coord *shoot_dir; 165 coord *shoot_dir;
528 525
529 /* 526 /*
530 * do_chase: 527 * do_chase:
531 * Make one thing chase another. 528 * Make one thing chase another.
532 */ 529 */
533 530 /* flee: True if running away or player is inaccessible in wall */
534 do_chase(th, flee) 531
535 register struct thing *th; 532 void
536 register bool flee; /* True if running away or player is inaccessible in wall */ 533 do_chase(struct thing *th, bool flee)
537 { 534 {
538 register struct room *rer, *ree, /* room of chaser, room of chasee */ 535 register struct room *rer, *ree, /* room of chaser, room of chasee */
539 *orig_rer, /* Original room of chaser */ 536 *orig_rer, /* Original room of chaser */
540 *new_room; /* new room of monster */ 537 *new_room; /* new room of monster */
541 int dist = MININT; 538 int dist = MININT;
828 /* 825 /*
829 * Get_hurl returns the weapon that the monster will "throw" if he has one 826 * Get_hurl returns the weapon that the monster will "throw" if he has one
830 */ 827 */
831 828
832 struct linked_list * 829 struct linked_list *
833 get_hurl(tp) 830 get_hurl(struct thing *tp)
834 register struct thing *tp;
835 { 831 {
836 struct linked_list *arrow, *bolt, *rock; 832 struct linked_list *arrow, *bolt, *rock;
837 register struct linked_list *pitem; 833 register struct linked_list *pitem;
838 bool bow=FALSE, crossbow=FALSE, sling=FALSE; 834 bool bow=FALSE, crossbow=FALSE, sling=FALSE;
839 835
859 /* 855 /*
860 * runners: 856 * runners:
861 * Make all the running monsters move. 857 * Make all the running monsters move.
862 */ 858 */
863 859
864 runners() 860 void
861 runners(void)
865 { 862 {
866 register struct linked_list *item; 863 register struct linked_list *item;
867 register struct thing *tp = NULL; 864 register struct thing *tp = NULL;
868 865
869 /* 866 /*
933 /* 930 /*
934 * runto: 931 * runto:
935 * Set a monster running after something 932 * Set a monster running after something
936 */ 933 */
937 934
938 runto(runner, spot) 935 void
939 register struct thing *runner; 936 runto(struct thing *runner, coord *spot)
940 coord *spot;
941 { 937 {
942 /* 938 /*
943 * Start the beastie running 939 * Start the beastie running
944 */ 940 */
945 runner->t_dest = spot; 941 runner->t_dest = spot;
957 * to shoot (if there is a line of sight). If shooting, monsters 953 * to shoot (if there is a line of sight). If shooting, monsters
958 * get in the way. Otherwise, they do not. 954 * get in the way. Otherwise, they do not.
959 */ 955 */
960 956
961 bool 957 bool
962 straight_shot(ery, erx, eey, eex, shooting) 958 straight_shot(int ery, int erx, int eey, int eex, coord *shooting)
963 register int ery, erx, eey, eex;
964 register coord *shooting;
965 { 959 {
966 register int dy, dx; /* Deltas */ 960 register int dy, dx; /* Deltas */
967 char ch; 961 char ch;
968 962
969 /* Does the monster have a straight shot at player */ 963 /* Does the monster have a straight shot at player */