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