1 /* file wand_head.h */
2 /***************************************************************************
3 *  Copyright 2003 -   Steven Shipway <steve@cheshire.demon.co.uk>          *
4 *                     Put "nospam" in subject to avoid spam filter         *
5 *                                                                          *
6 *  This program is free software; you can redistribute it and/or modify    *
7 *  it under the terms of the GNU General Public License as published by    *
8 *  the Free Software Foundation; either version 2 of the License, or       *
9 *  (at your option) any later version.                                     *
10 *                                                                          *
11 *  This program is distributed in the hope that it will be useful,         *
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14 *  GNU General Public License for more details.                            *
15 *                                                                          *
16 *  You should have received a copy of the GNU General Public License       *
17 *  along with this program; if not, write to the Free Software             *
18 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA               *
19 *  02111-1307, USA.                                                        *
20 ***************************************************************************/
21 
22 
23 #include <stdio.h>
24 #include <ncurses.h>
25 #include <string.h>
26 #include <fcntl.h>
27 
28 #undef MSDOS /* Marina */
29 
30 #ifndef MSDOS
31 #include <sys/file.h>
32 #endif
33 
34 #define VERSION "3.2"
35 
36                 /********** FILES ************/
37 
38 /* Change these to the necessary directories or files */
39 #define SCREENPATH  "/usr/local/share/wanderer/screens"
40 #define HISCOREPATH "/var/games/wandererscores"
41 #define DICTIONARY  "/usr/share/dict/words"
42 #define LOCKFILE    "/tmp/wanderer.lock"
43 
44                 /********** PASSWORDS *********/
45 
46 /* change this to anything, but dont forget what                         */
47 #define MASTERPASSWORD "chocolate chips"
48 
49 /* change the numbers in this as well, but keep it in the same form         */
50 #define PASSWD (num * num * 4373 + num * 16927 + 39)
51 
52 /* this is the randon number seed used for encryption                          */
53 #define BLURFL 32451
54 /* the word blurfl is used for historical reasons                         */
55 
56                 /********** OPTIONS ***********/
57 
58 /* To disable the recording of hiscores from games restored from saves         */
59 /* #define NO_RESTORED_GAME_HISCORES  */
60 /* #define COMPARE_BY_NAME  /* define this to compare by name, not uid         */
61 /* #define NO_ENCRYPTION /* define this to disable the savefile encryptor */
62 #define NOISY    /* do we want bells in the game ? */
63 
64                 /****** OTHER PARAMETERS ******/
65 
66 #define GUESTUID 0    /* guestuid always compared by name         */
67 #define EMSIZE 1024   /* size of editor moves memory              */
68 #define ENTRIES 15    /* size of hiscore file                     */
69 
70                 /*********** CBREAK ***********/
71 
72 /* cbreak switching via curses package.                                  */
73 /* on some Ultrix systems you may need to use crmode() and nocrmode()    */
74 /* if so, just change the #defs to the necessary. I also know that Xenix */
75 /* systems have to use crmode, so..                                      */
76 #ifdef XENIX
77 #define CBON crmode()
78 #define CBOFF nocrmode()
79 #else
80 #define CBON cbreak()
81 #define CBOFF nocbreak()
82 #endif
83 
84             /**** NOTHING TO CHANGE BELOW HERE ****/
85 
86 /* I wouldnt change these if I were you - it wont give you a bigger screen */
87 #define ROWLEN 40
88 #define NOOFROWS 16
89 
90 /* MSDOS modifications (M001) by Gregory H. Margo        */
91 #ifdef        MSDOS
92 #define        R_BIN        "rb"        /* binary mode for non-text files */
93 #define        W_BIN        "wb"
94 # ifdef        VOIDPTR
95 #  define VOIDSTAR        (void *)
96 # else
97 #  define VOIDSTAR        (char *)
98 # endif
99 #define        ASKNAME                /* ask user's name if not in environment         */
100 #define        COMPARE_BY_NAME        /* compare users with name, not uid                */
101 #undef        getchar                /* remove stdio's definition to use curses'         */
102 #define        getchar()        getch()        /* use curse's definition instead */
103 
104 #else /* not MSDOS */
105 #define        R_BIN        "r"
106 #define        W_BIN        "w"
107 #define        VOIDSTAR
108 #endif
109 
110 /* Save and Restore game additions (M002) by Gregory H. Margo        */
111 /* mon_rec structure needed by save.c */
112 struct mon_rec
113 {
114     int x,y,mx,my;
115     char under;
116     struct mon_rec *next,*prev;
117 };
118 
119 struct        save_vars        {
120         int        z_x, z_y,
121                 z_sx, z_sy,
122                 z_tx, z_ty,
123                 z_mx, z_my,
124                 z_diamonds,
125                 z_nf;
126 };
127 
128 struct        old_save_vars        {
129         int        z_x, z_y,
130                 z_nx, z_ny,
131                 z_sx, z_sy,
132                 z_tx, z_ty,
133                 z_lx, z_ly,
134                 z_mx, z_my,
135                 z_bx, z_by,
136                 z_nbx, z_nby,
137                 z_max_score,
138                 z_diamonds,
139                 z_nf,
140                 z_hd,
141                 z_vd,
142                 z_xdirection,
143                 z_ydirection;
144 };
145 
146 /* prototypes added by Gregory H. Margo */
147 #ifdef        LINT_ARGS        /* M001 */
148 /* DISPLAY.c */
149 extern  void map(char (*)[ROWLEN+1]);
150 extern  void display(int ,int ,char (*)[ROWLEN+1],int );
151 
152 /* EDIT.C */
153 extern  void instruct(void);
154 extern  void noins(void);
155 extern  void editscreen(int ,int *,int *,int ,char *);
156 
157 /* FALL.C */
158 extern  int check(int *,int *,int ,int ,int ,int ,int ,int ,char *);
159 extern  int fall(int *,int *,int ,int ,int ,int ,char *);
160 
161 /* GAME.C */
162 extern  struct mon_rec *make_monster(int ,int );
163 extern  char *playscreen(int *,int *,int *,int ,char *);
164 
165 /* ICON.C */
166 extern  void draw_symbol(int ,int ,char );
167 
168 /* JUMP.C */
169 extern  int scrn_passwd(int ,char *);
170 extern  void showpass(int );
171 extern  int jumpscreen(int );
172 extern  int getnum(void);
173 
174 /* READ.C */
175 extern  int rscreen(int ,int *);
176 extern  int wscreen(int ,int );
177 
178 /* SAVE.C */
179 extern  void save_game(int ,int *,int *,int ,struct mon_rec *,struct mon_rec *);
180 extern  void restore_game(int *,int *,int *,int *,struct mon_rec *,struct mon_rec **);
181 
182 /* SCORES.C */
183 extern  int savescore(char *,int ,int ,char *);
184 extern  void delete_entry(int );
185 extern  int erase_scores(void);
186 
187 #else
188 
189 /* DISPLAY.c */
190 extern  void map();
191 extern  void display();
192 
193 /* EDIT.C */
194 extern  void instruct();
195 extern  void noins();
196 extern  void editscreen();
197 
198 /* FALL.C */
199 extern  int check();
200 extern  int fall();
201 
202 /* GAME.C */
203 extern  struct mon_rec *make_monster();
204 extern  char *playscreen();
205 
206 /* ICON.C */
207 extern  void draw_symbol();
208 
209 /* JUMP.C */
210 extern  int scrn_passwd();
211 extern  void showpass();
212 extern  int jumpscreen();
213 extern  int getnum();
214 
215 /* READ.C */
216 extern  int rscreen();
217 extern  int wscreen();
218 
219 /* SAVE.C */
220 extern  void save_game();
221 extern  void restore_game();
222 
223 /* SCORES.C */
224 extern  int savescore();
225 extern  void delete_entry();
226 extern  int erase_scores();
227 
228 #endif
229 
230 /* for monster movement */
231 
232 #define viable(x,y) (((screen[y][x] == ' ') || (screen[y][x] == ':') ||\
233         (screen[y][x] == '@') || (screen[y][x] == '+') ||\
234         (screen[y][x] == 'S')) && (y >= 0) &&\
235         (x >= 0) && (y < NOOFROWS) && (x < ROWLEN))
236