robots.h revision 1.7
1/* $OpenBSD: robots.h,v 1.7 2014/11/03 22:14:54 deraadt 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#include <poll.h> 50 51/* 52 * miscellaneous constants 53 */ 54 55#define Y_FIELDSIZE 23 56#define X_FIELDSIZE 60 57#define Y_SIZE 24 58#define X_SIZE 80 59#define MAXLEVELS 4 60#define MAXROBOTS (MAXLEVELS * 10) 61#define ROB_SCORE 10 62#define S_BONUS (60 * ROB_SCORE) 63#define Y_SCORE 21 64#define X_SCORE (X_FIELDSIZE + 9) 65#define Y_PROMPT (Y_FIELDSIZE - 1) 66#define X_PROMPT (X_FIELDSIZE + 2) 67#define MAXSCORES (Y_SIZE - 2) 68 69/* 70 * characters on screen 71 */ 72 73#define ROBOT '+' 74#define HEAP '*' 75#define PLAYER '@' 76 77/* 78 * type definitions 79 */ 80 81typedef struct { 82 int y, x; 83} COORD; 84 85typedef struct { 86 uid_t s_uid; 87 int s_score; 88 char s_name[MAXLOGNAME]; 89} SCORE; 90 91typedef struct passwd PASSWD; 92 93/* 94 * global variables 95 */ 96 97extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running, 98 Teleport, Waiting, Was_bonus; 99 100#ifdef FANCY 101extern bool Pattern_roll, Stand_still; 102#endif 103 104extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move, 105 *Move_list, Run_ch; 106 107extern int Count, Level, Num_robots, Num_scores, Score, 108 Start_level, Wait_bonus; 109 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