- serialize null pointers correctly.

This commit is contained in:
Christoph Oelckers 2020-10-17 10:55:30 +02:00
parent 6f4a0c94e8
commit b1f2475230

View file

@ -42,10 +42,10 @@ extern FixedBitArray<MAXSPRITES> activeSprites;
template<> FSerializer& Serialize(FSerializer& arc, const char* key, Duke3d::weaponhit*& ht, Duke3d::weaponhit** def) template<> FSerializer& Serialize(FSerializer& arc, const char* key, Duke3d::weaponhit*& ht, Duke3d::weaponhit** def)
{ {
size_t index = ht - Duke3d::hittype; ptrdiff_t index = ht? ht - Duke3d::hittype : -1;
assert(index < MAXSPRITES); assert(index >= -1 && index < MAXSPRITES);
Serialize(arc, key, index, nullptr); Serialize(arc, key, index, nullptr);
ht = &Duke3d::hittype[index]; ht = index < 0? nullptr : &Duke3d::hittype[index];
return arc; return arc;
} }