- minor savegame optimizations.

Do not write out empty elements of arrays where these are by far the most common ones.
This commit is contained in:
Christoph Oelckers 2020-11-22 12:48:01 +01:00
parent 1a588c3cbf
commit 751c295b62
3 changed files with 16 additions and 10 deletions

View file

@ -6956,11 +6956,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, POSTPONE& w, POSTP
FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRITEHIT& w, SPRITEHIT* def)
{
int empty = 0;
if (arc.isReading()) w = {};
if (arc.BeginObject(keyname))
{
arc("hit", w.hit)
("ceilhit", w.ceilhit)
("florhit", w.florhit)
arc("hit", w.hit, &empty)
("ceilhit", w.ceilhit, &empty)
("florhit", w.florhit, &empty)
.EndObject();
}
return arc;

View file

@ -1750,14 +1750,18 @@ void aiInitSprite(spritetype *pSprite)
FSerializer& Serialize(FSerializer& arc, const char* keyname, DUDEEXTRA& w, DUDEEXTRA* def)
{
int empty = 0;
char empty2 = 0;
if (arc.isReading()) w = {};
if (arc.BeginObject(keyname))
{
arc("time", w.time)
("recoil", w.recoil)
("prio", w.prio)
("x1", w.at6.u1.xval1)
("x2", w.at6.u1.xval2)
("x3", w.at6.u1.xval3)
arc("time", w.time, &empty)
("recoil", w.recoil, &empty)
("prio", w.prio, &empty)
("x1", w.at6.u1.xval1, &empty)
("x2", w.at6.u1.xval2, &empty)
("x3", w.at6.u1.xval3, &empty2)
.EndObject();
}
return arc;

View file

@ -1998,7 +1998,7 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
case kGenDudePropertyMass: {
// to ensure mass gets updated, let's clear all cache
SPRITEMASS* pMass = &gSpriteMass[pSprite->index];
SPRITEMASS* pMass = &gSpriteMass[pSprite->extra];
pMass->seqId = pMass->picnum = pMass->xrepeat = pMass->yrepeat = pMass->clipdist = 0;
pMass->mass = pMass->airVel = pMass->fraction = 0;
getSpriteMassBySize(pSprite);