From e1ae4d1a77877d5f408947890cf752c0c0998291 Mon Sep 17 00:00:00 2001 From: dholland Date: Mon, 20 Jul 2009 06:00:56 +0000 Subject: Whitespace. --- robots/auto.c | 76 +++++++++++++------------- robots/extern.c | 72 ++++++++++++------------- robots/flush_in.c | 6 +-- robots/init_field.c | 12 ++--- robots/main.c | 26 ++++----- robots/make_level.c | 12 ++--- robots/move.c | 24 ++++----- robots/move_robs.c | 16 +++--- robots/play_level.c | 12 ++--- robots/query.c | 10 ++-- robots/rnd_pos.c | 12 ++--- robots/robots.h | 150 ++++++++++++++++++++++++++-------------------------- robots/score.c | 34 ++++++------ 13 files changed, 231 insertions(+), 231 deletions(-) (limited to 'robots') diff --git a/robots/auto.c b/robots/auto.c index dd853795..792c0ba5 100644 --- a/robots/auto.c +++ b/robots/auto.c @@ -1,4 +1,4 @@ -/* $NetBSD: auto.c,v 1.9 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: auto.c,v 1.10 2009/07/20 06:00:56 dholland Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -32,14 +32,14 @@ /* * Automatic move. * intelligent ? - * Algo : + * Algo : * IF scrapheaps don't exist THEN - * IF not in danger THEN + * IF not in danger THEN * stay at current position * ELSE * move away from the closest robot * FI - * ELSE + * ELSE * find closest heap * find closest robot * IF scrapheap is adjacent THEN @@ -70,16 +70,16 @@ static char move_between(COORD *, COORD *); static int between(COORD *, COORD *); /* distance(): - * return "move" number distance of the two coordinates + * return "move" number distance of the two coordinates */ -static int +static int distance(int x1, int y1, int x2, int y2) { return MAX(ABS(ABS(x1) - ABS(x2)), ABS(ABS(y1) - ABS(y2))); } /* xinc(): - * Return x coordinate moves + * Return x coordinate moves */ static int xinc(int dir) @@ -101,7 +101,7 @@ xinc(int dir) } /* yinc(): - * Return y coordinate moves + * Return y coordinate moves */ static int yinc(int dir) @@ -123,7 +123,7 @@ yinc(int dir) } /* find_moves(): - * Find possible moves + * Find possible moves */ static const char * find_moves(void) @@ -136,17 +136,17 @@ find_moves(void) static char ans[sizeof moves]; a = ans; - for(m = moves; *m; m++) { + for (m = moves; *m; m++) { test.x = My_pos.x + xinc(*m); test.y = My_pos.y + yinc(*m); move(test.y, test.x); switch(winch(stdscr)) { case ' ': case PLAYER: - for(x = test.x - 1; x <= test.x + 1; x++) { - for(y = test.y - 1; y <= test.y + 1; y++) { + for (x = test.x - 1; x <= test.x + 1; x++) { + for (y = test.y - 1; y <= test.y + 1; y++) { move(y, x); - if(winch(stdscr) == ROBOT) + if (winch(stdscr) == ROBOT) goto bad; } } @@ -155,15 +155,15 @@ find_moves(void) bad:; } *a = 0; - if(ans[0]) + if (ans[0]) return ans; else return "t"; } /* closest_robot(): - * return the robot closest to us - * and put in dist its distance + * return the robot closest to us + * and put in dist its distance */ static COORD * closest_robot(int *dist) @@ -183,10 +183,10 @@ closest_robot(int *dist) *dist = mindist; return minrob; } - + /* closest_heap(): - * return the heap closest to us - * and put in dist its distance + * return the heap closest to us + * and put in dist its distance */ static COORD * closest_heap(int *dist) @@ -210,9 +210,9 @@ closest_heap(int *dist) } /* move_towards(): - * move as close to the given direction as possible + * move as close to the given direction as possible */ -static char +static char move_towards(int dx, int dy) { char ok_moves[10], best_move; @@ -220,7 +220,7 @@ move_towards(int dx, int dy) int move_judge, cur_judge, mvx, mvy; (void)strcpy(ok_moves, find_moves()); - best_move = ok_moves[0]; + best_move = ok_moves[0]; if (best_move != 't') { mvx = xinc(best_move); mvy = yinc(best_move); @@ -239,7 +239,7 @@ move_towards(int dx, int dy) } /* move_away(): - * move away form the robot given + * move away form the robot given */ static char move_away(COORD *rob) @@ -253,7 +253,7 @@ move_away(COORD *rob) /* move_between(): - * move the closest heap between us and the closest robot + * move the closest heap between us and the closest robot */ static char move_between(COORD *rob, COORD *hp) @@ -263,8 +263,8 @@ move_between(COORD *rob, COORD *hp) /* equation of the line between us and the closest robot */ if (My_pos.x == rob->x) { - /* - * me and the robot are aligned in x + /* + * me and the robot are aligned in x * change my x so I get closer to the heap * and my y far from the robot */ @@ -274,7 +274,7 @@ move_between(COORD *rob, COORD *hp) } else if (My_pos.y == rob->y) { /* - * me and the robot are aligned in y + * me and the robot are aligned in y * change my y so I get closer to the heap * and my x far from the robot */ @@ -288,7 +288,7 @@ move_between(COORD *rob, COORD *hp) cons = slope * rob->y; if (ABS(My_pos.x - rob->x) > ABS(My_pos.y - rob->y)) { /* - * we are closest to the robot in x + * we are closest to the robot in x * move away from the robot in x and * close to the scrap in y */ @@ -306,9 +306,9 @@ move_between(COORD *rob, COORD *hp) My_pos.x, My_pos.y, rob->x, rob->y, hp->x, hp->y, dx, dy)); return move_towards(dx, dy); } - + /* between(): - * Return true if the heap is between us and the robot + * Return true if the heap is between us and the robot */ int between(COORD *rob, COORD *hp) @@ -333,11 +333,11 @@ between(COORD *rob, COORD *hp) } /* automove(): - * find and do the best move if flag - * else get the first move; + * find and do the best move if flag + * else get the first move; */ char -automove(void) +automove(void) { #if 0 return find_moves()[0]; @@ -349,20 +349,20 @@ automove(void) robot_close = closest_robot(&robot_dist); if (robot_dist > 1) return('.'); - if (!Num_scrap) + if (!Num_scrap) /* no scrap heaps just run away */ return move_away(robot_close); heap_close = closest_heap(&heap_dist); - robot_heap = distance(robot_close->x, robot_close->y, - heap_close->x, heap_close->y); + robot_heap = distance(robot_close->x, robot_close->y, + heap_close->x, heap_close->y); if (robot_heap <= heap_dist && !between(robot_close, heap_close)) { - /* + /* * robot is closest to us from the heap. Run away! */ return move_away(robot_close); } - + return move_between(robot_close, heap_close); #endif } diff --git a/robots/extern.c b/robots/extern.c index 8fb36fbb..15293621 100644 --- a/robots/extern.c +++ b/robots/extern.c @@ -1,4 +1,4 @@ -/* $NetBSD: extern.c,v 1.8 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: extern.c,v 1.9 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,49 +34,49 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: extern.c,v 1.8 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: extern.c,v 1.9 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" -bool Dead; /* Player is now dead */ -bool Full_clear = TRUE; /* Lots of junk for init_field to clear */ -bool Jump = FALSE; /* Jump while running, counting, or waiting */ -bool Newscore; /* There was a new score added */ -#ifdef FANCY -bool Pattern_roll = FALSE; /* Auto play for YHBJNLUK pattern */ +bool Dead; /* Player is now dead */ +bool Full_clear = TRUE; /* Lots of junk for init_field to clear */ +bool Jump = FALSE; /* Jump while running, counting, or waiting */ +bool Newscore; /* There was a new score added */ +#ifdef FANCY +bool Pattern_roll = FALSE; /* Auto play for YHBJNLUK pattern */ #endif -bool Real_time = FALSE; /* Play in real time? */ -bool Auto_bot = FALSE; /* Automatic mover */ -bool Running = FALSE; /* Currently in the middle of a run */ -#ifdef FANCY -bool Stand_still = FALSE; /* Auto play for standing still pattern */ +bool Real_time = FALSE; /* Play in real time? */ +bool Auto_bot = FALSE; /* Automatic mover */ +bool Running = FALSE; /* Currently in the middle of a run */ +#ifdef FANCY +bool Stand_still = FALSE; /* Auto play for standing still pattern */ #endif -bool Teleport = FALSE; /* Teleport automatically when player must */ -bool Waiting; /* Player is waiting for end */ -bool Was_bonus = FALSE; /* Was a bonus last level */ +bool Teleport = FALSE; /* Teleport automatically when player must */ +bool Waiting; /* Player is waiting for end */ +bool Was_bonus = FALSE; /* Was a bonus last level */ -char Cnt_move; /* Command which has preceded the count */ -char Field[Y_FIELDSIZE][X_FIELDSIZE]; /* the playing field itslef */ -const char *Next_move; /* Next move to be used in the pattern */ -const char *Move_list = "YHBJNLUK";/* List of moves in the pattern */ -char Run_ch; /* Character for the direction we are running */ +char Cnt_move; /* Command which has preceded the count */ +char Field[Y_FIELDSIZE][X_FIELDSIZE]; /* the playing field itslef */ +const char *Next_move; /* Next move to be used in the pattern */ +const char *Move_list = "YHBJNLUK";/* List of moves in the pattern */ +char Run_ch; /* Character for the direction we are running */ -int Count = 0; /* Command count */ -int Level; /* Current level */ -int Num_robots; /* Number of robots left */ -int Num_scrap; /* Number of scrap heaps */ -int Num_scores; /* Number of scores posted */ -int Num_games; /* Number of games to play */ -u_int32_t Score; /* Current score */ -int Start_level = 1; /* Level on which to start */ -int Wait_bonus; /* bonus for waiting */ +int Count = 0; /* Command count */ +int Level; /* Current level */ +int Num_robots; /* Number of robots left */ +int Num_scrap; /* Number of scrap heaps */ +int Num_scores; /* Number of scores posted */ +int Num_games; /* Number of games to play */ +u_int32_t Score; /* Current score */ +int Start_level = 1; /* Level on which to start */ +int Wait_bonus; /* bonus for waiting */ -COORD Max; /* Max area robots take up */ -COORD Min; /* Min area robots take up */ -COORD My_pos; /* Player's current position */ -COORD Robots[MAXROBOTS]; /* Robots' current positions */ -COORD Scrap[MAXROBOTS]; /* ScrapHeap' current position */ +COORD Max; /* Max area robots take up */ +COORD Min; /* Min area robots take up */ +COORD My_pos; /* Player's current position */ +COORD Robots[MAXROBOTS]; /* Robots' current positions */ +COORD Scrap[MAXROBOTS]; /* ScrapHeap' current position */ jmp_buf End_move; /* Jump to on Real_time */ diff --git a/robots/flush_in.c b/robots/flush_in.c index 5edb6480..b65215c9 100644 --- a/robots/flush_in.c +++ b/robots/flush_in.c @@ -1,4 +1,4 @@ -/* $NetBSD: flush_in.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: flush_in.c,v 1.8 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,11 +34,11 @@ #if 0 static char sccsid[] = "@(#)flush_in.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: flush_in.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: flush_in.c,v 1.8 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" /* * flush_in: diff --git a/robots/init_field.c b/robots/init_field.c index 371f3eeb..a16a4b7b 100644 --- a/robots/init_field.c +++ b/robots/init_field.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_field.c,v 1.9 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: init_field.c,v 1.10 2009/07/20 06:00:56 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.9 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: init_field.c,v 1.10 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ @@ -51,9 +51,9 @@ static int tely = 0; void init_field(void) { - int i; - static bool first = TRUE; - static const char *const desc[] = { + int i; + static bool first = TRUE; + static const char *const desc[] = { "Directions:", "", "y k u", @@ -116,7 +116,7 @@ init_field(void) if (first) refresh(); first = FALSE; -#ifdef FANCY +#ifdef FANCY if (Pattern_roll) Next_move = &Move_list[-1]; #endif diff --git a/robots/main.c b/robots/main.c index f1dce70a..ad09e3d2 100644 --- a/robots/main.c +++ b/robots/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.25 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: main.c,v 1.26 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,23 +39,23 @@ __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.25 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: main.c,v 1.26 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" -extern const char *Scorefile; -extern int Max_per_uid; +extern const char *Scorefile; +extern int Max_per_uid; int main(int ac, char **av) { - const char *sp; - bool bad_arg; - bool show_only; - int score_wfd; /* high score writable file descriptor */ - int score_err = 0; /* hold errno from score file open */ + const char *sp; + bool bad_arg; + bool show_only; + int score_wfd; /* high score writable file descriptor */ + int score_err = 0; /* hold errno from score file open */ score_wfd = open(Scorefile, O_RDWR); if (score_wfd < 0) @@ -117,7 +117,7 @@ main(int ac, char **av) case 't': Teleport = TRUE; break; - + default: fprintf(stderr, "robots: unknown option: %c\n", *sp); bad_arg = TRUE; @@ -207,9 +207,9 @@ quit(int dummy __unused) bool another(void) { - int y; + int y; -#ifdef FANCY +#ifdef FANCY if ((Stand_still || Pattern_roll) && !Newscore) return TRUE; #endif diff --git a/robots/make_level.c b/robots/make_level.c index 32af0933..de7f8d8f 100644 --- a/robots/make_level.c +++ b/robots/make_level.c @@ -1,4 +1,4 @@ -/* $NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: make_level.c,v 1.9 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,11 +34,11 @@ #if 0 static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: make_level.c,v 1.9 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" /* * make_level: @@ -47,9 +47,9 @@ __RCSID("$NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); void make_level(void) { - int i; - COORD *cp; - int x; + int i; + COORD *cp; + int x; reset_count(); for (i = 1; i < Y_FIELDSIZE; i++) diff --git a/robots/move.c b/robots/move.c index de030121..bc229ac3 100644 --- a/robots/move.c +++ b/robots/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: move.c,v 1.14 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,13 +34,13 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: move.c,v 1.14 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ #include "robots.h" -# define ESC '\033' +#define ESC '\033' /* * get_move: @@ -49,15 +49,15 @@ __RCSID("$NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $"); void get_move(void) { - int c; + int c; #ifdef FANCY - int lastmove; + int lastmove; #endif /*FANCY*/ if (Waiting) return; -#ifdef FANCY +#ifdef FANCY if (Pattern_roll) { if (Next_move >= Move_list) lastmove = *Next_move; @@ -73,7 +73,7 @@ get_move(void) c = Run_ch; else if (Count != 0) c = Cnt_move; -#ifdef FANCY +#ifdef FANCY else if (Num_robots > 1 && Stand_still) c = '>'; else if (Num_robots > 1 && Pattern_roll) { @@ -210,10 +210,10 @@ ret: bool must_telep(void) { - int x, y; - static COORD newpos; + int x, y; + static COORD newpos; -#ifdef FANCY +#ifdef FANCY if (Stand_still && Num_robots > 1 && eaten(&My_pos)) return TRUE; #endif @@ -242,7 +242,7 @@ must_telep(void) bool do_move(int dy, int dx) { - static COORD newpos; + static COORD newpos; newpos.y = My_pos.y + dy; newpos.x = My_pos.x + dx; @@ -278,7 +278,7 @@ do_move(int dy, int dx) bool eaten(const COORD *pos) { - int x, y; + int x, y; for (y = pos->y - 1; y <= pos->y + 1; y++) { if (y <= 0 || y >= Y_FIELDSIZE) diff --git a/robots/move_robs.c b/robots/move_robs.c index ce53c336..446d5b26 100644 --- a/robots/move_robs.c +++ b/robots/move_robs.c @@ -1,4 +1,4 @@ -/* $NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: move_robs.c,v 1.9 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,11 +34,11 @@ #if 0 static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: move_robs.c,v 1.9 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" /* * move_robots: @@ -47,16 +47,16 @@ __RCSID("$NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); void move_robots(int was_sig) { - COORD *rp; + COORD *rp; if (Real_time) signal(SIGALRM, move_robots); -# ifdef DEBUG +#ifdef DEBUG move(Min.y, Min.x); addch(inch()); move(Max.y, Max.x); addch(inch()); -# endif /* DEBUG */ +#endif /* DEBUG */ for (rp = Robots; rp < &Robots[MAXROBOTS]; rp++) { if (rp->y < 0) continue; @@ -111,14 +111,14 @@ move_robots(int was_sig) longjmp(End_move, 0); } -# ifdef DEBUG +#ifdef DEBUG standout(); move(Min.y, Min.x); addch(inch()); move(Max.y, Max.x); addch(inch()); standend(); -# endif /* DEBUG */ +#endif /* DEBUG */ if (Real_time) alarm(3); } diff --git a/robots/play_level.c b/robots/play_level.c index ba2b6a5c..b9fa09f5 100644 --- a/robots/play_level.c +++ b/robots/play_level.c @@ -1,4 +1,4 @@ -/* $NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: play_level.c,v 1.8 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,11 +34,11 @@ #if 0 static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: play_level.c,v 1.8 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" /* * play_level: @@ -47,7 +47,7 @@ __RCSID("$NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); void play_level(void) { - COORD *cp; + COORD *cp; move(My_pos.y, My_pos.x); addch(PLAYER); @@ -59,14 +59,14 @@ play_level(void) addch(ROBOT); } refresh(); -# ifdef DEBUG +#ifdef DEBUG standout(); move(Min.y, Min.x); addch(inch()); move(Max.y, Max.x); addch(inch()); standend(); -# endif /* DEBUG */ +#endif /* DEBUG */ setjmp(End_move); flush_in(); while (!Dead && Num_robots > 0) { diff --git a/robots/query.c b/robots/query.c index f3d885de..2c584e27 100644 --- a/robots/query.c +++ b/robots/query.c @@ -1,4 +1,4 @@ -/* $NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: query.c,v 1.8 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,11 +34,11 @@ #if 0 static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: query.c,v 1.8 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" /* * query: @@ -47,8 +47,8 @@ __RCSID("$NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); int query(const char *prompt) { - int c, retval; - int y, x; + int c, retval; + int y, x; getyx(stdscr, y, x); move(Y_PROMPT, X_PROMPT); diff --git a/robots/rnd_pos.c b/robots/rnd_pos.c index 6e739ea0..363149eb 100644 --- a/robots/rnd_pos.c +++ b/robots/rnd_pos.c @@ -1,4 +1,4 @@ -/* $NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: rnd_pos.c,v 1.7 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,13 +34,13 @@ #if 0 static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: rnd_pos.c,v 1.7 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" +#include "robots.h" -# define IS_SAME(p,y,x) ((p).y != -1 && (p).y == y && (p).x == x) +#define IS_SAME(p,y,x) ((p).y != -1 && (p).y == y && (p).x == x) /* * rnd_pos: @@ -49,8 +49,8 @@ __RCSID("$NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $"); COORD * rnd_pos(void) { - static COORD pos; - static int call = 0; + static COORD pos; + static int call = 0; do { pos.y = rnd(Y_FIELDSIZE - 1) + 1; diff --git a/robots/robots.h b/robots/robots.h index 63862c87..2e81ef22 100644 --- a/robots/robots.h +++ b/robots/robots.h @@ -1,4 +1,4 @@ -/* $NetBSD: robots.h,v 1.19 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: robots.h,v 1.20 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -31,116 +31,116 @@ * @(#)robots.h 8.1 (Berkeley) 5/31/93 */ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * miscellaneous constants */ -# define Y_FIELDSIZE 23 -# define X_FIELDSIZE 60 -# define Y_SIZE 24 -# define X_SIZE 80 -# define MAXLEVELS 4 -# define MAXROBOTS (MAXLEVELS * 10) -# define ROB_SCORE 10 -# undef S_BONUS -# define S_BONUS (60 * ROB_SCORE) -# define Y_SCORE 21 -# define X_SCORE (X_FIELDSIZE + 9) -# define Y_PROMPT (Y_FIELDSIZE - 1) -# define X_PROMPT (X_FIELDSIZE + 2) -# define MAXSCORES (Y_SIZE - 2) -# define MAXNAME 16 -# define MS_NAME "Ten" +#define Y_FIELDSIZE 23 +#define X_FIELDSIZE 60 +#define Y_SIZE 24 +#define X_SIZE 80 +#define MAXLEVELS 4 +#define MAXROBOTS (MAXLEVELS * 10) +#define ROB_SCORE 10 +#undef S_BONUS +#define S_BONUS (60 * ROB_SCORE) +#define Y_SCORE 21 +#define X_SCORE (X_FIELDSIZE + 9) +#define Y_PROMPT (Y_FIELDSIZE - 1) +#define X_PROMPT (X_FIELDSIZE + 2) +#define MAXSCORES (Y_SIZE - 2) +#define MAXNAME 16 +#define MS_NAME "Ten" /* * characters on screen */ -# define ROBOT '+' -# define HEAP '*' -# define PLAYER '@' +#define ROBOT '+' +#define HEAP '*' +#define PLAYER '@' /* * type definitions */ typedef struct { - int y, x; + int y, x; } COORD; typedef struct { - u_int32_t s_uid; - u_int32_t s_score; - u_int32_t s_auto; - u_int32_t s_level; - char s_name[MAXNAME]; + u_int32_t s_uid; + u_int32_t s_score; + u_int32_t s_auto; + u_int32_t s_level; + char s_name[MAXNAME]; } SCORE; -typedef struct passwd PASSWD; +typedef struct passwd PASSWD; /* * global variables */ -extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running, - Teleport, Waiting, Was_bonus, Auto_bot; +extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running, + Teleport, Waiting, Was_bonus, Auto_bot; -#ifdef FANCY -extern bool Pattern_roll, Stand_still; +#ifdef FANCY +extern bool Pattern_roll, Stand_still; #endif -extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch; +extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch; extern const char *Next_move, *Move_list; -extern int Count, Level, Num_robots, Num_scrap, Num_scores, - Start_level, Wait_bonus, Num_games; +extern int Count, Level, Num_robots, Num_scrap, Num_scores, + Start_level, Wait_bonus, Num_games; -extern u_int32_t Score; +extern u_int32_t Score; -extern COORD Max, Min, My_pos, Robots[], Scrap[]; +extern COORD Max, Min, My_pos, Robots[], Scrap[]; -extern jmp_buf End_move; +extern jmp_buf End_move; /* * functions */ -void add_score(int); -bool another(void); -char automove(void); -int cmp_sc(const void *, const void *); -bool do_move(int, int); -bool eaten(const COORD *); -void flush_in(void); -void get_move(void); -void init_field(void); -bool jumping(void); -void make_level(void); -void move_robots(int); -bool must_telep(void); -void play_level(void); -int query(const char *); -void quit(int) __dead; -void reset_count(void); -int rnd(int); -COORD *rnd_pos(void); -void score(int); -void set_name(SCORE *); -void show_score(void); -int sign(int); -void telmsg(int); +void add_score(int); +bool another(void); +char automove(void); +int cmp_sc(const void *, const void *); +bool do_move(int, int); +bool eaten(const COORD *); +void flush_in(void); +void get_move(void); +void init_field(void); +bool jumping(void); +void make_level(void); +void move_robots(int); +bool must_telep(void); +void play_level(void); +int query(const char *); +void quit(int) __dead; +void reset_count(void); +int rnd(int); +COORD *rnd_pos(void); +void score(int); +void set_name(SCORE *); +void show_score(void); +int sign(int); +void telmsg(int); diff --git a/robots/score.c b/robots/score.c index 17935329..84e7f5fb 100644 --- a/robots/score.c +++ b/robots/score.c @@ -1,4 +1,4 @@ -/* $NetBSD: score.c,v 1.19 2009/07/20 05:44:02 dholland Exp $ */ +/* $NetBSD: score.c,v 1.20 2009/07/20 06:00:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,20 +34,20 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: score.c,v 1.19 2009/07/20 05:44:02 dholland Exp $"); +__RCSID("$NetBSD: score.c,v 1.20 2009/07/20 06:00:56 dholland Exp $"); #endif #endif /* not lint */ -# include "robots.h" -# include "pathnames.h" +#include "robots.h" +#include "pathnames.h" -const char *Scorefile = _PATH_SCORE; +const char *Scorefile = _PATH_SCORE; -int Max_per_uid = MAX_PER_UID; +int Max_per_uid = MAX_PER_UID; -static SCORE Top[MAXSCORES]; +static SCORE Top[MAXSCORES]; -static u_int32_t numscores, max_uid; +static u_int32_t numscores, max_uid; static void read_score(int); static void write_score(int); @@ -59,7 +59,7 @@ static void write_score(int); static void read_score(int inf) { - SCORE *scp; + SCORE *scp; if (read(inf, &max_uid, sizeof max_uid) == sizeof max_uid) { max_uid = ntohl(max_uid); @@ -86,7 +86,7 @@ read_score(int inf) static void write_score(int inf) { - SCORE *scp; + SCORE *scp; lseek(inf, 0L, SEEK_SET); @@ -112,10 +112,10 @@ write_score(int inf) void score(int score_wfd) { - int inf = score_wfd; - SCORE *scp; - u_int32_t uid; - bool done_show = FALSE; + int inf = score_wfd; + SCORE *scp; + u_int32_t uid; + bool done_show = FALSE; Newscore = FALSE; if (inf < 0) @@ -188,7 +188,7 @@ score(int score_wfd) void set_name(SCORE *scp) { - PASSWD *pp; + PASSWD *pp; if ((pp = getpwuid(scp->s_uid)) == NULL) strncpy(scp->s_name, "???", MAXNAME); @@ -213,8 +213,8 @@ cmp_sc(const void *s1, const void *s2) void show_score(void) { - SCORE *scp; - int inf; + SCORE *scp; + int inf; if ((inf = open(Scorefile, O_RDONLY)) < 0) { warn("opening `%s'", Scorefile); -- cgit v1.2.3-56-ge451