- made the event manager an object so it can be instantiated multiple times.

This commit is contained in:
Christoph Oelckers 2019-02-02 10:46:34 +01:00
parent 8d83f03138
commit 484485f3cf
21 changed files with 257 additions and 246 deletions

View File

@ -423,7 +423,7 @@ void FCajunMaster::RemoveAllBots (FLevelLocals *Level, bool fromlist)
}
}
// [ZZ] run event hook
E_PlayerDisconnected(i);
eventManager.PlayerDisconnected(i);
Level->Behaviors.StartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true);
ClearPlayer (i, !fromlist);
}

View File

@ -273,7 +273,7 @@ void D_ProcessEvents (void)
if (M_Responder (ev))
continue; // menu ate the event
// check events
if (ev->type != EV_Mouse && E_Responder(ev)) // [ZZ] ZScript ate the event // update 07.03.17: mouse events are handled directly
if (ev->type != EV_Mouse && eventManager.Responder(ev)) // [ZZ] ZScript ate the event // update 07.03.17: mouse events are handled directly
continue;
G_Responder (ev);
}
@ -295,7 +295,7 @@ void D_PostEvent (const event_t *ev)
return;
}
events[eventhead] = *ev;
if (ev->type == EV_Mouse && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_Responder(ev) && !paused)
if (ev->type == EV_Mouse && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !eventManager.Responder(ev) && !paused)
{
if (Button_Mlook.bDown || freelook)
{
@ -2730,7 +2730,7 @@ void D_DoomMain (void)
{
Level->Thinkers.DestroyThinkersInList(STAT_STATIC);
}
E_Shutdown(false);
eventManager.Shutdown(false);
P_FreeLevelData();
M_SaveDefaults(NULL); // save config before the restart

View File

@ -2671,7 +2671,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
for (int i = 0; i < 3; i++)
arg[i] = ReadLong(stream);
bool manual = !!ReadByte(stream);
E_Console(player, s, arg[0], arg[1], arg[2], manual);
eventManager.Console(player, s, arg[0], arg[1], arg[2], manual);
}
break;

View File

@ -282,8 +282,8 @@ static void MarkRoot()
Mark(StatusBar);
M_MarkMenus();
Mark(DIntermissionController::CurrentIntermission);
Mark(E_FirstEventHandler);
Mark(E_LastEventHandler);
Mark(eventManager.FirstEventHandler);
Mark(eventManager.LastEventHandler);
for (auto Level : AllLevels())
Level->Mark();

View File

@ -42,14 +42,14 @@
#include "g_game.h"
#include "info.h"
DStaticEventHandler* E_FirstEventHandler = nullptr;
DStaticEventHandler* E_LastEventHandler = nullptr;
EventManager eventManager;
bool E_RegisterHandler(DStaticEventHandler* handler)
bool EventManager::RegisterHandler(DStaticEventHandler* handler)
{
if (handler == nullptr || handler->ObjectFlags & OF_EuthanizeMe)
return false;
if (E_CheckHandler(handler))
if (CheckHandler(handler))
return false;
handler->OnRegister();
@ -57,7 +57,7 @@ bool E_RegisterHandler(DStaticEventHandler* handler)
// link into normal list
// update: link at specific position based on order.
DStaticEventHandler* before = nullptr;
for (DStaticEventHandler* existinghandler = E_FirstEventHandler; existinghandler; existinghandler = existinghandler->next)
for (DStaticEventHandler* existinghandler = FirstEventHandler; existinghandler; existinghandler = existinghandler->next)
{
if (existinghandler->Order > handler->Order)
{
@ -67,9 +67,9 @@ bool E_RegisterHandler(DStaticEventHandler* handler)
}
// 1. MyHandler2->1:
// E_FirstEventHandler = MyHandler2, E_LastEventHandler = MyHandler2
// eventManager.FirstEventHandler = MyHandler2, eventManager.LastEventHandler = MyHandler2
// 2. MyHandler3->2:
// E_FirstEventHandler = MyHandler2, E_LastEventHandler = MyHandler3
// eventManager.FirstEventHandler = MyHandler2, eventManager.LastEventHandler = MyHandler3
// (Yes, all those write barriers here are really needed!)
if (before != nullptr)
@ -87,9 +87,9 @@ bool E_RegisterHandler(DStaticEventHandler* handler)
GC::WriteBarrier(handler, before->prev);
before->prev = handler;
GC::WriteBarrier(before, handler);
if (before == E_FirstEventHandler)
if (before == FirstEventHandler)
{
E_FirstEventHandler = handler;
FirstEventHandler = handler;
GC::WriteBarrier(handler);
}
}
@ -97,11 +97,11 @@ bool E_RegisterHandler(DStaticEventHandler* handler)
{
// so if before is null, it means add last.
// it can also mean that we have no handlers at all yet.
handler->prev = E_LastEventHandler;
GC::WriteBarrier(handler, E_LastEventHandler);
handler->prev = LastEventHandler;
GC::WriteBarrier(handler, LastEventHandler);
handler->next = nullptr;
if (E_FirstEventHandler == nullptr) E_FirstEventHandler = handler;
E_LastEventHandler = handler;
if (FirstEventHandler == nullptr) FirstEventHandler = handler;
LastEventHandler = handler;
GC::WriteBarrier(handler);
if (handler->prev != nullptr)
{
@ -118,11 +118,11 @@ bool E_RegisterHandler(DStaticEventHandler* handler)
return true;
}
bool E_UnregisterHandler(DStaticEventHandler* handler)
bool EventManager::UnregisterHandler(DStaticEventHandler* handler)
{
if (handler == nullptr || handler->ObjectFlags & OF_EuthanizeMe)
return false;
if (!E_CheckHandler(handler))
if (!CheckHandler(handler))
return false;
handler->OnUnregister();
@ -138,14 +138,14 @@ bool E_UnregisterHandler(DStaticEventHandler* handler)
handler->next->prev = handler->prev;
GC::WriteBarrier(handler->next, handler->prev);
}
if (handler == E_FirstEventHandler)
if (handler == FirstEventHandler)
{
E_FirstEventHandler = handler->next;
FirstEventHandler = handler->next;
GC::WriteBarrier(handler->next);
}
if (handler == E_LastEventHandler)
if (handler == LastEventHandler)
{
E_LastEventHandler = handler->prev;
LastEventHandler = handler->prev;
GC::WriteBarrier(handler->prev);
}
if (handler->IsStatic())
@ -156,7 +156,7 @@ bool E_UnregisterHandler(DStaticEventHandler* handler)
return true;
}
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual)
bool EventManager::SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual)
{
if (gamestate != GS_LEVEL)
return false;
@ -172,21 +172,21 @@ bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual)
return true;
}
bool E_CheckHandler(DStaticEventHandler* handler)
bool EventManager::CheckHandler(DStaticEventHandler* handler)
{
for (DStaticEventHandler* lhandler = E_FirstEventHandler; lhandler; lhandler = lhandler->next)
for (DStaticEventHandler* lhandler = FirstEventHandler; lhandler; lhandler = lhandler->next)
if (handler == lhandler) return true;
return false;
}
bool E_IsStaticType(PClass* type)
bool EventManager::IsStaticType(PClass* type)
{
assert(type != nullptr);
assert(type->IsDescendantOf(RUNTIME_CLASS(DStaticEventHandler)));
return !type->IsDescendantOf(RUNTIME_CLASS(DEventHandler));
}
void E_SerializeEvents(FSerializer& arc)
void EventManager::SerializeEvents(FSerializer& arc)
{
// todo : stuff
if (arc.BeginArray("eventhandlers"))
@ -197,12 +197,12 @@ void E_SerializeEvents(FSerializer& arc)
{
numlocalhandlers = arc.ArraySize();
// delete all current local handlers, if any
for (DStaticEventHandler* lhandler = E_FirstEventHandler; lhandler; lhandler = lhandler->next)
for (DStaticEventHandler* lhandler = FirstEventHandler; lhandler; lhandler = lhandler->next)
if (!lhandler->IsStatic()) lhandler->Destroy();
}
else
{
for (DStaticEventHandler* lhandler = E_FirstEventHandler; lhandler; lhandler = lhandler->next)
for (DStaticEventHandler* lhandler = FirstEventHandler; lhandler; lhandler = lhandler->next)
{
if (lhandler->IsStatic()) continue;
numlocalhandlers++;
@ -231,14 +231,14 @@ void E_SerializeEvents(FSerializer& arc)
{
// add all newly deserialized handlers into the list
for (int i = 0; i < numlocalhandlers; i++)
E_RegisterHandler(handlers[i]);
RegisterHandler(handlers[i]);
}
arc.EndArray();
}
}
static PClass* E_GetHandlerClass(const FString& typeName)
static PClass* GetHandlerClass(const FString& typeName)
{
PClass* type = PClass::FindClass(typeName);
@ -254,11 +254,11 @@ static PClass* E_GetHandlerClass(const FString& typeName)
return type;
}
static void E_InitHandler(PClass* type)
void EventManager::InitHandler(PClass* type)
{
// check if type already exists, don't add twice.
bool typeExists = false;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
{
if (handler->IsA(type))
{
@ -269,27 +269,27 @@ static void E_InitHandler(PClass* type)
if (typeExists) return;
DStaticEventHandler* handler = (DStaticEventHandler*)type->CreateNew();
E_RegisterHandler(handler);
RegisterHandler(handler);
}
void E_InitStaticHandlers(bool map)
void EventManager::InitStaticHandlers(bool map)
{
// don't initialize map handlers if restoring from savegame.
if (savegamerestore)
return;
// just make sure
E_Shutdown(map);
Shutdown(map);
// initialize event handlers from gameinfo
for (const FString& typeName : gameinfo.EventHandlers)
{
PClass* type = E_GetHandlerClass(typeName);
PClass* type = GetHandlerClass(typeName);
// don't init the really global stuff here on startup initialization.
// don't init map-local global stuff here on level setup.
if (map == E_IsStaticType(type))
if (map == IsStaticType(type))
continue;
E_InitHandler(type);
InitHandler(type);
}
if (!map)
@ -298,26 +298,26 @@ void E_InitStaticHandlers(bool map)
// initialize event handlers from mapinfo
for (const FString& typeName : level.info->EventHandlers)
{
PClass* type = E_GetHandlerClass(typeName);
if (E_IsStaticType(type))
PClass* type = GetHandlerClass(typeName);
if (IsStaticType(type))
I_Error("Fatal: invalid event handler class %s in MAPINFO!\nMap-specific event handlers cannot be static.\n", typeName.GetChars());
E_InitHandler(type);
InitHandler(type);
}
}
void E_Shutdown(bool map)
void EventManager::Shutdown(bool map)
{
// delete handlers.
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
{
if (handler->IsStatic() == !map)
handler->Destroy();
}
}
#define DEFINE_EVENT_LOOPER(name) void E_##name() \
#define DEFINE_EVENT_LOOPER(name) void EventManager::##name() \
{ \
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) \
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next) \
handler->name(); \
}
@ -325,9 +325,9 @@ void E_Shutdown(bool map)
// *Unsafe is executed on EVERY map load/close, including savegame loading, etc.
// There is no point in allowing non-static handlers to receive unsafe event separately, as there is no point in having static handlers receive safe event.
// Because the main point of safe WorldLoaded/Unloading is that it will be preserved in savegames.
void E_WorldLoaded()
void EventManager::WorldLoaded()
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
{
if (handler->IsStatic()) continue;
if (savegamerestore) continue; // don't execute WorldLoaded for handlers loaded from the savegame.
@ -335,70 +335,70 @@ void E_WorldLoaded()
}
}
void E_WorldUnloaded()
void EventManager::WorldUnloaded()
{
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
{
if (handler->IsStatic()) continue;
handler->WorldUnloaded();
}
}
void E_WorldLoadedUnsafe()
void EventManager::WorldLoadedUnsafe()
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
{
if (!handler->IsStatic()) continue;
handler->WorldLoaded();
}
}
void E_WorldUnloadedUnsafe()
void EventManager::WorldUnloadedUnsafe()
{
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
{
if (!handler->IsStatic()) continue;
handler->WorldUnloaded();
}
}
void E_WorldThingSpawned(AActor* actor)
void EventManager::WorldThingSpawned(AActor* actor)
{
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe)
return;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->WorldThingSpawned(actor);
}
void E_WorldThingDied(AActor* actor, AActor* inflictor)
void EventManager::WorldThingDied(AActor* actor, AActor* inflictor)
{
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe)
return;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->WorldThingDied(actor, inflictor);
}
void E_WorldThingRevived(AActor* actor)
void EventManager::WorldThingRevived(AActor* actor)
{
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe)
return;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->WorldThingRevived(actor);
}
void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle)
void EventManager::WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle)
{
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe)
return;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->WorldThingDamaged(actor, inflictor, source, damage, mod, flags, angle);
}
void E_WorldThingDestroyed(AActor* actor)
void EventManager::WorldThingDestroyed(AActor* actor)
{
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe)
@ -407,73 +407,73 @@ void E_WorldThingDestroyed(AActor* actor)
// this is because Destroyed should be reverse of Spawned. we don't want to catch random inventory give failures.
if (!(actor->ObjectFlags & OF_Spawned))
return;
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
handler->WorldThingDestroyed(actor);
}
void E_WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate)
void EventManager::WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->WorldLinePreActivated(line, actor, activationType, shouldactivate);
}
void E_WorldLineActivated(line_t* line, AActor* actor, int activationType)
void EventManager::WorldLineActivated(line_t* line, AActor* actor, int activationType)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->WorldLineActivated(line, actor, activationType);
}
int E_WorldSectorDamaged(sector_t* sector, AActor* source, int damage, FName damagetype, int part, DVector3 position, bool isradius)
int EventManager::WorldSectorDamaged(sector_t* sector, AActor* source, int damage, FName damagetype, int part, DVector3 position, bool isradius)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
damage = handler->WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
return damage;
}
int E_WorldLineDamaged(line_t* line, AActor* source, int damage, FName damagetype, int side, DVector3 position, bool isradius)
int EventManager::WorldLineDamaged(line_t* line, AActor* source, int damage, FName damagetype, int side, DVector3 position, bool isradius)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
damage = handler->WorldLineDamaged(line, source, damage, damagetype, side, position, isradius);
return damage;
}
void E_PlayerEntered(int num, bool fromhub)
void EventManager::PlayerEntered(int num, bool fromhub)
{
// this event can happen during savegamerestore. make sure that local handlers don't receive it.
// actually, global handlers don't want it too.
if (savegamerestore && !fromhub)
return;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->PlayerEntered(num, fromhub);
}
void E_PlayerRespawned(int num)
void EventManager::PlayerRespawned(int num)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->PlayerRespawned(num);
}
void E_PlayerDied(int num)
void EventManager::PlayerDied(int num)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->PlayerDied(num);
}
void E_PlayerDisconnected(int num)
void EventManager::PlayerDisconnected(int num)
{
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
handler->PlayerDisconnected(num);
}
bool E_Responder(const event_t* ev)
bool EventManager::Responder(const event_t* ev)
{
bool uiProcessorsFound = false;
if (ev->type == EV_GUI_Event)
{
// iterate handlers back to front by order, and give them this event.
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
{
if (handler->IsUiProcessor)
{
@ -486,7 +486,7 @@ bool E_Responder(const event_t* ev)
else
{
// not sure if we want to handle device changes, but whatevs.
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
{
if (handler->IsUiProcessor)
uiProcessorsFound = true;
@ -498,61 +498,61 @@ bool E_Responder(const event_t* ev)
return (uiProcessorsFound && (ev->type == EV_Mouse)); // mouse events are eaten by the event system if there are any uiprocessors.
}
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
void EventManager::Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->ConsoleProcess(player, name, arg1, arg2, arg3, manual);
}
void E_RenderOverlay(EHudState state)
void EventManager::RenderOverlay(EHudState state)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->RenderOverlay(state);
}
bool E_CheckUiProcessors()
bool EventManager::CheckUiProcessors()
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
if (handler->IsUiProcessor)
return true;
return false;
}
bool E_CheckRequireMouse()
bool EventManager::CheckRequireMouse()
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
if (handler->IsUiProcessor && handler->RequireMouse)
return true;
return false;
}
bool E_CheckReplacement( PClassActor *replacee, PClassActor **replacement )
bool EventManager::CheckReplacement( PClassActor *replacee, PClassActor **replacement )
{
bool final = false;
for (DStaticEventHandler *handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler *handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->CheckReplacement(replacee,replacement,&final);
return final;
}
bool E_CheckReplacee(PClassActor **replacee, PClassActor *replacement)
bool EventManager::CheckReplacee(PClassActor **replacee, PClassActor *replacement)
{
bool final = false;
for (DStaticEventHandler *handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler *handler = eventManager.FirstEventHandler; handler; handler = handler->next)
handler->CheckReplacee(replacee, replacement, &final);
return final;
}
void E_NewGame(EventHandlerType handlerType)
void EventManager::NewGame(EventHandlerType handlerType)
{
bool isStatic = handlerType == EventHandlerType::Global;
// Shut down all per-map event handlers before static NewGame events.
if (isStatic)
E_Shutdown(true);
EventManager::Shutdown(true);
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
{
if (handler->IsStatic() == isStatic)
handler->NewGame();
@ -644,7 +644,7 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder)
PARAM_SELF_PROLOGUE(DStaticEventHandler);
PARAM_INT(order);
if (E_CheckHandler(self))
if (eventManager.CheckHandler(self))
return 0;
self->Order = order;
@ -660,14 +660,14 @@ DEFINE_ACTION_FUNCTION(DEventHandler, SendNetworkEvent)
PARAM_INT(arg3);
//
ACTION_RETURN_BOOL(E_SendNetworkEvent(name, arg1, arg2, arg3, false));
ACTION_RETURN_BOOL(eventManager.SendNetworkEvent(name, arg1, arg2, arg3, false));
}
DEFINE_ACTION_FUNCTION(DEventHandler, Find)
{
PARAM_PROLOGUE;
PARAM_CLASS(t, DStaticEventHandler);
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
if (handler->GetClass() == t) // check precise class
ACTION_RETURN_OBJECT(handler);
ACTION_RETURN_OBJECT(nullptr);
@ -678,7 +678,7 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, Find)
{
PARAM_PROLOGUE;
PARAM_CLASS(t, DStaticEventHandler);
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
if (handler->GetClass() == t) // check precise class
ACTION_RETURN_OBJECT(handler);
ACTION_RETURN_OBJECT(nullptr);
@ -726,7 +726,7 @@ void DStaticEventHandler::OnUnregister()
}
}
static FWorldEvent E_SetupWorldEvent()
FWorldEvent EventManager::SetupWorldEvent()
{
FWorldEvent e;
e.IsSaveGame = savegamerestore;
@ -741,7 +741,7 @@ void DStaticEventHandler::WorldLoaded()
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
}
@ -753,7 +753,7 @@ void DStaticEventHandler::WorldUnloaded()
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
}
@ -765,7 +765,7 @@ void DStaticEventHandler::WorldThingSpawned(AActor* actor)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
@ -778,7 +778,7 @@ void DStaticEventHandler::WorldThingDied(AActor* actor, AActor* inflictor)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
e.Inflictor = inflictor;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
@ -792,7 +792,7 @@ void DStaticEventHandler::WorldThingRevived(AActor* actor)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
@ -805,7 +805,7 @@ void DStaticEventHandler::WorldThingDamaged(AActor* actor, AActor* inflictor, AA
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
e.Inflictor = inflictor;
e.Damage = damage;
@ -824,7 +824,7 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
@ -837,7 +837,7 @@ void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, int
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
e.ActivatedLine = line;
e.ActivationType = activationType;
@ -854,7 +854,7 @@ void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor, int ac
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.Thing = actor;
e.ActivatedLine = line;
e.ActivationType = activationType;
@ -869,7 +869,7 @@ int DStaticEventHandler::WorldSectorDamaged(sector_t* sector, AActor* source, in
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return damage;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.DamageSource = source;
e.DamageSector = sector;
e.NewDamage = e.Damage = damage;
@ -892,7 +892,7 @@ int DStaticEventHandler::WorldLineDamaged(line_t* line, AActor* source, int dama
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return damage;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
e.DamageSource = source;
e.DamageLine = line;
e.NewDamage = e.Damage = damage;
@ -915,7 +915,7 @@ void DStaticEventHandler::WorldLightning()
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FWorldEvent e = E_SetupWorldEvent();
FWorldEvent e = eventManager.SetupWorldEvent();
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
}
@ -932,7 +932,7 @@ void DStaticEventHandler::WorldTick()
}
}
static FRenderEvent E_SetupRenderEvent()
FRenderEvent EventManager::SetupRenderEvent()
{
FRenderEvent e;
auto &vp = r_viewpoint;
@ -952,7 +952,7 @@ void DStaticEventHandler::RenderFrame()
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FRenderEvent e = E_SetupRenderEvent();
FRenderEvent e = eventManager.SetupRenderEvent();
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
}
@ -965,7 +965,7 @@ void DStaticEventHandler::RenderOverlay(EHudState state)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
FRenderEvent e = E_SetupRenderEvent();
FRenderEvent e = eventManager.SetupRenderEvent();
e.HudState = int(state);
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
@ -1234,7 +1234,7 @@ void DStaticEventHandler::NewGame()
//
void DStaticEventHandler::OnDestroy()
{
E_UnregisterHandler(this);
eventManager.UnregisterHandler(this);
Super::OnDestroy();
}
@ -1255,7 +1255,7 @@ CCMD(event)
for (int i = 0; i < argn; i++)
arg[i] = atoi(argv[2 + i]);
// call locally
E_Console(-1, argv[1], arg[0], arg[1], arg[2], true);
eventManager.Console(-1, argv[1], arg[0], arg[1], arg[2], true);
}
}
@ -1280,6 +1280,6 @@ CCMD(netevent)
for (int i = 0; i < argn; i++)
arg[i] = atoi(argv[2 + i]);
// call networked
E_SendNetworkEvent(argv[1], arg[0], arg[1], arg[2], true);
eventManager.SendNetworkEvent(argv[1], arg[0], arg[1], arg[2], true);
}
}

View File

@ -15,89 +15,6 @@ enum class EventHandlerType
PerMap
};
// register
bool E_RegisterHandler(DStaticEventHandler* handler);
// unregister
bool E_UnregisterHandler(DStaticEventHandler* handler);
// find
bool E_CheckHandler(DStaticEventHandler* handler);
// check type
bool E_IsStaticType(PClass* type);
// init static handlers
void E_InitStaticHandlers(bool map);
// shutdown handlers
void E_Shutdown(bool map);
// called right after the map has loaded (approximately same time as OPEN ACS scripts)
void E_WorldLoaded();
// called when the map is about to unload (approximately same time as UNLOADING ACS scripts)
void E_WorldUnloaded();
// called right after the map has loaded (every time, UNSAFE VERSION)
void E_WorldLoadedUnsafe();
// called right before the map is unloaded (every time, UNSAFE VERSION)
void E_WorldUnloadedUnsafe();
// called around PostBeginPlay of each actor.
void E_WorldThingSpawned(AActor* actor);
// called after AActor::Die of each actor.
void E_WorldThingDied(AActor* actor, AActor* inflictor);
// called after AActor::Revive.
void E_WorldThingRevived(AActor* actor);
// called before P_DamageMobj and before AActor::DamageMobj virtuals.
void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle);
// called before AActor::Destroy of each actor.
void E_WorldThingDestroyed(AActor* actor);
// called in P_ActivateLine before executing special, set shouldactivate to false to prevent activation.
void E_WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate);
// called in P_ActivateLine after successful special execution.
void E_WorldLineActivated(line_t* line, AActor* actor, int activationType);
// called in P_DamageSector and P_DamageLinedef before receiving damage to the sector. returns actual damage
int E_WorldSectorDamaged(sector_t* sector, AActor* source, int damage, FName damagetype, int part, DVector3 position, bool isradius);
// called in P_DamageLinedef before receiving damage to the linedef. returns actual damage
int E_WorldLineDamaged(line_t* line, AActor* source, int damage, FName damagetype, int side, DVector3 position, bool isradius);
// same as ACS SCRIPT_Lightning
void E_WorldLightning();
// this executes on every tick, before everything, only when in valid level and not paused
void E_WorldTick();
// this executes on every tick on UI side, always
void E_UiTick();
// this executes on every tick on UI side, always AND immediately after everything else
void E_PostUiTick();
// called on each render frame once.
void E_RenderFrame();
// called after everything's been rendered, but before console/menus
void E_RenderOverlay(EHudState state);
// this executes when a player enters the level (once). PlayerEnter+inhub = RETURN
void E_PlayerEntered(int num, bool fromhub);
// this executes when a player respawns. includes resurrect cheat.
void E_PlayerRespawned(int num);
// this executes when a player dies (partially duplicating worldthingdied, but whatever)
void E_PlayerDied(int num);
// this executes when a player leaves the game
void E_PlayerDisconnected(int num);
// this executes on events.
bool E_Responder(const event_t* ev); // splits events into InputProcess and UiProcess
// this executes on console/net events.
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
// called when looking up the replacement for an actor class
bool E_CheckReplacement(PClassActor* replacee, PClassActor** replacement);
// called when looking up the replaced for an actor class
bool E_CheckReplacee(PClassActor** replacee, PClassActor* replacement);
// called on new game
void E_NewGame(EventHandlerType handlerType);
// send networked event. unified function.
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual);
// check if there is anything that should receive GUI events
bool E_CheckUiProcessors();
// check if we need native mouse due to UiProcessors
bool E_CheckRequireMouse();
// serialization stuff
void E_SerializeEvents(FSerializer& arc);
// ==============================================
//
// EventHandler - base class
@ -200,8 +117,6 @@ class DEventHandler : public DStaticEventHandler
public:
bool IsStatic() override { return false; }
};
extern DStaticEventHandler* E_FirstEventHandler;
extern DStaticEventHandler* E_LastEventHandler;
struct FRenderEvent
{
@ -311,4 +226,100 @@ struct FReplacedEvent
bool IsFinal;
};
struct EventManager
{
DStaticEventHandler* FirstEventHandler = nullptr;
DStaticEventHandler* LastEventHandler = nullptr;
// register
bool RegisterHandler(DStaticEventHandler* handler);
// unregister
bool UnregisterHandler(DStaticEventHandler* handler);
// find
bool CheckHandler(DStaticEventHandler* handler);
// check type
bool IsStaticType(PClass* type);
// init static handlers
void InitStaticHandlers(bool map);
// shutdown handlers
void Shutdown(bool map);
// 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)
void WorldUnloaded();
// called right after the map has loaded (every time, UNSAFE VERSION)
void WorldLoadedUnsafe();
// called right before the map is unloaded (every time, UNSAFE VERSION)
void WorldUnloadedUnsafe();
// called around PostBeginPlay of each actor.
void WorldThingSpawned(AActor* actor);
// called after AActor::Die of each actor.
void WorldThingDied(AActor* actor, AActor* inflictor);
// called after AActor::Revive.
void WorldThingRevived(AActor* actor);
// called before P_DamageMobj and before AActor::DamageMobj virtuals.
void WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle);
// called before AActor::Destroy of each actor.
void WorldThingDestroyed(AActor* actor);
// called in P_ActivateLine before executing special, set shouldactivate to false to prevent activation.
void WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate);
// called in P_ActivateLine after successful special execution.
void WorldLineActivated(line_t* line, AActor* actor, int activationType);
// called in P_DamageSector and P_DamageLinedef before receiving damage to the sector. returns actual damage
int WorldSectorDamaged(sector_t* sector, AActor* source, int damage, FName damagetype, int part, DVector3 position, bool isradius);
// called in P_DamageLinedef before receiving damage to the linedef. returns actual damage
int WorldLineDamaged(line_t* line, AActor* source, int damage, FName damagetype, int side, DVector3 position, bool isradius);
// same as ACS SCRIPT_Lightning
void WorldLightning();
// this executes on every tick, before everything, only when in valid level and not paused
void WorldTick();
// this executes on every tick on UI side, always
void UiTick();
// this executes on every tick on UI side, always AND immediately after everything else
void PostUiTick();
// called on each render frame once.
void RenderFrame();
// called after everything's been rendered, but before console/menus
void RenderOverlay(EHudState state);
// this executes when a player enters the level (once). PlayerEnter+inhub = RETURN
void PlayerEntered(int num, bool fromhub);
// this executes when a player respawns. includes resurrect cheat.
void PlayerRespawned(int num);
// this executes when a player dies (partially duplicating worldthingdied, but whatever)
void PlayerDied(int num);
// this executes when a player leaves the game
void PlayerDisconnected(int num);
// this executes on events.
bool Responder(const event_t* ev); // splits events into InputProcess and UiProcess
// this executes on console/net events.
void Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
// called when looking up the replacement for an actor class
bool CheckReplacement(PClassActor* replacee, PClassActor** replacement);
// called when looking up the replaced for an actor class
bool CheckReplacee(PClassActor** replacee, PClassActor* replacement);
// called on new game
void NewGame(EventHandlerType handlerType);
// send networked event. unified function.
bool SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual);
// check if there is anything that should receive GUI events
bool CheckUiProcessors();
// check if we need native mouse due to UiProcessors
bool CheckRequireMouse();
// serialization stuff
void SerializeEvents(FSerializer& arc);
void InitHandler(PClass* type);
FWorldEvent SetupWorldEvent();
FRenderEvent SetupRenderEvent();
};
extern EventManager eventManager;
#endif

View File

@ -1173,7 +1173,7 @@ void G_Ticker ()
}
// [ZZ] also tick the UI part of the events
E_UiTick();
eventManager.UiTick();
C_RunDelayedCommands();
// do main actions
@ -1213,7 +1213,7 @@ void G_Ticker ()
}
// [MK] Additional ticker for UI events right after all others
E_PostUiTick();
eventManager.PostUiTick();
}
@ -1697,7 +1697,7 @@ void G_DoPlayerPop(int playernum)
auto mo = players[playernum].mo;
mo->Level->Behaviors.StopMyScripts(mo);
// [ZZ] fire player disconnect hook
E_PlayerDisconnected(playernum);
eventManager.PlayerDisconnected(playernum);
// [RH] Let the scripts know the player left
mo->Level->Behaviors.StartTypedScripts(SCRIPT_Disconnect, mo, true, playernum, true);
if (mo != NULL)

View File

@ -454,7 +454,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
// did we have any level before?
if (primaryLevel->info != nullptr)
E_WorldUnloadedUnsafe();
eventManager.WorldUnloadedUnsafe();
if (!savegamerestore)
{
@ -663,9 +663,9 @@ void FLevelLocals::ChangeLevel(const char *levelname, int position, int flags, i
unloading = true;
Behaviors.StartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true);
// [ZZ] safe world unload
E_WorldUnloaded();
eventManager.WorldUnloaded();
// [ZZ] unsafe world unload (changemap != map)
E_WorldUnloadedUnsafe();
eventManager.WorldUnloadedUnsafe();
unloading = false;
STAT_ChangeLevel(nextlevel, this);
@ -1063,7 +1063,7 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
if (newGame)
{
E_NewGame(EventHandlerType::Global);
eventManager.NewGame(EventHandlerType::Global);
}
P_SetupLevel (this, position, newGame);
@ -1118,7 +1118,7 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
}
const bool fromSnapshot = FromSnapshot;
E_PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub);
eventManager.PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub);
if (fromSnapshot)
{
@ -1136,9 +1136,9 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
StatusBar->AttachToPlayer (&players[consoleplayer]);
// unsafe world load
E_WorldLoadedUnsafe();
eventManager.WorldLoadedUnsafe();
// regular world load (savegames are handled internally)
E_WorldLoaded();
eventManager.WorldLoaded();
DoDeferedScripts (); // [RH] Do script actions that were triggered on another map.

View File

@ -178,7 +178,7 @@ void DLightningThinker::LightningFlash ()
Level->flags |= LEVEL_SWAPSKIES; // set alternate sky
S_Sound (CHAN_AUTO, "world/thunder", 1.0, ATTN_NONE);
// [ZZ] just in case
E_WorldLightning();
eventManager.WorldLightning();
// start LIGHTNING scripts
Level->Behaviors.StartTypedScripts (SCRIPT_Lightning, NULL, false); // [RH] Run lightning scripts

View File

@ -1147,7 +1147,7 @@ void DBaseStatusBar::DrawTopStuff (EHudState state)
DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT);
}
DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT);
E_RenderOverlay(state);
eventManager.RenderOverlay(state);
DrawConsistancy ();
DrawWaiting ();

View File

@ -395,7 +395,7 @@ void PClassActor::StaticInit()
InitBotStuff();
// reinit GLOBAL static stuff from gameinfo, once classes are loaded.
E_InitStaticHandlers(false);
eventManager.InitStaticHandlers(false);
}
//==========================================================================
@ -538,7 +538,7 @@ PClassActor *PClassActor::GetReplacement(bool lookskill)
}
// [MK] ZScript replacement through Event Handlers, has priority over others
PClassActor *Replacement = ActorInfo()->Replacement;
if ( E_CheckReplacement(this,&Replacement) )
if (eventManager.CheckReplacement(this,&Replacement) )
{
// [MK] the replacement is final, so don't continue with the chain
return Replacement ? Replacement : this;
@ -598,7 +598,7 @@ PClassActor *PClassActor::GetReplacee(bool lookskill)
// showing up, one can assign an Arachnotron as the one being replaced
// so functions like CheckReplacee and A_BossDeath can actually work, given
// modders set it up that way.
if (E_CheckReplacee(&savedrep, this))
if (eventManager.CheckReplacee(&savedrep, this))
{
// [MK] the replacement is final, so don't continue with the chain
return savedrep ? savedrep : this;

View File

@ -124,7 +124,7 @@ void P_DamageLinedef(line_t* line, AActor* source, int damage, FName damagetype,
if (dogroups)
{
damage = E_WorldLineDamaged(line, source, damage, damagetype, side, position, isradius);
damage = eventManager.WorldLineDamaged(line, source, damage, damagetype, side, position, isradius);
if (damage < 0) damage = 0;
}
@ -160,7 +160,7 @@ void P_DamageSector(sector_t* sector, AActor* source, int damage, FName damagety
if (dogroups)
{
damage = E_WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
damage = eventManager.WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
if (damage < 0) damage = 0;
}

View File

@ -347,7 +347,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
}
// [ZZ] Fire WorldThingDied script hook.
E_WorldThingDied(this, inflictor);
eventManager.WorldThingDied(this, inflictor);
// [JM] Fire KILL type scripts for actor. Not needed for players, since they have the "DEATH" script type.
if (!player && !(flags7 & MF7_NOKILLSCRIPTS) && ((flags7 & MF7_USEKILLSCRIPTS) || gameinfo.forcekillscripts))
@ -560,7 +560,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
ClientObituary (this, inflictor, source, dmgflags, MeansOfDeath);
// [ZZ] fire player death hook
E_PlayerDied(Level->PlayerNum(player));
eventManager.PlayerDied(Level->PlayerNum(player));
// Death script execution, care of Skull Tag
Level->Behaviors.StartTypedScripts (SCRIPT_Death, this, true);
@ -1460,7 +1460,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
}
const int realdamage = MAX(0, damage);
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
eventManager.WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
needevent = false;
target->CallDie (source, inflictor, flags, MeansOfDeath);
@ -1481,7 +1481,7 @@ static int DoDamageMobj(AActor *target, AActor *inflictor, AActor *source, int d
if (realdamage > 0 && needevent)
{
// [ZZ] event handlers only need the resultant damage (they can't do anything about it anyway)
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
eventManager.WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
}
return MAX(0, realdamage);

View File

@ -4682,7 +4682,7 @@ void AActor::PostBeginPlay ()
void AActor::CallPostBeginPlay()
{
Super::CallPostBeginPlay();
E_WorldThingSpawned(this);
eventManager.WorldThingSpawned(this);
}
bool AActor::isFast()
@ -4800,7 +4800,7 @@ void AActor::OnDestroy ()
// note that this differs from ThingSpawned in that you can actually override OnDestroy to avoid calling the hook.
// but you can't really do that without utterly breaking the game, so it's ok.
// note: if OnDestroy is ever made optional, E_WorldThingDestroyed should still be called for ANY thing.
E_WorldThingDestroyed(this);
eventManager.WorldThingDestroyed(this);
DeleteAttachedLights();
ClearRenderSectorList();
@ -5155,7 +5155,7 @@ AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flag
DObject::StaticPointerSubstitution (oldactor, p->mo);
E_PlayerRespawned(PlayerNum(p));
eventManager.PlayerRespawned(PlayerNum(p));
Behaviors.StartTypedScripts (SCRIPT_Respawn, p->mo, true);
}
}
@ -7137,7 +7137,7 @@ void AActor::Revive()
}
// [ZZ] resurrect hook
E_WorldThingRevived(this);
eventManager.WorldThingRevived(this);
}
int AActor::GetGibHealth() const

View File

@ -1000,7 +1000,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
// [ZZ] serialize health groups
P_SerializeHealthGroups(this, arc);
// [ZZ] serialize events
E_SerializeEvents(arc);
eventManager.SerializeEvents(arc);
Thinkers.SerializeThinkers(arc, hubload);
arc("polyobjs", Polyobjects);
SerializeSubsectors(arc, "subsectors");

View File

@ -350,7 +350,7 @@ void P_FreeLevelData ()
{
// [ZZ] delete per-map event handlers
E_Shutdown(true);
eventManager.Shutdown(true);
R_FreePastViewers();
for (auto Level : AllLevels())
@ -425,7 +425,7 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
// [ZZ] init per-map static handlers. we need to call this before everything is set up because otherwise scripts don't receive PlayerEntered event
// (which happens at god-knows-what stage in this function, but definitely not the last part, because otherwise it'd work to put E_InitStaticHandlers before the player spawning)
E_InitStaticHandlers(true);
eventManager.InitStaticHandlers(true);
// generate a checksum for the level, to be included and checked with savegames.
map->GetChecksum(Level->md5);
@ -434,7 +434,7 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
if (newGame)
{
E_NewGame(EventHandlerType::PerMap);
eventManager.NewGame(EventHandlerType::PerMap);
}
MapLoader loader(Level);
@ -587,7 +587,7 @@ static void P_Shutdown ()
}
P_FreeLevelData ();
// [ZZ] delete global event handlers
E_Shutdown(false);
eventManager.Shutdown(false);
ST_Clear();
for (auto &p : players)
{

View File

@ -168,7 +168,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
// [MK] Use WorldLinePreActivated to decide if activation should continue
bool shouldactivate = true;
E_WorldLinePreActivated(line, mo, activationType, &shouldactivate);
eventManager.WorldLinePreActivated(line, mo, activationType, &shouldactivate);
if ( !shouldactivate ) return false;
bool remote = (line->special != 7 && line->special != 8 && (line->special < 11 || line->special > 14));
@ -180,7 +180,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
buttonSuccess = P_ExecuteSpecial(line->GetLevel(), line->special, line, mo, side == 1, line->args[0], line->args[1], line->args[2], line->args[3], line->args[4]);
// [MK] Fire up WorldLineActivated
if ( buttonSuccess ) E_WorldLineActivated(line, mo, activationType);
if ( buttonSuccess ) eventManager.WorldLineActivated(line, mo, activationType);
special = line->special;
if (!repeat && buttonSuccess)

View File

@ -149,7 +149,7 @@ void P_Ticker (void)
P_PlayerThink (&players[i]);
// [ZZ] call the WorldTick hook
E_WorldTick();
eventManager.WorldTick();
StatusBar->CallTick (); // [RH] moved this here
for (auto Level : AllLevels())
{

View File

@ -654,7 +654,7 @@ bool player_t::Resurrect()
// player is now alive.
// fire E_PlayerRespawned and start the ACS SCRIPT_Respawn.
E_PlayerRespawned(pnum);
eventManager.PlayerRespawned(pnum);
//
mo->Level->Behaviors.StartTypedScripts(SCRIPT_Respawn, mo, true);
return true;

View File

@ -174,7 +174,7 @@ static void I_CheckGUICapture ()
}
// [ZZ] check active event handlers that want the UI processing
if (!wantCapt && E_CheckUiProcessors())
if (!wantCapt && eventManager.CheckUiProcessors())
wantCapt = true;
if (wantCapt != GUICapture)

View File

@ -311,7 +311,7 @@ void I_CheckNativeMouse(bool preferNative)
}
}
if (!want_native && E_CheckRequireMouse())
if (!want_native && eventManager.CheckRequireMouse())
want_native = true;
//Printf ("%d %d %d\n", wantNative, preferNative, NativeMouse);