Wed Aug 12 08:04:05 2009 UTC ()
sprinkle static


(dholland)
diff -r1.9 -r1.10 src/games/larn/bill.c
diff -r1.8 -r1.9 src/games/larn/display.c
diff -r1.12 -r1.13 src/games/larn/extern.h
diff -r1.6 -r1.7 src/games/larn/fortune.c
diff -r1.6 -r1.7 src/games/larn/movem.c
diff -r1.7 -r1.8 src/games/larn/help.c
diff -r1.23 -r1.24 src/games/larn/io.c
diff -r1.23 -r1.24 src/games/larn/main.c
diff -r1.16 -r1.17 src/games/larn/monster.c
diff -r1.14 -r1.15 src/games/larn/object.c
diff -r1.14 -r1.15 src/games/larn/store.c
diff -r1.17 -r1.18 src/games/larn/scores.c

cvs diff -r1.9 -r1.10 src/games/larn/bill.c (expand / switch to unified diff)

--- src/games/larn/bill.c 2008/02/03 03:49:15 1.9
+++ src/games/larn/bill.c 2009/08/12 08:04:05 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bill.c,v 1.9 2008/02/03 03:49:15 dholland Exp $ */ 1/* $NetBSD: bill.c,v 1.10 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991 The Regents of the University of California. 4 * Copyright (c) 1991 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,43 +24,43 @@ @@ -24,43 +24,43 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91"; 35static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
36#else 36#else
37__RCSID("$NetBSD: bill.c,v 1.9 2008/02/03 03:49:15 dholland Exp $"); 37__RCSID("$NetBSD: bill.c,v 1.10 2009/08/12 08:04:05 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/file.h> 41#include <sys/file.h>
42#include <sys/wait.h> 42#include <sys/wait.h>
43#include <stdio.h> 43#include <stdio.h>
44#include <string.h> 44#include <string.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <unistd.h> 46#include <unistd.h>
47#include <paths.h> 47#include <paths.h>
48#include "header.h" 48#include "header.h"
49#include "extern.h" 49#include "extern.h"
50 50
51/* bill.c Larn is copyrighted 1986 by Noah Morgan. */ 51/* bill.c Larn is copyrighted 1986 by Noah Morgan. */
52 52
53const char *mail[] = { 53static const char *mail[] = {
54 "From: the LRS (Larn Revenue Service)\n", 54 "From: the LRS (Larn Revenue Service)\n",
55 "~s undeclared income\n", 55 "~s undeclared income\n",
56 "\n We have heard you survived the caverns of Larn. Let me be the", 56 "\n We have heard you survived the caverns of Larn. Let me be the",
57 "\nfirst to congratulate you on your success. It was quite a feat.", 57 "\nfirst to congratulate you on your success. It was quite a feat.",
58 "\nIt was also very profitable for you...", 58 "\nIt was also very profitable for you...",
59 "\n\n The Dungeon Master has informed us that you brought", 59 "\n\n The Dungeon Master has informed us that you brought",
60 "1", 60 "1",
61 "\ncounty of Larn is in dire need of funds, we have spared no time", 61 "\ncounty of Larn is in dire need of funds, we have spared no time",
62 "2", 62 "2",
63 "\nof this notice, and is due within 5 days. Failure to pay will", 63 "\nof this notice, and is due within 5 days. Failure to pay will",
64 "\nmean penalties. Once again, congratulations, We look forward", 64 "\nmean penalties. Once again, congratulations, We look forward",
65 "\nto your future successful expeditions.\n", 65 "\nto your future successful expeditions.\n",
66 NULL, 66 NULL,

cvs diff -r1.8 -r1.9 src/games/larn/display.c (expand / switch to unified diff)

--- src/games/larn/display.c 2008/02/03 19:20:41 1.8
+++ src/games/larn/display.c 2009/08/12 08:04:05 1.9
@@ -1,35 +1,35 @@ @@ -1,35 +1,35 @@
1/* $NetBSD: display.c,v 1.8 2008/02/03 19:20:41 dholland Exp $ */ 1/* $NetBSD: display.c,v 1.9 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* display.c Larn is copyrighted 1986 by Noah Morgan. */ 3/* display.c Larn is copyrighted 1986 by Noah Morgan. */
4#include <sys/cdefs.h> 4#include <sys/cdefs.h>
5#ifndef lint 5#ifndef lint
6__RCSID("$NetBSD: display.c,v 1.8 2008/02/03 19:20:41 dholland Exp $"); 6__RCSID("$NetBSD: display.c,v 1.9 2009/08/12 08:04:05 dholland Exp $");
7#endif /* not lint */ 7#endif /* not lint */
8 8
9#include "header.h" 9#include "header.h"
10#include "extern.h" 10#include "extern.h"
11 11
12#define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c)) 12#define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c))
13 13
14static void bot_hpx(void); 14static void bot_hpx(void);
15static void bot_spellx(void); 15static void bot_spellx(void);
16static void botside(void); 16static void botside(void);
17static void botsub(int, const char *); 17static void botsub(int, const char *);
18static void seepage(void); 18static void seepage(void);
19 19
20static int minx, maxx, miny, maxy, k, m; 20static int minx, maxx, miny, maxy, k, m;
21static char bot1f = 0, bot2f = 0, bot3f = 0; 21static char bot1f = 0, bot2f = 0, bot3f = 0;
22char always = 0; 22static char always = 0;
23/* 23/*
24 bottomline() 24 bottomline()
25 25
26 now for the bottom line of the display 26 now for the bottom line of the display
27 */ 27 */
28void 28void
29bottomline() 29bottomline()
30{ 30{
31 recalc(); 31 recalc();
32 bot1f = 1; 32 bot1f = 1;
33} 33}
34 34
35void 35void
@@ -231,27 +231,27 @@ botsub(int idx, const char *str) @@ -231,27 +231,27 @@ botsub(int idx, const char *str)
231 if (c[idx] != cbak[idx]) { 231 if (c[idx] != cbak[idx]) {
232 cbak[idx] = c[idx]; 232 cbak[idx] = c[idx];
233 cursor(x, y); 233 cursor(x, y);
234 lprintf(str, (long) c[idx]); 234 lprintf(str, (long) c[idx]);
235 } 235 }
236} 236}
237 237
238/* 238/*
239 * subroutine to draw only a section of the screen 239 * subroutine to draw only a section of the screen
240 * only the top section of the screen is updated. 240 * only the top section of the screen is updated.
241 * If entire lines are being drawn, then they will be cleared first. 241 * If entire lines are being drawn, then they will be cleared first.
242 */ 242 */
243/* for limited screen drawing */ 243/* for limited screen drawing */
244int d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY; 244static int d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY;
245 245
246void 246void
247draws(xmin, xmax, ymin, ymax) 247draws(xmin, xmax, ymin, ymax)
248 int xmin, xmax, ymin, ymax; 248 int xmin, xmax, ymin, ymax;
249{ 249{
250 int i, idx; 250 int i, idx;
251 if (xmin == 0 && xmax == MAXX) { /* clear section of screen as 251 if (xmin == 0 && xmax == MAXX) { /* clear section of screen as
252 * needed */ 252 * needed */
253 if (ymin == 0) 253 if (ymin == 0)
254 cl_up(79, ymax); 254 cl_up(79, ymax);
255 else 255 else
256 for (i = ymin; i < ymin; i++) 256 for (i = ymin; i < ymin; i++)
257 cl_line(1, i + 1); 257 cl_line(1, i + 1);
@@ -270,27 +270,28 @@ draws(xmin, xmax, ymin, ymax) @@ -270,27 +270,28 @@ draws(xmin, xmax, ymin, ymax)
270 cursor(70, i + 1); 270 cursor(70, i + 1);
271 lprcat(bot_data[i].string); 271 lprcat(bot_data[i].string);
272 } 272 }
273 cbak[idx] = c[idx]; 273 cbak[idx] = c[idx];
274 } 274 }
275 } 275 }
276} 276}
277 277
278/* 278/*
279 drawscreen() 279 drawscreen()
280 280
281 subroutine to redraw the whole screen as the player knows it 281 subroutine to redraw the whole screen as the player knows it
282 */ 282 */
283u_char screen[MAXX][MAXY], d_flag; /* template for the screen */ 283u_char screen[MAXX][MAXY]; /* template for the screen */
 284static u_char d_flag;
284void 285void
285drawscreen() 286drawscreen()
286{ 287{
287 int i, j, kk; 288 int i, j, kk;
288 int lastx, lasty; /* variables used to optimize the 289 int lastx, lasty; /* variables used to optimize the
289 * object printing */ 290 * object printing */
290 if (d_xmin == 0 && d_xmax == MAXX && d_ymin == 0 && d_ymax == MAXY) { 291 if (d_xmin == 0 && d_xmax == MAXX && d_ymin == 0 && d_ymax == MAXY) {
291 d_flag = 1; 292 d_flag = 1;
292 clear(); /* clear the screen */ 293 clear(); /* clear the screen */
293 } else { 294 } else {
294 d_flag = 0; 295 d_flag = 0;
295 cursor(1, 1); 296 cursor(1, 1);
296 } 297 }

cvs diff -r1.12 -r1.13 src/games/larn/extern.h (expand / switch to unified diff)

--- src/games/larn/extern.h 2008/02/19 06:05:26 1.12
+++ src/games/larn/extern.h 2009/08/12 08:04:05 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: extern.h,v 1.12 2008/02/19 06:05:26 dholland Exp $ */ 1/* $NetBSD: extern.h,v 1.13 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Christos Zoulas. All rights reserved. 4 * Copyright (c) 1997 Christos Zoulas. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -103,27 +103,26 @@ int nearbymonst(void); @@ -103,27 +103,26 @@ int nearbymonst(void);
103int stealsomething(void); 103int stealsomething(void);
104int emptyhanded(void); 104int emptyhanded(void);
105void creategem(void); 105void creategem(void);
106void adjustcvalues(int, int); 106void adjustcvalues(int, int);
107int getpassword(void); 107int getpassword(void);
108int getyn(void); 108int getyn(void);
109int packweight(void); 109int packweight(void);
110int rnd(int); 110int rnd(int);
111int rund(int); 111int rund(int);
112 112
113/* help.c */ 113/* help.c */
114void help(void); 114void help(void);
115void welcome(void); 115void welcome(void);
116void retcont(void); 
117 116
118/* io.c */ 117/* io.c */
119void setupvt100(void); 118void setupvt100(void);
120void clearvt100(void); 119void clearvt100(void);
121int ttgetch(void); 120int ttgetch(void);
122void scbr(void); 121void scbr(void);
123void sncbr(void); 122void sncbr(void);
124void newgame(void); 123void newgame(void);
125void lprintf(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); 124void lprintf(const char *, ...) __attribute__((__format__(__printf__, 1, 2)));
126void lprint(long); 125void lprint(long);
127void lwrite(char *, int); 126void lwrite(char *, int);
128long lgetc(void); 127long lgetc(void);
129long larn_lrint(void); 128long larn_lrint(void);
@@ -140,158 +139,93 @@ void cursor(int, int); @@ -140,158 +139,93 @@ void cursor(int, int);
140void cursors(void); 139void cursors(void);
141void init_term(void); 140void init_term(void);
142void cl_line(int, int); 141void cl_line(int, int);
143void cl_up(int, int); 142void cl_up(int, int);
144void cl_dn(int, int); 143void cl_dn(int, int);
145void standout(const char *); 144void standout(const char *);
146void set_score_output(void); 145void set_score_output(void);
147void lflush(void); 146void lflush(void);
148char *tmcapcnv(char *, char *); 147char *tmcapcnv(char *, char *);
149void beep(void); 148void beep(void);
150 149
151/* main.c */ 150/* main.c */
152int main(int, char **); 151int main(int, char **);
153void showstr(void); 
154void qshowstr(void); 152void qshowstr(void);
155void t_setup(int); 
156void t_endup(int); 
157void showwear(void); 
158void showwield(void); 
159void showread(void); 
160void showeat(void); 
161void showquaff(void); 
162void show1(int, const char *[]); 
163void show3(int); 153void show3(int);
164void randmonst(void); 
165void parse(void); 
166void parse2(void); 154void parse2(void);
167void run(int); 
168void wield(void); 
169void ydhi(int); 
170void ycwi(int); 
171void wear(void); 
172void dropobj(void); 
173void readscr(void); 
174void eatcookie(void); 
175void quaff(void); 
176unsigned long readnum(long); 155unsigned long readnum(long);
177void szero(char *); 156void szero(char *);
178 157
179/* monster.c */ 158/* monster.c */
180void createmonster(int); 159void createmonster(int);
181void createitem(int, int); 160void createitem(int, int);
182void cast(void); 161void cast(void);
183void speldamage(int); 
184void loseint(void); 
185int isconfuse(void); 
186int nospell(int, int); 
187int fullhit(int); 
188void direct(int, int, const char *, int); 
189void godirect(int, int, const char *, int, int); 162void godirect(int, int, const char *, int, int);
190void ifblind(int, int); 
191void tdirect(int); 
192void omnidirect(int, int, const char *); 
193int vxy(int *, int *); 163int vxy(int *, int *);
194void dirpoly(int); 
195void hitmonster(int, int); 164void hitmonster(int, int);
196int hitm(int, int, int); 
197void hitplayer(int, int); 165void hitplayer(int, int);
198void dropgold(int); 166void dropgold(int);
199void something(int); 167void something(int);
200int newobject(int, int *); 168int newobject(int, int *);
201void checkloss(int); 169void checkloss(int);
202int annihilate(void); 170int annihilate(void);
203int newsphere(int, int, int, int); 171int newsphere(int, int, int, int);
204int rmsphere(int, int); 172int rmsphere(int, int);
205void sphboom(int, int); 
206void genmonst(void); 
207 173
208/* moreobj.c */ 174/* moreobj.c */
209void oaltar(void); 175void oaltar(void);
210void othrone(int); 176void othrone(int);
211void odeadthrone(void); 177void odeadthrone(void);
212void ochest(void); 178void ochest(void);
213void ofountain(void); 179void ofountain(void);
214void fntchange(int); 180void fntchange(int);
215 181
216/* movem.c */ 182/* movem.c */
217void movemonst(void); 183void movemonst(void);
218void movemt(int, int); 
219void mmove(int, int, int, int); 
220void movsphere(void); 
221 184
222/* nap.c */ 185/* nap.c */
223void nap(int); 186void nap(int);
224 187
225/* object.c */ 188/* object.c */
226void lookforobject(void); 189void lookforobject(void);
227void finditem(int); 
228void ostairs(int); 
229void oteleport(int); 190void oteleport(int);
230void opotion(int); 
231void quaffpotion(int); 191void quaffpotion(int);
232void oscroll(int); 
233void adjusttime(long); 192void adjusttime(long);
234void read_scroll(int); 193void read_scroll(int);
235void oorb(void); 
236void opit(void); 
237void obottomless(void); 
238void oelevator(int); 
239void ostatue(void); 
240void omirror(void); 
241void obook(void); 
242void readbook(int); 194void readbook(int);
243void ocookie(void); 
244void ogold(int); 
245void ohome(void); 
246void iopts(void); 195void iopts(void);
247void ignore(void); 196void ignore(void);
248 197
249/* regen.c */ 198/* regen.c */
250void regen(void); 199void regen(void);
251 200
252/* savelev.c */ 201/* savelev.c */
253void savelevel(void); 202void savelevel(void);
254void getlevel(void); 203void getlevel(void);
255 204
256/* scores.c */ 205/* scores.c */
257int readboard(void); 
258int writeboard(void); 
259int makeboard(void); 206int makeboard(void);
260int hashewon(void); 207int hashewon(void);
261long paytaxes(long); 208long paytaxes(long);
262int winshou(void); 
263int shou(int); 
264void showscores(void); 209void showscores(void);
265void showallscores(void); 210void showallscores(void);
266int sortboard(void); 
267void newscore(long, char *, int, int); 
268void new1sub(long, int, char *, long); 
269void new2sub(long, int, char *, int); 
270void died(int); 211void died(int);
271void diedsub(int); 
272void diedlog(void); 212void diedlog(void);
273int getplid(char *); 213int getplid(char *);
274 214
275/* signal.c */ 215/* signal.c */
276void sigsetup(void); 216void sigsetup(void);
277 217
278/* store.c */ 218/* store.c */
279void dnd_2hed(void); 
280void dnd_hed(void); 
281void dndstore(void); 219void dndstore(void);
282void sch_hed(void); 
283void oschool(void); 220void oschool(void);
284void obank(void); 221void obank(void);
285void obank2(void); 222void obank2(void);
286void ointerest(void); 223void ointerest(void);
287void obanksub(void); 
288void appraise(int); 
289void otradepost(void); 224void otradepost(void);
290void cnsitm(void); 
291void olrs(void); 225void olrs(void);
292 226
293/* tok.c */ 227/* tok.c */
294int yylex(void); 228int yylex(void);
295void flushall(void); 229void flushall(void);
296void sethard(int); 230void sethard(int);
297void readopts(void); 231void readopts(void);

cvs diff -r1.6 -r1.7 src/games/larn/fortune.c (expand / switch to unified diff)

--- src/games/larn/fortune.c 2008/01/28 05:38:53 1.6
+++ src/games/larn/fortune.c 2009/08/12 08:04:05 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fortune.c,v 1.6 2008/01/28 05:38:53 dholland Exp $ */ 1/* $NetBSD: fortune.c,v 1.7 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991 The Regents of the University of California. 4 * Copyright (c) 1991 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,41 +24,41 @@ @@ -24,41 +24,41 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)fortune.c 5.5 (Berkeley) 6/10/91"; 35static char sccsid[] = "@(#)fortune.c 5.5 (Berkeley) 6/10/91";
36#else 36#else
37__RCSID("$NetBSD: fortune.c,v 1.6 2008/01/28 05:38:53 dholland Exp $"); 37__RCSID("$NetBSD: fortune.c,v 1.7 2009/08/12 08:04:05 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42 42
43#include "header.h" 43#include "header.h"
44#include "extern.h" 44#include "extern.h"
45/* fortune.c Larn is copyrighted 1986 by Noah Morgan. */ 45/* fortune.c Larn is copyrighted 1986 by Noah Morgan. */
46 46
47/* 47/*
48 * function to return a random fortune from the fortune file 48 * function to return a random fortune from the fortune file
49 */ 49 */
50 50
51const char *flines[] = { 51static const char *flines[] = {
52 "gem value = gem * 2 ^ perfection", 52 "gem value = gem * 2 ^ perfection",
53 "sitting down can have unexpected results", 53 "sitting down can have unexpected results",
54 "don't pry into the affairs of others", 54 "don't pry into the affairs of others",
55 "drinking can be hazardous to your health", 55 "drinking can be hazardous to your health",
56 "beware of the gusher!", 56 "beware of the gusher!",
57 "some monsters are greedy", 57 "some monsters are greedy",
58 "nymphs have light fingers", 58 "nymphs have light fingers",
59 "try kissing a disenchantress!", 59 "try kissing a disenchantress!",
60 "hammers and brains don't mix", 60 "hammers and brains don't mix",
61 "what does a potion of cure dianthroritis taste like?", 61 "what does a potion of cure dianthroritis taste like?",
62 "hit point gain/loss when raising a level depends on constitution", 62 "hit point gain/loss when raising a level depends on constitution",
63 "healing a mighty wizard can be exhilarating", 63 "healing a mighty wizard can be exhilarating",
64 "be sure to pay your taxes", 64 "be sure to pay your taxes",

cvs diff -r1.6 -r1.7 src/games/larn/movem.c (expand / switch to unified diff)

--- src/games/larn/movem.c 2008/01/28 05:38:54 1.6
+++ src/games/larn/movem.c 2009/08/12 08:04:05 1.7
@@ -1,33 +1,37 @@ @@ -1,33 +1,37 @@
1/* $NetBSD: movem.c,v 1.6 2008/01/28 05:38:54 dholland Exp $ */ 1/* $NetBSD: movem.c,v 1.7 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* 3/*
4 * movem.c (move monster) Larn is copyrighted 1986 by Noah Morgan. 4 * movem.c (move monster) Larn is copyrighted 1986 by Noah Morgan.
5 * 5 *
6 * Here are the functions in this file: 6 * Here are the functions in this file:
7 * 7 *
8 * movemonst() Routine to move the monsters toward the player 8 * movemonst() Routine to move the monsters toward the player
9 * movemt(x,y) Function to move a monster at (x,y) -- must determine where 9 * movemt(x,y) Function to move a monster at (x,y) -- must determine where
10 * mmove(x,y,xd,yd) Function to actually perform the monster movement 10 * mmove(x,y,xd,yd) Function to actually perform the monster movement
11 * movsphere() Function to look for and move spheres of annihilation 11 * movsphere() Function to look for and move spheres of annihilation
12 */ 12 */
13#include <sys/cdefs.h> 13#include <sys/cdefs.h>
14#ifndef lint 14#ifndef lint
15__RCSID("$NetBSD: movem.c,v 1.6 2008/01/28 05:38:54 dholland Exp $"); 15__RCSID("$NetBSD: movem.c,v 1.7 2009/08/12 08:04:05 dholland Exp $");
16#endif /* not lint */ 16#endif /* not lint */
17 17
18#include "header.h" 18#include "header.h"
19#include "extern.h" 19#include "extern.h"
20 20
 21static void movemt(int, int);
 22static void mmove(int, int, int, int);
 23static void movsphere(void);
 24
21/* 25/*
22 * movemonst() Routine to move the monsters toward the player 26 * movemonst() Routine to move the monsters toward the player
23 * 27 *
24 * This routine has the responsibility to determine which monsters are to 28 * This routine has the responsibility to determine which monsters are to
25 * move, and call movemt() to do the move. 29 * move, and call movemt() to do the move.
26 * Returns no value. 30 * Returns no value.
27 */ 31 */
28static short w1[9], w1x[9], w1y[9]; 32static short w1[9], w1x[9], w1y[9];
29static int tmp1, tmp2, tmp3, tmp4, distance; 33static int tmp1, tmp2, tmp3, tmp4, distance;
30void 34void
31movemonst() 35movemonst()
32{ 36{
33 int i, j; 37 int i, j;
@@ -117,27 +121,27 @@ movemonst() @@ -117,27 +121,27 @@ movemonst()
117 } 121 }
118 } 122 }
119} 123}
120 124
121/* 125/*
122 * movemt(x,y) Function to move a monster at (x,y) -- must determine where 126 * movemt(x,y) Function to move a monster at (x,y) -- must determine where
123 * int x,y; 127 * int x,y;
124 * 128 *
125 * This routine is responsible for determining where one monster at (x,y) will 129 * This routine is responsible for determining where one monster at (x,y) will
126 * move to. Enter with the monsters coordinates in (x,y). 130 * move to. Enter with the monsters coordinates in (x,y).
127 * Returns no value. 131 * Returns no value.
128 */ 132 */
129static int tmpitem, xl, xh, yl, yh; 133static int tmpitem, xl, xh, yl, yh;
130void 134static void
131movemt(i, j) 135movemt(i, j)
132 int i, j; 136 int i, j;
133{ 137{
134 int k, m, z, tmp, xtmp, ytmp, monst; 138 int k, m, z, tmp, xtmp, ytmp, monst;
135 switch (monst = mitem[i][j]) { /* for half speed monsters */ 139 switch (monst = mitem[i][j]) { /* for half speed monsters */
136 case TROGLODYTE: 140 case TROGLODYTE:
137 case HOBGOBLIN: 141 case HOBGOBLIN:
138 case METAMORPH: 142 case METAMORPH:
139 case XVART: 143 case XVART:
140 case INVISIBLESTALKER: 144 case INVISIBLESTALKER:
141 case ICELIZARD: 145 case ICELIZARD:
142 if ((gltime & 1) == 1) 146 if ((gltime & 1) == 1)
143 return; 147 return;
@@ -259,27 +263,27 @@ out: if (tmp < distance) /* did find co @@ -259,27 +263,27 @@ out: if (tmp < distance) /* did find co
259 263
260 if (w1[tmp] < 10000) 264 if (w1[tmp] < 10000)
261 if ((i != w1x[tmp]) || (j != w1y[tmp])) 265 if ((i != w1x[tmp]) || (j != w1y[tmp]))
262 mmove(i, j, w1x[tmp], w1y[tmp]); 266 mmove(i, j, w1x[tmp], w1y[tmp]);
263} 267}
264 268
265/* 269/*
266 * mmove(x,y,xd,yd) Function to actually perform the monster movement 270 * mmove(x,y,xd,yd) Function to actually perform the monster movement
267 * int x,y,xd,yd; 271 * int x,y,xd,yd;
268 * 272 *
269 * Enter with the from coordinates in (x,y) and the destination coordinates 273 * Enter with the from coordinates in (x,y) and the destination coordinates
270 * in (xd,yd). 274 * in (xd,yd).
271 */ 275 */
272void 276static void
273mmove(aa, bb, cc, dd) 277mmove(aa, bb, cc, dd)
274 int aa, bb, cc, dd; 278 int aa, bb, cc, dd;
275{ 279{
276 int tmp, i, flag; 280 int tmp, i, flag;
277 const char *who = NULL, *p; 281 const char *who = NULL, *p;
278 282
279 flag = 0; /* set to 1 if monster hit by arrow trap */ 283 flag = 0; /* set to 1 if monster hit by arrow trap */
280 if ((cc == playerx) && (dd == playery)) { 284 if ((cc == playerx) && (dd == playery)) {
281 hitplayer(aa, bb); 285 hitplayer(aa, bb);
282 moved[aa][bb] = 1; 286 moved[aa][bb] = 1;
283 return; 287 return;
284 } 288 }
285 i = item[cc][dd]; 289 i = item[cc][dd];
@@ -392,27 +396,27 @@ mmove(aa, bb, cc, dd) @@ -392,27 +396,27 @@ mmove(aa, bb, cc, dd)
392 396
393/* 397/*
394 * movsphere() Function to look for and move spheres of annihilation 398 * movsphere() Function to look for and move spheres of annihilation
395 * 399 *
396 * This function works on the sphere linked list, first duplicating the list 400 * This function works on the sphere linked list, first duplicating the list
397 * (the act of moving changes the list), then processing each sphere in order 401 * (the act of moving changes the list), then processing each sphere in order
398 * to move it. They eat anything in their way, including stairs, volcanic 402 * to move it. They eat anything in their way, including stairs, volcanic
399 * shafts, potions, etc, except for upper level demons, who can dispel 403 * shafts, potions, etc, except for upper level demons, who can dispel
400 * spheres. 404 * spheres.
401 * No value is returned. 405 * No value is returned.
402 */ 406 */
403#define SPHMAX 20 /* maximum number of spheres movsphere can 407#define SPHMAX 20 /* maximum number of spheres movsphere can
404 * handle */ 408 * handle */
405void 409static void
406movsphere() 410movsphere()
407{ 411{
408 int x, y, dir, len; 412 int x, y, dir, len;
409 struct sphere *sp, *sp2; 413 struct sphere *sp, *sp2;
410 struct sphere sph[SPHMAX]; 414 struct sphere sph[SPHMAX];
411 415
412 /* first duplicate sphere list */ 416 /* first duplicate sphere list */
413 for (sp = 0, x = 0, sp2 = spheres; sp2; sp2 = sp2->p) /* look through sphere 417 for (sp = 0, x = 0, sp2 = spheres; sp2; sp2 = sp2->p) /* look through sphere
414 * list */ 418 * list */
415 if (sp2->lev == level) { /* only if this level */ 419 if (sp2->lev == level) { /* only if this level */
416 sph[x] = *sp2; 420 sph[x] = *sp2;
417 sph[x++].p = 0; /* copy the struct */ 421 sph[x++].p = 0; /* copy the struct */
418 if (x > 1) 422 if (x > 1)

cvs diff -r1.7 -r1.8 src/games/larn/help.c (expand / switch to unified diff)

--- src/games/larn/help.c 2008/02/03 21:24:58 1.7
+++ src/games/larn/help.c 2009/08/12 08:04:05 1.8
@@ -1,26 +1,27 @@ @@ -1,26 +1,27 @@
1/* $NetBSD: help.c,v 1.7 2008/02/03 21:24:58 dholland Exp $ */ 1/* $NetBSD: help.c,v 1.8 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* help.c Larn is copyrighted 1986 by Noah Morgan. */ 3/* help.c Larn is copyrighted 1986 by Noah Morgan. */
4#include <sys/cdefs.h> 4#include <sys/cdefs.h>
5#ifndef lint 5#ifndef lint
6__RCSID("$NetBSD: help.c,v 1.7 2008/02/03 21:24:58 dholland Exp $"); 6__RCSID("$NetBSD: help.c,v 1.8 2009/08/12 08:04:05 dholland Exp $");
7#endif /* not lint */ 7#endif /* not lint */
8 8
9#include <unistd.h> 9#include <unistd.h>
10 10
11#include "header.h" 11#include "header.h"
12#include "extern.h" 12#include "extern.h"
13 13
 14static void retcont(void);
14static int openhelp(void); 15static int openhelp(void);
15 16
16/* 17/*
17 * help function to display the help info 18 * help function to display the help info
18 * 19 *
19 * format of the .larn.help file 20 * format of the .larn.help file
20 * 21 *
21 * 1st character of file: # of pages of help available (ascii digit) 22 * 1st character of file: # of pages of help available (ascii digit)
22 * page (23 lines) for the introductory message (not counted in above) 23 * page (23 lines) for the introductory message (not counted in above)
23 * pages of help text (23 lines per page) 24 * pages of help text (23 lines per page)
24 */ 25 */
25void 26void
26help() 27help()
@@ -88,27 +89,27 @@ welcome() @@ -88,27 +89,27 @@ welcome()
88#else /* VT100 */ 89#else /* VT100 */
89 { 90 {
90 tmcapcnv(tmbuf, lgetl()); 91 tmcapcnv(tmbuf, lgetl());
91 lprcat(tmbuf); 92 lprcat(tmbuf);
92 } /* intercept \33's */ 93 } /* intercept \33's */
93#endif /* VT100 */ 94#endif /* VT100 */
94 lrclose(); 95 lrclose();
95 retcont(); /* press return to continue */ 96 retcont(); /* press return to continue */
96} 97}
97 98
98/* 99/*
99 * function to say press return to continue and reset scroll when done 100 * function to say press return to continue and reset scroll when done
100 */ 101 */
101void 102static void
102retcont() 103retcont()
103{ 104{
104 cursor(1, 24); 105 cursor(1, 24);
105 lprcat("Press "); 106 lprcat("Press ");
106 standout("return"); 107 standout("return");
107 lprcat(" to continue: "); 108 lprcat(" to continue: ");
108 while (ttgetch() != '\n'); 109 while (ttgetch() != '\n');
109 setscroll(); 110 setscroll();
110} 111}
111 112
112/* 113/*
113 * routine to open the help file and return the first character - '0' 114 * routine to open the help file and return the first character - '0'
114 */ 115 */

cvs diff -r1.23 -r1.24 src/games/larn/io.c (expand / switch to unified diff)

--- src/games/larn/io.c 2008/02/03 21:24:58 1.23
+++ src/games/larn/io.c 2009/08/12 08:04:05 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: io.c,v 1.23 2008/02/03 21:24:58 dholland Exp $ */ 1/* $NetBSD: io.c,v 1.24 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* 3/*
4 * io.c Larn is copyrighted 1986 by Noah Morgan. 4 * io.c Larn is copyrighted 1986 by Noah Morgan.
5 *  5 *
6 * Below are the functions in this file: 6 * Below are the functions in this file:
7 *  7 *
8 * setupvt100() Subroutine to set up terminal in correct mode for game 8 * setupvt100() Subroutine to set up terminal in correct mode for game
9 * clearvt100() Subroutine to clean up terminal when the game is over 9 * clearvt100() Subroutine to clean up terminal when the game is over
10 * ttgetch() Routine to read in one character from the terminal 10 * ttgetch() Routine to read in one character from the terminal
11 * scbr() Function to set cbreak -echo for the terminal 11 * scbr() Function to set cbreak -echo for the terminal
12 * sncbr() Function to set -cbreak echo for the terminal 12 * sncbr() Function to set -cbreak echo for the terminal
13 * newgame() Subroutine to save the initial time and seed rnd() 13 * newgame() Subroutine to save the initial time and seed rnd()
14 *  14 *
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * lear screen from [1,y] to end of display. standout(str) 52 * lear screen from [1,y] to end of display. standout(str)
53 * rint the string in standout mode. set_score_output() 53 * rint the string in standout mode. set_score_output()
54 * alled when output should be literally printed. * ttputch(ch) 54 * alled when output should be literally printed. * ttputch(ch)
55 * rint one character in decoded output buffer. * flush_buf() 55 * rint one character in decoded output buffer. * flush_buf()
56 * lush buffer with decoded output. * init_term() 56 * lush buffer with decoded output. * init_term()
57 * erminal initialization -- setup termcap info * char *tmcapcnv(sd,ss) 57 * erminal initialization -- setup termcap info * char *tmcapcnv(sd,ss)
58 * outine to convert VT100 \33's to termcap format beep() 58 * outine to convert VT100 \33's to termcap format beep()
59 * e to emit a beep if enabled (see no-beep in .larnopts) 59 * e to emit a beep if enabled (see no-beep in .larnopts)
60 *  60 *
61 * Note: ** entries are available only in termcap mode. 61 * Note: ** entries are available only in termcap mode.
62 */ 62 */
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64#ifndef lint 64#ifndef lint
65__RCSID("$NetBSD: io.c,v 1.23 2008/02/03 21:24:58 dholland Exp $"); 65__RCSID("$NetBSD: io.c,v 1.24 2009/08/12 08:04:05 dholland Exp $");
66#endif /* not lint */ 66#endif /* not lint */
67 67
68#include "header.h" 68#include "header.h"
69#include "extern.h" 69#include "extern.h"
70#include <string.h> 70#include <string.h>
71#include <unistd.h> 71#include <unistd.h>
72#include <stdio.h> 72#include <stdio.h>
73#include <stdlib.h> 73#include <stdlib.h>
74#include <termcap.h> 74#include <termcap.h>
75#include <fcntl.h> 75#include <fcntl.h>
76#include <errno.h> 76#include <errno.h>
77#include <ctype.h> 77#include <ctype.h>
78 78
@@ -640,28 +640,28 @@ void @@ -640,28 +640,28 @@ void
640cursors() 640cursors()
641{ 641{
642 cursor(1, 24); 642 cursor(1, 24);
643} 643}
644 644
645#ifndef VT100 645#ifndef VT100
646/* 646/*
647 * Warning: ringing the bell is control code 7. Don't use in defines. 647 * Warning: ringing the bell is control code 7. Don't use in defines.
648 * Don't change the order of these defines. 648 * Don't change the order of these defines.
649 * Also used in helpfiles. Codes used in helpfiles should be \E[1 to \E[7 with 649 * Also used in helpfiles. Codes used in helpfiles should be \E[1 to \E[7 with
650 * obvious meanings. 650 * obvious meanings.
651 */ 651 */
652 652
653struct tinfo *info; 653static struct tinfo *info;
654char *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL; /* Termcap capabilities */ 654static char *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL; /* Termcap capabilities */
655static char *outbuf = 0; /* translated output buffer */ 655static char *outbuf = 0; /* translated output buffer */
656 656
657/* 657/*
658 * init_term() Terminal initialization -- setup termcap info 658 * init_term() Terminal initialization -- setup termcap info
659 */ 659 */
660void 660void
661init_term() 661init_term()
662{ 662{
663 char *term; 663 char *term;
664 664
665 switch (t_getent(&info, term = getenv("TERM"))) { 665 switch (t_getent(&info, term = getenv("TERM"))) {
666 case -1: 666 case -1:
667 write(2, "Cannot open termcap file.\n", 26); 667 write(2, "Cannot open termcap file.\n", 26);

cvs diff -r1.23 -r1.24 src/games/larn/main.c (expand / switch to unified diff)

--- src/games/larn/main.c 2008/02/03 21:24:58 1.23
+++ src/games/larn/main.c 2009/08/12 08:04:05 1.24
@@ -1,30 +1,50 @@ @@ -1,30 +1,50 @@
1/* $NetBSD: main.c,v 1.23 2008/02/03 21:24:58 dholland Exp $ */ 1/* $NetBSD: main.c,v 1.24 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* main.c */ 3/* main.c */
4#include <sys/cdefs.h> 4#include <sys/cdefs.h>
5#ifndef lint 5#ifndef lint
6__RCSID("$NetBSD: main.c,v 1.23 2008/02/03 21:24:58 dholland Exp $"); 6__RCSID("$NetBSD: main.c,v 1.24 2009/08/12 08:04:05 dholland Exp $");
7#endif /* not lint */ 7#endif /* not lint */
8 8
9#include <sys/types.h> 9#include <sys/types.h>
10#include <stdio.h> 10#include <stdio.h>
11#include <pwd.h> 11#include <pwd.h>
12#include <unistd.h> 12#include <unistd.h>
13#include <stdlib.h> 13#include <stdlib.h>
14#include <string.h> 14#include <string.h>
15#include "header.h" 15#include "header.h"
16#include "extern.h" 16#include "extern.h"
17 17
 18static void showstr(void);
 19static void t_setup(int);
 20static void t_endup(int);
 21static void showwear(void);
 22static void showwield(void);
 23static void showread(void);
 24static void showeat(void);
 25static void showquaff(void);
 26static void show1(int, const char *[]);
 27static void randmonst(void);
 28static void parse(void);
 29static void run(int);
 30static void wield(void);
 31static void ydhi(int);
 32static void ycwi(int);
 33static void wear(void);
 34static void dropobj(void);
 35static void readscr(void);
 36static void eatcookie(void);
 37static void quaff(void);
18static int whatitem(const char *); 38static int whatitem(const char *);
19 39
20static char copyright[] = "\nLarn is copyrighted 1986 by Noah Morgan.\n"; 40static char copyright[] = "\nLarn is copyrighted 1986 by Noah Morgan.\n";
21int srcount = 0; /* line counter for showstr() */ 41int srcount = 0; /* line counter for showstr() */
22int dropflag = 0; /* if 1 then don't lookforobject() next round */ 42int dropflag = 0; /* if 1 then don't lookforobject() next round */
23int rmst = 80; /* random monster creation counter */ 43int rmst = 80; /* random monster creation counter */
24int userid; /* the players login user id number */ 44int userid; /* the players login user id number */
25gid_t gid, egid; /* used for security */ 45gid_t gid, egid; /* used for security */
26u_char nowelcome = 0, nomove = 0; /* if (nomove) then don't 46u_char nowelcome = 0, nomove = 0; /* if (nomove) then don't
27 * count next iteration as a 47 * count next iteration as a
28 * move */ 48 * move */
29static char viewflag = 0; 49static char viewflag = 0;
30/* 50/*
@@ -299,27 +319,27 @@ main(argc, argv) @@ -299,27 +319,27 @@ main(argc, argv)
299 if (--rmst <= 0) { 319 if (--rmst <= 0) {
300 rmst = 120 - (level << 2); 320 rmst = 120 - (level << 2);
301 fillmonst(makemonst(level)); 321 fillmonst(makemonst(level));
302 } 322 }
303 } 323 }
304} 324}
305 325
306 326
307/* 327/*
308 showstr() 328 showstr()
309 329
310 show character's inventory 330 show character's inventory
311 */ 331 */
312void 332static void
313showstr() 333showstr()
314{ 334{
315 int i, number; 335 int i, number;
316 for (number = 3, i = 0; i < 26; i++) 336 for (number = 3, i = 0; i < 26; i++)
317 if (iven[i]) 337 if (iven[i])
318 number++; /* count items in inventory */ 338 number++; /* count items in inventory */
319 t_setup(number); 339 t_setup(number);
320 qshowstr(); 340 qshowstr();
321 t_endup(number); 341 t_endup(number);
322} 342}
323 343
324void 344void
325qshowstr() 345qshowstr()
@@ -338,58 +358,58 @@ qshowstr() @@ -338,58 +358,58 @@ qshowstr()
338 for (j = 0; j <= k; j++) 358 for (j = 0; j <= k; j++)
339 if (i == iven[j]) 359 if (i == iven[j])
340 show3(j); 360 show3(j);
341 k = 0; 361 k = 0;
342 } 362 }
343 lprintf("\nElapsed time is %ld. You have %ld mobuls left", (long) ((gltime + 99) / 100 + 1), (long) ((TIMELIMIT - gltime) / 100)); 363 lprintf("\nElapsed time is %ld. You have %ld mobuls left", (long) ((gltime + 99) / 100 + 1), (long) ((TIMELIMIT - gltime) / 100));
344 more(); 364 more();
345 nosignal = sigsav; 365 nosignal = sigsav;
346} 366}
347 367
348/* 368/*
349 * subroutine to clear screen depending on # lines to display 369 * subroutine to clear screen depending on # lines to display
350 */ 370 */
351void 371static void
352t_setup(count) 372t_setup(count)
353 int count; 373 int count;
354{ 374{
355 if (count < 20) { /* how do we clear the screen? */ 375 if (count < 20) { /* how do we clear the screen? */
356 cl_up(79, count); 376 cl_up(79, count);
357 cursor(1, 1); 377 cursor(1, 1);
358 } else { 378 } else {
359 resetscroll(); 379 resetscroll();
360 clear(); 380 clear();
361 } 381 }
362} 382}
363 383
364/* 384/*
365 * subroutine to restore normal display screen depending on t_setup() 385 * subroutine to restore normal display screen depending on t_setup()
366 */ 386 */
367void 387static void
368t_endup(count) 388t_endup(count)
369 int count; 389 int count;
370{ 390{
371 if (count < 18) /* how did we clear the screen? */ 391 if (count < 18) /* how did we clear the screen? */
372 draws(0, MAXX, 0, (count > MAXY) ? MAXY : count); 392 draws(0, MAXX, 0, (count > MAXY) ? MAXY : count);
373 else { 393 else {
374 drawscreen(); 394 drawscreen();
375 setscroll(); 395 setscroll();
376 } 396 }
377} 397}
378 398
379/* 399/*
380 function to show the things player is wearing only 400 function to show the things player is wearing only
381 */ 401 */
382void 402static void
383showwear() 403showwear()
384{ 404{
385 int i, j, sigsav, count; 405 int i, j, sigsav, count;
386 sigsav = nosignal; 406 sigsav = nosignal;
387 nosignal = 1; /* don't allow ^c etc */ 407 nosignal = 1; /* don't allow ^c etc */
388 srcount = 0; 408 srcount = 0;
389 409
390 for (count = 2, j = 0; j <= 26; j++) /* count number of items we 410 for (count = 2, j = 0; j <= 26; j++) /* count number of items we
391 * will display */ 411 * will display */
392 if ((i = iven[j]) != 0) 412 if ((i = iven[j]) != 0)
393 switch (i) { 413 switch (i) {
394 case OLEATHER: 414 case OLEATHER:
395 case OPLATE: 415 case OPLATE:
@@ -418,27 +438,27 @@ showwear() @@ -418,27 +438,27 @@ showwear()
418 case OPLATEARMOR: 438 case OPLATEARMOR:
419 case OSSPLATE: 439 case OSSPLATE:
420 case OSHIELD: 440 case OSHIELD:
421 show3(j); 441 show3(j);
422 }; 442 };
423 more(); 443 more();
424 nosignal = sigsav; 444 nosignal = sigsav;
425 t_endup(count); 445 t_endup(count);
426} 446}
427 447
428/* 448/*
429 function to show the things player can wield only 449 function to show the things player can wield only
430 */ 450 */
431void 451static void
432showwield() 452showwield()
433{ 453{
434 int i, j, sigsav, count; 454 int i, j, sigsav, count;
435 sigsav = nosignal; 455 sigsav = nosignal;
436 nosignal = 1; /* don't allow ^c etc */ 456 nosignal = 1; /* don't allow ^c etc */
437 srcount = 0; 457 srcount = 0;
438 458
439 for (count = 2, j = 0; j <= 26; j++) /* count how many items */ 459 for (count = 2, j = 0; j <= 26; j++) /* count how many items */
440 if ((i = iven[j]) != 0) 460 if ((i = iven[j]) != 0)
441 switch (i) { 461 switch (i) {
442 case ODIAMOND: 462 case ODIAMOND:
443 case ORUBY: 463 case ORUBY:
444 case OEMERALD: 464 case OEMERALD:
@@ -476,27 +496,27 @@ showwield() @@ -476,27 +496,27 @@ showwield()
476 case OSCROLL: 496 case OSCROLL:
477 break; 497 break;
478 default: 498 default:
479 show3(j); 499 show3(j);
480 }; 500 };
481 more(); 501 more();
482 nosignal = sigsav; 502 nosignal = sigsav;
483 t_endup(count); 503 t_endup(count);
484} 504}
485 505
486/* 506/*
487 * function to show the things player can read only 507 * function to show the things player can read only
488 */ 508 */
489void 509static void
490showread() 510showread()
491{ 511{
492 int i, j, sigsav, count; 512 int i, j, sigsav, count;
493 sigsav = nosignal; 513 sigsav = nosignal;
494 nosignal = 1; /* don't allow ^c etc */ 514 nosignal = 1; /* don't allow ^c etc */
495 srcount = 0; 515 srcount = 0;
496 516
497 for (count = 2, j = 0; j <= 26; j++) 517 for (count = 2, j = 0; j <= 26; j++)
498 switch (iven[j]) { 518 switch (iven[j]) {
499 case OBOOK: 519 case OBOOK:
500 case OSCROLL: 520 case OSCROLL:
501 count++; 521 count++;
502 }; 522 };
@@ -508,27 +528,27 @@ showread() @@ -508,27 +528,27 @@ showread()
508 switch (i) { 528 switch (i) {
509 case OBOOK: 529 case OBOOK:
510 case OSCROLL: 530 case OSCROLL:
511 show3(j); 531 show3(j);
512 }; 532 };
513 more(); 533 more();
514 nosignal = sigsav; 534 nosignal = sigsav;
515 t_endup(count); 535 t_endup(count);
516} 536}
517 537
518/* 538/*
519 * function to show the things player can eat only 539 * function to show the things player can eat only
520 */ 540 */
521void 541static void
522showeat() 542showeat()
523{ 543{
524 int i, j, sigsav, count; 544 int i, j, sigsav, count;
525 sigsav = nosignal; 545 sigsav = nosignal;
526 nosignal = 1; /* don't allow ^c etc */ 546 nosignal = 1; /* don't allow ^c etc */
527 srcount = 0; 547 srcount = 0;
528 548
529 for (count = 2, j = 0; j <= 26; j++) 549 for (count = 2, j = 0; j <= 26; j++)
530 switch (iven[j]) { 550 switch (iven[j]) {
531 case OCOOKIE: 551 case OCOOKIE:
532 count++; 552 count++;
533 }; 553 };
534 t_setup(count); 554 t_setup(count);
@@ -538,54 +558,54 @@ showeat() @@ -538,54 +558,54 @@ showeat()
538 if (i == iven[j]) 558 if (i == iven[j])
539 switch (i) { 559 switch (i) {
540 case OCOOKIE: 560 case OCOOKIE:
541 show3(j); 561 show3(j);
542 }; 562 };
543 more(); 563 more();
544 nosignal = sigsav; 564 nosignal = sigsav;
545 t_endup(count); 565 t_endup(count);
546} 566}
547 567
548/* 568/*
549 function to show the things player can quaff only 569 function to show the things player can quaff only
550 */ 570 */
551void 571static void
552showquaff() 572showquaff()
553{ 573{
554 int i, j, sigsav, count; 574 int i, j, sigsav, count;
555 sigsav = nosignal; 575 sigsav = nosignal;
556 nosignal = 1; /* don't allow ^c etc */ 576 nosignal = 1; /* don't allow ^c etc */
557 srcount = 0; 577 srcount = 0;
558 578
559 for (count = 2, j = 0; j <= 26; j++) 579 for (count = 2, j = 0; j <= 26; j++)
560 switch (iven[j]) { 580 switch (iven[j]) {
561 case OPOTION: 581 case OPOTION:
562 count++; 582 count++;
563 }; 583 };
564 t_setup(count); 584 t_setup(count);
565 585
566 for (i = 22; i < 84; i++) 586 for (i = 22; i < 84; i++)
567 for (j = 0; j <= 26; j++) 587 for (j = 0; j <= 26; j++)
568 if (i == iven[j]) 588 if (i == iven[j])
569 switch (i) { 589 switch (i) {
570 case OPOTION: 590 case OPOTION:
571 show3(j); 591 show3(j);
572 }; 592 };
573 more(); 593 more();
574 nosignal = sigsav; 594 nosignal = sigsav;
575 t_endup(count); 595 t_endup(count);
576} 596}
577 597
578void 598static void
579show1(idx, str2) 599show1(idx, str2)
580 int idx; 600 int idx;
581 const char *str2[]; 601 const char *str2[];
582{ 602{
583 lprintf("\n%c) %s", idx + 'a', objectname[iven[idx]]); 603 lprintf("\n%c) %s", idx + 'a', objectname[iven[idx]]);
584 if (str2 != 0 && str2[ivenarg[idx]][0] != 0) 604 if (str2 != 0 && str2[ivenarg[idx]][0] != 0)
585 lprintf(" of%s", str2[ivenarg[idx]]); 605 lprintf(" of%s", str2[ivenarg[idx]]);
586} 606}
587 607
588void 608void
589show3(int indx) 609show3(int indx)
590{ 610{
591 switch (iven[indx]) { 611 switch (iven[indx]) {
@@ -622,45 +642,45 @@ show3(int indx) @@ -622,45 +642,45 @@ show3(int indx)
622 lprcat(" (weapon in hand)"); 642 lprcat(" (weapon in hand)");
623 if ((c[WEAR] == indx) || (c[SHIELD] == indx)) 643 if ((c[WEAR] == indx) || (c[SHIELD] == indx))
624 lprcat(" (being worn)"); 644 lprcat(" (being worn)");
625 if (++srcount >= 22) { 645 if (++srcount >= 22) {
626 srcount = 0; 646 srcount = 0;
627 more(); 647 more();
628 clear(); 648 clear();
629 } 649 }
630} 650}
631 651
632/* 652/*
633 subroutine to randomly create monsters if needed 653 subroutine to randomly create monsters if needed
634 */ 654 */
635void 655static void
636randmonst() 656randmonst()
637{ 657{
638 if (c[TIMESTOP]) 658 if (c[TIMESTOP])
639 return; /* don't make monsters if time is stopped */ 659 return; /* don't make monsters if time is stopped */
640 if (--rmst <= 0) { 660 if (--rmst <= 0) {
641 rmst = 120 - (level << 2); 661 rmst = 120 - (level << 2);
642 fillmonst(makemonst(level)); 662 fillmonst(makemonst(level));
643 } 663 }
644} 664}
645 665
646 666
647 667
648/* 668/*
649 parse() 669 parse()
650 670
651 get and execute a command 671 get and execute a command
652 */ 672 */
653void 673static void
654parse() 674parse()
655{ 675{
656 int i, j, k, flag; 676 int i, j, k, flag;
657 while (1) { 677 while (1) {
658 k = yylex(); 678 k = yylex();
659 switch (k) { /* get the token from the input and switch on 679 switch (k) { /* get the token from the input and switch on
660 * it */ 680 * it */
661 case 'h': 681 case 'h':
662 moveplayer(4); 682 moveplayer(4);
663 return; /* west */ 683 return; /* west */
664 case 'H': 684 case 'H':
665 run(4); 685 run(4);
666 return; /* west */ 686 return; /* west */
@@ -959,52 +979,52 @@ parse() @@ -959,52 +979,52 @@ parse()
959 } 979 }
960} 980}
961 981
962void 982void
963parse2() 983parse2()
964{ 984{
965 if (c[HASTEMONST]) 985 if (c[HASTEMONST])
966 movemonst(); 986 movemonst();
967 movemonst(); /* move the monsters */ 987 movemonst(); /* move the monsters */
968 randmonst(); 988 randmonst();
969 regen(); 989 regen();
970} 990}
971 991
972void 992static void
973run(dir) 993run(dir)
974 int dir; 994 int dir;
975{ 995{
976 int i; 996 int i;
977 i = 1; 997 i = 1;
978 while (i) { 998 while (i) {
979 i = moveplayer(dir); 999 i = moveplayer(dir);
980 if (i > 0) { 1000 if (i > 0) {
981 if (c[HASTEMONST]) 1001 if (c[HASTEMONST])
982 movemonst(); 1002 movemonst();
983 movemonst(); 1003 movemonst();
984 randmonst(); 1004 randmonst();
985 regen(); 1005 regen();
986 } 1006 }
987 if (hitflag) 1007 if (hitflag)
988 i = 0; 1008 i = 0;
989 if (i != 0) 1009 if (i != 0)
990 showcell(playerx, playery); 1010 showcell(playerx, playery);
991 } 1011 }
992} 1012}
993 1013
994/* 1014/*
995 function to wield a weapon 1015 function to wield a weapon
996 */ 1016 */
997void 1017static void
998wield() 1018wield()
999{ 1019{
1000 int i; 1020 int i;
1001 while (1) { 1021 while (1) {
1002 if ((i = whatitem("wield")) == '\33') 1022 if ((i = whatitem("wield")) == '\33')
1003 return; 1023 return;
1004 if (i != '.') { 1024 if (i != '.') {
1005 if (i == '*') 1025 if (i == '*')
1006 showwield(); 1026 showwield();
1007 else if (iven[i - 'a'] == 0) { 1027 else if (iven[i - 'a'] == 0) {
1008 ydhi(i); 1028 ydhi(i);
1009 return; 1029 return;
1010 } else if (iven[i - 'a'] == OPOTION) { 1030 } else if (iven[i - 'a'] == OPOTION) {
@@ -1022,45 +1042,45 @@ wield() @@ -1022,45 +1042,45 @@ wield()
1022 c[LANCEDEATH] = 1; 1042 c[LANCEDEATH] = 1;
1023 else 1043 else
1024 c[LANCEDEATH] = 0; 1044 c[LANCEDEATH] = 0;
1025 bottomline(); 1045 bottomline();
1026 return; 1046 return;
1027 } 1047 }
1028 } 1048 }
1029 } 1049 }
1030} 1050}
1031 1051
1032/* 1052/*
1033 common routine to say you don't have an item 1053 common routine to say you don't have an item
1034 */ 1054 */
1035void 1055static void
1036ydhi(x) 1056ydhi(x)
1037 int x; 1057 int x;
1038{ 1058{
1039 cursors(); 1059 cursors();
1040 lprintf("\nYou don't have item %c!", x); 1060 lprintf("\nYou don't have item %c!", x);
1041} 1061}
1042void 1062static void
1043ycwi(x) 1063ycwi(x)
1044 int x; 1064 int x;
1045{ 1065{
1046 cursors(); 1066 cursors();
1047 lprintf("\nYou can't wield item %c!", x); 1067 lprintf("\nYou can't wield item %c!", x);
1048} 1068}
1049 1069
1050/* 1070/*
1051 function to wear armor 1071 function to wear armor
1052 */ 1072 */
1053void 1073static void
1054wear() 1074wear()
1055{ 1075{
1056 int i; 1076 int i;
1057 while (1) { 1077 while (1) {
1058 if ((i = whatitem("wear")) == '\33') 1078 if ((i = whatitem("wear")) == '\33')
1059 return; 1079 return;
1060 if (i != '.') { 1080 if (i != '.') {
1061 if (i == '*') 1081 if (i == '*')
1062 showwear(); 1082 showwear();
1063 else 1083 else
1064 switch (iven[i - 'a']) { 1084 switch (iven[i - 'a']) {
1065 case 0: 1085 case 0:
1066 ydhi(i); 1086 ydhi(i);
@@ -1092,27 +1112,27 @@ wear() @@ -1092,27 +1112,27 @@ wear()
1092 c[SHIELD] = i - 'a'; 1112 c[SHIELD] = i - 'a';
1093 bottomline(); 1113 bottomline();
1094 return; 1114 return;
1095 default: 1115 default:
1096 lprcat("\nYou can't wear that!"); 1116 lprcat("\nYou can't wear that!");
1097 }; 1117 };
1098 } 1118 }
1099 } 1119 }
1100} 1120}
1101 1121
1102/* 1122/*
1103 function to drop an object 1123 function to drop an object
1104 */ 1124 */
1105void 1125static void
1106dropobj() 1126dropobj()
1107{ 1127{
1108 int i; 1128 int i;
1109 unsigned char *p; 1129 unsigned char *p;
1110 long amt; 1130 long amt;
1111 p = &item[playerx][playery]; 1131 p = &item[playerx][playery];
1112 while (1) { 1132 while (1) {
1113 if ((i = whatitem("drop")) == '\33') 1133 if ((i = whatitem("drop")) == '\33')
1114 return; 1134 return;
1115 if (i == '*') 1135 if (i == '*')
1116 showstr(); 1136 showstr();
1117 else { 1137 else {
1118 if (i == '.') { /* drop some gold */ 1138 if (i == '.') { /* drop some gold */
@@ -1156,27 +1176,27 @@ dropobj() @@ -1156,27 +1176,27 @@ dropobj()
1156 know[playerx][playery] = 0; 1176 know[playerx][playery] = 0;
1157 dropflag = 1; 1177 dropflag = 1;
1158 return; 1178 return;
1159 } 1179 }
1160 drop_object(i - 'a'); 1180 drop_object(i - 'a');
1161 return; 1181 return;
1162 } 1182 }
1163 } 1183 }
1164} 1184}
1165 1185
1166/* 1186/*
1167 * readscr() Subroutine to read a scroll one is carrying 1187 * readscr() Subroutine to read a scroll one is carrying
1168 */ 1188 */
1169void 1189static void
1170readscr() 1190readscr()
1171{ 1191{
1172 int i; 1192 int i;
1173 while (1) { 1193 while (1) {
1174 if ((i = whatitem("read")) == '\33') 1194 if ((i = whatitem("read")) == '\33')
1175 return; 1195 return;
1176 if (i != '.') { 1196 if (i != '.') {
1177 if (i == '*') 1197 if (i == '*')
1178 showread(); 1198 showread();
1179 else { 1199 else {
1180 if (iven[i - 'a'] == OSCROLL) { 1200 if (iven[i - 'a'] == OSCROLL) {
1181 read_scroll(ivenarg[i - 'a']); 1201 read_scroll(ivenarg[i - 'a']);
1182 iven[i - 'a'] = 0; 1202 iven[i - 'a'] = 0;
@@ -1191,27 +1211,27 @@ readscr() @@ -1191,27 +1211,27 @@ readscr()
1191 ydhi(i); 1211 ydhi(i);
1192 return; 1212 return;
1193 } 1213 }
1194 lprcat("\nThere's nothing on it to read"); 1214 lprcat("\nThere's nothing on it to read");
1195 return; 1215 return;
1196 } 1216 }
1197 } 1217 }
1198 } 1218 }
1199} 1219}
1200 1220
1201/* 1221/*
1202 * subroutine to eat a cookie one is carrying 1222 * subroutine to eat a cookie one is carrying
1203 */ 1223 */
1204void 1224static void
1205eatcookie(void) 1225eatcookie(void)
1206{ 1226{
1207 const char *p; 1227 const char *p;
1208 int i; 1228 int i;
1209 1229
1210 while (1) { 1230 while (1) {
1211 if ((i = whatitem("eat")) == '\33') 1231 if ((i = whatitem("eat")) == '\33')
1212 return; 1232 return;
1213 if (i != '.') { 1233 if (i != '.') {
1214 if (i == '*') 1234 if (i == '*')
1215 showeat(); 1235 showeat();
1216 else { 1236 else {
1217 if (iven[i - 'a'] == OCOOKIE) { 1237 if (iven[i - 'a'] == OCOOKIE) {
@@ -1229,27 +1249,27 @@ eatcookie(void) @@ -1229,27 +1249,27 @@ eatcookie(void)
1229 ydhi(i); 1249 ydhi(i);
1230 return; 1250 return;
1231 } 1251 }
1232 lprcat("\nYou can't eat that!"); 1252 lprcat("\nYou can't eat that!");
1233 return; 1253 return;
1234 } 1254 }
1235 } 1255 }
1236 } 1256 }
1237} 1257}
1238 1258
1239/* 1259/*
1240 * subroutine to quaff a potion one is carrying 1260 * subroutine to quaff a potion one is carrying
1241 */ 1261 */
1242void 1262static void
1243quaff() 1263quaff()
1244{ 1264{
1245 int i; 1265 int i;
1246 while (1) { 1266 while (1) {
1247 if ((i = whatitem("quaff")) == '\33') 1267 if ((i = whatitem("quaff")) == '\33')
1248 return; 1268 return;
1249 if (i != '.') { 1269 if (i != '.') {
1250 if (i == '*') 1270 if (i == '*')
1251 showquaff(); 1271 showquaff();
1252 else { 1272 else {
1253 if (iven[i - 'a'] == OPOTION) { 1273 if (iven[i - 'a'] == OPOTION) {
1254 quaffpotion(ivenarg[i - 'a']); 1274 quaffpotion(ivenarg[i - 'a']);
1255 iven[i - 'a'] = 0; 1275 iven[i - 'a'] = 0;

cvs diff -r1.16 -r1.17 src/games/larn/monster.c (expand / switch to unified diff)

--- src/games/larn/monster.c 2008/02/03 21:24:58 1.16
+++ src/games/larn/monster.c 2009/08/12 08:04:05 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: monster.c,v 1.16 2008/02/03 21:24:58 dholland Exp $ */ 1/* $NetBSD: monster.c,v 1.17 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* 3/*
4 * monster.c Larn is copyrighted 1986 by Noah Morgan. 4 * monster.c Larn is copyrighted 1986 by Noah Morgan.
5 * 5 *
6 * This file contains the following functions: 6 * This file contains the following functions:
7 * ---------------------------------------------------------------------------- 7 * ----------------------------------------------------------------------------
8 * 8 *
9 * createmonster(monstno) Function to create a monster next to the player 9 * createmonster(monstno) Function to create a monster next to the player
10 * int monstno; 10 * int monstno;
11 * 11 *
12 * int cgood(x,y,itm,monst)Function to check location for emptiness 12 * int cgood(x,y,itm,monst)Function to check location for emptiness
13 * int x,y,itm,monst; 13 * int x,y,itm,monst;
14 * 14 *
@@ -90,45 +90,58 @@ @@ -90,45 +90,58 @@
90 * int x,y,dir,lifetime; 90 * int x,y,dir,lifetime;
91 * 91 *
92 * rmsphere(x,y) Function to delete a sphere of annihilation from list 92 * rmsphere(x,y) Function to delete a sphere of annihilation from list
93 * int x,y; 93 * int x,y;
94 * 94 *
95 * sphboom(x,y) Function to perform the effects of a sphere detonation 95 * sphboom(x,y) Function to perform the effects of a sphere detonation
96 * int x,y; 96 * int x,y;
97 * 97 *
98 * genmonst() Function to ask for monster and genocide from game 98 * genmonst() Function to ask for monster and genocide from game
99 * 99 *
100 */ 100 */
101#include <sys/cdefs.h> 101#include <sys/cdefs.h>
102#ifndef lint 102#ifndef lint
103__RCSID("$NetBSD: monster.c,v 1.16 2008/02/03 21:24:58 dholland Exp $"); 103__RCSID("$NetBSD: monster.c,v 1.17 2009/08/12 08:04:05 dholland Exp $");
104#endif /* not lint */ 104#endif /* not lint */
105 105
106#include <string.h> 106#include <string.h>
107#include <stdlib.h> 107#include <stdlib.h>
108#include <ctype.h> 108#include <ctype.h>
109#include "header.h" 109#include "header.h"
110#include "extern.h" 110#include "extern.h"
111 111
112struct isave { /* used for altar reality */ 112struct isave { /* used for altar reality */
113 char type; /* 0=item, 1=monster */ 113 char type; /* 0=item, 1=monster */
114 char id; /* item number or monster number */ 114 char id; /* item number or monster number */
115 short arg; /* the type of item or hitpoints of monster */ 115 short arg; /* the type of item or hitpoints of monster */
116}; 116};
117 117
118static int cgood(int, int, int, int); 118static int cgood(int, int, int, int);
 119static void speldamage(int);
 120static void loseint(void);
 121static int isconfuse(void);
 122static int nospell(int, int);
 123static int fullhit(int);
 124static void direct(int, int, const char *, int);
 125static void ifblind(int, int);
 126static void tdirect(int);
 127static void omnidirect(int, int, const char *);
119static int dirsub(int *, int *); 128static int dirsub(int *, int *);
 129static void dirpoly(int);
 130static int hitm(int, int, int);
120static void dropsomething(int); 131static void dropsomething(int);
121static int spattack(int, int, int); 132static int spattack(int, int, int);
 133static void sphboom(int, int);
 134static void genmonst(void);
122 135
123/* 136/*
124 * createmonster(monstno) Function to create a monster next to the player 137 * createmonster(monstno) Function to create a monster next to the player
125 * int monstno; 138 * int monstno;
126 * 139 *
127 * Enter with the monster number (1 to MAXMONST+8) 140 * Enter with the monster number (1 to MAXMONST+8)
128 * Returns no value. 141 * Returns no value.
129 */ 142 */
130void 143void
131createmonster(mon) 144createmonster(mon)
132 int mon; 145 int mon;
133{ 146{
134 int x, y, k, i; 147 int x, y, k, i;
@@ -264,27 +277,27 @@ over: lprcat(aborted); @@ -264,27 +277,27 @@ over: lprcat(aborted);
264 } 277 }
265 if (j == -1) 278 if (j == -1)
266 lprcat(" Nothing Happened "); 279 lprcat(" Nothing Happened ");
267 bottomline(); 280 bottomline();
268} 281}
269 282
270/* 283/*
271 * speldamage(x) Function to perform spell functions cast by the player 284 * speldamage(x) Function to perform spell functions cast by the player
272 * int x; 285 * int x;
273 * 286 *
274 * Enter with the spell number, returns no value. 287 * Enter with the spell number, returns no value.
275 * Please insure that there are 2 spaces before all messages here 288 * Please insure that there are 2 spaces before all messages here
276 */ 289 */
277void 290static void
278speldamage(int x) 291speldamage(int x)
279{ 292{
280 int i, j, clev; 293 int i, j, clev;
281 int xl, xh, yl, yh; 294 int xl, xh, yl, yh;
282 u_char *p, *kn, *pm; 295 u_char *p, *kn, *pm;
283 296
284 if (x >= SPNUM) 297 if (x >= SPNUM)
285 return; /* no such spell */ 298 return; /* no such spell */
286 if (c[TIMESTOP]) { 299 if (c[TIMESTOP]) {
287 lprcat(" It didn't seem to work"); 300 lprcat(" It didn't seem to work");
288 return; 301 return;
289 } /* not if time stopped */ 302 } /* not if time stopped */
290 clev = c[LEVEL]; 303 clev = c[LEVEL];
@@ -629,103 +642,103 @@ speldamage(int x) @@ -629,103 +642,103 @@ speldamage(int x)
629 642
630 default: 643 default:
631 lprintf(" spell %ld not available!", (long) x); 644 lprintf(" spell %ld not available!", (long) x);
632 beep(); 645 beep();
633 return; 646 return;
634 }; 647 };
635} 648}
636 649
637/* 650/*
638 * loseint() Routine to subtract 1 from your int (intelligence) if > 3 651 * loseint() Routine to subtract 1 from your int (intelligence) if > 3
639 * 652 *
640 * No arguments and no return value 653 * No arguments and no return value
641 */ 654 */
642void 655static void
643loseint() 656loseint()
644{ 657{
645 if (--c[INTELLIGENCE] < 3) 658 if (--c[INTELLIGENCE] < 3)
646 c[INTELLIGENCE] = 3; 659 c[INTELLIGENCE] = 3;
647} 660}
648 661
649/* 662/*
650 * isconfuse() Routine to check to see if player is confused 663 * isconfuse() Routine to check to see if player is confused
651 * 664 *
652 * This routine prints out a message saying "You can't aim your magic!" 665 * This routine prints out a message saying "You can't aim your magic!"
653 * returns 0 if not confused, non-zero (time remaining confused) if confused 666 * returns 0 if not confused, non-zero (time remaining confused) if confused
654 */ 667 */
655int 668static int
656isconfuse() 669isconfuse()
657{ 670{
658 if (c[CONFUSE]) { 671 if (c[CONFUSE]) {
659 lprcat(" You can't aim your magic!"); 672 lprcat(" You can't aim your magic!");
660 beep(); 673 beep();
661 } 674 }
662 return (c[CONFUSE]); 675 return (c[CONFUSE]);
663} 676}
664 677
665/* 678/*
666 * nospell(x,monst) Routine to return 1 if a spell doesn't affect a monster 679 * nospell(x,monst) Routine to return 1 if a spell doesn't affect a monster
667 * int x,monst; 680 * int x,monst;
668 * 681 *
669 * Subroutine to return 1 if the spell can't affect the monster 682 * Subroutine to return 1 if the spell can't affect the monster
670 * otherwise returns 0 683 * otherwise returns 0
671 * Enter with the spell number in x, and the monster number in monst. 684 * Enter with the spell number in x, and the monster number in monst.
672 */ 685 */
673int 686static int
674nospell(x, monst) 687nospell(x, monst)
675 int x, monst; 688 int x, monst;
676{ 689{
677 int tmp; 690 int tmp;
678 if (x >= SPNUM || monst >= MAXMONST + 8 || monst < 0 || x < 0) 691 if (x >= SPNUM || monst >= MAXMONST + 8 || monst < 0 || x < 0)
679 return (0); /* bad spell or monst */ 692 return (0); /* bad spell or monst */
680 if ((tmp = spelweird[monst - 1][x]) == 0) 693 if ((tmp = spelweird[monst - 1][x]) == 0)
681 return (0); 694 return (0);
682 cursors(); 695 cursors();
683 lprc('\n'); 696 lprc('\n');
684 lprintf(spelmes[tmp], monster[monst].name); 697 lprintf(spelmes[tmp], monster[monst].name);
685 return (1); 698 return (1);
686} 699}
687 700
688/* 701/*
689 * fullhit(xx) Function to return full damage against a monster (aka web) 702 * fullhit(xx) Function to return full damage against a monster (aka web)
690 * int xx; 703 * int xx;
691 * 704 *
692 * Function to return hp damage to monster due to a number of full hits 705 * Function to return hp damage to monster due to a number of full hits
693 * Enter with the number of full hits being done 706 * Enter with the number of full hits being done
694 */ 707 */
695int 708static int
696fullhit(xx) 709fullhit(xx)
697 int xx; 710 int xx;
698{ 711{
699 int i; 712 int i;
700 if (xx < 0 || xx > 20) 713 if (xx < 0 || xx > 20)
701 return (0); /* fullhits are out of range */ 714 return (0); /* fullhits are out of range */
702 if (c[LANCEDEATH]) 715 if (c[LANCEDEATH])
703 return (10000); /* lance of death */ 716 return (10000); /* lance of death */
704 i = xx * ((c[WCLASS] >> 1) + c[STRENGTH] + c[STREXTRA] - c[HARDGAME] - 12 + c[MOREDAM]); 717 i = xx * ((c[WCLASS] >> 1) + c[STRENGTH] + c[STREXTRA] - c[HARDGAME] - 12 + c[MOREDAM]);
705 return ((i >= 1) ? i : xx); 718 return ((i >= 1) ? i : xx);
706} 719}
707 720
708/* 721/*
709 * direct(spnum,dam,str,arg) Routine to direct spell damage 1 square in 1 dir 722 * direct(spnum,dam,str,arg) Routine to direct spell damage 1 square in 1 dir
710 * int spnum,dam,arg; 723 * int spnum,dam,arg;
711 * char *str; 724 * char *str;
712 * 725 *
713 * Routine to ask for a direction to a spell and then hit the monster 726 * Routine to ask for a direction to a spell and then hit the monster
714 * Enter with the spell number in spnum, the damage to be done in dam, 727 * Enter with the spell number in spnum, the damage to be done in dam,
715 * lprintf format string in str, and lprintf's argument in arg. 728 * lprintf format string in str, and lprintf's argument in arg.
716 * Returns no value. 729 * Returns no value.
717 */ 730 */
718void 731static void
719direct(spnum, dam, str, arg) 732direct(spnum, dam, str, arg)
720 int spnum, dam, arg; 733 int spnum, dam, arg;
721 const char *str; 734 const char *str;
722{ 735{
723 int x, y; 736 int x, y;
724 int m; 737 int m;
725 if (spnum < 0 || spnum >= SPNUM || str == 0) 738 if (spnum < 0 || spnum >= SPNUM || str == 0)
726 return; /* bad arguments */ 739 return; /* bad arguments */
727 if (isconfuse()) 740 if (isconfuse())
728 return; 741 return;
729 dirsub(&x, &y); 742 dirsub(&x, &y);
730 m = mitem[x][y]; 743 m = mitem[x][y];
731 if (item[x][y] == OMIRROR) { 744 if (item[x][y] == OMIRROR) {
@@ -891,51 +904,51 @@ godirect(spnum, dam, str, delay, cshow) @@ -891,51 +904,51 @@ godirect(spnum, dam, str, delay, cshow)
891 }; 904 };
892 dam -= 3 + (c[HARDGAME] >> 1); 905 dam -= 3 + (c[HARDGAME] >> 1);
893 } 906 }
894} 907}
895 908
896/* 909/*
897 * ifblind(x,y) Routine to put "monster" or the monster name into lastmosnt 910 * ifblind(x,y) Routine to put "monster" or the monster name into lastmosnt
898 * int x,y; 911 * int x,y;
899 * 912 *
900 * Subroutine to copy the word "monster" into lastmonst if the player is blind 913 * Subroutine to copy the word "monster" into lastmonst if the player is blind
901 * Enter with the coordinates (x,y) of the monster 914 * Enter with the coordinates (x,y) of the monster
902 * Returns no value. 915 * Returns no value.
903 */ 916 */
904void 917static void
905ifblind(int x, int y) 918ifblind(int x, int y)
906{ 919{
907 const char *p; 920 const char *p;
908 921
909 vxy(&x, &y); /* verify correct x,y coordinates */ 922 vxy(&x, &y); /* verify correct x,y coordinates */
910 if (c[BLINDCOUNT]) { 923 if (c[BLINDCOUNT]) {
911 lastnum = 279; 924 lastnum = 279;
912 p = "monster"; 925 p = "monster";
913 } else { 926 } else {
914 lastnum = mitem[x][y]; 927 lastnum = mitem[x][y];
915 p = monster[lastnum].name; 928 p = monster[lastnum].name;
916 } 929 }
917 strcpy(lastmonst, p); 930 strcpy(lastmonst, p);
918} 931}
919 932
920/* 933/*
921 * tdirect(spnum) Routine to teleport away a monster 934 * tdirect(spnum) Routine to teleport away a monster
922 * int spnum; 935 * int spnum;
923 * 936 *
924 * Routine to ask for a direction to a spell and then teleport away monster 937 * Routine to ask for a direction to a spell and then teleport away monster
925 * Enter with the spell number that wants to teleport away 938 * Enter with the spell number that wants to teleport away
926 * Returns no value. 939 * Returns no value.
927 */ 940 */
928void 941static void
929tdirect(spnum) 942tdirect(spnum)
930 int spnum; 943 int spnum;
931{ 944{
932 int x, y; 945 int x, y;
933 int m; 946 int m;
934 if (spnum < 0 || spnum >= SPNUM) 947 if (spnum < 0 || spnum >= SPNUM)
935 return; /* bad args */ 948 return; /* bad args */
936 if (isconfuse()) 949 if (isconfuse())
937 return; 950 return;
938 dirsub(&x, &y); 951 dirsub(&x, &y);
939 if ((m = mitem[x][y]) == 0) { 952 if ((m = mitem[x][y]) == 0) {
940 lprcat(" There wasn't anything there!"); 953 lprcat(" There wasn't anything there!");
941 return; 954 return;
@@ -950,27 +963,27 @@ tdirect(spnum) @@ -950,27 +963,27 @@ tdirect(spnum)
950 mitem[x][y] = know[x][y] = 0; 963 mitem[x][y] = know[x][y] = 0;
951} 964}
952 965
953/* 966/*
954 * omnidirect(sp,dam,str) Routine to damage all monsters 1 square from player 967 * omnidirect(sp,dam,str) Routine to damage all monsters 1 square from player
955 * int sp,dam; 968 * int sp,dam;
956 * char *str; 969 * char *str;
957 * 970 *
958 * Routine to cast a spell and then hit the monster in all directions 971 * Routine to cast a spell and then hit the monster in all directions
959 * Enter with the spell number in sp, the damage done to wach square in dam, 972 * Enter with the spell number in sp, the damage done to wach square in dam,
960 * and the lprintf string to identify the spell in str. 973 * and the lprintf string to identify the spell in str.
961 * Returns no value. 974 * Returns no value.
962 */ 975 */
963void 976static void
964omnidirect(int spnum, int dam, const char *str) 977omnidirect(int spnum, int dam, const char *str)
965{ 978{
966 int x, y, m; 979 int x, y, m;
967 980
968 if (spnum < 0 || spnum >= SPNUM || str == 0) 981 if (spnum < 0 || spnum >= SPNUM || str == 0)
969 return; /* bad args */ 982 return; /* bad args */
970 for (x = playerx - 1; x < playerx + 2; x++) 983 for (x = playerx - 1; x < playerx + 2; x++)
971 for (y = playery - 1; y < playery + 2; y++) { 984 for (y = playery - 1; y < playery + 2; y++) {
972 if ((m = mitem[x][y]) != 0) { 985 if ((m = mitem[x][y]) != 0) {
973 if (nospell(spnum, m) == 0) { 986 if (nospell(spnum, m) == 0) {
974 ifblind(x, y); 987 ifblind(x, y);
975 cursors(); 988 cursors();
976 lprc('\n'); 989 lprc('\n');
@@ -1058,27 +1071,27 @@ vxy(x, y) @@ -1058,27 +1071,27 @@ vxy(x, y)
1058 flag++; 1071 flag++;
1059 } 1072 }
1060 return (flag); 1073 return (flag);
1061} 1074}
1062 1075
1063/* 1076/*
1064 * dirpoly(spnum) Routine to ask for a direction and polymorph a monst 1077 * dirpoly(spnum) Routine to ask for a direction and polymorph a monst
1065 * int spnum; 1078 * int spnum;
1066 * 1079 *
1067 * Subroutine to polymorph a monster and ask for the direction its in 1080 * Subroutine to polymorph a monster and ask for the direction its in
1068 * Enter with the spell number in spmun. 1081 * Enter with the spell number in spmun.
1069 * Returns no value. 1082 * Returns no value.
1070 */ 1083 */
1071void 1084static void
1072dirpoly(spnum) 1085dirpoly(spnum)
1073 int spnum; 1086 int spnum;
1074{ 1087{
1075 int x, y, m; 1088 int x, y, m;
1076 if (spnum < 0 || spnum >= SPNUM) 1089 if (spnum < 0 || spnum >= SPNUM)
1077 return; /* bad args */ 1090 return; /* bad args */
1078 if (isconfuse()) 1091 if (isconfuse())
1079 return; /* if he is confused, he can't aim his magic */ 1092 return; /* if he is confused, he can't aim his magic */
1080 dirsub(&x, &y); 1093 dirsub(&x, &y);
1081 if (mitem[x][y] == 0) { 1094 if (mitem[x][y] == 0) {
1082 lprcat(" There wasn't anything there!"); 1095 lprcat(" There wasn't anything there!");
1083 return; 1096 return;
1084 } 1097 }
@@ -1144,27 +1157,27 @@ hitmonster(x, y) @@ -1144,27 +1157,27 @@ hitmonster(x, y)
1144 mitem[x][y] = BAT; 1157 mitem[x][y] = BAT;
1145 know[x][y] = 0; 1158 know[x][y] = 0;
1146 } 1159 }
1147} 1160}
1148 1161
1149/* 1162/*
1150 * hitm(x,y,amt) Function to just hit a monster at a given coordinates 1163 * hitm(x,y,amt) Function to just hit a monster at a given coordinates
1151 * int x,y,amt; 1164 * int x,y,amt;
1152 * 1165 *
1153 * Returns the number of hitpoints the monster absorbed 1166 * Returns the number of hitpoints the monster absorbed
1154 * This routine is used to specifically damage a monster at a location (x,y) 1167 * This routine is used to specifically damage a monster at a location (x,y)
1155 * Called by hitmonster(x,y) 1168 * Called by hitmonster(x,y)
1156 */ 1169 */
1157int 1170static int
1158hitm(x, y, amt) 1171hitm(x, y, amt)
1159 int x, y; 1172 int x, y;
1160 int amt; 1173 int amt;
1161{ 1174{
1162 int monst; 1175 int monst;
1163 int hpoints, amt2; 1176 int hpoints, amt2;
1164 vxy(&x, &y); /* verify coordinates are within range */ 1177 vxy(&x, &y); /* verify coordinates are within range */
1165 amt2 = amt; /* save initial damage so we can return it */ 1178 amt2 = amt; /* save initial damage so we can return it */
1166 monst = mitem[x][y]; 1179 monst = mitem[x][y];
1167 if (c[HALFDAM]) 1180 if (c[HALFDAM])
1168 amt >>= 1; /* if half damage curse adjust damage points */ 1181 amt >>= 1; /* if half damage curse adjust damage points */
1169 if (amt <= 0) 1182 if (amt <= 0)
1170 amt2 = amt = 1; 1183 amt2 = amt = 1;
@@ -1857,27 +1870,27 @@ rmsphere(x, y) @@ -1857,27 +1870,27 @@ rmsphere(x, y)
1857 free((char *) sp); 1870 free((char *) sp);
1858 } 1871 }
1859 break; 1872 break;
1860 } 1873 }
1861 return (c[SPHCAST]); /* return number of spheres in the world */ 1874 return (c[SPHCAST]); /* return number of spheres in the world */
1862} 1875}
1863 1876
1864/* 1877/*
1865 * sphboom(x,y) Function to perform the effects of a sphere detonation 1878 * sphboom(x,y) Function to perform the effects of a sphere detonation
1866 * int x,y; 1879 * int x,y;
1867 * 1880 *
1868 * Enter with the coordinates of the blast, Returns no value 1881 * Enter with the coordinates of the blast, Returns no value
1869 */ 1882 */
1870void 1883static void
1871sphboom(x, y) 1884sphboom(x, y)
1872 int x, y; 1885 int x, y;
1873{ 1886{
1874 int i, j; 1887 int i, j;
1875 if (c[HOLDMONST]) 1888 if (c[HOLDMONST])
1876 c[HOLDMONST] = 1; 1889 c[HOLDMONST] = 1;
1877 if (c[CANCELLATION]) 1890 if (c[CANCELLATION])
1878 c[CANCELLATION] = 1; 1891 c[CANCELLATION] = 1;
1879 for (j = max(1, x - 2); j < min(x + 3, MAXX - 1); j++) 1892 for (j = max(1, x - 2); j < min(x + 3, MAXX - 1); j++)
1880 for (i = max(1, y - 2); i < min(y + 3, MAXY - 1); i++) { 1893 for (i = max(1, y - 2); i < min(y + 3, MAXY - 1); i++) {
1881 item[j][i] = mitem[j][i] = 0; 1894 item[j][i] = mitem[j][i] = 0;
1882 show1cell(j, i); 1895 show1cell(j, i);
1883 if (playerx == j && playery == i) { 1896 if (playerx == j && playery == i) {
@@ -1885,27 +1898,27 @@ sphboom(x, y) @@ -1885,27 +1898,27 @@ sphboom(x, y)
1885 beep(); 1898 beep();
1886 lprcat("\nYou were too close to the sphere!"); 1899 lprcat("\nYou were too close to the sphere!");
1887 nap(3000); 1900 nap(3000);
1888 died(283); /* player killed in explosion */ 1901 died(283); /* player killed in explosion */
1889 } 1902 }
1890 } 1903 }
1891} 1904}
1892 1905
1893/* 1906/*
1894 * genmonst() Function to ask for monster and genocide from game 1907 * genmonst() Function to ask for monster and genocide from game
1895 * 1908 *
1896 * This is done by setting a flag in the monster[] structure 1909 * This is done by setting a flag in the monster[] structure
1897 */ 1910 */
1898void 1911static void
1899genmonst() 1912genmonst()
1900{ 1913{
1901 int i, j; 1914 int i, j;
1902 cursors(); 1915 cursors();
1903 lprcat("\nGenocide what monster? "); 1916 lprcat("\nGenocide what monster? ");
1904 for (i = 0; (!isalpha(i)) && (i != ' '); i = ttgetch()); 1917 for (i = 0; (!isalpha(i)) && (i != ' '); i = ttgetch());
1905 lprc(i); 1918 lprc(i);
1906 for (j = 0; j < MAXMONST; j++) /* search for the monster type */ 1919 for (j = 0; j < MAXMONST; j++) /* search for the monster type */
1907 if (monstnamelist[j] == i) { /* have we found it? */ 1920 if (monstnamelist[j] == i) { /* have we found it? */
1908 monster[j].genocided = 1; /* genocided from game */ 1921 monster[j].genocided = 1; /* genocided from game */
1909 lprintf(" There will be no more %s's", monster[j].name); 1922 lprintf(" There will be no more %s's", monster[j].name);
1910 /* now wipe out monsters on this level */ 1923 /* now wipe out monsters on this level */
1911 newcavelevel(level); 1924 newcavelevel(level);

cvs diff -r1.14 -r1.15 src/games/larn/object.c (expand / switch to unified diff)

--- src/games/larn/object.c 2008/02/04 01:07:01 1.14
+++ src/games/larn/object.c 2009/08/12 08:04:05 1.15
@@ -1,24 +1,39 @@ @@ -1,24 +1,39 @@
1/* $NetBSD: object.c,v 1.14 2008/02/04 01:07:01 dholland Exp $ */ 1/* $NetBSD: object.c,v 1.15 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* object.c Larn is copyrighted 1986 by Noah Morgan. */ 3/* object.c Larn is copyrighted 1986 by Noah Morgan. */
4 4
5#include <sys/cdefs.h> 5#include <sys/cdefs.h>
6#ifndef lint 6#ifndef lint
7__RCSID("$NetBSD: object.c,v 1.14 2008/02/04 01:07:01 dholland Exp $"); 7__RCSID("$NetBSD: object.c,v 1.15 2009/08/12 08:04:05 dholland Exp $");
8#endif /* not lint */ 8#endif /* not lint */
9#include "header.h" 9#include "header.h"
10#include "extern.h" 10#include "extern.h"
11 11
 12static void finditem(int);
 13static void ostairs(int);
 14static void opotion(int);
 15static void oscroll(int);
 16static void oorb(void);
 17static void opit(void);
 18static void obottomless(void);
 19static void oelevator(int);
 20static void ostatue(void);
 21static void omirror(void);
 22static void obook(void);
 23static void ocookie(void);
 24static void ogold(int);
 25static void ohome(void);
 26
12/* 27/*
13 lookforobject 28 lookforobject
14 29
15 subroutine to look for an object and give the player his options 30 subroutine to look for an object and give the player his options
16 if an object was found. 31 if an object was found.
17 */ 32 */
18void 33void
19lookforobject() 34lookforobject()
20{ 35{
21 int i, j; 36 int i, j;
22 if (c[TIMESTOP]) 37 if (c[TIMESTOP])
23 return; /* can't find objects if time is stopped */ 38 return; /* can't find objects if time is stopped */
24 i = item[playerx][playery]; 39 i = item[playerx][playery];
@@ -485,27 +500,27 @@ lookforobject() @@ -485,27 +500,27 @@ lookforobject()
485 else 500 else
486 lprcat(" stay here"); 501 lprcat(" stay here");
487 break; 502 break;
488 503
489 default: 504 default:
490 finditem(i); 505 finditem(i);
491 break; 506 break;
492 }; 507 };
493} 508}
494 509
495/* 510/*
496 function to say what object we found and ask if player wants to take it 511 function to say what object we found and ask if player wants to take it
497 */ 512 */
498void 513static void
499finditem(int theitem) 514finditem(int theitem)
500{ 515{
501 int tmp, i; 516 int tmp, i;
502 lprintf("\n\nYou have found %s ", objectname[theitem]); 517 lprintf("\n\nYou have found %s ", objectname[theitem]);
503 tmp = iarg[playerx][playery]; 518 tmp = iarg[playerx][playery];
504 switch (theitem) { 519 switch (theitem) {
505 case ODIAMOND: 520 case ODIAMOND:
506 case ORUBY: 521 case ORUBY:
507 case OEMERALD: 522 case OEMERALD:
508 case OSAPPHIRE: 523 case OSAPPHIRE:
509 case OSPIRITSCARAB: 524 case OSPIRITSCARAB:
510 case OORBOFDRAGON: 525 case OORBOFDRAGON:
511 case OCUBEofUNDEAD: 526 case OCUBEofUNDEAD:
@@ -528,27 +543,27 @@ finditem(int theitem) @@ -528,27 +543,27 @@ finditem(int theitem)
528 if (take(theitem, tmp) == 0) 543 if (take(theitem, tmp) == 0)
529 forget(); 544 forget();
530 return; 545 return;
531 } 546 }
532 ignore(); 547 ignore();
533} 548}
534 549
535 550
536 551
537/* 552/*
538 subroutine to process the stair cases 553 subroutine to process the stair cases
539 if dir > 0 the up else down 554 if dir > 0 the up else down
540 */ 555 */
541void 556static void
542ostairs(dir) 557ostairs(dir)
543 int dir; 558 int dir;
544{ 559{
545 int k; 560 int k;
546 lprcat("\nDo you (s) stay here "); 561 lprcat("\nDo you (s) stay here ");
547 if (dir > 0) 562 if (dir > 0)
548 lprcat("(u) go up "); 563 lprcat("(u) go up ");
549 else 564 else
550 lprcat("(d) go down "); 565 lprcat("(d) go down ");
551 lprcat("or (f) kick stairs? "); 566 lprcat("or (f) kick stairs? ");
552 567
553 while (1) 568 while (1)
554 switch (ttgetch()) { 569 switch (ttgetch()) {
@@ -631,27 +646,27 @@ oteleport(err) @@ -631,27 +646,27 @@ oteleport(err)
631 playerx = rnd(MAXX - 2); 646 playerx = rnd(MAXX - 2);
632 playery = rnd(MAXY - 2); 647 playery = rnd(MAXY - 2);
633 if (level != tmp) 648 if (level != tmp)
634 newcavelevel(tmp); 649 newcavelevel(tmp);
635 positionplayer(); 650 positionplayer();
636 draws(0, MAXX, 0, MAXY); 651 draws(0, MAXX, 0, MAXY);
637 bot_linex(); 652 bot_linex();
638} 653}
639 654
640 655
641/* 656/*
642 function to process a potion 657 function to process a potion
643 */ 658 */
644void 659static void
645opotion(pot) 660opotion(pot)
646 int pot; 661 int pot;
647{ 662{
648 lprcat("\nDo you (d) drink it, (t) take it"); 663 lprcat("\nDo you (d) drink it, (t) take it");
649 iopts(); 664 iopts();
650 while (1) 665 while (1)
651 switch (ttgetch()) { 666 switch (ttgetch()) {
652 case '\33': 667 case '\33':
653 case 'i': 668 case 'i':
654 ignore(); 669 ignore();
655 return; 670 return;
656 671
657 case 'd': 672 case 'd':
@@ -840,27 +855,27 @@ quaffpotion(pot) @@ -840,27 +855,27 @@ quaffpotion(pot)
840 lprcat("\nYou feel your vision sharpen"); /* see invisible */ 855 lprcat("\nYou feel your vision sharpen"); /* see invisible */
841 c[SEEINVISIBLE] += rnd(1000) + 400; 856 c[SEEINVISIBLE] += rnd(1000) + 400;
842 monstnamelist[INVISIBLESTALKER] = 'I'; 857 monstnamelist[INVISIBLESTALKER] = 'I';
843 return; 858 return;
844 }; 859 };
845 bottomline(); /* show new stats */ 860 bottomline(); /* show new stats */
846 return; 861 return;
847} 862}
848 863
849 864
850/* 865/*
851 function to process a magic scroll 866 function to process a magic scroll
852 */ 867 */
853void 868static void
854oscroll(typ) 869oscroll(typ)
855 int typ; 870 int typ;
856{ 871{
857 lprcat("\nDo you "); 872 lprcat("\nDo you ");
858 if (c[BLINDCOUNT] == 0) 873 if (c[BLINDCOUNT] == 0)
859 lprcat("(r) read it, "); 874 lprcat("(r) read it, ");
860 lprcat("(t) take it"); 875 lprcat("(t) take it");
861 iopts(); 876 iopts();
862 while (1) 877 while (1)
863 switch (ttgetch()) { 878 switch (ttgetch()) {
864 case '\33': 879 case '\33':
865 case 'i': 880 case 'i':
866 ignore(); 881 ignore();
@@ -890,27 +905,27 @@ oscroll(typ) @@ -890,27 +905,27 @@ oscroll(typ)
890 data for the function to read a scroll 905 data for the function to read a scroll
891 */ 906 */
892static int xh, yh, yl, xl; 907static int xh, yh, yl, xl;
893static u_char curse[] = { 908static u_char curse[] = {
894 BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING, 909 BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
895 LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM 910 LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM
896}; 911};
897 912
898static u_char exten[] = { 913static u_char exten[] = {
899 PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT, INVISIBILITY, 914 PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT, INVISIBILITY,
900 CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP 915 CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP
901}; 916};
902 917
903u_char time_change[] = { 918static u_char time_change[] = {
904 HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT, STRCOUNT, 919 HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT, STRCOUNT,
905 GIANTSTR, CHARMCOUNT, INVISIBILITY, CANCELLATION, HASTESELF, 920 GIANTSTR, CHARMCOUNT, INVISIBILITY, CANCELLATION, HASTESELF,
906 AGGRAVATE, SCAREMONST, STEALTH, AWARENESS, HOLDMONST, 921 AGGRAVATE, SCAREMONST, STEALTH, AWARENESS, HOLDMONST,
907 HASTEMONST, FIRERESISTANCE, GLOBE, SPIRITPRO, UNDEADPRO, 922 HASTEMONST, FIRERESISTANCE, GLOBE, SPIRITPRO, UNDEADPRO,
908 HALFDAM, SEEINVISIBLE, ITCHING, CLUMSINESS, WTW 923 HALFDAM, SEEINVISIBLE, ITCHING, CLUMSINESS, WTW
909}; 924};
910 925
911/* 926/*
912 * function to adjust time when time warping and taking courses in school 927 * function to adjust time when time warping and taking courses in school
913 */ 928 */
914void 929void
915adjusttime(tim) 930adjusttime(tim)
916 long tim; 931 long tim;
@@ -1072,32 +1087,32 @@ read_scroll(typ) @@ -1072,32 +1087,32 @@ read_scroll(typ)
1072 break; /* scroll of annihilation */ 1087 break; /* scroll of annihilation */
1073 1088
1074 case 22: 1089 case 22:
1075 godirect(22, 150, "The ray hits the %s", 0, ' '); /* pulverization */ 1090 godirect(22, 150, "The ray hits the %s", 0, ' '); /* pulverization */
1076 break; 1091 break;
1077 case 23: 1092 case 23:
1078 c[LIFEPROT]++; 1093 c[LIFEPROT]++;
1079 break; /* life protection */ 1094 break; /* life protection */
1080 }; 1095 };
1081} 1096}
1082 1097
1083 1098
1084 1099
1085void 1100static void
1086oorb() 1101oorb()
1087{ 1102{
1088} 1103}
1089 1104
1090void 1105static void
1091opit() 1106opit()
1092{ 1107{
1093 int i; 1108 int i;
1094 if (rnd(101) < 81) { 1109 if (rnd(101) < 81) {
1095 if (rnd(70) > 9 * c[DEXTERITY] - packweight() || rnd(101) < 5) { 1110 if (rnd(70) > 9 * c[DEXTERITY] - packweight() || rnd(101) < 5) {
1096 if (level == MAXLEVEL - 1) 1111 if (level == MAXLEVEL - 1)
1097 obottomless(); 1112 obottomless();
1098 else if (level == MAXLEVEL + MAXVLEVEL - 1) 1113 else if (level == MAXLEVEL + MAXVLEVEL - 1)
1099 obottomless(); 1114 obottomless();
1100 else { 1115 else {
1101 if (rnd(101) < 20) { 1116 if (rnd(101) < 20) {
1102 i = 0; 1117 i = 0;
1103 lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n"); 1118 lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n");
@@ -1106,56 +1121,57 @@ opit() @@ -1106,56 +1121,57 @@ opit()
1106 lprintf("\nYou fell into a pit! You suffer %ld hit points damage", (long) i); 1121 lprintf("\nYou fell into a pit! You suffer %ld hit points damage", (long) i);
1107 lastnum = 261; /* if he dies scoreboard 1122 lastnum = 261; /* if he dies scoreboard
1108 * will say so */ 1123 * will say so */
1109 } 1124 }
1110 losehp(i); 1125 losehp(i);
1111 nap(2000); 1126 nap(2000);
1112 newcavelevel(level + 1); 1127 newcavelevel(level + 1);
1113 draws(0, MAXX, 0, MAXY); 1128 draws(0, MAXX, 0, MAXY);
1114 } 1129 }
1115 } 1130 }
1116 } 1131 }
1117} 1132}
1118 1133
1119void 1134static void
1120obottomless() 1135obottomless()
1121{ 1136{
1122 lprcat("\nYou fell into a bottomless pit!"); 1137 lprcat("\nYou fell into a bottomless pit!");
1123 beep(); 1138 beep();
1124 nap(3000); 1139 nap(3000);
1125 died(262); 1140 died(262);
1126} 1141}
1127void 1142
 1143static void
1128oelevator(dir) 1144oelevator(dir)
1129 int dir; 1145 int dir;
1130{ 1146{
1131#ifdef lint 1147#ifdef lint
1132 int x; 1148 int x;
1133 x = dir; 1149 x = dir;
1134 dir = x; 1150 dir = x;
1135#endif /* lint */ 1151#endif /* lint */
1136} 1152}
1137 1153
1138void 1154static void
1139ostatue() 1155ostatue()
1140{ 1156{
1141} 1157}
1142 1158
1143void 1159static void
1144omirror() 1160omirror()
1145{ 1161{
1146} 1162}
1147 1163
1148void 1164static void
1149obook() 1165obook()
1150{ 1166{
1151 lprcat("\nDo you "); 1167 lprcat("\nDo you ");
1152 if (c[BLINDCOUNT] == 0) 1168 if (c[BLINDCOUNT] == 0)
1153 lprcat("(r) read it, "); 1169 lprcat("(r) read it, ");
1154 lprcat("(t) take it"); 1170 lprcat("(t) take it");
1155 iopts(); 1171 iopts();
1156 while (1) 1172 while (1)
1157 switch (ttgetch()) { 1173 switch (ttgetch()) {
1158 case '\33': 1174 case '\33':
1159 case 'i': 1175 case 'i':
1160 ignore(); 1176 ignore();
1161 return; 1177 return;
@@ -1187,27 +1203,27 @@ readbook(lev) @@ -1187,27 +1203,27 @@ readbook(lev)
1187 if (lev <= 3) 1203 if (lev <= 3)
1188 i = rund((tmp = splev[lev]) ? tmp : 1); 1204 i = rund((tmp = splev[lev]) ? tmp : 1);
1189 else 1205 else
1190 i = rnd((tmp = splev[lev] - 9) ? tmp : 1) + 9; 1206 i = rnd((tmp = splev[lev] - 9) ? tmp : 1) + 9;
1191 spelknow[i] = 1; 1207 spelknow[i] = 1;
1192 lprintf("\nSpell \"%s\": %s\n%s", spelcode[i], spelname[i], speldescript[i]); 1208 lprintf("\nSpell \"%s\": %s\n%s", spelcode[i], spelname[i], speldescript[i]);
1193 if (rnd(10) == 4) { 1209 if (rnd(10) == 4) {
1194 lprcat("\nYour int went up by one!"); 1210 lprcat("\nYour int went up by one!");
1195 c[INTELLIGENCE]++; 1211 c[INTELLIGENCE]++;
1196 bottomline(); 1212 bottomline();
1197 } 1213 }
1198} 1214}
1199 1215
1200void 1216static void
1201ocookie(void) 1217ocookie(void)
1202{ 1218{
1203 const char *p; 1219 const char *p;
1204 1220
1205 lprcat("\nDo you (e) eat it, (t) take it"); 1221 lprcat("\nDo you (e) eat it, (t) take it");
1206 iopts(); 1222 iopts();
1207 while (1) 1223 while (1)
1208 switch (ttgetch()) { 1224 switch (ttgetch()) {
1209 case '\33': 1225 case '\33':
1210 case 'i': 1226 case 'i':
1211 ignore(); 1227 ignore();
1212 return; 1228 return;
1213 1229
@@ -1225,45 +1241,45 @@ ocookie(void) @@ -1225,45 +1241,45 @@ ocookie(void)
1225 case 't': 1241 case 't':
1226 lprcat("take"); 1242 lprcat("take");
1227 if (take(OCOOKIE, 0) == 0) 1243 if (take(OCOOKIE, 0) == 0)
1228 forget(); /* no more book */ 1244 forget(); /* no more book */
1229 return; 1245 return;
1230 }; 1246 };
1231} 1247}
1232 1248
1233 1249
1234/* 1250/*
1235 * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth 1251 * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
1236 * 100* the argument 1252 * 100* the argument
1237 */ 1253 */
1238void 1254static void
1239ogold(arg) 1255ogold(arg)
1240 int arg; 1256 int arg;
1241{ 1257{
1242 long i; 1258 long i;
1243 i = iarg[playerx][playery]; 1259 i = iarg[playerx][playery];
1244 if (arg == OMAXGOLD) 1260 if (arg == OMAXGOLD)
1245 i *= 100; 1261 i *= 100;
1246 else if (arg == OKGOLD) 1262 else if (arg == OKGOLD)
1247 i *= 1000; 1263 i *= 1000;
1248 else if (arg == ODGOLD) 1264 else if (arg == ODGOLD)
1249 i *= 10; 1265 i *= 10;
1250 lprintf("\nIt is worth %ld!", (long) i); 1266 lprintf("\nIt is worth %ld!", (long) i);
1251 c[GOLD] += i; 1267 c[GOLD] += i;
1252 bottomgold(); 1268 bottomgold();
1253 item[playerx][playery] = know[playerx][playery] = 0; /* destroy gold */ 1269 item[playerx][playery] = know[playerx][playery] = 0; /* destroy gold */
1254} 1270}
1255 1271
1256void 1272static void
1257ohome() 1273ohome()
1258{ 1274{
1259 int i; 1275 int i;
1260 nosignal = 1; /* disable signals */ 1276 nosignal = 1; /* disable signals */
1261 for (i = 0; i < 26; i++) 1277 for (i = 0; i < 26; i++)
1262 if (iven[i] == OPOTION) 1278 if (iven[i] == OPOTION)
1263 if (ivenarg[i] == 21) { 1279 if (ivenarg[i] == 21) {
1264 iven[i] = 0; /* remove the potion of cure 1280 iven[i] = 0; /* remove the potion of cure
1265 * dianthroritis from 1281 * dianthroritis from
1266 * inventory */ 1282 * inventory */
1267 clear(); 1283 clear();
1268 lprcat("Congratulations. You found a potion of cure dianthroritis.\n"); 1284 lprcat("Congratulations. You found a potion of cure dianthroritis.\n");
1269 lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n"); 1285 lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n");

cvs diff -r1.14 -r1.15 src/games/larn/store.c (expand / switch to unified diff)

--- src/games/larn/store.c 2008/02/03 21:24:59 1.14
+++ src/games/larn/store.c 2009/08/12 08:04:05 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: store.c,v 1.14 2008/02/03 21:24:59 dholland Exp $ */ 1/* $NetBSD: store.c,v 1.15 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1988 The Regents of the University of California. 4 * Copyright (c) 1988 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,40 +24,42 @@ @@ -24,40 +24,42 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)store.c 5.4 (Berkeley) 5/13/91"; 35static char sccsid[] = "@(#)store.c 5.4 (Berkeley) 5/13/91";
36#else 36#else
37__RCSID("$NetBSD: store.c,v 1.14 2008/02/03 21:24:59 dholland Exp $"); 37__RCSID("$NetBSD: store.c,v 1.15 2009/08/12 08:04:05 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41/* store.c Larn is copyrighted 1986 by Noah Morgan. */ 41/* store.c Larn is copyrighted 1986 by Noah Morgan. */
42#include "header.h" 42#include "header.h"
43#include "extern.h" 43#include "extern.h"
44 44
45static void handsfull(void); 45static void handsfull(void);
46static void outofstock(void); 46static void outofstock(void);
47static void nogold(void); 47static void nogold(void);
48static void dnditem(int); 48static void dnditem(int);
49static void banktitle(const char *); 49static void banktitle(const char *);
 50static void obanksub(void);
50static void otradhead(void); 51static void otradhead(void);
 52static void cnsitm(void);
51 53
52static int dndcount = 0, dnditm = 0; 54static int dndcount = 0, dnditm = 0;
53 55
54/* number of items in the dnd inventory table */ 56/* number of items in the dnd inventory table */
55#define MAXITM 83 57#define MAXITM 83
56 58
57/* this is the data for the stuff in the dnd store */ 59/* this is the data for the stuff in the dnd store */
58struct _itm itm[90] = { 60struct _itm itm[90] = {
59 /* 61 /*
60 * cost iven name iven arg how gp 62 * cost iven name iven arg how gp
61 * iven[] ivenarg[] many 63 * iven[] ivenarg[] many
62 */ 64 */
63 65
@@ -179,36 +181,36 @@ struct _itm itm[90] = { @@ -179,36 +181,36 @@ struct _itm itm[90] = {
179 {500, OSCROLL, 16, 2}, 181 {500, OSCROLL, 16, 2},
180 {1000, OSCROLL, 17, 1}, 182 {1000, OSCROLL, 17, 1},
181 {500, OSCROLL, 18, 1}, 183 {500, OSCROLL, 18, 1},
182 {340, OSCROLL, 19, 2}, 184 {340, OSCROLL, 19, 2},
183 {220, OSCROLL, 20, 3}, 185 {220, OSCROLL, 20, 3},
184 {3900, OSCROLL, 21, 0}, 186 {3900, OSCROLL, 21, 0},
185 {610, OSCROLL, 22, 1}, 187 {610, OSCROLL, 22, 1},
186 {3000, OSCROLL, 23, 0} 188 {3000, OSCROLL, 23, 0}
187}; 189};
188 190
189/* 191/*
190 function for the dnd store 192 function for the dnd store
191 */ 193 */
192void 194static void
193dnd_2hed() 195dnd_2hed(void)
194{ 196{
195 lprcat("Welcome to the Larn Thrift Shoppe. We stock many items explorers find useful\n"); 197 lprcat("Welcome to the Larn Thrift Shoppe. We stock many items explorers find useful\n");
196 lprcat(" in their adventures. Feel free to browse to your hearts content.\n"); 198 lprcat(" in their adventures. Feel free to browse to your hearts content.\n");
197 lprcat("Also be advised, if you break 'em, you pay for 'em."); 199 lprcat("Also be advised, if you break 'em, you pay for 'em.");
198} 200}
199 201
200void 202static void
201dnd_hed() 203dnd_hed(void)
202{ 204{
203 int i; 205 int i;
204 for (i = dnditm; i < 26 + dnditm; i++) 206 for (i = dnditm; i < 26 + dnditm; i++)
205 dnditem(i); 207 dnditem(i);
206 cursor(50, 18); 208 cursor(50, 18);
207 lprcat("You have "); 209 lprcat("You have ");
208} 210}
209 211
210static void 212static void
211handsfull() 213handsfull()
212{ 214{
213 lprcat("\nYou can't carry anything more!"); 215 lprcat("\nYou can't carry anything more!");
214 lflush(); 216 lflush();
@@ -336,32 +338,32 @@ dnditem(i) @@ -336,32 +338,32 @@ dnditem(i)
336 lprintf("scroll of%s", scrollhide[itm[i].arg]); 338 lprintf("scroll of%s", scrollhide[itm[i].arg]);
337 } else 339 } else
338 lprintf("%s", objectname[itm[i].obj]); 340 lprintf("%s", objectname[itm[i].obj]);
339 cursor(j + 31, k); 341 cursor(j + 31, k);
340 lprintf("%6ld", (long) (itm[i].price * 10)); 342 lprintf("%6ld", (long) (itm[i].price * 10));
341} 343}
342 344
343 345
344 346
345/* 347/*
346 for the college of larn 348 for the college of larn
347 */ 349 */
348u_char course[26] = {0}; /* the list of courses taken */ 350u_char course[26] = {0}; /* the list of courses taken */
349char coursetime[] = {10, 15, 10, 20, 10, 10, 10, 5}; 351static char coursetime[] = {10, 15, 10, 20, 10, 10, 10, 5};
350/* 352/*
351 function to display the header info for the school 353 function to display the header info for the school
352 */ 354 */
353void 355static void
354sch_hed() 356sch_hed(void)
355{ 357{
356 clear(); 358 clear();
357 lprcat("The College of Larn offers the exciting opportunity of higher education to\n"); 359 lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
358 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n"); 360 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n");
359 lprcat("\t\t Course Name \t Time Needed\n\n"); 361 lprcat("\t\t Course Name \t Time Needed\n\n");
360 362
361 if (course[0] == 0) 363 if (course[0] == 0)
362 lprcat("\t\ta) Fighters Training I 10 mobuls"); /* line 7 of crt */ 364 lprcat("\t\ta) Fighters Training I 10 mobuls"); /* line 7 of crt */
363 lprc('\n'); 365 lprc('\n');
364 if (course[1] == 0) 366 if (course[1] == 0)
365 lprcat("\t\tb) Fighters Training II 15 mobuls"); 367 lprcat("\t\tb) Fighters Training II 15 mobuls");
366 lprc('\n'); 368 lprc('\n');
367 if (course[2] == 0) 369 if (course[2] == 0)
@@ -689,32 +691,32 @@ obanksub() @@ -689,32 +691,32 @@ obanksub()
689 } 691 }
690 break; 692 break;
691 693
692 case '\33': 694 case '\33':
693 return; 695 return;
694 }; 696 };
695 cursor(40, 17); 697 cursor(40, 17);
696 lprintf("%8ld", (long) c[BANKACCOUNT]); 698 lprintf("%8ld", (long) c[BANKACCOUNT]);
697 cursor(49, 18); 699 cursor(49, 18);
698 lprintf("%8ld", (long) c[GOLD]); 700 lprintf("%8ld", (long) c[GOLD]);
699 } 701 }
700} 702}
701 703
 704#if 0 /* XXX: apparently unused */
702/* 705/*
703 subroutine to appraise any stone for the bank 706 subroutine to appraise any stone for the bank
704 */ 707 */
705void 708static void
706appraise(gemstone) 709appraise(int gemstone)
707 int gemstone; 
708{ 710{
709 int j, amt; 711 int j, amt;
710 for (j = 0; j < 26; j++) 712 for (j = 0; j < 26; j++)
711 if (iven[j] == gemstone) { 713 if (iven[j] == gemstone) {
712 lprintf("\nI see you have %s", objectname[gemstone]); 714 lprintf("\nI see you have %s", objectname[gemstone]);
713 if (gemstone == OLARNEYE) 715 if (gemstone == OLARNEYE)
714 lprcat(" I must commend you. I didn't think\nyou could get it."); 716 lprcat(" I must commend you. I didn't think\nyou could get it.");
715 lprcat(" Shall I appraise it for you? "); 717 lprcat(" Shall I appraise it for you? ");
716 yrepcount = 0; 718 yrepcount = 0;
717 if (getyn() == 'y') { 719 if (getyn() == 'y') {
718 lprcat("yes.\n Just one moment please \n"); 720 lprcat("yes.\n Just one moment please \n");
719 nap(1000); 721 nap(1000);
720 if (gemstone == OLARNEYE) { 722 if (gemstone == OLARNEYE) {
@@ -728,26 +730,28 @@ appraise(gemstone) @@ -728,26 +730,28 @@ appraise(gemstone)
728 yrepcount = 0; 730 yrepcount = 0;
729 if (getyn() == 'y') { 731 if (getyn() == 'y') {
730 lprcat("yes\n"); 732 lprcat("yes\n");
731 c[GOLD] += amt; 733 c[GOLD] += amt;
732 iven[j] = 0; 734 iven[j] = 0;
733 } else 735 } else
734 lprcat("no thank you.\n"); 736 lprcat("no thank you.\n");
735 if (gemstone == OLARNEYE) 737 if (gemstone == OLARNEYE)
736 lprcat("It is, of course, your privilege to keep the stone\n"); 738 lprcat("It is, of course, your privilege to keep the stone\n");
737 } else 739 } else
738 lprcat("no\nO. K.\n"); 740 lprcat("no\nO. K.\n");
739 } 741 }
740} 742}
 743#endif /* 0 - unused */
 744
741/* 745/*
742 function for the trading post 746 function for the trading post
743 */ 747 */
744static void 748static void
745otradhead() 749otradhead()
746{ 750{
747 clear(); 751 clear();
748 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n"); 752 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n");
749 lprcat("useful. Since the condition of the items you bring in is not certain,\n"); 753 lprcat("useful. Since the condition of the items you bring in is not certain,\n");
750 lprcat("and we incur great expense in reconditioning the items, we usually pay\n"); 754 lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
751 lprcat("only 20% of their value were they to be new. If the items are badly\n"); 755 lprcat("only 20% of their value were they to be new. If the items are badly\n");
752 lprcat("damaged, we will pay only 10% of their new value.\n\n"); 756 lprcat("damaged, we will pay only 10% of their new value.\n\n");
753} 757}
@@ -829,28 +833,28 @@ otradepost() @@ -829,28 +833,28 @@ otradepost()
829 iven[isub] = 0; 833 iven[isub] = 0;
830 } else 834 } else
831 lprcat("no thanks.\n"); 835 lprcat("no thanks.\n");
832 j = MAXITM + 100; /* get out of the inner 836 j = MAXITM + 100; /* get out of the inner
833 * loop */ 837 * loop */
834 } 838 }
835 if (j <= MAXITM + 2) 839 if (j <= MAXITM + 2)
836 lprcat("\nSo sorry, but we are not authorized to accept that item."); 840 lprcat("\nSo sorry, but we are not authorized to accept that item.");
837 } 841 }
838 } 842 }
839 } 843 }
840} 844}
841 845
842void 846static void
843cnsitm() 847cnsitm(void)
844{ 848{
845 lprcat("\nSorry, we can't accept unidentified objects."); 849 lprcat("\nSorry, we can't accept unidentified objects.");
846} 850}
847 851
848/* 852/*
849 * for the Larn Revenue Service 853 * for the Larn Revenue Service
850 */ 854 */
851void 855void
852olrs() 856olrs()
853{ 857{
854 int i, first; 858 int i, first;
855 long amt; 859 long amt;
856 first = nosignal = 1; /* disable signals */ 860 first = nosignal = 1; /* disable signals */

cvs diff -r1.17 -r1.18 src/games/larn/scores.c (expand / switch to unified diff)

--- src/games/larn/scores.c 2008/02/03 20:41:53 1.17
+++ src/games/larn/scores.c 2009/08/12 08:04:05 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: scores.c,v 1.17 2008/02/03 20:41:53 dholland Exp $ */ 1/* $NetBSD: scores.c,v 1.18 2009/08/12 08:04:05 dholland Exp $ */
2 2
3/* 3/*
4 * scores.c Larn is copyrighted 1986 by Noah Morgan. 4 * scores.c Larn is copyrighted 1986 by Noah Morgan.
5 *  5 *
6 * Functions in this file are: 6 * Functions in this file are:
7 *  7 *
8 * readboard() Function to read in the scoreboard into a static buffer 8 * readboard() Function to read in the scoreboard into a static buffer
9 * writeboard() Function to write the scoreboard from readboard()'s buffer 9 * writeboard() Function to write the scoreboard from readboard()'s buffer
10 * makeboard() Function to create a new scoreboard (wipe out old one) 10 * makeboard() Function to create a new scoreboard (wipe out old one)
11 * hashewon() Function to return 1 if player has won a game before, else 0 11 * hashewon() Function to return 1 if player has won a game before, else 0
12 * long paytaxes(x) Function to pay taxes if any are due winshou() 12 * long paytaxes(x) Function to pay taxes if any are due winshou()
13 * ubroutine to print out the winning scoreboard shou(x) 13 * ubroutine to print out the winning scoreboard shou(x)
14 * ubroutine to print out the non-winners scoreboard showscores() 14 * ubroutine to print out the non-winners scoreboard showscores()
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * Function to show scores and the iven lists that go with them sortboard() 16 * Function to show scores and the iven lists that go with them sortboard()
17 * unction to sort the scoreboard newscore(score, whoo, whyded, winner) 17 * unction to sort the scoreboard newscore(score, whoo, whyded, winner)
18 * Function to add entry to scoreboard new1sub(score,i,whoo,taxes) 18 * Function to add entry to scoreboard new1sub(score,i,whoo,taxes)
19 * Subroutine to put player into a new2sub(score,i,whoo,whyded) 19 * Subroutine to put player into a new2sub(score,i,whoo,whyded)
20 * Subroutine to put player into a died(x) Subroutine to record who 20 * Subroutine to put player into a died(x) Subroutine to record who
21 * played larn, and what the score was diedsub(x) Subroutine to print out a 21 * played larn, and what the score was diedsub(x) Subroutine to print out a
22 * line showing player when he is killed diedlog() Subroutine to read a 22 * line showing player when he is killed diedlog() Subroutine to read a
23 * log file and print it out in ascii format getplid(name) 23 * log file and print it out in ascii format getplid(name)
24 * on to get players id # from id file 24 * on to get players id # from id file
25 *  25 *
26 */ 26 */
27#include <sys/cdefs.h> 27#include <sys/cdefs.h>
28#ifndef lint 28#ifndef lint
29__RCSID("$NetBSD: scores.c,v 1.17 2008/02/03 20:41:53 dholland Exp $"); 29__RCSID("$NetBSD: scores.c,v 1.18 2009/08/12 08:04:05 dholland Exp $");
30#endif /* not lint */ 30#endif /* not lint */
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/times.h> 32#include <sys/times.h>
33#include <sys/stat.h> 33#include <sys/stat.h>
34#include <stdio.h> 34#include <stdio.h>
35#include <string.h> 35#include <string.h>
36#include <unistd.h> 36#include <unistd.h>
37#include <stdlib.h> 37#include <stdlib.h>
38#include "header.h" 38#include "header.h"
39#include "extern.h" 39#include "extern.h"
40 40
41struct scofmt { /* This is the structure for the scoreboard */ 41struct scofmt { /* This is the structure for the scoreboard */
42 long score; /* the score of the player */ 42 long score; /* the score of the player */
@@ -92,59 +92,69 @@ static const char *whydead[] = { @@ -92,59 +92,69 @@ static const char *whydead[] = {
92 "a winner", "trapped in solid rock", "killed by a missing save file", 92 "a winner", "trapped in solid rock", "killed by a missing save file",
93 "killed by an old save file", "caught by the greedy cheater checker trap", 93 "killed by an old save file", "caught by the greedy cheater checker trap",
94 "killed by a protected save file", "killed his family and committed suicide", 94 "killed by a protected save file", "killed his family and committed suicide",
95 "erased by a wayward finger", "fell through a bottomless trap door", 95 "erased by a wayward finger", "fell through a bottomless trap door",
96 "fell through a trap door", "drank some poisonous water", 96 "fell through a trap door", "drank some poisonous water",
97 "fried by an electric shock", "slipped on a volcano shaft", 97 "fried by an electric shock", "slipped on a volcano shaft",
98 "killed by a stupid act of frustration", "attacked by a revolting demon", 98 "killed by a stupid act of frustration", "attacked by a revolting demon",
99 "hit by his own magic", "demolished by an unseen attacker", 99 "hit by his own magic", "demolished by an unseen attacker",
100 "fell into the dreadful sleep", "killed by an exploding chest", 100 "fell into the dreadful sleep", "killed by an exploding chest",
101 /* 26 */ "killed by a missing maze data file", "annihilated in a sphere", 101 /* 26 */ "killed by a missing maze data file", "annihilated in a sphere",
102 "died a post mortem death", "wasted by a malloc() failure" 102 "died a post mortem death", "wasted by a malloc() failure"
103}; 103};
104 104
 105static int readboard(void);
 106static int writeboard(void);
 107static int winshou(void);
 108static int shou(int);
 109static int sortboard(void);
 110static void newscore(long, char *, int, int);
 111static void new1sub(long, int, char *, long);
 112static void new2sub(long, int, char *, int);
 113static void diedsub(int);
 114
105/* 115/*
106 * readboard() Function to read in the scoreboard into a static buffer 116 * readboard() Function to read in the scoreboard into a static buffer
107 * 117 *
108 * returns -1 if unable to read in the scoreboard, returns 0 if all is OK 118 * returns -1 if unable to read in the scoreboard, returns 0 if all is OK
109 */ 119 */
110int 120static int
111readboard() 121readboard()
112{ 122{
113 int i; 123 int i;
114 124
115 if (gid != egid) 125 if (gid != egid)
116 setegid(egid); 126 setegid(egid);
117 i = lopen(scorefile); 127 i = lopen(scorefile);
118 if (gid != egid) 128 if (gid != egid)
119 setegid(gid); 129 setegid(gid);
120 if (i < 0) { 130 if (i < 0) {
121 lprcat("Can't read scoreboard\n"); 131 lprcat("Can't read scoreboard\n");
122 lflush(); 132 lflush();
123 return (-1); 133 return (-1);
124 } 134 }
125 lrfill((char *) sco, sizeof(sco)); 135 lrfill((char *) sco, sizeof(sco));
126 lrfill((char *) winr, sizeof(winr)); 136 lrfill((char *) winr, sizeof(winr));
127 lrclose(); 137 lrclose();
128 lcreat((char *) 0); 138 lcreat((char *) 0);
129 return (0); 139 return (0);
130} 140}
131 141
132/* 142/*
133 * writeboard() Function to write the scoreboard from readboard()'s buffer 143 * writeboard() Function to write the scoreboard from readboard()'s buffer
134 * 144 *
135 * returns -1 if unable to write the scoreboard, returns 0 if all is OK 145 * returns -1 if unable to write the scoreboard, returns 0 if all is OK
136 */ 146 */
137int 147static int
138writeboard() 148writeboard()
139{ 149{
140 int i; 150 int i;
141 151
142 set_score_output(); 152 set_score_output();
143 if (gid != egid) 153 if (gid != egid)
144 setegid(egid); 154 setegid(egid);
145 i = lcreat(scorefile); 155 i = lcreat(scorefile);
146 if (gid != egid) 156 if (gid != egid)
147 setegid(gid); 157 setegid(gid);
148 if (i < 0) { 158 if (i < 0) {
149 lprcat("Can't write scoreboard\n"); 159 lprcat("Can't write scoreboard\n");
150 lflush(); 160 lflush();
@@ -236,27 +246,27 @@ paytaxes(x) @@ -236,27 +246,27 @@ paytaxes(x)
236 set_score_output(); 246 set_score_output();
237 if (writeboard() < 0) 247 if (writeboard() < 0)
238 return (0); 248 return (0);
239 return (amt); 249 return (amt);
240 } 250 }
241 return (0L); /* couldn't find user on winning scoreboard */ 251 return (0L); /* couldn't find user on winning scoreboard */
242} 252}
243 253
244/* 254/*
245 * winshou() Subroutine to print out the winning scoreboard 255 * winshou() Subroutine to print out the winning scoreboard
246 * 256 *
247 * Returns the number of players on scoreboard that were shown 257 * Returns the number of players on scoreboard that were shown
248 */ 258 */
249int 259static int
250winshou() 260winshou()
251{ 261{
252 struct wscofmt *p; 262 struct wscofmt *p;
253 int i, j, count; 263 int i, j, count;
254 for (count = j = i = 0; i < SCORESIZE; i++) /* is there anyone on 264 for (count = j = i = 0; i < SCORESIZE; i++) /* is there anyone on
255 * the scoreboard? */ 265 * the scoreboard? */
256 if (winr[i].score != 0) { 266 if (winr[i].score != 0) {
257 j++; 267 j++;
258 break; 268 break;
259 } 269 }
260 if (j) { 270 if (j) {
261 lprcat("\n Score Difficulty Time Needed Larn Winners List\n"); 271 lprcat("\n Score Difficulty Time Needed Larn Winners List\n");
262 272
@@ -275,27 +285,27 @@ winshou() @@ -275,27 +285,27 @@ winshou()
275 } 285 }
276 } 286 }
277 } 287 }
278 return (count); /* return number of people on scoreboard */ 288 return (count); /* return number of people on scoreboard */
279} 289}
280 290
281/* 291/*
282 * shou(x) Subroutine to print out the non-winners scoreboard 292 * shou(x) Subroutine to print out the non-winners scoreboard
283 * int x; 293 * int x;
284 * 294 *
285 * Enter with 0 to list the scores, enter with 1 to list inventories too 295 * Enter with 0 to list the scores, enter with 1 to list inventories too
286 * Returns the number of players on scoreboard that were shown 296 * Returns the number of players on scoreboard that were shown
287 */ 297 */
288int 298static int
289shou(x) 299shou(x)
290 int x; 300 int x;
291{ 301{
292 int i, j, n, k; 302 int i, j, n, k;
293 int count; 303 int count;
294 for (count = j = i = 0; i < SCORESIZE; i++) /* is the scoreboard 304 for (count = j = i = 0; i < SCORESIZE; i++) /* is the scoreboard
295 * empty? */ 305 * empty? */
296 if (sco[i].score != 0) { 306 if (sco[i].score != 0) {
297 j++; 307 j++;
298 break; 308 break;
299 } 309 }
300 if (j) { 310 if (j) {
301 lprcat("\n Score Difficulty Larn Visitor Log\n"); 311 lprcat("\n Score Difficulty Larn Visitor Log\n");
@@ -380,27 +390,27 @@ showallscores() @@ -380,27 +390,27 @@ showallscores()
380 j = shou(1); 390 j = shou(1);
381 if (i + j == 0) 391 if (i + j == 0)
382 lprcat(esb); 392 lprcat(esb);
383 else 393 else
384 lprc('\n'); 394 lprc('\n');
385 lflush(); 395 lflush();
386} 396}
387 397
388/* 398/*
389 * sortboard() Function to sort the scoreboard 399 * sortboard() Function to sort the scoreboard
390 * 400 *
391 * Returns 0 if no sorting done, else returns 1 401 * Returns 0 if no sorting done, else returns 1
392 */ 402 */
393int 403static int
394sortboard() 404sortboard()
395{ 405{
396 int i, j = 0, pos; 406 int i, j = 0, pos;
397 long jdat; 407 long jdat;
398 for (i = 0; i < SCORESIZE; i++) 408 for (i = 0; i < SCORESIZE; i++)
399 sco[i].order = winr[i].order = -1; 409 sco[i].order = winr[i].order = -1;
400 pos = 0; 410 pos = 0;
401 while (pos < SCORESIZE) { 411 while (pos < SCORESIZE) {
402 jdat = 0; 412 jdat = 0;
403 for (i = 0; i < SCORESIZE; i++) 413 for (i = 0; i < SCORESIZE; i++)
404 if ((sco[i].order < 0) && (sco[i].score >= jdat)) { 414 if ((sco[i].order < 0) && (sco[i].score >= jdat)) {
405 j = i; 415 j = i;
406 jdat = sco[i].score; 416 jdat = sco[i].score;
@@ -419,27 +429,27 @@ sortboard() @@ -419,27 +429,27 @@ sortboard()
419 } 429 }
420 return (1); 430 return (1);
421} 431}
422 432
423/* 433/*
424 * newscore(score, whoo, whyded, winner) Function to add entry to scoreboard 434 * newscore(score, whoo, whyded, winner) Function to add entry to scoreboard
425 * int score, winner, whyded; 435 * int score, winner, whyded;
426 * char *whoo; 436 * char *whoo;
427 * 437 *
428 * Enter with the total score in gp in score, players name in whoo, 438 * Enter with the total score in gp in score, players name in whoo,
429 * died() reason # in whyded, and TRUE/FALSE in winner if a winner 439 * died() reason # in whyded, and TRUE/FALSE in winner if a winner
430 * ex. newscore(1000, "player 1", 32, 0); 440 * ex. newscore(1000, "player 1", 32, 0);
431 */ 441 */
432void 442static void
433newscore(score, whoo, whyded, winner) 443newscore(score, whoo, whyded, winner)
434 long score; 444 long score;
435 int winner, whyded; 445 int winner, whyded;
436 char *whoo; 446 char *whoo;
437{ 447{
438 int i; 448 int i;
439 long taxes; 449 long taxes;
440 if (readboard() < 0) 450 if (readboard() < 0)
441 return; /* do the scoreboard */ 451 return; /* do the scoreboard */
442 /* if a winner then delete all non-winning scores */ 452 /* if a winner then delete all non-winning scores */
443 if (cheat) 453 if (cheat)
444 winner = 0; /* if he cheated, don't let him win */ 454 winner = 0; /* if he cheated, don't let him win */
445 if (winner) { 455 if (winner) {
@@ -488,54 +498,54 @@ newscore(score, whoo, whyded, winner) @@ -488,54 +498,54 @@ newscore(score, whoo, whyded, winner)
488 } 498 }
489} 499}
490 500
491/* 501/*
492 * new1sub(score,i,whoo,taxes) Subroutine to put player into a 502 * new1sub(score,i,whoo,taxes) Subroutine to put player into a
493 * int score,i,whyded,taxes; winning scoreboard entry if his score 503 * int score,i,whyded,taxes; winning scoreboard entry if his score
494 * char *whoo; is high enough 504 * char *whoo; is high enough
495 * 505 *
496 * Enter with the total score in gp in score, players name in whoo, 506 * Enter with the total score in gp in score, players name in whoo,
497 * died() reason # in whyded, and TRUE/FALSE in winner if a winner 507 * died() reason # in whyded, and TRUE/FALSE in winner if a winner
498 * slot in scoreboard in i, and the tax bill in taxes. 508 * slot in scoreboard in i, and the tax bill in taxes.
499 * Returns nothing of value 509 * Returns nothing of value
500 */ 510 */
501void 511static void
502new1sub(score, i, whoo, taxes) 512new1sub(score, i, whoo, taxes)
503 long score, taxes; 513 long score, taxes;
504 int i; 514 int i;
505 char *whoo; 515 char *whoo;
506{ 516{
507 struct wscofmt *p; 517 struct wscofmt *p;
508 p = &winr[i]; 518 p = &winr[i];
509 p->taxes += taxes; 519 p->taxes += taxes;
510 if ((score >= p->score) || (c[HARDGAME] > p->hardlev)) { 520 if ((score >= p->score) || (c[HARDGAME] > p->hardlev)) {
511 strcpy(p->who, whoo); 521 strcpy(p->who, whoo);
512 p->score = score; 522 p->score = score;
513 p->hardlev = c[HARDGAME]; 523 p->hardlev = c[HARDGAME];
514 p->suid = userid; 524 p->suid = userid;
515 p->timeused = gltime / 100; 525 p->timeused = gltime / 100;
516 } 526 }
517} 527}
518 528
519/* 529/*
520 * new2sub(score,i,whoo,whyded) Subroutine to put player into a 530 * new2sub(score,i,whoo,whyded) Subroutine to put player into a
521 * int score,i,whyded,taxes; non-winning scoreboard entry if his 531 * int score,i,whyded,taxes; non-winning scoreboard entry if his
522 * char *whoo; score is high enough 532 * char *whoo; score is high enough
523 * 533 *
524 * Enter with the total score in gp in score, players name in whoo, 534 * Enter with the total score in gp in score, players name in whoo,
525 * died() reason # in whyded, and slot in scoreboard in i. 535 * died() reason # in whyded, and slot in scoreboard in i.
526 * Returns nothing of value 536 * Returns nothing of value
527 */ 537 */
528void 538static void
529new2sub(score, i, whoo, whyded) 539new2sub(score, i, whoo, whyded)
530 long score; 540 long score;
531 int i, whyded; 541 int i, whyded;
532 char *whoo; 542 char *whoo;
533{ 543{
534 int j; 544 int j;
535 struct scofmt *p; 545 struct scofmt *p;
536 p = &sco[i]; 546 p = &sco[i];
537 if ((score >= p->score) || (c[HARDGAME] > p->hardlev)) { 547 if ((score >= p->score) || (c[HARDGAME] > p->hardlev)) {
538 strcpy(p->who, whoo); 548 strcpy(p->who, whoo);
539 p->score = score; 549 p->score = score;
540 p->what = whyded; 550 p->what = whyded;
541 p->hardlev = c[HARDGAME]; 551 p->hardlev = c[HARDGAME];
@@ -722,27 +732,27 @@ invalid: @@ -722,27 +732,27 @@ invalid:
722 if ((x == 256) || (x == 257) || (f != 0)) 732 if ((x == 256) || (x == 257) || (f != 0))
723 exit(0); 733 exit(0);
724 if (scorerror == 0) 734 if (scorerror == 0)
725 showscores(); /* if we updated the scoreboard */ 735 showscores(); /* if we updated the scoreboard */
726 if (x == 263) 736 if (x == 263)
727 mailbill(); 737 mailbill();
728 exit(0); 738 exit(0);
729} 739}
730 740
731/* 741/*
732 * diedsub(x) Subroutine to print out the line showing the player when he is killed 742 * diedsub(x) Subroutine to print out the line showing the player when he is killed
733 * int x; 743 * int x;
734 */ 744 */
735void 745static void
736diedsub(int x) 746diedsub(int x)
737{ 747{
738 char ch; 748 char ch;
739 const char *mod; 749 const char *mod;
740 750
741 lprintf("Score: %ld, Diff: %ld, %s ", (long) c[GOLD], (long) c[HARDGAME], logname); 751 lprintf("Score: %ld, Diff: %ld, %s ", (long) c[GOLD], (long) c[HARDGAME], logname);
742 if (x < 256) { 752 if (x < 256) {
743 ch = *monster[x].name; 753 ch = *monster[x].name;
744 if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') 754 if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
745 mod = "an"; 755 mod = "an";
746 else 756 else
747 mod = "a"; 757 mod = "a";
748 lprintf("killed by %s %s", mod, monster[x].name); 758 lprintf("killed by %s %s", mod, monster[x].name);