]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/savelev.c
oops, we do need privs. do the right seteuid() thing.
[bsdgames-darwin.git] / larn / savelev.c
1 #ifndef lint
2 static char rcsid[] = "$NetBSD: savelev.c,v 1.3 1995/03/23 08:34:13 cgd Exp $";
3 #endif /* not lint */
4
5 /* savelev.c Larn is copyrighted 1986 by Noah Morgan. */
6 #include "header.h"
7 extern struct cel *cell;
8
9 /*
10 * routine to save the present level into storage
11 */
12 savelevel()
13 {
14 register struct cel *pcel;
15 register char *pitem,*pknow,*pmitem;
16 register short *phitp,*piarg;
17 register struct cel *pecel;
18 pcel = &cell[level*MAXX*MAXY]; /* pointer to this level's cells */
19 pecel = pcel + MAXX*MAXY; /* pointer to past end of this level's cells */
20 pitem=item[0]; piarg=iarg[0]; pknow=know[0]; pmitem=mitem[0]; phitp=hitp[0];
21 while (pcel < pecel)
22 {
23 pcel->mitem = *pmitem++;
24 pcel->hitp = *phitp++;
25 pcel->item = *pitem++;
26 pcel->know = *pknow++;
27 pcel++->iarg = *piarg++;
28 }
29 }
30
31 /*
32 * routine to restore a level from storage
33 */
34 getlevel()
35 {
36 register struct cel *pcel;
37 register char *pitem,*pknow,*pmitem;
38 register short *phitp,*piarg;
39 register struct cel *pecel;
40 pcel = &cell[level*MAXX*MAXY]; /* pointer to this level's cells */
41 pecel = pcel + MAXX*MAXY; /* pointer to past end of this level's cells */
42 pitem=item[0]; piarg=iarg[0]; pknow=know[0]; pmitem=mitem[0]; phitp=hitp[0];
43 while (pcel < pecel)
44 {
45 *pmitem++ = pcel->mitem;
46 *phitp++ = pcel->hitp;
47 *pitem++ = pcel->item;
48 *pknow++ = pcel->know;
49 *piarg++ = pcel++->iarg;
50 }
51 }