robots.h revision 1.12
1/* $OpenBSD: robots.h,v 1.12 2015/12/25 20:59:09 mestre 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/types.h> 36#include <sys/time.h> 37#include <ctype.h> 38#include <curses.h> 39#include <err.h> 40#include <errno.h> 41#include <fcntl.h> 42#include <limits.h> 43#include <signal.h> 44#include <string.h> 45#include <stdlib.h> 46#include <termios.h> 47#include <unistd.h> 48#include <poll.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[LOGIN_NAME_MAX]; 88} SCORE; 89 90/* 91 * global variables 92 */ 93 94extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running, 95 Teleport, Waiting, Was_bonus; 96 97#ifdef FANCY 98extern bool Pattern_roll, Stand_still; 99#endif 100 101extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move, 102 *Move_list, Run_ch; 103 104extern int Count, Level, Num_robots, Num_scores, Score, 105 Start_level, Wait_bonus; 106 107extern struct timespec tv; 108 109extern COORD Max, Min, My_pos, Robots[]; 110 111 112/* 113 * functions types 114 */ 115 116void add_score(int); 117bool another(void); 118int cmp_sc(const void *, const void *); 119bool do_move(int, int); 120bool eaten(COORD *); 121void get_move(void); 122void init_field(void); 123bool jumping(void); 124void make_level(void); 125void move_robots(void); 126bool must_telep(void); 127void play_level(void); 128int query(char *); 129void quit(int); 130void reset_count(void); 131int rnd(int); 132COORD *rnd_pos(void); 133void score(int); 134void set_name(SCORE *); 135void show_score(void); 136int sign(int); 137__dead void usage(void); 138