robots.h revision 1.6
1/*	$OpenBSD: robots.h,v 1.6 2003/06/03 03:01:41 millert Exp $	*/
2/*	$NetBSD: robots.h,v 1.5 1995/04/24 12:24:54 cgd Exp $	*/
3
4/*
5 * Copyright (c) 1980, 1993
6 *	The Regents of the University of California.  All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 *	@(#)robots.h	8.1 (Berkeley) 5/31/93
33 */
34
35#include	<sys/param.h>
36#include	<sys/types.h>
37#include	<sys/time.h>
38#include	<ctype.h>
39#include	<curses.h>
40#include	<err.h>
41#include	<errno.h>
42#include	<fcntl.h>
43#include	<pwd.h>
44#include	<signal.h>
45#include	<string.h>
46#include	<stdlib.h>
47#include	<termios.h>
48#include	<unistd.h>
49
50/*
51 * miscellaneous constants
52 */
53
54#define	Y_FIELDSIZE	23
55#define	X_FIELDSIZE	60
56#define	Y_SIZE		24
57#define	X_SIZE		80
58#define	MAXLEVELS	4
59#define	MAXROBOTS	(MAXLEVELS * 10)
60#define	ROB_SCORE	10
61#define	S_BONUS		(60 * ROB_SCORE)
62#define	Y_SCORE		21
63#define	X_SCORE		(X_FIELDSIZE + 9)
64#define	Y_PROMPT	(Y_FIELDSIZE - 1)
65#define	X_PROMPT	(X_FIELDSIZE + 2)
66#define	MAXSCORES	(Y_SIZE - 2)
67
68/*
69 * characters on screen
70 */
71
72#define	ROBOT	'+'
73#define	HEAP	'*'
74#define	PLAYER	'@'
75
76/*
77 * type definitions
78 */
79
80typedef struct {
81	int	y, x;
82} COORD;
83
84typedef struct {
85	uid_t	s_uid;
86	int	s_score;
87	char	s_name[MAXLOGNAME];
88} SCORE;
89
90typedef struct passwd	PASSWD;
91
92/*
93 * global variables
94 */
95
96extern bool	Dead, Full_clear, Jump, Newscore, Real_time, Running,
97		Teleport, Waiting, Was_bonus;
98
99#ifdef	FANCY
100extern bool	Pattern_roll, Stand_still;
101#endif
102
103extern char	Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move,
104		*Move_list, Run_ch;
105
106extern int	Count, Level, Num_robots, Num_scores, Score,
107		Start_level, Wait_bonus;
108
109extern fd_set	rset;
110extern struct timeval	tv;
111
112extern COORD	Max, Min, My_pos, Robots[];
113
114
115/*
116 * functions types
117 */
118
119void	add_score(int);
120bool	another(void);
121int	cmp_sc(const void *, const void *);
122bool	do_move(int, int);
123bool	eaten(COORD *);
124void	get_move(void);
125void	init_field(void);
126bool	jumping(void);
127void	make_level(void);
128void	move_robots(void);
129bool	must_telep(void);
130void	play_level(void);
131int	query(char *);
132void	quit(int);
133void	reset_count(void);
134int	rnd(int);
135COORD	*rnd_pos(void);
136void	score(int);
137void	set_name(SCORE *);
138void	show_score(void);
139int	sign(int);
140void	usage(void);
141