Allow WorldUnloaded events to know the next map name (if any).

This commit is contained in:
Mari the Deer 2021-09-27 19:40:57 +02:00 committed by Christoph Oelckers
commit 457f7c31c3
4 changed files with 13 additions and 8 deletions

View file

@ -294,11 +294,11 @@ void EventManager::WorldLoaded()
}
}
void EventManager::WorldUnloaded()
void EventManager::WorldUnloaded(const FString& nextmap)
{
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
{
handler->WorldUnloaded();
handler->WorldUnloaded(nextmap);
}
}
@ -629,6 +629,7 @@ DEFINE_FIELD_X(RenderEvent, FRenderEvent, Camera);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, IsSaveGame);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, IsReopen);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, NextMap);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, Thing);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, Inflictor);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, Damage);
@ -769,13 +770,14 @@ void DStaticEventHandler::WorldLoaded()
}
}
void DStaticEventHandler::WorldUnloaded()
void DStaticEventHandler::WorldUnloaded(const FString& nextmap)
{
IFVIRTUAL(DStaticEventHandler, WorldUnloaded)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = owner->SetupWorldEvent();
e.NextMap = nextmap;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
}