mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
copy in from cvs; cvs2svn fucked up big time
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# $NetBSD: Makefile,v 1.14 1998/02/18 22:37:32 jtc Exp $
|
||||
# $NetBSD: Makefile,v 1.15 1999/05/15 23:56:35 christos Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
|
||||
PROG= robots
|
||||
CPPFLAGS+=-DMAX_PER_UID=5
|
||||
SRCS= extern.c init_field.c main.c make_level.c move.c move_robs.c \
|
||||
SRCS= auto.c extern.c init_field.c main.c make_level.c move.c move_robs.c \
|
||||
play_level.c query.c rnd_pos.c score.c flush_in.c
|
||||
MAN= robots.6
|
||||
DPADD= ${LIBCURSES}
|
||||
|
||||
@@ -1,4 +1,30 @@
|
||||
# Makefile - makefile for robots
|
||||
#
|
||||
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
robots_DEFS := -DFANCY -DMAX_PER_UID=5
|
||||
robots_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: auto.c,v 1.4 1999/09/08 21:17:56 jsm Exp $ */
|
||||
/* $NetBSD: auto.c,v 1.5 2002/01/31 17:35:52 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@@ -236,7 +236,7 @@ move_towards(dx, dy)
|
||||
|
||||
(void)strcpy(ok_moves, find_moves());
|
||||
best_move = ok_moves[0];
|
||||
if (best_move != 'F') {
|
||||
if (best_move != 't') {
|
||||
mvx = xinc(best_move);
|
||||
mvy = yinc(best_move);
|
||||
move_judge = ABS(mvx - dx) + ABS(mvy - dy);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.c,v 1.4 1997/10/12 14:09:56 lukem Exp $ */
|
||||
/* $NetBSD: extern.c,v 1.7 1999/09/18 19:38:53 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: extern.c,v 1.4 1997/10/12 14:09:56 lukem Exp $");
|
||||
__RCSID("$NetBSD: extern.c,v 1.7 1999/09/18 19:38:53 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -52,6 +52,7 @@ bool Newscore; /* There was a new score added */
|
||||
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 */
|
||||
@@ -62,15 +63,17 @@ 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 */
|
||||
char *Next_move; /* Next move to be used in the pattern */
|
||||
char *Move_list = "YHBJNLUK";/* List of moves in the pattern */
|
||||
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 Score; /* Current score */
|
||||
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 */
|
||||
|
||||
@@ -78,5 +81,6 @@ 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 */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: init_field.c,v 1.5 1997/10/12 14:09:57 lukem Exp $ */
|
||||
/* $NetBSD: init_field.c,v 1.7 2002/01/31 17:35:52 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,12 +38,15 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)init_field.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: init_field.c,v 1.5 1997/10/12 14:09:57 lukem Exp $");
|
||||
__RCSID("$NetBSD: init_field.c,v 1.7 2002/01/31 17:35:52 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
# include "robots.h"
|
||||
|
||||
static int telx = 0;
|
||||
static int tely = 0;
|
||||
|
||||
/*
|
||||
* init_field:
|
||||
* Lay down the initial pattern whih is constant across all levels,
|
||||
@@ -54,7 +57,7 @@ init_field()
|
||||
{
|
||||
int i;
|
||||
static bool first = TRUE;
|
||||
static char *desc[] = {
|
||||
static const char *const desc[] = {
|
||||
"Directions:",
|
||||
"",
|
||||
"y k u",
|
||||
@@ -112,6 +115,8 @@ init_field()
|
||||
move(i, X_FIELDSIZE + 2);
|
||||
addstr(desc[i]);
|
||||
}
|
||||
telx = X_FIELDSIZE + 2;
|
||||
tely = i;
|
||||
if (first)
|
||||
refresh();
|
||||
first = FALSE;
|
||||
@@ -120,3 +125,11 @@ init_field()
|
||||
Next_move = &Move_list[-1];
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
telmsg(on)
|
||||
int on;
|
||||
{
|
||||
move(tely, telx);
|
||||
addstr(on ? "Teleport!" : " ");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make_level.c,v 1.5 1997/10/12 14:16:27 lukem Exp $ */
|
||||
/* $NetBSD: make_level.c,v 1.6 1999/05/15 23:56:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: make_level.c,v 1.5 1997/10/12 14:16:27 lukem Exp $");
|
||||
__RCSID("$NetBSD: make_level.c,v 1.6 1999/05/15 23:56:36 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -78,6 +78,8 @@ make_level()
|
||||
if ((i = Level * 10) > MAXROBOTS)
|
||||
i = MAXROBOTS;
|
||||
Num_robots = i;
|
||||
memset(Scrap, 0, sizeof(Scrap[0]) * MAXROBOTS);
|
||||
Num_scrap = 0;
|
||||
while (i-- > 0) {
|
||||
cp = rnd_pos();
|
||||
Robots[i] = *cp;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: move.c,v 1.7 1998/07/24 23:28:02 hubertf Exp $ */
|
||||
/* $NetBSD: move.c,v 1.10 2002/01/31 17:35:52 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: move.c,v 1.7 1998/07/24 23:28:02 hubertf Exp $");
|
||||
__RCSID("$NetBSD: move.c,v 1.10 2002/01/31 17:35:52 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -94,7 +94,10 @@ get_move()
|
||||
#endif
|
||||
else {
|
||||
over:
|
||||
c = getchar();
|
||||
if (Auto_bot)
|
||||
c = automove();
|
||||
else
|
||||
c = getchar();
|
||||
if (isdigit(c)) {
|
||||
Count = (c - '0');
|
||||
while (isdigit(c = getchar()))
|
||||
@@ -172,6 +175,10 @@ teleport:
|
||||
Running = FALSE;
|
||||
mvaddch(My_pos.y, My_pos.x, ' ');
|
||||
My_pos = *rnd_pos();
|
||||
telmsg(1);
|
||||
refresh();
|
||||
sleep(1);
|
||||
telmsg(0);
|
||||
mvaddch(My_pos.y, My_pos.x, PLAYER);
|
||||
leaveok(stdscr, FALSE);
|
||||
refresh();
|
||||
@@ -271,7 +278,7 @@ do_move(dy, dx)
|
||||
*/
|
||||
bool
|
||||
eaten(pos)
|
||||
COORD *pos;
|
||||
const COORD *pos;
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: move_robs.c,v 1.4 1997/10/12 14:10:00 lukem Exp $ */
|
||||
/* $NetBSD: move_robs.c,v 1.6 2001/01/16 02:50:28 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: move_robs.c,v 1.4 1997/10/12 14:10:00 lukem Exp $");
|
||||
__RCSID("$NetBSD: move_robs.c,v 1.6 2001/01/16 02:50:28 cgd Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -61,7 +61,7 @@ move_robots(was_sig)
|
||||
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;
|
||||
@@ -91,6 +91,7 @@ move_robots(was_sig)
|
||||
Dead = TRUE;
|
||||
else if (Field[rp->y][rp->x] > 1) {
|
||||
mvaddch(rp->y, rp->x, HEAP);
|
||||
Scrap[Num_scrap++] = *rp;
|
||||
rp->y = -1;
|
||||
Num_robots--;
|
||||
if (Waiting)
|
||||
@@ -122,7 +123,7 @@ move_robots(was_sig)
|
||||
move(Max.y, Max.x);
|
||||
addch(inch());
|
||||
standend();
|
||||
# endif DEBUG
|
||||
# endif /* DEBUG */
|
||||
if (Real_time)
|
||||
alarm(3);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: play_level.c,v 1.4 1997/10/12 14:10:01 lukem Exp $ */
|
||||
/* $NetBSD: play_level.c,v 1.5 2001/01/16 02:50:28 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: play_level.c,v 1.4 1997/10/12 14:10:01 lukem Exp $");
|
||||
__RCSID("$NetBSD: play_level.c,v 1.5 2001/01/16 02:50:28 cgd Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -70,7 +70,7 @@ play_level()
|
||||
move(Max.y, Max.x);
|
||||
addch(inch());
|
||||
standend();
|
||||
# endif DEBUG
|
||||
# endif /* DEBUG */
|
||||
setjmp(End_move);
|
||||
flush_in();
|
||||
while (!Dead && Num_robots > 0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $ */
|
||||
/* $NetBSD: query.c,v 1.5 1999/09/08 21:17:57 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $");
|
||||
__RCSID("$NetBSD: query.c,v 1.5 1999/09/08 21:17:57 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -50,7 +50,7 @@ __RCSID("$NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $");
|
||||
*/
|
||||
int
|
||||
query(prompt)
|
||||
char *prompt;
|
||||
const char *prompt;
|
||||
{
|
||||
int c, retval;
|
||||
int y, x;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: robots.6,v 1.6 1997/10/12 14:10:03 lukem Exp $
|
||||
.\" $NetBSD: robots.6,v 1.11 2002/09/26 18:32:04 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -37,11 +37,11 @@
|
||||
.Dt ROBOTS 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm robots
|
||||
.Nm robots
|
||||
.Nd fight off villainous robots
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl sjta
|
||||
.Op Fl Asjtan
|
||||
.Op Ar scorefile
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
@@ -61,7 +61,7 @@ you start on the next field.
|
||||
This keeps up until they finally get you.
|
||||
.Pp
|
||||
Robots are represented on the screen by a
|
||||
.Sq \+ ,
|
||||
.Sq \&+ ,
|
||||
the junk heaps from their collisions by a
|
||||
.Sq \(** ,
|
||||
and you
|
||||
@@ -91,7 +91,7 @@ move one square down and right
|
||||
(also space) do nothing for one turn
|
||||
.It Ic HJKLBNYU
|
||||
run as far as possible in the given direction
|
||||
.It Ic \>
|
||||
.It Ic \*[Gt]
|
||||
do nothing for as long as possible
|
||||
.It Ic t
|
||||
teleport to a random location
|
||||
@@ -106,7 +106,7 @@ redraw the screen
|
||||
All commands can be preceded by a count.
|
||||
.Pp
|
||||
If you use the
|
||||
.Sq Ic w
|
||||
.Sq Ic w
|
||||
command and survive to the next level, you will get a bonus of 10%
|
||||
for each robot which died after you decided to wait.
|
||||
If you die, however, you get nothing.
|
||||
@@ -138,9 +138,15 @@ This is a little disconcerting until you get used to it, and then it is
|
||||
very nice.
|
||||
.It Fl a
|
||||
Advance into the higher levels directly, skipping the lower, easier levels.
|
||||
.It Fl A
|
||||
Auto-bot mode.
|
||||
Lets the game play itself.
|
||||
.It Fl n
|
||||
Increase the number of games played by one.
|
||||
.El
|
||||
.Sh AUTHOR
|
||||
Ken Arnold
|
||||
Christos Zoulas (autobot mode)
|
||||
.Sh FILES
|
||||
.Bl -tag -width @robots_scorefile@ -compact
|
||||
.It Pa @robots_scorefile@
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: robots.h,v 1.8 1998/09/13 15:27:29 hubertf Exp $ */
|
||||
/* $NetBSD: robots.h,v 1.15 2002/01/31 17:35:52 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -41,6 +41,7 @@
|
||||
# include <err.h>
|
||||
# include <errno.h>
|
||||
# include <fcntl.h>
|
||||
# include <netinet/in.h>
|
||||
# include <pwd.h>
|
||||
# include <setjmp.h>
|
||||
# include <signal.h>
|
||||
@@ -87,9 +88,11 @@ typedef struct {
|
||||
} COORD;
|
||||
|
||||
typedef struct {
|
||||
int s_uid;
|
||||
int s_score;
|
||||
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;
|
||||
@@ -99,19 +102,21 @@ typedef struct passwd PASSWD;
|
||||
*/
|
||||
|
||||
extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running,
|
||||
Teleport, Waiting, Was_bonus;
|
||||
Teleport, Waiting, Was_bonus, Auto_bot;
|
||||
|
||||
#ifdef FANCY
|
||||
extern bool Pattern_roll, Stand_still;
|
||||
#endif
|
||||
|
||||
extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move,
|
||||
*Move_list, 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_scores, Score,
|
||||
Start_level, Wait_bonus;
|
||||
extern int Count, Level, Num_robots, Num_scrap, Num_scores,
|
||||
Start_level, Wait_bonus, Num_games;
|
||||
|
||||
extern COORD Max, Min, My_pos, Robots[];
|
||||
extern u_int32_t Score;
|
||||
|
||||
extern COORD Max, Min, My_pos, Robots[], Scrap[];
|
||||
|
||||
extern jmp_buf End_move;
|
||||
|
||||
@@ -121,9 +126,10 @@ extern jmp_buf End_move;
|
||||
|
||||
void add_score __P((int));
|
||||
bool another __P((void));
|
||||
char automove __P((void));
|
||||
int cmp_sc __P((const void *, const void *));
|
||||
bool do_move __P((int, int));
|
||||
bool eaten __P((COORD *));
|
||||
bool eaten __P((const COORD *));
|
||||
void flush_in __P((void));
|
||||
void get_move __P((void));
|
||||
void init_field __P((void));
|
||||
@@ -132,7 +138,7 @@ void make_level __P((void));
|
||||
void move_robots __P((int));
|
||||
bool must_telep __P((void));
|
||||
void play_level __P((void));
|
||||
int query __P((char *));
|
||||
int query __P((const char *));
|
||||
void quit __P((int)) __attribute__((__noreturn__));
|
||||
void reset_count __P((void));
|
||||
int rnd __P((int));
|
||||
@@ -141,3 +147,4 @@ void score __P((int));
|
||||
void set_name __P((SCORE *));
|
||||
void show_score __P((void));
|
||||
int sign __P((int));
|
||||
void telmsg __P((int));
|
||||
|
||||
Reference in New Issue
Block a user