-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsavelev.c
82 lines (65 loc) · 1.38 KB
/
savelev.c
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* savelev.c */
#include "includes/larncons.h"
#include "includes/larndata.h"
#include "includes/larnfunc.h"
#include "includes/savelev.h"
/*
* routine to save the present level into storage
*/
void
savelevel (void)
{
struct cel *pcel;
int *pitem, *pknow, *pmitem;
int *phitp, *piarg;
struct cel *pecel;
/* pointer to this level's cells */
pcel = &cell[level * MAXX * MAXY];
/* pointer to past end of this level's cells */
pecel = pcel + MAXX * MAXY;
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++;
pcel++;
}
}
/*
* routine to restore a level from storage
*/
void
getlevel (void)
{
struct cel *pcel;
int *pitem;
int *pknow;
int *pmitem;
int *phitp, *piarg;
struct cel *pecel;
/* pointer to this level's cells */
pcel = &cell[level * MAXX * MAXY];
/* pointer to past end of this level's cells */
pecel = pcel + MAXX * MAXY;
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;
pcel++;
}
}