- fixed: The Hexen bridge must make its balls disappear when it gets destroyed.

Hexen did this with a call to A_BridgeRemove in Thing_Destroy which merely set a flag in the bridge object, which cannot be done safely in ZDoom because it's not guaranteed that the ball object calls A_BridgeOrbit and the garbage collector may delete the bridge actor before it can be checked so now the Bridge's Destroy method deletes all balls attached to the bridge object itself.
This commit is contained in:
Christoph Oelckers 2013-09-13 10:07:43 +02:00
parent 11c026ee84
commit ea0e4ed344

View file

@ -38,6 +38,7 @@ class ACustomBridge : public AActor
DECLARE_CLASS (ACustomBridge, AActor)
public:
void BeginPlay ();
void Destroy();
};
IMPLEMENT_CLASS(ACustomBridge)
@ -58,6 +59,24 @@ void ACustomBridge::BeginPlay ()
}
}
void ACustomBridge::Destroy()
{
// Hexen originally just set a flag to make the bridge balls remove themselves in A_BridgeOrbit.
// But this is not safe with custom bridge balls that do not necessarily call that function.
// So the best course of action is to look for all bridge balls here and destroy them ourselves.
TThinkerIterator<AActor> it;
AActor *thing;
while ((thing = it.Next()))
{
if (thing->target == this)
{
thing->Destroy();
}
}
}
// Action functions for the non-Doom bridge --------------------------------
#define ORBIT_RADIUS 15
@ -89,10 +108,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
// Set rotation radius
if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / (100 * FRACUNIT));
if (self->target->special1)
{
self->SetState (NULL);
}
self->angle += rotationspeed;
self->x = self->target->x + rotationradius * finecosine[self->angle >> ANGLETOFINESHIFT];
self->y = self->target->y + rotationradius * finesine[self->angle >> ANGLETOFINESHIFT];
@ -115,7 +130,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
cy = self->y;
cz = self->z;
startangle = pr_orbit() << 24;
self->special1 = 0;
// Spawn triad into world -- may be more than a triad now.
int ballcount = self->args[2]==0 ? 3 : self->args[2];
@ -129,14 +143,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
}
}
/* never used
void A_BridgeRemove (AActor *self)
{
self->special1 = true; // Removing the bridge
self->flags &= ~MF_SOLID;
self->SetState (&ABridge::States[S_FREE_BRIDGE]);
}
*/
// Invisible bridge --------------------------------------------------------