Quasar
Moderator

Posts: 4615
Registered: 08-00 |
Found the source of the problem. It's old, very old in fact. From MBF:
code:
for(i = -n; i <= n; i += 8) // launch mushroom cloud
{
for(j = -n; j <= n; j += 8)
{
Mobj target = *actor, *mo; // Oh my GOD this does not work!
target.x += i << FRACBITS; // Aim in many directions from source
target.y += j << FRACBITS;
target.z += P_AproxDistance(i,j) * misc1; // Aim fairly high
mo = P_SpawnMissile(actor, &target, ShotType,
actor->z + DEFAULTMISSILEZ); // Launch fireball
mo->momx = FixedMul(mo->momx, misc2);
mo->momy = FixedMul(mo->momy, misc2); // Slow down a bit
mo->momz = FixedMul(mo->momz, misc2);
mo->flags &= ~MF_NOGRAVITY; // Make debris fall under gravity
}
}
What I don't understand is why this is just now suddenly acting like a problem after all these years.
EDIT:
Figured that out too. It's because now that Mobj is based on ZoneObject, and ZoneObject has a destructor, the stack-allocated bitwise copy of the original Mobj falling out of scope causes information related to the original Mobj to be corrupted, including the zone objectbytag links.
The problem stems from the combination of the lack of an explicit copy constructor in any of the ZoneObject or Thinker hierarchy of classes and this bizarre abuse of the Mobj type.
EDIT 2: Fixed by adding a new P_SpawnMissile variant that takes an alternate coordinate to shoot the missile toward instead of using the destination object's x/y/z, while preserving as much of the rest of the behavior as possible.
Last edited by Quasar on 08-07-11 at 07:03
|