- scriptified CustomBridge.OnDestroy.

This commit is contained in:
Christoph Oelckers 2017-01-12 22:56:06 +01:00
parent 7b7623d2c4
commit 3d73919092
4 changed files with 22 additions and 36 deletions

View File

@ -1158,7 +1158,6 @@ set (PCH_SOURCES
g_inventory/a_weapons.cpp
g_strife/strife_sbar.cpp
g_shared/a_action.cpp
g_shared/a_bridge.cpp
g_shared/a_decals.cpp
g_shared/a_fastprojectile.cpp
g_shared/a_flashfader.cpp

View File

@ -1,33 +0,0 @@
#include "actor.h"
#include "info.h"
#include "gi.h"
// Custom bridge --------------------------------------------------------
class ACustomBridge : public AActor
{
DECLARE_CLASS (ACustomBridge, AActor)
public:
void OnDestroy() override;
};
IMPLEMENT_CLASS(ACustomBridge, false, false)
void ACustomBridge::OnDestroy()
{
// 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();
}
}
Super::OnDestroy();
}

View File

@ -1290,7 +1290,7 @@ CCMD(clearnodecache)
}
catch (CRecoverableError &err)
{
Printf("%s", err.GetMessage());
Printf("%s\n", err.GetMessage());
return;
}

View File

@ -70,7 +70,7 @@ class BridgeBall : Actor
// The bridge itself -------------------------------------------------------
class CustomBridge : Actor native
class CustomBridge : Actor
{
const ORBIT_RADIUS = 15;
@ -114,6 +114,26 @@ class CustomBridge : Actor native
A_SetRenderStyle(1., STYLE_Normal);
}
}
override void OnDestroy()
{
// 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.
let it = ThinkerIterator.Create("Actor");
Actor thing;
while ((thing = Actor(it.Next())))
{
if (thing.target == self)
{
thing.Destroy();
}
}
Super.OnDestroy();
}
void A_BridgeInit(class<Actor> balltype = "BridgeBall")
{