From 5dd0a43bcab8b6ccae87897ebf41336f5f176054 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 17 Oct 2023 18:17:22 +0200 Subject: [PATCH] make sure that all places that read from SpriteMass ensure that the cache is up to date. This allows removing the serializer for it. --- source/games/blood/src/actor.cpp | 2 +- source/games/blood/src/loadsave.cpp | 3 +-- source/games/blood/src/nnexts.cpp | 24 +++--------------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index d875d28ef..1445418f3 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4660,7 +4660,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3 { if (actor->xspr.physAttr & kPhysDebrisVector) { - int mass = max(actor->spriteMass.mass, 10); + int mass = max(getSpriteMassBySize(actor), 10); double thrust = double(pVectorData->impulse) / (mass * 4096); actor->vel += dv * thrust; diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index de14a8a19..ff4e47ce6 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -544,8 +544,7 @@ void DBloodActor::Serialize(FSerializer& arc) #ifdef NOONE_EXTENSIONS if (gModernMap) { - arc//("spritemass", spriteMass) // should always be cached and not written out. - ("prevmarker", prevmarker) + arc("prevmarker", prevmarker) ("customdude", customDude) .Array("conditions", condition, 4); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 9fa2dc275..d288ebd60 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1785,9 +1785,10 @@ void debrisConcuss(DBloodActor* owneractor, DBloodActor* actor, const DVector3& double size = (tex->GetDisplayWidth() * actor->spr.scale.X * tex->GetDisplayHeight() * actor->spr.scale.Y) * 2048; if (actor->xspr.physAttr & kPhysDebrisExplode) { - if (actor->spriteMass.mass > 0) + int mass = getSpriteMassBySize(actor); + if (mass > 0) { - double t = double(dmg) * size / actor->spriteMass.mass; + double t = double(dmg) * size / mass; actor->vel += dv * t / (1 << 24); } @@ -8901,25 +8902,6 @@ int nnExtDudeStartHealth(DBloodActor* pSpr, int nHealth) return getDudeInfo(pSpr->GetType())->startHealth << 4; } -#if 0 // no need to save if we ensure it never gets accessed directly without validating the content -FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRITEMASS& w, SPRITEMASS* def) -{ - static SPRITEMASS nul; - if (arc.isReading()) w = {}; - if (arc.BeginObject(keyname)) - { - arc("seq", w.seqId, &nul.seqId) - ("texid", w.texid, &nul.texid) - ("scale", w.scale, &nul.scale) - ("clipdist", w.clipDist) - ("mass", w.mass) - ("airvel", w.airVel) - ("fraction", w.fraction) - .EndObject(); - } - return arc; -} -#endif void SerializeConditions(FSerializer& arc);