mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-10 11:11:51 +00:00
Merged https://github.com/ZDoom/gzdoom/pull/1964 (OnEngineInitialize())
This commit is contained in:
parent
93bc2a3caf
commit
050f982fe2
4 changed files with 26 additions and 0 deletions
|
@ -3524,6 +3524,8 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray<FString>& allwads, TArr
|
|||
D_StartTitle (); // start up intro loop
|
||||
setmodeneeded = false; // This may be set to true here, but isn't needed for a restart
|
||||
}
|
||||
|
||||
staticEventManager.OnEngineInitialize();
|
||||
return 0;
|
||||
}
|
||||
//==========================================================================
|
||||
|
|
|
@ -280,6 +280,14 @@ void EventManager::Shutdown()
|
|||
handler->name(); \
|
||||
}
|
||||
|
||||
void EventManager::OnEngineInitialize()
|
||||
{
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
{
|
||||
if (handler->IsStatic())
|
||||
handler->OnEngineInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
// note for the functions below.
|
||||
// *Unsafe is executed on EVERY map load/close, including savegame loading, etc.
|
||||
|
@ -773,6 +781,18 @@ FWorldEvent EventManager::SetupWorldEvent()
|
|||
return e;
|
||||
}
|
||||
|
||||
void DStaticEventHandler::OnEngineInitialize()
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, OnEngineInitialize)
|
||||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
VMValue params[1] = { (DStaticEventHandler*)this };
|
||||
VMCall(func, params, 1, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DStaticEventHandler::WorldLoaded()
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, WorldLoaded)
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
void OnUnregister();
|
||||
|
||||
//
|
||||
void OnEngineInitialize();
|
||||
void WorldLoaded();
|
||||
void WorldUnloaded(const FString& nextmap);
|
||||
void WorldThingSpawned(AActor* actor);
|
||||
|
@ -230,6 +231,8 @@ struct EventManager
|
|||
// shutdown handlers
|
||||
void Shutdown();
|
||||
|
||||
// after the engine is done creating data
|
||||
void OnEngineInitialize();
|
||||
// called right after the map has loaded (approximately same time as OPEN ACS scripts)
|
||||
void WorldLoaded();
|
||||
// called when the map is about to unload (approximately same time as UNLOADING ACS scripts)
|
||||
|
|
|
@ -89,6 +89,7 @@ class StaticEventHandler : Object native play version("2.4")
|
|||
virtual void OnUnregister() {}
|
||||
|
||||
// actual handlers are here
|
||||
virtual void OnEngineInitialize() {}
|
||||
virtual void WorldLoaded(WorldEvent e) {}
|
||||
virtual void WorldUnloaded(WorldEvent e) {}
|
||||
virtual void WorldThingSpawned(WorldEvent e) {}
|
||||
|
|
Loading…
Reference in a new issue