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.
This commit is contained in:
Christoph Oelckers 2023-10-09 16:39:44 +02:00
parent 49ee6fcc30
commit 5ea03b339f
4 changed files with 5 additions and 13 deletions

View file

@ -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())
{

View file

@ -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;

View file

@ -1,7 +1,6 @@
class BloodThingBase : BloodActor
{
meta int defhealth;
meta int mass;
meta int defflags;
meta int bouncefactor;
meta int dmgResist;

View file

@ -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;