From 5ea03b339fcda6dd5297d9b15ce18c3fcff44c1e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Oct 2023 16:39:44 +0200 Subject: [PATCH] fixed problem with retrieving mass from a former dude actor in actFireVector. This was accessing undefined memory because the new metadata no longer had the field. Moved mass to BloodActor so that access remains safe and defined. This seems to be the only place where this happened. --- source/games/blood/src/actor.cpp | 15 ++++----------- wadsrc/static/zscript/games/blood/actors/dudes.zs | 1 - .../static/zscript/games/blood/actors/things.zs | 1 - wadsrc/static/zscript/games/blood/bloodactor.zs | 1 + 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 48a1bbae7..d5fe8ef46 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -1564,10 +1564,9 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector if (actor->spr.flags & kPhysMove) { - double mass = 0; + double mass = actor->mass(); if (actor->IsDudeActor()) { - mass = actor->mass(); #ifdef NOONE_EXTENSIONS if (actor->GetType() == kDudeModernCustom || actor->GetType() == kDudeModernCustomBurning) { @@ -1575,11 +1574,7 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector } #endif } - else if (actor->GetType() >= kThingBase && actor->GetType() < kThingMax) - { - mass = actor->IntVar("mass"); - } - else + else if (actor->GetType() < kThingBase || actor->GetType() >= kThingMax) { Printf(PRINT_HIGH, "Unexpected type in ConcussSprite(): Sprite: %d Type: %d Stat: %d", actor->GetIndex(), (int)actor->GetType(), (int)actor->spr.statnum); return; @@ -5245,10 +5240,10 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3 actDamageSprite(shooter, actor, pVectorData->dmgType, pVectorData->dmg << shift); if (actor->hasX() && actor->xspr.Vector) trTriggerSprite(actor, kCmdSpriteImpact, shooter); + int mass = actor->mass(); if (actor->spr.statnum == kStatThing) { - int mass = actor->IntVar("mass"); if (mass > 0 && pVectorData->impulse) { double thrust = double(pVectorData->impulse) / (mass * 1024); @@ -5260,10 +5255,8 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3 actBurnSprite(shooter->GetOwner(), actor, pVectorData->burnTime); } } - if (actor->spr.statnum == kStatDude && actor->hasX()) + else if (actor->spr.statnum == kStatDude && actor->hasX()) { - int mass = actor->mass(); - #ifdef NOONE_EXTENSIONS if (actor->IsDudeActor()) { diff --git a/wadsrc/static/zscript/games/blood/actors/dudes.zs b/wadsrc/static/zscript/games/blood/actors/dudes.zs index 2823cf489..56de487a0 100644 --- a/wadsrc/static/zscript/games/blood/actors/dudes.zs +++ b/wadsrc/static/zscript/games/blood/actors/dudes.zs @@ -2,7 +2,6 @@ class BloodDudeBase : Bloodactor { meta int seqStartID; meta int starthealth; - meta int mass; meta int eyeHeight; meta int aimHeight; // used by just Cerberus meta double hearDist; diff --git a/wadsrc/static/zscript/games/blood/actors/things.zs b/wadsrc/static/zscript/games/blood/actors/things.zs index 105576833..87de2e419 100644 --- a/wadsrc/static/zscript/games/blood/actors/things.zs +++ b/wadsrc/static/zscript/games/blood/actors/things.zs @@ -1,7 +1,6 @@ class BloodThingBase : BloodActor { meta int defhealth; - meta int mass; meta int defflags; meta int bouncefactor; meta int dmgResist; diff --git a/wadsrc/static/zscript/games/blood/bloodactor.zs b/wadsrc/static/zscript/games/blood/bloodactor.zs index c770f8abf..145dafdb0 100644 --- a/wadsrc/static/zscript/games/blood/bloodactor.zs +++ b/wadsrc/static/zscript/games/blood/bloodactor.zs @@ -93,6 +93,7 @@ class BloodActor : CoreActor native meta int defshade; meta int defpal; meta double defclipdist; + meta int mass; // this must be here so access is defined for all classes. It can get read after a dude changes type! Property prefix: none; property shade: defshade; property pal: defpal;