- Blood: always compare xsector and xwall serialization against a null base to reduce file size.

This commit is contained in:
Christoph Oelckers 2020-11-23 11:32:54 +01:00
parent 48049d5548
commit 88666c3e95
3 changed files with 16 additions and 8 deletions

View file

@ -47,9 +47,6 @@ XSPRITE xsprite[kMaxXSprites];
XSECTOR xsector[kMaxXSectors];
XWALL xwall[kMaxXWalls];
XSECTOR xsectorbackup[kMaxXSectors];
XWALL xwallbackup[kMaxXWalls];
SPRITEHIT gSpriteHit[kMaxXSprites];
int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites];
@ -1063,7 +1060,6 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
memcpy(wallbackup, wall, sizeof(wallbackup));
memcpy(sectorbackup, sector, sizeof(sectorbackup));
// todo: back up xsector and xwall as well
}

View file

@ -305,8 +305,6 @@ extern XSPRITE xsprite[kMaxXSprites];
extern XSECTOR xsector[kMaxXSectors];
extern XWALL xwall[kMaxXWalls];
extern XSECTOR xsectorbackup[kMaxXSectors];
extern XWALL xwallbackup[kMaxXWalls];
extern FixedBitArray<MAXSPRITES> activeXSprites;
extern SPRITEHIT gSpriteHit[kMaxXSprites];

View file

@ -438,6 +438,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, AISTATE*& w, AISTA
FSerializer& Serialize(FSerializer& arc, const char* keyname, XWALL& w, XWALL* def)
{
static XWALL nul;
if (!def)
{
def = &nul;
if (arc.isReading()) w = {};
}
if (arc.BeginObject(keyname))
{
arc("flags", w.flags, def->flags)
@ -461,6 +468,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, XWALL& w, XWALL* d
FSerializer& Serialize(FSerializer& arc, const char* keyname, XSECTOR& w, XSECTOR* def)
{
static XSECTOR nul;
if (!def)
{
def = &nul;
if (arc.isReading()) w = {};
}
if (arc.BeginObject(keyname))
{
arc("flags", w.flags, def->flags)
@ -632,8 +646,8 @@ void SerializeState(FSerializer& arc)
("numtiles", pSky->lognumtiles)
("gameoptions", gGameOptions)
.Array("xwall", xwall, xwallbackup, XWallsUsed) // todo
.Array("xsector", xsector, xsectorbackup, XSectorsUsed)
.Array("xwall", xwall, XWallsUsed) // todo
.Array("xsector", xsector, XSectorsUsed)
.SparseArray("xsprite", xsprite, kMaxXSprites, activeXSprites)
.SparseArray("xvel", xvel, kMaxSprites, activeSprites)
.SparseArray("yvel", yvel, kMaxSprites, activeSprites)