- fixed loading of Blood savegames.

This was a strange case of C++ not doing what was to be expected due to hidden semantics.
Note: never assign {} to a type that has a non-default constructor!
Fixes #212
This commit is contained in:
Christoph Oelckers 2020-12-06 08:18:03 +01:00
parent d04013066c
commit 2f4abf93af
2 changed files with 6 additions and 3 deletions

View file

@ -25,7 +25,11 @@ public:
DBloodActor() :index(int(this - base())) { /*assert(index >= 0 && index < kMaxSprites);*/ }
DBloodActor& operator=(const DBloodActor& other) = default;
bool hasX() { return sprite[index].extra > 0; }
void Clear()
{
dudeSlope = 0;
}
bool hasX() { return sprite[index].extra > 0; }
spritetype& s() { return sprite[index]; }
XSPRITE& x() { return xsprite[sprite[index].extra]; } // calling this does not validate the xsprite!
SPRITEHIT& hit() { return gSpriteHit[sprite[index].extra]; }

View file

@ -443,12 +443,11 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, DBloodActor& w, DB
if (!def)
{
def = &nul;
if (arc.isReading()) w = {};
if (arc.isReading()) w.Clear();
}
if (arc.BeginObject(keyname))
{
// The rest is only relevant if the actor has an xsprite.
if (w.s().extra > 0)
{