diff options
author | dholland <dholland@NetBSD.org> | 2009-07-20 05:44:02 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2009-07-20 05:44:02 +0000 |
commit | ce061e17a9dda9852d7bfd583c089bbd8dac1333 (patch) | |
tree | 012204b893307d40ce4f844f199906efcea20d69 /robots | |
parent | 275e28ad8575814dcb1749559423a55a82960cfe (diff) | |
download | bsdgames-darwin-ce061e17a9dda9852d7bfd583c089bbd8dac1333.tar.gz bsdgames-darwin-ce061e17a9dda9852d7bfd583c089bbd8dac1333.tar.zst bsdgames-darwin-ce061e17a9dda9852d7bfd583c089bbd8dac1333.zip |
ANSIfy. Use __dead. Object diffs checked.
Diffstat (limited to 'robots')
-rw-r--r-- | robots/auto.c | 51 | ||||
-rw-r--r-- | robots/flush_in.c | 6 | ||||
-rw-r--r-- | robots/init_field.c | 9 | ||||
-rw-r--r-- | robots/main.c | 15 | ||||
-rw-r--r-- | robots/make_level.c | 6 | ||||
-rw-r--r-- | robots/move.c | 18 | ||||
-rw-r--r-- | robots/move_robs.c | 13 | ||||
-rw-r--r-- | robots/play_level.c | 6 | ||||
-rw-r--r-- | robots/query.c | 7 | ||||
-rw-r--r-- | robots/rnd_pos.c | 9 | ||||
-rw-r--r-- | robots/robots.h | 6 | ||||
-rw-r--r-- | robots/score.c | 21 |
12 files changed, 69 insertions, 98 deletions
diff --git a/robots/auto.c b/robots/auto.c index 4b772de8..dd853795 100644 --- a/robots/auto.c +++ b/robots/auto.c @@ -1,4 +1,4 @@ -/* $NetBSD: auto.c,v 1.8 2008/04/28 20:22:54 martin Exp $ */ +/* $NetBSD: auto.c,v 1.9 2009/07/20 05:44:02 dholland Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -73,18 +73,16 @@ static int between(COORD *, COORD *); * return "move" number distance of the two coordinates */ static int -distance(x1, y1, x2, y2) - int x1, y1, x2, y2; +distance(int x1, int y1, int x2, int y2) { return MAX(ABS(ABS(x1) - ABS(x2)), ABS(ABS(y1) - ABS(y2))); -} /* end distance */ +} /* xinc(): * Return x coordinate moves */ static int -xinc(dir) - int dir; +xinc(int dir) { switch(dir) { case 'b': @@ -106,8 +104,7 @@ xinc(dir) * Return y coordinate moves */ static int -yinc(dir) - int dir; +yinc(int dir) { switch(dir) { case 'k': @@ -129,7 +126,7 @@ yinc(dir) * Find possible moves */ static const char * -find_moves() +find_moves(void) { int x, y; COORD test; @@ -169,8 +166,7 @@ find_moves() * and put in dist its distance */ static COORD * -closest_robot(dist) - int *dist; +closest_robot(int *dist) { COORD *rob, *end, *minrob = NULL; int tdist, mindist; @@ -186,15 +182,14 @@ closest_robot(dist) } *dist = mindist; return minrob; -} /* end closest_robot */ +} /* closest_heap(): * return the heap closest to us * and put in dist its distance */ static COORD * -closest_heap(dist) - int *dist; +closest_heap(int *dist) { COORD *hp, *end, *minhp = NULL; int mindist, tdist; @@ -212,14 +207,13 @@ closest_heap(dist) } *dist = mindist; return minhp; -} /* end closest_heap */ +} /* move_towards(): * move as close to the given direction as possible */ static char -move_towards(dx, dy) - int dx, dy; +move_towards(int dx, int dy) { char ok_moves[10], best_move; char *ptr; @@ -242,30 +236,27 @@ move_towards(dx, dy) } } return best_move; -} /* end move_towards */ +} /* move_away(): * move away form the robot given */ static char -move_away(rob) - COORD *rob; +move_away(COORD *rob) { int dx, dy; dx = sign(My_pos.x - rob->x); dy = sign(My_pos.y - rob->y); return move_towards(dx, dy); -} /* end move_away */ +} /* move_between(): * move the closest heap between us and the closest robot */ static char -move_between(rob, hp) - COORD *rob; - COORD *hp; +move_between(COORD *rob, COORD *hp) { int dx, dy; float slope, cons; @@ -314,15 +305,13 @@ move_between(rob, hp) CONSDEBUG(("me (%d,%d) robot(%d,%d) heap(%d,%d) delta(%d,%d)", My_pos.x, My_pos.y, rob->x, rob->y, hp->x, hp->y, dx, dy)); return move_towards(dx, dy); -} /* end move_between */ +} /* between(): * Return true if the heap is between us and the robot */ int -between(rob, hp) - COORD *rob; - COORD *hp; +between(COORD *rob, COORD *hp) { /* I = @ */ if (hp->x > rob->x && My_pos.x < rob->x) @@ -341,14 +330,14 @@ between(rob, hp) if (hp->y > rob->y && My_pos.y < rob->y) return 0; return 1; -} /* end between */ +} /* automove(): * find and do the best move if flag * else get the first move; */ char -automove() +automove(void) { #if 0 return find_moves()[0]; @@ -376,4 +365,4 @@ automove() return move_between(robot_close, heap_close); #endif -} /* end automove */ +} diff --git a/robots/flush_in.c b/robots/flush_in.c index 68ae4c33..5edb6480 100644 --- a/robots/flush_in.c +++ b/robots/flush_in.c @@ -1,4 +1,4 @@ -/* $NetBSD: flush_in.c,v 1.6 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: flush_in.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)flush_in.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: flush_in.c,v 1.6 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: flush_in.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID("$NetBSD: flush_in.c,v 1.6 2003/08/07 09:37:36 agc Exp $"); * Flush all pending input. */ void -flush_in() +flush_in(void) { tcflush(fileno(stdin), TCIFLUSH); } diff --git a/robots/init_field.c b/robots/init_field.c index 96d61096..371f3eeb 100644 --- a/robots/init_field.c +++ b/robots/init_field.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_field.c,v 1.8 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: init_field.c,v 1.9 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)init_field.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: init_field.c,v 1.8 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: init_field.c,v 1.9 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -49,7 +49,7 @@ static int tely = 0; * and initialize all the global variables. */ void -init_field() +init_field(void) { int i; static bool first = TRUE; @@ -123,8 +123,7 @@ init_field() } void -telmsg(on) - int on; +telmsg(int on) { move(tely, telx); addstr(on ? "Teleport!" : " "); diff --git a/robots/main.c b/robots/main.c index 98e2ff29..f1dce70a 100644 --- a/robots/main.c +++ b/robots/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.24 2008/08/08 16:10:47 drochner Exp $ */ +/* $NetBSD: main.c,v 1.25 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,21 +39,17 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.24 2008/08/08 16:10:47 drochner Exp $"); +__RCSID("$NetBSD: main.c,v 1.25 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ # include "robots.h" -int main(int, char **); - extern const char *Scorefile; extern int Max_per_uid; int -main(ac, av) - int ac; - char **av; +main(int ac, char **av) { const char *sp; bool bad_arg; @@ -197,8 +193,7 @@ main(ac, av) * Leave the program elegantly. */ void -quit(dummy) - int dummy __unused; +quit(int dummy __unused) { endwin(); exit(0); @@ -210,7 +205,7 @@ quit(dummy) * See if another game is desired */ bool -another() +another(void) { int y; diff --git a/robots/make_level.c b/robots/make_level.c index b3e11924..32af0933 100644 --- a/robots/make_level.c +++ b/robots/make_level.c @@ -1,4 +1,4 @@ -/* $NetBSD: make_level.c,v 1.7 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: make_level.c,v 1.7 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID("$NetBSD: make_level.c,v 1.7 2003/08/07 09:37:36 agc Exp $"); * Make the current level */ void -make_level() +make_level(void) { int i; COORD *cp; diff --git a/robots/move.c b/robots/move.c index 7edaae35..de030121 100644 --- a/robots/move.c +++ b/robots/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $ */ +/* $NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $"); +__RCSID("$NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -47,7 +47,7 @@ __RCSID("$NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $"); * Get and execute a move from the player */ void -get_move() +get_move(void) { int c; #ifdef FANCY @@ -208,7 +208,7 @@ ret: * being eaten? */ bool -must_telep() +must_telep(void) { int x, y; static COORD newpos; @@ -240,8 +240,7 @@ must_telep() * Execute a move */ bool -do_move(dy, dx) - int dy, dx; +do_move(int dy, int dx) { static COORD newpos; @@ -277,8 +276,7 @@ do_move(dy, dx) * Player would get eaten at this place */ bool -eaten(pos) - const COORD *pos; +eaten(const COORD *pos) { int x, y; @@ -300,7 +298,7 @@ eaten(pos) * Reset the count variables */ void -reset_count() +reset_count(void) { Count = 0; Running = FALSE; @@ -313,7 +311,7 @@ reset_count() * See if we are jumping, i.e., we should not refresh. */ bool -jumping() +jumping(void) { return (Jump && (Count || Running || Waiting)); } diff --git a/robots/move_robs.c b/robots/move_robs.c index 9b5f8947..ce53c336 100644 --- a/robots/move_robs.c +++ b/robots/move_robs.c @@ -1,4 +1,4 @@ -/* $NetBSD: move_robs.c,v 1.7 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move_robs.c,v 1.7 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,8 +45,7 @@ __RCSID("$NetBSD: move_robs.c,v 1.7 2003/08/07 09:37:37 agc Exp $"); * Move the robots around */ void -move_robots(was_sig) - int was_sig; +move_robots(int was_sig) { COORD *rp; @@ -129,8 +128,7 @@ move_robots(was_sig) * Add a score to the overall point total */ void -add_score(add) - int add; +add_score(int add) { Score += add; move(Y_SCORE, X_SCORE); @@ -142,8 +140,7 @@ add_score(add) * Return the sign of the number */ int -sign(n) - int n; +sign(int n) { if (n < 0) return -1; diff --git a/robots/play_level.c b/robots/play_level.c index 3cb3d0ab..ba2b6a5c 100644 --- a/robots/play_level.c +++ b/robots/play_level.c @@ -1,4 +1,4 @@ -/* $NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID("$NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $"); * Let the player play the current level */ void -play_level() +play_level(void) { COORD *cp; diff --git a/robots/query.c b/robots/query.c index 739ed1f8..f3d885de 100644 --- a/robots/query.c +++ b/robots/query.c @@ -1,4 +1,4 @@ -/* $NetBSD: query.c,v 1.6 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: query.c,v 1.6 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,8 +45,7 @@ __RCSID("$NetBSD: query.c,v 1.6 2003/08/07 09:37:37 agc Exp $"); * Ask a question and get a yes or no answer. Default is "no". */ int -query(prompt) - const char *prompt; +query(const char *prompt) { int c, retval; int y, x; diff --git a/robots/rnd_pos.c b/robots/rnd_pos.c index 5afff5a8..6e739ea0 100644 --- a/robots/rnd_pos.c +++ b/robots/rnd_pos.c @@ -1,4 +1,4 @@ -/* $NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -47,7 +47,7 @@ __RCSID("$NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $"); * Pick a random, unoccupied position */ COORD * -rnd_pos() +rnd_pos(void) { static COORD pos; static int call = 0; @@ -62,8 +62,7 @@ rnd_pos() } int -rnd(range) - int range; +rnd(int range) { return rand() % range; diff --git a/robots/robots.h b/robots/robots.h index b08909ad..63862c87 100644 --- a/robots/robots.h +++ b/robots/robots.h @@ -1,4 +1,4 @@ -/* $NetBSD: robots.h,v 1.18 2004/01/27 20:30:30 jsm Exp $ */ +/* $NetBSD: robots.h,v 1.19 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -117,7 +117,7 @@ extern COORD Max, Min, My_pos, Robots[], Scrap[]; extern jmp_buf End_move; /* - * functions types + * functions */ void add_score(int); @@ -135,7 +135,7 @@ void move_robots(int); bool must_telep(void); void play_level(void); int query(const char *); -void quit(int) __attribute__((__noreturn__)); +void quit(int) __dead; void reset_count(void); int rnd(int); COORD *rnd_pos(void); diff --git a/robots/score.c b/robots/score.c index 62709435..17935329 100644 --- a/robots/score.c +++ b/robots/score.c @@ -1,4 +1,4 @@ -/* $NetBSD: score.c,v 1.18 2006/03/17 23:11:47 abs Exp $ */ +/* $NetBSD: score.c,v 1.19 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: score.c,v 1.18 2006/03/17 23:11:47 abs Exp $"); +__RCSID("$NetBSD: score.c,v 1.19 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -57,8 +57,7 @@ static void write_score(int); * Read the score file in MI format */ static void -read_score(inf) - int inf; +read_score(int inf) { SCORE *scp; @@ -85,8 +84,7 @@ read_score(inf) * Write the score file in MI format */ static void -write_score(inf) - int inf; +write_score(int inf) { SCORE *scp; @@ -112,8 +110,7 @@ write_score(inf) * top list. */ void -score(score_wfd) - int score_wfd; +score(int score_wfd) { int inf = score_wfd; SCORE *scp; @@ -189,8 +186,7 @@ score(score_wfd) } void -set_name(scp) - SCORE *scp; +set_name(SCORE *scp) { PASSWD *pp; @@ -205,8 +201,7 @@ set_name(scp) * Compare two scores. */ int -cmp_sc(s1, s2) - const void *s1, *s2; +cmp_sc(const void *s1, const void *s2) { return ((const SCORE *)s2)->s_score - ((const SCORE *)s1)->s_score; } @@ -216,7 +211,7 @@ cmp_sc(s1, s2) * Show the score list for the '-s' option. */ void -show_score() +show_score(void) { SCORE *scp; int inf; |