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
|
static gzFile f = NULL;
bool demorecording = false;
bool demoplayback = false;
bool demoloading = false;
static OFMutableArray<DynamicEntity *> *playerhistory;
int democlientnum = 0;
void startdemo();
void
gzput(int i)
{
gzputc(f, i);
}
void
gzputi(int i)
{
gzwrite(f, &i, sizeof(int));
}
void
gzputv(OFVector3D &v)
{
gzwrite(f, &v, sizeof(OFVector3D));
}
void
gzcheck(int a, int b)
{
if (a != b)
fatal(@"savegame file corrupt (short)");
}
int
gzget()
{
char c = gzgetc(f);
return c;
}
int
gzgeti()
{
int i;
gzcheck(gzread(f, &i, sizeof(int)), sizeof(int));
return i;
}
void
gzgetv(OFVector3D &v)
{
gzcheck(gzread(f, &v, sizeof(OFVector3D)), sizeof(OFVector3D));
}
void
stop()
{
if (f) {
if (demorecording)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
static gzFile f = NULL;
bool demorecording = false;
bool demoplayback = false;
bool demoloading = false;
static OFMutableArray<DynamicEntity *> *playerhistory;
int democlientnum = 0;
extern void startdemo();
static void
gzput(int i)
{
gzputc(f, i);
}
static void
gzputi(int i)
{
gzwrite(f, &i, sizeof(int));
}
static void
gzputv(const OFVector3D *v)
{
gzwrite(f, v, sizeof(OFVector3D));
}
static void
gzcheck(int a, int b)
{
if (a != b)
fatal(@"savegame file corrupt (short)");
}
static int
gzget()
{
char c = gzgetc(f);
return c;
}
static int
gzgeti()
{
int i;
gzcheck(gzread(f, &i, sizeof(int)), sizeof(int));
return i;
}
static void
gzgetv(OFVector3D *v)
{
gzcheck(gzread(f, v, sizeof(OFVector3D)), sizeof(OFVector3D));
}
void
stop()
{
if (f) {
if (demorecording)
|
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
gzput(player1.armourtype);
loopi(NUMGUNS) gzput(player1.ammo[i]);
gzput(player1.state);
gzputi(bdamage);
bdamage = 0;
gzputi(ddamage);
if (ddamage) {
gzputv(dorig);
ddamage = 0;
}
// FIXME: add all other client state which is not send through
// the network
}
}
|
|
|
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
gzput(player1.armourtype);
loopi(NUMGUNS) gzput(player1.ammo[i]);
gzput(player1.state);
gzputi(bdamage);
bdamage = 0;
gzputi(ddamage);
if (ddamage) {
gzputv(&dorig);
ddamage = 0;
}
// FIXME: add all other client state which is not send through
// the network
}
}
|
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
target.armourtype = gzget();
loopi(NUMGUNS) target.ammo[i] = gzget();
target.state = gzget();
target.lastmove = playbacktime;
if ((bdamage = gzgeti()))
damageblend(bdamage);
if ((ddamage = gzgeti())) {
gzgetv(dorig);
particle_splash(3, ddamage, 1000, &dorig);
}
// FIXME: set more client state here
}
// insert latest copy of player into history
if (extras &&
|
|
|
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
target.armourtype = gzget();
loopi(NUMGUNS) target.ammo[i] = gzget();
target.state = gzget();
target.lastmove = playbacktime;
if ((bdamage = gzgeti()))
damageblend(bdamage);
if ((ddamage = gzgeti())) {
gzgetv(&dorig);
particle_splash(3, ddamage, 1000, &dorig);
}
// FIXME: set more client state here
}
// insert latest copy of player into history
if (extras &&
|