Assorted minor cleanups, no functional change:
- u_int* -> uint* - don't make private typedefs of system structures - use curses TRUE and FALSE only with curses booleans, otherwise true and false; - includes cleanup - group globals in extern.c by functionality Object file diffs inspected.
This commit is contained in:
parent
26abeccab5
commit
a4cc1f4f06
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: auto.c,v 1.10 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: auto.c,v 1.11 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -50,6 +50,8 @@
|
|||
* FI
|
||||
* FI
|
||||
*/
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include "robots.h"
|
||||
|
||||
#define ABS(a) (((a)>0)?(a):-(a))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.c,v 1.9 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: extern.c,v 1.10 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,45 +34,48 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: extern.c,v 1.9 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: extern.c,v 1.10 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "robots.h"
|
||||
|
||||
bool Real_time = false; /* Play in real time? */
|
||||
bool Auto_bot = false; /* Automatic mover */
|
||||
bool Jump = false; /* Jump while running, counting, or waiting */
|
||||
bool Teleport = false; /* Teleport automatically when player must */
|
||||
|
||||
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 */
|
||||
#endif
|
||||
bool Teleport = FALSE; /* Teleport automatically when player must */
|
||||
bool Running = false; /* Currently in the middle of a run */
|
||||
bool Waiting; /* Player is waiting for end */
|
||||
bool Was_bonus = FALSE; /* Was a bonus last level */
|
||||
bool Newscore; /* There was a new score added */
|
||||
bool Was_bonus = false; /* Was a bonus last level */
|
||||
bool Full_clear = true; /* Lots of junk for init_field to clear */
|
||||
|
||||
#ifdef FANCY
|
||||
bool Pattern_roll = false; /* Auto play for YHBJNLUK pattern */
|
||||
bool Stand_still = false; /* Auto play for standing still pattern */
|
||||
#endif
|
||||
|
||||
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 Field[Y_FIELDSIZE][X_FIELDSIZE]; /* the playing field itself */
|
||||
|
||||
const char *Next_move; /* Next move to be used in the pattern */
|
||||
const char *Move_list = "YHBJNLUK";/* List of moves in the pattern */
|
||||
|
||||
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 */
|
||||
|
||||
uint32_t Score; /* Current score */
|
||||
|
||||
COORD Max; /* Max area robots take up */
|
||||
COORD Min; /* Min area robots take up */
|
||||
COORD My_pos; /* Player's current position */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: flush_in.c,v 1.8 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: flush_in.c,v 1.9 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,12 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)flush_in.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: flush_in.c,v 1.8 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: flush_in.c,v 1.9 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include "robots.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init_field.c,v 1.11 2009/07/20 06:09:29 dholland Exp $ */
|
||||
/* $NetBSD: init_field.c,v 1.12 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,11 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)init_field.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: init_field.c,v 1.11 2009/07/20 06:09:29 dholland Exp $");
|
||||
__RCSID("$NetBSD: init_field.c,v 1.12 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include "robots.h"
|
||||
|
||||
static int telx = 0;
|
||||
|
@ -52,7 +53,7 @@ void
|
|||
init_field(void)
|
||||
{
|
||||
int i;
|
||||
static bool first = TRUE;
|
||||
static bool first = true;
|
||||
static const char *const desc[] = {
|
||||
"Directions:",
|
||||
"",
|
||||
|
@ -79,8 +80,8 @@ init_field(void)
|
|||
NULL
|
||||
};
|
||||
|
||||
Dead = FALSE;
|
||||
Waiting = FALSE;
|
||||
Dead = false;
|
||||
Waiting = false;
|
||||
Score = 0;
|
||||
|
||||
erase();
|
||||
|
@ -115,7 +116,7 @@ init_field(void)
|
|||
tely = i;
|
||||
if (first)
|
||||
refresh();
|
||||
first = FALSE;
|
||||
first = false;
|
||||
#ifdef FANCY
|
||||
if (Pattern_roll)
|
||||
Next_move = &Move_list[-1];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.27 2009/07/20 06:09:29 dholland Exp $ */
|
||||
/* $NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -39,10 +39,18 @@ __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.27 2009/07/20 06:09:29 dholland Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "robots.h"
|
||||
|
||||
extern const char *Scorefile;
|
||||
|
@ -66,10 +74,10 @@ main(int ac, char **av)
|
|||
/* Revoke setgid privileges */
|
||||
setgid(getgid());
|
||||
|
||||
show_only = FALSE;
|
||||
show_only = false;
|
||||
Num_games = 1;
|
||||
if (ac > 1) {
|
||||
bad_arg = FALSE;
|
||||
bad_arg = false;
|
||||
for (++av; ac > 1 && *av[0]; av++, ac--)
|
||||
if (av[0][0] != '-')
|
||||
if (isdigit((unsigned char)av[0][0]))
|
||||
|
@ -86,24 +94,24 @@ main(int ac, char **av)
|
|||
if (sp == NULL)
|
||||
sp = Scorefile;
|
||||
if (strcmp(sp, "pattern_roll") == 0)
|
||||
Pattern_roll = TRUE;
|
||||
Pattern_roll = true;
|
||||
else if (strcmp(sp, "stand_still") == 0)
|
||||
Stand_still = TRUE;
|
||||
Stand_still = true;
|
||||
if (Pattern_roll || Stand_still)
|
||||
Teleport = TRUE;
|
||||
Teleport = true;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
for (sp = &av[0][1]; *sp; sp++)
|
||||
switch (*sp) {
|
||||
case 'A':
|
||||
Auto_bot = TRUE;
|
||||
Auto_bot = true;
|
||||
break;
|
||||
case 's':
|
||||
show_only = TRUE;
|
||||
show_only = true;
|
||||
break;
|
||||
case 'r':
|
||||
Real_time = TRUE;
|
||||
Real_time = true;
|
||||
break;
|
||||
case 'a':
|
||||
Start_level = 4;
|
||||
|
@ -112,15 +120,15 @@ main(int ac, char **av)
|
|||
Num_games++;
|
||||
break;
|
||||
case 'j':
|
||||
Jump = TRUE;
|
||||
Jump = true;
|
||||
break;
|
||||
case 't':
|
||||
Teleport = TRUE;
|
||||
Teleport = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "robots: unknown option: %c\n", *sp);
|
||||
bad_arg = TRUE;
|
||||
bad_arg = true;
|
||||
break;
|
||||
}
|
||||
if (bad_arg) {
|
||||
|
@ -211,7 +219,7 @@ another(void)
|
|||
|
||||
#ifdef FANCY
|
||||
if ((Stand_still || Pattern_roll) && !Newscore)
|
||||
return TRUE;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (query("Another game?")) {
|
||||
|
@ -222,7 +230,7 @@ another(void)
|
|||
}
|
||||
refresh();
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: make_level.c,v 1.9 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: make_level.c,v 1.10 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,12 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: make_level.c,v 1.9 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: make_level.c,v 1.10 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include "robots.h"
|
||||
|
||||
/*
|
||||
|
@ -59,7 +61,7 @@ make_level(void)
|
|||
if (My_pos.y > 0)
|
||||
mvaddch(My_pos.y, My_pos.x, ' ');
|
||||
|
||||
Waiting = FALSE;
|
||||
Waiting = false;
|
||||
Wait_bonus = 0;
|
||||
leaveok(stdscr, FALSE);
|
||||
for (cp = Robots; cp < &Robots[MAXROBOTS]; cp++)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: move.c,v 1.14 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: move.c,v 1.15 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,15 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: move.c,v 1.14 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: move.c,v 1.15 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ttydefaults.h> /* for CTRL */
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#include <unistd.h>
|
||||
#include "robots.h"
|
||||
|
||||
#define ESC '\033'
|
||||
|
@ -151,7 +156,7 @@ over:
|
|||
case 'Y': case 'U': case 'H': case 'J':
|
||||
case 'K': case 'L': case 'B': case 'N':
|
||||
case '>':
|
||||
Running = TRUE;
|
||||
Running = true;
|
||||
if (c == '>')
|
||||
Run_ch = ' ';
|
||||
else
|
||||
|
@ -166,13 +171,13 @@ over:
|
|||
break;
|
||||
case 'w':
|
||||
case 'W':
|
||||
Waiting = TRUE;
|
||||
Waiting = true;
|
||||
leaveok(stdscr, TRUE);
|
||||
goto ret;
|
||||
case 't':
|
||||
case 'T':
|
||||
teleport:
|
||||
Running = FALSE;
|
||||
Running = false;
|
||||
mvaddch(My_pos.y, My_pos.x, ' ');
|
||||
My_pos = *rnd_pos();
|
||||
telmsg(1);
|
||||
|
@ -215,7 +220,7 @@ must_telep(void)
|
|||
|
||||
#ifdef FANCY
|
||||
if (Stand_still && Num_robots > 1 && eaten(&My_pos))
|
||||
return TRUE;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
for (y = -1; y <= 1; y++) {
|
||||
|
@ -229,10 +234,10 @@ must_telep(void)
|
|||
if (Field[newpos.y][newpos.x] > 0)
|
||||
continue;
|
||||
if (!eaten(&newpos))
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -250,7 +255,7 @@ do_move(int dy, int dx)
|
|||
newpos.x <= 0 || newpos.x >= X_FIELDSIZE ||
|
||||
Field[newpos.y][newpos.x] > 0 || eaten(&newpos)) {
|
||||
if (Running) {
|
||||
Running = FALSE;
|
||||
Running = false;
|
||||
leaveok(stdscr, FALSE);
|
||||
move(My_pos.y, My_pos.x);
|
||||
refresh();
|
||||
|
@ -259,16 +264,16 @@ do_move(int dy, int dx)
|
|||
putchar(CTRL('G'));
|
||||
reset_count();
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
else if (dy == 0 && dx == 0)
|
||||
return TRUE;
|
||||
return true;
|
||||
mvaddch(My_pos.y, My_pos.x, ' ');
|
||||
My_pos = newpos;
|
||||
mvaddch(My_pos.y, My_pos.x, PLAYER);
|
||||
if (!jumping())
|
||||
refresh();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -287,10 +292,10 @@ eaten(const COORD *pos)
|
|||
if (x <= 0 || x >= X_FIELDSIZE)
|
||||
continue;
|
||||
if (Field[y][x] == 1)
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -301,7 +306,7 @@ void
|
|||
reset_count(void)
|
||||
{
|
||||
Count = 0;
|
||||
Running = FALSE;
|
||||
Running = false;
|
||||
leaveok(stdscr, FALSE);
|
||||
refresh();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: move_robs.c,v 1.9 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: move_robs.c,v 1.10 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,13 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: move_robs.c,v 1.9 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: move_robs.c,v 1.10 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "robots.h"
|
||||
|
||||
/*
|
||||
|
@ -83,7 +86,7 @@ move_robots(int was_sig)
|
|||
if (rp->y < 0)
|
||||
continue;
|
||||
else if (rp->y == My_pos.y && rp->x == My_pos.x)
|
||||
Dead = TRUE;
|
||||
Dead = true;
|
||||
else if (Field[rp->y][rp->x] > 1) {
|
||||
mvaddch(rp->y, rp->x, HEAP);
|
||||
Scrap[Num_scrap++] = *rp;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: play_level.c,v 1.8 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: play_level.c,v 1.9 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,12 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: play_level.c,v 1.8 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: play_level.c,v 1.9 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include <unistd.h>
|
||||
#include "robots.h"
|
||||
|
||||
/*
|
||||
|
@ -77,15 +79,15 @@ play_level(void)
|
|||
if (Real_time)
|
||||
alarm(0);
|
||||
if (Field[My_pos.y][My_pos.x] != 0)
|
||||
Dead = TRUE;
|
||||
Dead = true;
|
||||
if (!Dead)
|
||||
move_robots(FALSE);
|
||||
move_robots(false);
|
||||
if (Was_bonus) {
|
||||
move(Y_PROMPT, X_PROMPT);
|
||||
clrtoeol();
|
||||
move(Y_PROMPT + 1, X_PROMPT);
|
||||
clrtoeol();
|
||||
Was_bonus = FALSE;
|
||||
Was_bonus = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,14 +96,14 @@ play_level(void)
|
|||
*/
|
||||
|
||||
if (!Dead) {
|
||||
Was_bonus = FALSE;
|
||||
Was_bonus = false;
|
||||
|
||||
if (Level == Start_level && Start_level > 1) {
|
||||
move(Y_PROMPT, X_PROMPT);
|
||||
printw("Advance bonus: %d", S_BONUS);
|
||||
refresh();
|
||||
add_score(S_BONUS);
|
||||
Was_bonus = TRUE;
|
||||
Was_bonus = true;
|
||||
}
|
||||
|
||||
if (Wait_bonus != 0) {
|
||||
|
@ -112,7 +114,7 @@ play_level(void)
|
|||
printw("Wait bonus: %d", Wait_bonus);
|
||||
refresh();
|
||||
add_score(Wait_bonus);
|
||||
Was_bonus = TRUE;
|
||||
Was_bonus = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: query.c,v 1.8 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: query.c,v 1.9 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,11 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: query.c,v 1.8 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: query.c,v 1.9 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include "robots.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rnd_pos.c,v 1.7 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: rnd_pos.c,v 1.8 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,12 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: rnd_pos.c,v 1.7 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: rnd_pos.c,v 1.8 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include <stdlib.h>
|
||||
#include "robots.h"
|
||||
|
||||
#define IS_SAME(p,y,x) ((p).y != -1 && (p).y == y && (p).x == x)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: robots.h,v 1.20 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: robots.h,v 1.21 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -31,20 +31,11 @@
|
|||
* @(#)robots.h 8.1 (Berkeley) 5/31/93
|
||||
*/
|
||||
|
||||
#include <sys/ttydefaults.h>
|
||||
#include <sys/endian.h>
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* miscellaneous constants
|
||||
|
@ -84,15 +75,13 @@ typedef struct {
|
|||
} COORD;
|
||||
|
||||
typedef struct {
|
||||
u_int32_t s_uid;
|
||||
u_int32_t s_score;
|
||||
u_int32_t s_auto;
|
||||
u_int32_t s_level;
|
||||
uint32_t s_uid;
|
||||
uint32_t s_score;
|
||||
uint32_t s_auto;
|
||||
uint32_t s_level;
|
||||
char s_name[MAXNAME];
|
||||
} SCORE;
|
||||
|
||||
typedef struct passwd PASSWD;
|
||||
|
||||
/*
|
||||
* global variables
|
||||
*/
|
||||
|
@ -110,7 +99,7 @@ extern const char *Next_move, *Move_list;
|
|||
extern int Count, Level, Num_robots, Num_scrap, Num_scores,
|
||||
Start_level, Wait_bonus, Num_games;
|
||||
|
||||
extern u_int32_t Score;
|
||||
extern uint32_t Score;
|
||||
|
||||
extern COORD Max, Min, My_pos, Robots[], Scrap[];
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: score.c,v 1.20 2009/07/20 06:00:56 dholland Exp $ */
|
||||
/* $NetBSD: score.c,v 1.21 2009/07/20 06:39:06 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -34,10 +34,18 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: score.c,v 1.20 2009/07/20 06:00:56 dholland Exp $");
|
||||
__RCSID("$NetBSD: score.c,v 1.21 2009/07/20 06:39:06 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "robots.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
|
@ -47,10 +55,7 @@ int Max_per_uid = MAX_PER_UID;
|
|||
|
||||
static SCORE Top[MAXSCORES];
|
||||
|
||||
static u_int32_t numscores, max_uid;
|
||||
|
||||
static void read_score(int);
|
||||
static void write_score(int);
|
||||
static uint32_t numscores, max_uid;
|
||||
|
||||
/*
|
||||
* read_score:
|
||||
|
@ -114,10 +119,10 @@ score(int score_wfd)
|
|||
{
|
||||
int inf = score_wfd;
|
||||
SCORE *scp;
|
||||
u_int32_t uid;
|
||||
bool done_show = FALSE;
|
||||
uint32_t uid;
|
||||
bool done_show = false;
|
||||
|
||||
Newscore = FALSE;
|
||||
Newscore = false;
|
||||
if (inf < 0)
|
||||
return;
|
||||
|
||||
|
@ -135,7 +140,7 @@ score(int score_wfd)
|
|||
scp->s_auto = Auto_bot;
|
||||
scp->s_level = Level;
|
||||
set_name(scp);
|
||||
Newscore = TRUE;
|
||||
Newscore = true;
|
||||
break;
|
||||
}
|
||||
if (scp == &Top[MAXSCORES]) {
|
||||
|
@ -144,19 +149,19 @@ score(int score_wfd)
|
|||
Top[MAXSCORES-1].s_auto = Auto_bot;
|
||||
Top[MAXSCORES-1].s_level = Level;
|
||||
set_name(&Top[MAXSCORES-1]);
|
||||
Newscore = TRUE;
|
||||
Newscore = true;
|
||||
}
|
||||
if (Newscore)
|
||||
qsort(Top, MAXSCORES, sizeof Top[0], cmp_sc);
|
||||
}
|
||||
|
||||
if (!Newscore) {
|
||||
Full_clear = FALSE;
|
||||
Full_clear = false;
|
||||
lseek(inf, 0, SEEK_SET);
|
||||
return;
|
||||
}
|
||||
else
|
||||
Full_clear = TRUE;
|
||||
Full_clear = true;
|
||||
|
||||
move(1, 15);
|
||||
printw("%5.5s %5.5s %-9.9s %-8.8s %5.5s", "Rank", "Score", "User",
|
||||
|
@ -173,7 +178,7 @@ score(int score_wfd)
|
|||
scp->s_auto ? "(autobot)" : "", scp->s_level);
|
||||
if (!done_show && scp->s_uid == uid && scp->s_score == Score) {
|
||||
standend();
|
||||
done_show = TRUE;
|
||||
done_show = true;
|
||||
}
|
||||
}
|
||||
Num_scores = scp - Top;
|
||||
|
@ -188,7 +193,7 @@ score(int score_wfd)
|
|||
void
|
||||
set_name(SCORE *scp)
|
||||
{
|
||||
PASSWD *pp;
|
||||
struct passwd *pp;
|
||||
|
||||
if ((pp = getpwuid(scp->s_uid)) == NULL)
|
||||
strncpy(scp->s_name, "???", MAXNAME);
|
||||
|
|
Loading…
Reference in New Issue