blob: a2aa5c44a6f9188cedecd89a46d3b96ab05b2c84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* $OpenBSD: savelev.c,v 1.2 1998/09/15 05:12:33 pjanzen Exp $ */
/* $NetBSD: savelev.c,v 1.4 1997/10/18 20:03:45 christos Exp $ */
/* savelev.c Larn is copyrighted 1986 by Noah Morgan. */
#ifndef lint
static char rcsid[] = "$OpenBSD: savelev.c,v 1.2 1998/09/15 05:12:33 pjanzen Exp $";
#endif /* not lint */
#include "header.h"
#include "extern.h"
/*
* routine to save the present level into storage
*/
void
savelevel()
{
struct cel *pcel;
char *pitem, *pknow, *pmitem;
short *phitp, *piarg;
struct cel *pecel;
pcel = &cell[level * MAXX * MAXY]; /* pointer to this level's
* cells */
pecel = pcel + MAXX * MAXY; /* pointer to past end of this
* level's cells */
pitem = item[0];
piarg = iarg[0];
pknow = know[0];
pmitem = mitem[0];
phitp = hitp[0];
while (pcel < pecel) {
pcel->mitem = *pmitem++;
pcel->hitp = *phitp++;
pcel->item = *pitem++;
pcel->know = *pknow++;
pcel++->iarg = *piarg++;
}
}
/*
* routine to restore a level from storage
*/
void
getlevel()
{
struct cel *pcel;
char *pitem, *pknow, *pmitem;
short *phitp, *piarg;
struct cel *pecel;
pcel = &cell[level * MAXX * MAXY]; /* pointer to this level's
* cells */
pecel = pcel + MAXX * MAXY; /* pointer to past end of this
* level's cells */
pitem = item[0];
piarg = iarg[0];
pknow = know[0];
pmitem = mitem[0];
phitp = hitp[0];
while (pcel < pecel) {
*pmitem++ = pcel->mitem;
*phitp++ = pcel->hitp;
*pitem++ = pcel->item;
*pknow++ = pcel->know;
*piarg++ = pcel++->iarg;
}
}
|