1 /* $OpenBSD: robots.h,v 1.8 2014/11/16 04:49:48 guenther 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 <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 81 typedef struct { 82 int y, x; 83 } COORD; 84 85 typedef struct { 86 uid_t s_uid; 87 int s_score; 88 char s_name[LOGIN_NAME_MAX]; 89 } SCORE; 90 91 typedef struct passwd PASSWD; 92 93 /* 94 * global variables 95 */ 96 97 extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running, 98 Teleport, Waiting, Was_bonus; 99 100 #ifdef FANCY 101 extern bool Pattern_roll, Stand_still; 102 #endif 103 104 extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move, 105 *Move_list, Run_ch; 106 107 extern int Count, Level, Num_robots, Num_scores, Score, 108 Start_level, Wait_bonus; 109 110 extern struct timeval tv; 111 112 extern COORD Max, Min, My_pos, Robots[]; 113 114 115 /* 116 * functions types 117 */ 118 119 void add_score(int); 120 bool another(void); 121 int cmp_sc(const void *, const void *); 122 bool do_move(int, int); 123 bool eaten(COORD *); 124 void get_move(void); 125 void init_field(void); 126 bool jumping(void); 127 void make_level(void); 128 void move_robots(void); 129 bool must_telep(void); 130 void play_level(void); 131 int query(char *); 132 void quit(int); 133 void reset_count(void); 134 int rnd(int); 135 COORD *rnd_pos(void); 136 void score(int); 137 void set_name(SCORE *); 138 void show_score(void); 139 int sign(int); 140 void usage(void); 141