comparison srogue/chase.c @ 217:94a0d9dd5ce1

Super-Rogue: convert to ANSI-style function declarations. This fixes most of the build warnings.
author John "Elwin" Edwards
date Sun, 31 Jan 2016 13:45:07 -0500
parents 2128c7dc8a40
children e52a8a7ad4c5
comparison
equal deleted inserted replaced
216:b24545357d2e 217:94a0d9dd5ce1
12 * All rights reserved. 12 * All rights reserved.
13 * 13 *
14 * See the file LICENSE.TXT for full copyright and licensing information. 14 * See the file LICENSE.TXT for full copyright and licensing information.
15 */ 15 */
16 16
17 #include <stdlib.h>
17 #include "rogue.h" 18 #include "rogue.h"
18 #include "rogue.ext" 19 #include "rogue.ext"
19 20
20 #define FARAWAY 32767 21 #define FARAWAY 32767
21 #define RDIST(a, b) (DISTANCE((a)->y, (a)->x, (b).y, (b).x)) 22 #define RDIST(a, b) (DISTANCE((a)->y, (a)->x, (b).y, (b).x))
22 23
24 int do_chase(struct linked_list *mon);
25 int chase(struct thing *tp, struct coord *ee, bool runaway, bool dofight);
26
23 struct coord ch_ret; /* Where chasing takes you */ 27 struct coord ch_ret; /* Where chasing takes you */
24 28
25 /* 29 /*
26 * runners: 30 * runners:
27 * Make all the running monsters move. 31 * Make all the running monsters move.
28 */ 32 */
29 runners() 33 void
34 runners(void)
30 { 35 {
31 reg struct thing *tp; 36 reg struct thing *tp;
32 reg struct linked_list *mon,*nextmon; 37 reg struct linked_list *mon,*nextmon;
33 38
34 for (mon = mlist; mon != NULL; mon = nextmon) { 39 for (mon = mlist; mon != NULL; mon = nextmon) {
52 57
53 /* 58 /*
54 * do_chase: 59 * do_chase:
55 * Make one thing chase another. 60 * Make one thing chase another.
56 */ 61 */
57 do_chase(mon) 62 int
58 struct linked_list *mon; 63 do_chase(struct linked_list *mon)
59 { 64 {
60 reg struct thing *th; 65 reg struct thing *th;
61 reg struct room *rer, *ree, *rxx; 66 reg struct room *rer, *ree, *rxx;
62 reg int mindist, i, dist; 67 reg int mindist, i, dist;
63 struct stats *st; 68 struct stats *st;
239 * chase: 244 * chase:
240 * Find the spot for the chaser to move closer to the 245 * Find the spot for the chaser to move closer to the
241 * chasee. Returns TRUE if we want to keep on chasing 246 * chasee. Returns TRUE if we want to keep on chasing
242 * later FALSE if we reach the goal. 247 * later FALSE if we reach the goal.
243 */ 248 */
244 chase(tp, ee, runaway, dofight) 249 int
245 struct thing *tp; 250 chase(struct thing *tp, struct coord *ee, bool runaway, bool dofight)
246 struct coord *ee;
247 bool runaway, dofight;
248 { 251 {
249 reg int x, y, ch; 252 reg int x, y, ch;
250 reg int dist, thisdist, closest; 253 reg int dist, thisdist, closest;
251 reg struct coord *er = &tp->t_pos; 254 reg struct coord *er = &tp->t_pos;
252 struct coord try, closecoord; 255 struct coord try, closecoord;
383 386
384 /* 387 /*
385 * runto: 388 * runto:
386 * Set a monster running after something 389 * Set a monster running after something
387 */ 390 */
388 runto(runner, spot) 391 void
389 struct coord *runner; 392 runto(struct coord *runner, struct coord *spot)
390 struct coord *spot;
391 { 393 {
392 reg struct linked_list *item; 394 reg struct linked_list *item;
393 reg struct thing *tp; 395 reg struct thing *tp;
394 396
395 if ((item = find_mons(runner->y, runner->x)) == NULL) 397 if ((item = find_mons(runner->y, runner->x)) == NULL)
407 * roomin: 409 * roomin:
408 * Find what room some coordinates are in. 410 * Find what room some coordinates are in.
409 * NULL means they aren't in any room. 411 * NULL means they aren't in any room.
410 */ 412 */
411 struct room * 413 struct room *
412 roomin(cp) 414 roomin(struct coord *cp)
413 struct coord *cp;
414 { 415 {
415 reg struct room *rp; 416 reg struct room *rp;
416 417
417 if (cordok(cp->y, cp->x)) { 418 if (cordok(cp->y, cp->x)) {
418 for (rp = rooms; rp < &rooms[MAXROOMS]; rp += 1) 419 for (rp = rooms; rp < &rooms[MAXROOMS]; rp += 1)
426 /* 427 /*
427 * find_mons: 428 * find_mons:
428 * Find the monster from his coordinates 429 * Find the monster from his coordinates
429 */ 430 */
430 struct linked_list * 431 struct linked_list *
431 find_mons(y, x) 432 find_mons(int y, int x)
432 int y, x;
433 { 433 {
434 reg struct linked_list *item; 434 reg struct linked_list *item;
435 reg struct thing *th; 435 reg struct thing *th;
436 436
437 for (item = mlist; item != NULL; item = next(item)) { 437 for (item = mlist; item != NULL; item = next(item)) {
445 445
446 /* 446 /*
447 * diag_ok: 447 * diag_ok:
448 * Check to see if the move is legal if it is diagonal 448 * Check to see if the move is legal if it is diagonal
449 */ 449 */
450 diag_ok(sp, ep) 450 bool
451 struct coord *sp, *ep; 451 diag_ok(struct coord *sp, struct coord *ep)
452 { 452 {
453 if (ep->x == sp->x || ep->y == sp->y) 453 if (ep->x == sp->x || ep->y == sp->y)
454 return TRUE; 454 return TRUE;
455 if (step_ok(mvinch(ep->y,sp->x)) && step_ok(mvinch(sp->y,ep->x))) 455 if (step_ok(mvinch(ep->y,sp->x)) && step_ok(mvinch(sp->y,ep->x)))
456 return TRUE; 456 return TRUE;
460 460
461 /* 461 /*
462 * cansee: 462 * cansee:
463 * returns true if the hero can see a certain coordinate. 463 * returns true if the hero can see a certain coordinate.
464 */ 464 */
465 cansee(y, x) 465 bool
466 int y, x; 466 cansee(int y, int x)
467 { 467 {
468 reg struct room *rer; 468 reg struct room *rer;
469 struct coord tp; 469 struct coord tp;
470 470
471 if (pl_on(ISBLIND)) 471 if (pl_on(ISBLIND))