mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- separation of static and map-local event handlers into separate lists.
Having everything lumped together made this a maintenance hassle because it affected how the level has to be stored. This hasn't been tested yet, so it may not work as intended!
This commit is contained in:
parent
d005e0b483
commit
66eb4e5048
29 changed files with 240 additions and 242 deletions
|
@ -404,27 +404,27 @@ void FCajunMaster::RemoveAllBots (FLevelLocals *Level, bool fromlist)
|
|||
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (players[i].Bot != NULL)
|
||||
if (Level->Players[i]->Bot != nullptr)
|
||||
{
|
||||
// If a player is looking through this bot's eyes, make him
|
||||
// look through his own eyes instead.
|
||||
for (j = 0; j < MAXPLAYERS; ++j)
|
||||
{
|
||||
if (i != j && playeringame[j] && players[j].Bot == NULL)
|
||||
if (i != j && Level->PlayerInGame(j) && Level->Players[j]->Bot == nullptr)
|
||||
{
|
||||
if (players[j].camera == players[i].mo)
|
||||
if (Level->Players[j]->camera == Level->Players[i]->mo)
|
||||
{
|
||||
players[j].camera = players[j].mo;
|
||||
if (j == consoleplayer)
|
||||
Level->Players[j]->camera = Level->Players[j]->mo;
|
||||
if (Level->isConsolePlayer(Level->Players[j]->mo))
|
||||
{
|
||||
StatusBar->AttachToPlayer (players + j);
|
||||
StatusBar->AttachToPlayer (Level->Players[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// [ZZ] run event hook
|
||||
eventManager.PlayerDisconnected(i);
|
||||
Level->Behaviors.StartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true);
|
||||
Level->localEventManager->PlayerDisconnected(i);
|
||||
Level->Behaviors.StartTypedScripts (SCRIPT_Disconnect, Level->Players[i]->mo, true, i, true);
|
||||
ClearPlayer (i, !fromlist);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ void D_ProcessEvents (void)
|
|||
if (M_Responder (ev))
|
||||
continue; // menu ate the event
|
||||
// check events
|
||||
if (ev->type != EV_Mouse && eventManager.Responder(ev)) // [ZZ] ZScript ate the event // update 07.03.17: mouse events are handled directly
|
||||
if (ev->type != EV_Mouse && primaryLevel->localEventManager->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 && !eventManager.Responder(ev) && !paused)
|
||||
if (ev->type == EV_Mouse && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !primaryLevel->localEventManager->Responder(ev) && !paused)
|
||||
{
|
||||
if (Button_Mlook.bDown || freelook)
|
||||
{
|
||||
|
@ -2730,7 +2730,7 @@ void D_DoomMain (void)
|
|||
{
|
||||
Level->Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
}
|
||||
eventManager.Shutdown(false);
|
||||
staticEventManager.Shutdown();
|
||||
P_FreeLevelData();
|
||||
|
||||
M_SaveDefaults(NULL); // save config before the restart
|
||||
|
|
|
@ -2561,7 +2561,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
|||
if (cls != NULL)
|
||||
{
|
||||
killcount = primaryLevel->Massacre(false, cls->TypeName);
|
||||
PClassActor *cls_rep = cls->GetReplacement();
|
||||
PClassActor *cls_rep = cls->GetReplacement(primaryLevel);
|
||||
if (cls != cls_rep)
|
||||
{
|
||||
killcount += primaryLevel->Massacre(false, cls_rep->TypeName);
|
||||
|
@ -2583,7 +2583,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
|||
if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
removecount = RemoveClass(primaryLevel, cls);
|
||||
const PClass *cls_rep = cls->GetReplacement();
|
||||
const PClass *cls_rep = cls->GetReplacement(primaryLevel);
|
||||
if (cls != cls_rep)
|
||||
{
|
||||
removecount += RemoveClass(primaryLevel, cls_rep);
|
||||
|
@ -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);
|
||||
eventManager.Console(player, s, arg[0], arg[1], arg[2], manual);
|
||||
primaryLevel->localEventManager->Console(player, s, arg[0], arg[1], arg[2], manual);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -282,8 +282,8 @@ static void MarkRoot()
|
|||
Mark(StatusBar);
|
||||
M_MarkMenus();
|
||||
Mark(DIntermissionController::CurrentIntermission);
|
||||
Mark(eventManager.FirstEventHandler);
|
||||
Mark(eventManager.LastEventHandler);
|
||||
Mark(staticEventManager.FirstEventHandler);
|
||||
Mark(staticEventManager.LastEventHandler);
|
||||
for (auto Level : AllLevels())
|
||||
Level->Mark();
|
||||
|
||||
|
|
253
src/events.cpp
253
src/events.cpp
|
@ -42,6 +42,7 @@
|
|||
#include "g_game.h"
|
||||
#include "info.h"
|
||||
|
||||
EventManager staticEventManager;
|
||||
EventManager eventManager;
|
||||
|
||||
|
||||
|
@ -53,6 +54,7 @@ bool EventManager::RegisterHandler(DStaticEventHandler* handler)
|
|||
return false;
|
||||
|
||||
handler->OnRegister();
|
||||
handler->owner = this;
|
||||
|
||||
// link into normal list
|
||||
// update: link at specific position based on order.
|
||||
|
@ -66,11 +68,6 @@ bool EventManager::RegisterHandler(DStaticEventHandler* handler)
|
|||
}
|
||||
}
|
||||
|
||||
// 1. MyHandler2->1:
|
||||
// eventManager.FirstEventHandler = MyHandler2, eventManager.LastEventHandler = MyHandler2
|
||||
// 2. MyHandler3->2:
|
||||
// eventManager.FirstEventHandler = MyHandler2, eventManager.LastEventHandler = MyHandler3
|
||||
|
||||
// (Yes, all those write barriers here are really needed!)
|
||||
if (before != nullptr)
|
||||
{
|
||||
|
@ -186,58 +183,6 @@ bool EventManager::IsStaticType(PClass* type)
|
|||
return !type->IsDescendantOf(RUNTIME_CLASS(DEventHandler));
|
||||
}
|
||||
|
||||
void EventManager::SerializeEvents(FSerializer& arc)
|
||||
{
|
||||
// todo : stuff
|
||||
if (arc.BeginArray("eventhandlers"))
|
||||
{
|
||||
int numlocalhandlers = 0;
|
||||
TArray<DStaticEventHandler*> handlers;
|
||||
if (arc.isReading())
|
||||
{
|
||||
numlocalhandlers = arc.ArraySize();
|
||||
// delete all current local handlers, if any
|
||||
for (DStaticEventHandler* lhandler = FirstEventHandler; lhandler; lhandler = lhandler->next)
|
||||
if (!lhandler->IsStatic()) lhandler->Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (DStaticEventHandler* lhandler = FirstEventHandler; lhandler; lhandler = lhandler->next)
|
||||
{
|
||||
if (lhandler->IsStatic()) continue;
|
||||
numlocalhandlers++;
|
||||
handlers.Push(lhandler);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < numlocalhandlers; i++)
|
||||
{
|
||||
// serialize the object properly.
|
||||
if (arc.isReading())
|
||||
{
|
||||
// get object and put it into the array
|
||||
DStaticEventHandler* lhandler;
|
||||
arc(nullptr, lhandler);
|
||||
if (lhandler != nullptr)
|
||||
handlers.Push(lhandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
::Serialize<DStaticEventHandler>(arc, nullptr, handlers[i], nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (arc.isReading())
|
||||
{
|
||||
// add all newly deserialized handlers into the list
|
||||
for (int i = 0; i < numlocalhandlers; i++)
|
||||
RegisterHandler(handlers[i]);
|
||||
}
|
||||
|
||||
arc.EndArray();
|
||||
}
|
||||
}
|
||||
|
||||
static PClass* GetHandlerClass(const FString& typeName)
|
||||
{
|
||||
PClass* type = PClass::FindClass(typeName);
|
||||
|
@ -279,7 +224,7 @@ void EventManager::InitStaticHandlers(bool map)
|
|||
return;
|
||||
|
||||
// just make sure
|
||||
Shutdown(map);
|
||||
Shutdown();
|
||||
|
||||
// initialize event handlers from gameinfo
|
||||
for (const FString& typeName : gameinfo.EventHandlers)
|
||||
|
@ -305,22 +250,23 @@ void EventManager::InitStaticHandlers(bool map)
|
|||
}
|
||||
}
|
||||
|
||||
void EventManager::Shutdown(bool map)
|
||||
void EventManager::Shutdown()
|
||||
{
|
||||
// delete handlers.
|
||||
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (handler->IsStatic() == !map)
|
||||
handler->Destroy();
|
||||
handler->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFINE_EVENT_LOOPER(name) void EventManager::##name() \
|
||||
#define DEFINE_EVENT_LOOPER(name, play) void EventManager::##name() \
|
||||
{ \
|
||||
if (ShouldCallStatic(play)) staticEventManager.name(); \
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next) \
|
||||
handler->name(); \
|
||||
}
|
||||
|
||||
|
||||
// note for the functions below.
|
||||
// *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.
|
||||
|
@ -329,7 +275,6 @@ void EventManager::WorldLoaded()
|
|||
{
|
||||
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.
|
||||
handler->WorldLoaded();
|
||||
}
|
||||
|
@ -337,29 +282,15 @@ void EventManager::WorldLoaded()
|
|||
|
||||
void EventManager::WorldUnloaded()
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
|
||||
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (handler->IsStatic()) continue;
|
||||
handler->WorldUnloaded();
|
||||
}
|
||||
}
|
||||
|
||||
void EventManager::WorldLoadedUnsafe()
|
||||
bool EventManager::ShouldCallStatic(bool forplay)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
{
|
||||
if (!handler->IsStatic()) continue;
|
||||
handler->WorldLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
void EventManager::WorldUnloadedUnsafe()
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (!handler->IsStatic()) continue;
|
||||
handler->WorldUnloaded();
|
||||
}
|
||||
return this != &staticEventManager && Level == primaryLevel;
|
||||
}
|
||||
|
||||
void EventManager::WorldThingSpawned(AActor* actor)
|
||||
|
@ -367,7 +298,10 @@ 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 = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldThingSpawned(actor);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->WorldThingSpawned(actor);
|
||||
}
|
||||
|
||||
|
@ -376,7 +310,10 @@ 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 = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldThingDied(actor, inflictor);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->WorldThingDied(actor, inflictor);
|
||||
}
|
||||
|
||||
|
@ -385,7 +322,10 @@ 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 = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldThingRevived(actor);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->WorldThingRevived(actor);
|
||||
}
|
||||
|
||||
|
@ -394,7 +334,10 @@ void EventManager::WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* s
|
|||
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
|
||||
if (actor->ObjectFlags & OF_EuthanizeMe)
|
||||
return;
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldThingDamaged(actor, inflictor, source, damage, mod, flags, angle);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->WorldThingDamaged(actor, inflictor, source, damage, mod, flags, angle);
|
||||
}
|
||||
|
||||
|
@ -407,32 +350,43 @@ void EventManager::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 = eventManager.LastEventHandler; handler; handler = handler->prev)
|
||||
|
||||
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
|
||||
handler->WorldThingDestroyed(actor);
|
||||
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldThingDestroyed(actor);
|
||||
}
|
||||
|
||||
void EventManager::WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldLinePreActivated(line, actor, activationType, shouldactivate);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->WorldLinePreActivated(line, actor, activationType, shouldactivate);
|
||||
}
|
||||
|
||||
void EventManager::WorldLineActivated(line_t* line, AActor* actor, int activationType)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldLineActivated(line, actor, activationType);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->WorldLineActivated(line, actor, activationType);
|
||||
}
|
||||
|
||||
int EventManager::WorldSectorDamaged(sector_t* sector, AActor* source, int damage, FName damagetype, int part, DVector3 position, bool isradius)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
damage = handler->WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
|
||||
return damage;
|
||||
}
|
||||
|
||||
int EventManager::WorldLineDamaged(line_t* line, AActor* source, int damage, FName damagetype, int side, DVector3 position, bool isradius)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.WorldLineDamaged(line, source, damage, damagetype, side, position, isradius);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
damage = handler->WorldLineDamaged(line, source, damage, damagetype, side, position, isradius);
|
||||
return damage;
|
||||
}
|
||||
|
@ -444,26 +398,34 @@ void EventManager::PlayerEntered(int num, bool fromhub)
|
|||
if (savegamerestore && !fromhub)
|
||||
return;
|
||||
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.PlayerEntered(num, fromhub);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->PlayerEntered(num, fromhub);
|
||||
}
|
||||
|
||||
void EventManager::PlayerRespawned(int num)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.PlayerRespawned(num);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->PlayerRespawned(num);
|
||||
}
|
||||
|
||||
void EventManager::PlayerDied(int num)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(true)) staticEventManager.PlayerDied(num);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->PlayerDied(num);
|
||||
}
|
||||
|
||||
void EventManager::PlayerDisconnected(int num)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
|
||||
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
|
||||
handler->PlayerDisconnected(num);
|
||||
|
||||
if (ShouldCallStatic(true)) staticEventManager.PlayerDisconnected(num);
|
||||
}
|
||||
|
||||
bool EventManager::Responder(const event_t* ev)
|
||||
|
@ -473,7 +435,7 @@ bool EventManager::Responder(const event_t* ev)
|
|||
if (ev->type == EV_GUI_Event)
|
||||
{
|
||||
// iterate handlers back to front by order, and give them this event.
|
||||
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
|
||||
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (handler->IsUiProcessor)
|
||||
{
|
||||
|
@ -486,7 +448,7 @@ bool EventManager::Responder(const event_t* ev)
|
|||
else
|
||||
{
|
||||
// not sure if we want to handle device changes, but whatevs.
|
||||
for (DStaticEventHandler* handler = eventManager.LastEventHandler; handler; handler = handler->prev)
|
||||
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (handler->IsUiProcessor)
|
||||
uiProcessorsFound = true;
|
||||
|
@ -494,25 +456,35 @@ bool EventManager::Responder(const event_t* ev)
|
|||
return true; // event was processed
|
||||
}
|
||||
}
|
||||
if (ShouldCallStatic(false)) uiProcessorsFound = staticEventManager.Responder(ev);
|
||||
|
||||
return (uiProcessorsFound && (ev->type == EV_Mouse)); // mouse events are eaten by the event system if there are any uiprocessors.
|
||||
}
|
||||
|
||||
void EventManager::Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(false)) staticEventManager.Console(player, name, arg1, arg2, arg3, manual);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->ConsoleProcess(player, name, arg1, arg2, arg3, manual);
|
||||
}
|
||||
|
||||
void EventManager::RenderOverlay(EHudState state)
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(false)) staticEventManager.RenderOverlay(state);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->RenderOverlay(state);
|
||||
}
|
||||
|
||||
bool EventManager::CheckUiProcessors()
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(false))
|
||||
{
|
||||
if (staticEventManager.CheckUiProcessors()) return true;
|
||||
}
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->IsUiProcessor)
|
||||
return true;
|
||||
|
||||
|
@ -521,7 +493,12 @@ bool EventManager::CheckUiProcessors()
|
|||
|
||||
bool EventManager::CheckRequireMouse()
|
||||
{
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(false))
|
||||
{
|
||||
if (staticEventManager.CheckRequireMouse()) return true;
|
||||
}
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->IsUiProcessor && handler->RequireMouse)
|
||||
return true;
|
||||
|
||||
|
@ -531,7 +508,11 @@ bool EventManager::CheckRequireMouse()
|
|||
bool EventManager::CheckReplacement( PClassActor *replacee, PClassActor **replacement )
|
||||
{
|
||||
bool final = false;
|
||||
for (DStaticEventHandler *handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
|
||||
// This is play scope but unlike in-game events needs to be handled like UI by static handlers.
|
||||
if (ShouldCallStatic(false)) final = staticEventManager.CheckReplacement(replacee, replacement);
|
||||
|
||||
for (DStaticEventHandler *handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->CheckReplacement(replacee,replacement,&final);
|
||||
return final;
|
||||
}
|
||||
|
@ -539,32 +520,28 @@ bool EventManager::CheckReplacement( PClassActor *replacee, PClassActor **replac
|
|||
bool EventManager::CheckReplacee(PClassActor **replacee, PClassActor *replacement)
|
||||
{
|
||||
bool final = false;
|
||||
for (DStaticEventHandler *handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (ShouldCallStatic(false)) final = staticEventManager.CheckReplacee(replacee, replacement);
|
||||
|
||||
for (DStaticEventHandler *handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->CheckReplacee(replacee, replacement, &final);
|
||||
return final;
|
||||
}
|
||||
|
||||
void EventManager::NewGame(EventHandlerType handlerType)
|
||||
void EventManager::NewGame()
|
||||
{
|
||||
bool isStatic = handlerType == EventHandlerType::Global;
|
||||
|
||||
// Shut down all per-map event handlers before static NewGame events.
|
||||
if (isStatic)
|
||||
EventManager::Shutdown(true);
|
||||
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
//This is called separately for static and local handlers, so no forwarding here.
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
{
|
||||
if (handler->IsStatic() == isStatic)
|
||||
handler->NewGame();
|
||||
handler->NewGame();
|
||||
}
|
||||
}
|
||||
|
||||
// normal event loopers (non-special, argument-less)
|
||||
DEFINE_EVENT_LOOPER(RenderFrame)
|
||||
DEFINE_EVENT_LOOPER(WorldLightning)
|
||||
DEFINE_EVENT_LOOPER(WorldTick)
|
||||
DEFINE_EVENT_LOOPER(UiTick)
|
||||
DEFINE_EVENT_LOOPER(PostUiTick)
|
||||
DEFINE_EVENT_LOOPER(RenderFrame, false)
|
||||
DEFINE_EVENT_LOOPER(WorldLightning, true)
|
||||
DEFINE_EVENT_LOOPER(WorldTick, true)
|
||||
DEFINE_EVENT_LOOPER(UiTick, false)
|
||||
DEFINE_EVENT_LOOPER(PostUiTick, false)
|
||||
|
||||
// declarations
|
||||
IMPLEMENT_CLASS(DStaticEventHandler, false, true);
|
||||
|
@ -644,8 +621,10 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder)
|
|||
PARAM_SELF_PROLOGUE(DStaticEventHandler);
|
||||
PARAM_INT(order);
|
||||
|
||||
/* not really needed - this is never checked again. To re-add, the handlers need a pointer to their manager but that's not worth it just for this check.
|
||||
if (eventManager.CheckHandler(self))
|
||||
return 0;
|
||||
*/
|
||||
|
||||
self->Order = order;
|
||||
return 0;
|
||||
|
@ -660,14 +639,14 @@ DEFINE_ACTION_FUNCTION(DEventHandler, SendNetworkEvent)
|
|||
PARAM_INT(arg3);
|
||||
//
|
||||
|
||||
ACTION_RETURN_BOOL(eventManager.SendNetworkEvent(name, arg1, arg2, arg3, false));
|
||||
ACTION_RETURN_BOOL(currentVMLevel->localEventManager->SendNetworkEvent(name, arg1, arg2, arg3, false));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DEventHandler, Find)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
for (DStaticEventHandler* handler = currentVMLevel->localEventManager->FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
ACTION_RETURN_OBJECT(nullptr);
|
||||
|
@ -678,7 +657,7 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, Find)
|
|||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
for (DStaticEventHandler* handler = eventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
for (DStaticEventHandler* handler = staticEventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
ACTION_RETURN_OBJECT(nullptr);
|
||||
|
@ -730,7 +709,7 @@ FWorldEvent EventManager::SetupWorldEvent()
|
|||
{
|
||||
FWorldEvent e;
|
||||
e.IsSaveGame = savegamerestore;
|
||||
e.IsReopen = level.FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1.
|
||||
e.IsReopen = Level->FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1.
|
||||
e.DamageAngle = 0.0;
|
||||
return e;
|
||||
}
|
||||
|
@ -741,7 +720,7 @@ void DStaticEventHandler::WorldLoaded()
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FWorldEvent e = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
|
@ -753,7 +732,7 @@ void DStaticEventHandler::WorldUnloaded()
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FWorldEvent e = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
|
@ -765,7 +744,7 @@ void DStaticEventHandler::WorldThingSpawned(AActor* actor)
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FWorldEvent e = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
|
@ -778,7 +757,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 = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
e.Inflictor = inflictor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
|
@ -792,7 +771,7 @@ void DStaticEventHandler::WorldThingRevived(AActor* actor)
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FWorldEvent e = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
|
@ -805,7 +784,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 = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
e.Inflictor = inflictor;
|
||||
e.Damage = damage;
|
||||
|
@ -824,7 +803,7 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor)
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FWorldEvent e = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
|
@ -837,7 +816,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 = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
e.ActivatedLine = line;
|
||||
e.ActivationType = activationType;
|
||||
|
@ -854,7 +833,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 = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
e.ActivatedLine = line;
|
||||
e.ActivationType = activationType;
|
||||
|
@ -869,7 +848,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 = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.DamageSource = source;
|
||||
e.DamageSector = sector;
|
||||
e.NewDamage = e.Damage = damage;
|
||||
|
@ -892,7 +871,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 = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
e.DamageSource = source;
|
||||
e.DamageLine = line;
|
||||
e.NewDamage = e.Damage = damage;
|
||||
|
@ -915,7 +894,7 @@ void DStaticEventHandler::WorldLightning()
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FWorldEvent e = eventManager.SetupWorldEvent();
|
||||
FWorldEvent e = owner->SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
|
@ -952,7 +931,7 @@ void DStaticEventHandler::RenderFrame()
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FRenderEvent e = eventManager.SetupRenderEvent();
|
||||
FRenderEvent e = owner->SetupRenderEvent;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
|
@ -965,7 +944,7 @@ void DStaticEventHandler::RenderOverlay(EHudState state)
|
|||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FRenderEvent e = eventManager.SetupRenderEvent();
|
||||
FRenderEvent e = owner->SetupRenderEvent();
|
||||
e.HudState = int(state);
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
|
@ -1190,7 +1169,7 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int
|
|||
}
|
||||
}
|
||||
|
||||
void DStaticEventHandler::CheckReplacement( PClassActor *replacee, PClassActor **replacement, bool *final )
|
||||
void DStaticEventHandler::CheckReplacement(PClassActor *replacee, PClassActor **replacement, bool *final )
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, CheckReplacement)
|
||||
{
|
||||
|
@ -1255,7 +1234,7 @@ CCMD(event)
|
|||
for (int i = 0; i < argn; i++)
|
||||
arg[i] = atoi(argv[2 + i]);
|
||||
// call locally
|
||||
eventManager.Console(-1, argv[1], arg[0], arg[1], arg[2], true);
|
||||
primaryLevel->localEventManager->Console(-1, argv[1], arg[0], arg[1], arg[2], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1280,6 +1259,6 @@ CCMD(netevent)
|
|||
for (int i = 0; i < argn; i++)
|
||||
arg[i] = atoi(argv[2 + i]);
|
||||
// call networked
|
||||
eventManager.SendNetworkEvent(argv[1], arg[0], arg[1], arg[2], true);
|
||||
primaryLevel->localEventManager->SendNetworkEvent(argv[1], arg[0], arg[1], arg[2], true);
|
||||
}
|
||||
}
|
||||
|
|
35
src/events.h
35
src/events.h
|
@ -1,5 +1,4 @@
|
|||
#ifndef EVENTS_H
|
||||
#define EVENTS_H
|
||||
#pragma once
|
||||
|
||||
#include "dobject.h"
|
||||
#include "serializer.h"
|
||||
|
@ -8,6 +7,7 @@
|
|||
#include "sbar.h"
|
||||
|
||||
class DStaticEventHandler;
|
||||
struct EventManager;
|
||||
|
||||
enum class EventHandlerType
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ public:
|
|||
IsUiProcessor = false;
|
||||
}
|
||||
|
||||
EventManager *owner;
|
||||
DStaticEventHandler* prev;
|
||||
DStaticEventHandler* next;
|
||||
virtual bool IsStatic() { return true; }
|
||||
|
@ -58,6 +59,8 @@ public:
|
|||
}
|
||||
*/
|
||||
|
||||
arc("next", next);
|
||||
arc("prev", prev);
|
||||
arc("Order", Order);
|
||||
arc("IsUiProcessor", IsUiProcessor);
|
||||
arc("RequireMouse", RequireMouse);
|
||||
|
@ -228,9 +231,15 @@ struct FReplacedEvent
|
|||
|
||||
struct EventManager
|
||||
{
|
||||
FLevelLocals *Level = nullptr;
|
||||
DStaticEventHandler* FirstEventHandler = nullptr;
|
||||
DStaticEventHandler* LastEventHandler = nullptr;
|
||||
|
||||
EventManager() = default;
|
||||
EventManager(FLevelLocals *l) { Level = l; }
|
||||
~EventManager() { Shutdown(); }
|
||||
bool ShouldCallStatic(bool forplay);
|
||||
|
||||
// register
|
||||
bool RegisterHandler(DStaticEventHandler* handler);
|
||||
// unregister
|
||||
|
@ -242,16 +251,12 @@ struct EventManager
|
|||
// init static handlers
|
||||
void InitStaticHandlers(bool map);
|
||||
// shutdown handlers
|
||||
void Shutdown(bool map);
|
||||
void Shutdown();
|
||||
|
||||
// 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.
|
||||
|
@ -301,7 +306,7 @@ struct EventManager
|
|||
bool CheckReplacee(PClassActor** replacee, PClassActor* replacement);
|
||||
|
||||
// called on new game
|
||||
void NewGame(EventHandlerType handlerType);
|
||||
void NewGame();
|
||||
|
||||
// send networked event. unified function.
|
||||
bool SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
|
@ -311,15 +316,19 @@ struct EventManager
|
|||
// 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();
|
||||
|
||||
void SetOwnerForHandlers()
|
||||
{
|
||||
for (DStaticEventHandler* existinghandler = FirstEventHandler; existinghandler; existinghandler = existinghandler->next)
|
||||
{
|
||||
existinghandler->owner = this;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern EventManager eventManager;
|
||||
|
||||
#endif
|
||||
extern EventManager staticEventManager;
|
||||
|
|
|
@ -3615,7 +3615,7 @@ void FParser::SF_ThingCount(void)
|
|||
pClass=T_GetMobjType(t_argv[0]);
|
||||
if (!pClass) return;
|
||||
// If we want to count map items we must consider actor replacement
|
||||
pClass = pClass->GetReplacement();
|
||||
pClass = pClass->GetReplacement(Level);
|
||||
|
||||
again:
|
||||
auto it = Level->GetThinkerIterator<AActor>();
|
||||
|
@ -3644,7 +3644,7 @@ void FParser::SF_ThingCount(void)
|
|||
{
|
||||
// Again, with decorate replacements
|
||||
replacemented = true;
|
||||
PClassActor *newkind = pClass->GetReplacement();
|
||||
PClassActor *newkind = pClass->GetReplacement(Level);
|
||||
if (newkind != pClass)
|
||||
{
|
||||
pClass = newkind;
|
||||
|
|
|
@ -1173,7 +1173,7 @@ void G_Ticker ()
|
|||
}
|
||||
|
||||
// [ZZ] also tick the UI part of the events
|
||||
eventManager.UiTick();
|
||||
primaryLevel->localEventManager->UiTick();
|
||||
C_RunDelayedCommands();
|
||||
|
||||
// do main actions
|
||||
|
@ -1213,7 +1213,7 @@ void G_Ticker ()
|
|||
}
|
||||
|
||||
// [MK] Additional ticker for UI events right after all others
|
||||
eventManager.PostUiTick();
|
||||
primaryLevel->localEventManager->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
|
||||
eventManager.PlayerDisconnected(playernum);
|
||||
mo->Level->localEventManager->PlayerDisconnected(playernum);
|
||||
// [RH] Let the scripts know the player left
|
||||
mo->Level->Behaviors.StartTypedScripts(SCRIPT_Disconnect, mo, true, playernum, true);
|
||||
if (mo != NULL)
|
||||
|
|
|
@ -454,7 +454,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
|
|||
|
||||
// did we have any level before?
|
||||
if (primaryLevel->info != nullptr)
|
||||
eventManager.WorldUnloadedUnsafe();
|
||||
staticEventManager.WorldUnloaded();
|
||||
|
||||
if (!savegamerestore)
|
||||
{
|
||||
|
@ -663,9 +663,13 @@ 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
|
||||
eventManager.WorldUnloaded();
|
||||
for (auto Level : AllLevels())
|
||||
{
|
||||
// Todo: This must be exolicitly sandboxed!
|
||||
Level->localEventManager->WorldUnloaded();
|
||||
}
|
||||
// [ZZ] unsafe world unload (changemap != map)
|
||||
eventManager.WorldUnloadedUnsafe();
|
||||
staticEventManager.WorldUnloaded();
|
||||
unloading = false;
|
||||
|
||||
STAT_ChangeLevel(nextlevel, this);
|
||||
|
@ -1019,13 +1023,16 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
|
|||
if (flags2 & LEVEL2_FORCETEAMPLAYOFF)
|
||||
teamplay = false;
|
||||
|
||||
FString mapname = nextmapname;
|
||||
mapname.ToLower();
|
||||
Printf (
|
||||
if (isPrimaryLevel())
|
||||
{
|
||||
FString mapname = nextmapname;
|
||||
mapname.ToLower();
|
||||
Printf(
|
||||
"\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
|
||||
"\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"
|
||||
TEXTCOLOR_BOLD "%s - %s\n\n",
|
||||
mapname.GetChars(), LevelName.GetChars());
|
||||
}
|
||||
|
||||
// Set the sky map.
|
||||
// First thing, we have a dummy sky texture name,
|
||||
|
@ -1063,7 +1070,7 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
|
|||
|
||||
if (newGame)
|
||||
{
|
||||
eventManager.NewGame(EventHandlerType::Global);
|
||||
staticEventManager.NewGame();
|
||||
}
|
||||
|
||||
P_SetupLevel (this, position, newGame);
|
||||
|
@ -1118,7 +1125,7 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
|
|||
}
|
||||
|
||||
const bool fromSnapshot = FromSnapshot;
|
||||
eventManager.PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub);
|
||||
localEventManager->PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub);
|
||||
|
||||
if (fromSnapshot)
|
||||
{
|
||||
|
@ -1136,9 +1143,9 @@ void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool au
|
|||
|
||||
StatusBar->AttachToPlayer (&players[consoleplayer]);
|
||||
// unsafe world load
|
||||
eventManager.WorldLoadedUnsafe();
|
||||
staticEventManager.WorldLoaded();
|
||||
// regular world load (savegames are handled internally)
|
||||
eventManager.WorldLoaded();
|
||||
localEventManager->WorldLoaded();
|
||||
DoDeferedScripts (); // [RH] Do script actions that were triggered on another map.
|
||||
|
||||
|
||||
|
@ -1484,6 +1491,7 @@ void FLevelLocals::Init()
|
|||
P_InitParticles(this);
|
||||
P_ClearParticles(this);
|
||||
BaseBlendA = 0.0f; // Remove underwater blend effect, if any
|
||||
localEventManager = new EventManager;
|
||||
|
||||
gravity = sv_gravity * 35/TICRATE;
|
||||
aircontrol = sv_aircontrol;
|
||||
|
@ -2121,6 +2129,8 @@ void FLevelLocals::Mark()
|
|||
GC::Mark(BotInfo.firstthing);
|
||||
GC::Mark(BotInfo.body1);
|
||||
GC::Mark(BotInfo.body2);
|
||||
GC::Mark(localEventManager->FirstEventHandler);
|
||||
GC::Mark(localEventManager->LastEventHandler);
|
||||
Thinkers.MarkRoots();
|
||||
canvasTextureInfo.Mark();
|
||||
for (auto &c : CorpseQueue)
|
||||
|
|
|
@ -96,6 +96,7 @@ class DAutomapBase;
|
|||
struct wbstartstruct_t;
|
||||
class DSectorMarker;
|
||||
struct FTranslator;
|
||||
struct EventManager;
|
||||
|
||||
typedef TMap<int, int> FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS)
|
||||
typedef TMap<FName, int> FDialogueMap; // maps actor class names to dialogue array index
|
||||
|
@ -442,6 +443,7 @@ public:
|
|||
TArray<FLinePortalSpan> linePortalSpans;
|
||||
FSectionContainer sections;
|
||||
FCanvasTextureInfo canvasTextureInfo;
|
||||
EventManager *localEventManager = nullptr;
|
||||
|
||||
// [ZZ] Destructible geometry information
|
||||
TMap<int, FHealthGroup> healthGroups;
|
||||
|
|
|
@ -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
|
||||
eventManager.WorldLightning();
|
||||
Level->localEventManager->WorldLightning();
|
||||
// start LIGHTNING scripts
|
||||
Level->Behaviors.StartTypedScripts (SCRIPT_Lightning, NULL, false); // [RH] Run lightning scripts
|
||||
|
||||
|
|
|
@ -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);
|
||||
eventManager.RenderOverlay(state);
|
||||
primaryLevel->localEventManager->RenderOverlay(state);
|
||||
|
||||
DrawConsistancy ();
|
||||
DrawWaiting ();
|
||||
|
|
|
@ -395,7 +395,7 @@ void PClassActor::StaticInit()
|
|||
InitBotStuff();
|
||||
|
||||
// reinit GLOBAL static stuff from gameinfo, once classes are loaded.
|
||||
eventManager.InitStaticHandlers(false);
|
||||
staticEventManager.InitStaticHandlers(false);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -517,7 +517,7 @@ void PClassActor::RegisterIDs()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PClassActor *PClassActor::GetReplacement(bool lookskill)
|
||||
PClassActor *PClassActor::GetReplacement(FLevelLocals *Level, bool lookskill)
|
||||
{
|
||||
FName skillrepname = NAME_None;
|
||||
|
||||
|
@ -538,7 +538,7 @@ PClassActor *PClassActor::GetReplacement(bool lookskill)
|
|||
}
|
||||
// [MK] ZScript replacement through Event Handlers, has priority over others
|
||||
PClassActor *Replacement = ActorInfo()->Replacement;
|
||||
if (eventManager.CheckReplacement(this,&Replacement) )
|
||||
if (Level->localEventManager->CheckReplacement(this,&Replacement) )
|
||||
{
|
||||
// [MK] the replacement is final, so don't continue with the chain
|
||||
return Replacement ? Replacement : this;
|
||||
|
@ -573,7 +573,7 @@ PClassActor *PClassActor::GetReplacement(bool lookskill)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PClassActor *PClassActor::GetReplacee(bool lookskill)
|
||||
PClassActor *PClassActor::GetReplacee(FLevelLocals *Level, bool lookskill)
|
||||
{
|
||||
FName skillrepname = NAME_None;
|
||||
|
||||
|
@ -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 (eventManager.CheckReplacee(&savedrep, this))
|
||||
if (Level->localEventManager->CheckReplacee(&savedrep, this))
|
||||
{
|
||||
// [MK] the replacement is final, so don't continue with the chain
|
||||
return savedrep ? savedrep : this;
|
||||
|
|
|
@ -350,8 +350,8 @@ public:
|
|||
return i != nullptr && state >= i->OwnedStates && state < i->OwnedStates + i->NumOwnedStates;
|
||||
}
|
||||
|
||||
PClassActor *GetReplacement(bool lookskill=true);
|
||||
PClassActor *GetReplacee(bool lookskill=true);
|
||||
PClassActor *GetReplacement(FLevelLocals *Level, bool lookskill=true);
|
||||
PClassActor *GetReplacee(FLevelLocals *Level, bool lookskill=true);
|
||||
|
||||
// For those times when being able to scan every kind of actor is convenient
|
||||
static TArray<PClassActor *> AllActorClasses;
|
||||
|
|
|
@ -3639,7 +3639,7 @@ do_count:
|
|||
{
|
||||
// Again, with decorate replacements
|
||||
replacemented = true;
|
||||
PClassActor *newkind = kind->GetReplacement();
|
||||
PClassActor *newkind = kind->GetReplacement(Level);
|
||||
if (newkind != kind)
|
||||
{
|
||||
kind = newkind;
|
||||
|
@ -3727,7 +3727,7 @@ int DLevelScript::DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle,
|
|||
|
||||
if (info != NULL)
|
||||
{
|
||||
info = info->GetReplacement ();
|
||||
info = info->GetReplacement (Level);
|
||||
|
||||
if ((GetDefaultByType (info)->flags3 & MF3_ISMONSTER) &&
|
||||
((dmflags & DF_NO_MONSTERS) || (Level->flags2 & LEVEL2_NOMONSTERS)))
|
||||
|
|
|
@ -3393,7 +3393,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WolfAttack)
|
|||
|| (self->target->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)));
|
||||
if (flags & WAF_USEPUFF && pufftype)
|
||||
{
|
||||
AActor *dpuff = GetDefaultByType(pufftype->GetReplacement());
|
||||
AActor *dpuff = GetDefaultByType(pufftype->GetReplacement(self->Level));
|
||||
mod = dpuff->DamageType;
|
||||
|
||||
if (dpuff->flags2 & MF2_THRUGHOST && self->target->flags3 & MF3_GHOST)
|
||||
|
|
|
@ -124,7 +124,7 @@ void P_DamageLinedef(line_t* line, AActor* source, int damage, FName damagetype,
|
|||
|
||||
if (dogroups)
|
||||
{
|
||||
damage = eventManager.WorldLineDamaged(line, source, damage, damagetype, side, position, isradius);
|
||||
damage = line->GetLevel()->localEventManager->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 = eventManager.WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
|
||||
damage = sector->Level->localEventManager->WorldSectorDamaged(sector, source, damage, damagetype, part, position, isradius);
|
||||
if (damage < 0) damage = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3073,7 +3073,7 @@ void A_BossDeath(AActor *self)
|
|||
FName mytype = self->GetClass()->TypeName;
|
||||
|
||||
// Ugh...
|
||||
FName type = self->GetClass()->GetReplacee()->TypeName;
|
||||
FName type = self->GetClass()->GetReplacee(self->Level)->TypeName;
|
||||
|
||||
// Do generic special death actions first
|
||||
bool checked = false;
|
||||
|
|
|
@ -347,7 +347,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
}
|
||||
|
||||
// [ZZ] Fire WorldThingDied script hook.
|
||||
eventManager.WorldThingDied(this, inflictor);
|
||||
Level->localEventManager->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
|
||||
eventManager.PlayerDied(Level->PlayerNum(player));
|
||||
Level->localEventManager->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);
|
||||
eventManager.WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
|
||||
target->Level->localEventManager->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)
|
||||
eventManager.WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
|
||||
target->Level->localEventManager->WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
|
||||
}
|
||||
|
||||
return MAX(0, realdamage);
|
||||
|
|
|
@ -4415,7 +4415,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
shootz += sz;
|
||||
|
||||
// We need to check the defaults of the replacement here
|
||||
AActor *puffDefaults = GetDefaultByType(pufftype->GetReplacement());
|
||||
AActor *puffDefaults = GetDefaultByType(pufftype->GetReplacement(t1->Level));
|
||||
|
||||
TData.hitGhosts = (t1->player != NULL &&
|
||||
t1->player->ReadyWeapon != NULL &&
|
||||
|
@ -5161,7 +5161,7 @@ void P_RailAttack(FRailParams *p)
|
|||
int flags;
|
||||
|
||||
assert(puffclass != NULL); // Because we set it to a default above
|
||||
AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement()); //Contains all the flags such as FOILINVUL, etc.
|
||||
AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement(source->Level)); //Contains all the flags such as FOILINVUL, etc.
|
||||
|
||||
// disabled because not complete yet.
|
||||
flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? TRACE_ReportPortals : TRACE_PCross | TRACE_Impact | TRACE_ReportPortals;
|
||||
|
|
|
@ -1208,7 +1208,7 @@ bool AActor::Grind(bool items)
|
|||
|
||||
if (i != NULL)
|
||||
{
|
||||
i = i->GetReplacement();
|
||||
i = i->GetReplacement(Level);
|
||||
|
||||
const AActor *defaults = GetDefaultByType (i);
|
||||
if (defaults->SpawnState == NULL ||
|
||||
|
@ -4539,7 +4539,7 @@ AActor *AActor::StaticSpawn(FLevelLocals *Level, PClassActor *type, const DVecto
|
|||
|
||||
if (allowreplacement)
|
||||
{
|
||||
type = type->GetReplacement();
|
||||
type = type->GetReplacement(Level);
|
||||
}
|
||||
|
||||
AActor *actor;
|
||||
|
@ -4682,7 +4682,7 @@ void AActor::PostBeginPlay ()
|
|||
void AActor::CallPostBeginPlay()
|
||||
{
|
||||
Super::CallPostBeginPlay();
|
||||
eventManager.WorldThingSpawned(this);
|
||||
Level->localEventManager->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.
|
||||
eventManager.WorldThingDestroyed(this);
|
||||
Level->localEventManager->WorldThingDestroyed(this);
|
||||
|
||||
DeleteAttachedLights();
|
||||
ClearRenderSectorList();
|
||||
|
@ -5155,7 +5155,7 @@ AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flag
|
|||
|
||||
DObject::StaticPointerSubstitution (oldactor, p->mo);
|
||||
|
||||
eventManager.PlayerRespawned(PlayerNum(p));
|
||||
localEventManager->PlayerRespawned(PlayerNum(p));
|
||||
Behaviors.StartTypedScripts (SCRIPT_Respawn, p->mo, true);
|
||||
}
|
||||
}
|
||||
|
@ -5363,7 +5363,7 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position)
|
|||
// it to the unknown thing.
|
||||
// Handle decorate replacements explicitly here
|
||||
// to check for missing frames in the replacement object.
|
||||
i = mentry->Type->GetReplacement();
|
||||
i = mentry->Type->GetReplacement(this);
|
||||
|
||||
const AActor *defaults = GetDefaultByType (i);
|
||||
if (defaults->SpawnState == NULL ||
|
||||
|
@ -7137,7 +7137,7 @@ void AActor::Revive()
|
|||
}
|
||||
|
||||
// [ZZ] resurrect hook
|
||||
eventManager.WorldThingRevived(this);
|
||||
Level->localEventManager->WorldThingRevived(this);
|
||||
}
|
||||
|
||||
int AActor::GetGibHealth() const
|
||||
|
|
|
@ -1000,7 +1000,8 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
|
|||
// [ZZ] serialize health groups
|
||||
P_SerializeHealthGroups(this, arc);
|
||||
// [ZZ] serialize events
|
||||
eventManager.SerializeEvents(arc);
|
||||
arc("firstevent", localEventManager->FirstEventHandler)
|
||||
("lastevent", localEventManager->LastEventHandler);
|
||||
Thinkers.SerializeThinkers(arc, hubload);
|
||||
arc("polyobjs", Polyobjects);
|
||||
SerializeSubsectors(arc, "subsectors");
|
||||
|
@ -1024,6 +1025,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
|
|||
FWeaponSlots::SetupWeaponSlots(Players[i]->mo);
|
||||
}
|
||||
}
|
||||
localEventManager->SetOwnerForHandlers(); // This cannot be automated.
|
||||
RecreateAllAttachedLights();
|
||||
InitPortalGroups(this);
|
||||
|
||||
|
|
|
@ -338,6 +338,8 @@ void FLevelLocals::ClearLevelData()
|
|||
Scrolls.Clear();
|
||||
if (automap) automap->Destroy();
|
||||
Behaviors.UnloadModules();
|
||||
delete localEventManager;
|
||||
localEventManager = nullptr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -348,9 +350,6 @@ void FLevelLocals::ClearLevelData()
|
|||
|
||||
void P_FreeLevelData ()
|
||||
{
|
||||
|
||||
// [ZZ] delete per-map event handlers
|
||||
eventManager.Shutdown(true);
|
||||
R_FreePastViewers();
|
||||
|
||||
for (auto Level : AllLevels())
|
||||
|
@ -425,7 +424,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)
|
||||
eventManager.InitStaticHandlers(true);
|
||||
Level->localEventManager->InitStaticHandlers(true);
|
||||
|
||||
// generate a checksum for the level, to be included and checked with savegames.
|
||||
map->GetChecksum(Level->md5);
|
||||
|
@ -434,7 +433,7 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
|
|||
|
||||
if (newGame)
|
||||
{
|
||||
eventManager.NewGame(EventHandlerType::PerMap);
|
||||
Level->localEventManager->NewGame();
|
||||
}
|
||||
|
||||
MapLoader loader(Level);
|
||||
|
@ -587,7 +586,7 @@ static void P_Shutdown ()
|
|||
}
|
||||
P_FreeLevelData ();
|
||||
// [ZZ] delete global event handlers
|
||||
eventManager.Shutdown(false);
|
||||
staticEventManager.Shutdown(); // clear out the handlers before starting the engine shutdown
|
||||
ST_Clear();
|
||||
for (auto &p : players)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
eventManager.WorldLinePreActivated(line, mo, activationType, &shouldactivate);
|
||||
Level->localEventManager->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 ) eventManager.WorldLineActivated(line, mo, activationType);
|
||||
if ( buttonSuccess ) Level->localEventManager->WorldLineActivated(line, mo, activationType);
|
||||
|
||||
special = line->special;
|
||||
if (!repeat && buttonSuccess)
|
||||
|
|
|
@ -62,7 +62,7 @@ bool FLevelLocals::EV_Thing_Spawn (int tid, AActor *source, int type, DAngle ang
|
|||
return false;
|
||||
|
||||
// Handle decorate replacements.
|
||||
kind = kind->GetReplacement();
|
||||
kind = kind->GetReplacement(this);
|
||||
|
||||
if ((GetDefaultByType(kind)->flags3 & MF3_ISMONSTER) &&
|
||||
((dmflags & DF_NO_MONSTERS) || (flags2 & LEVEL2_NOMONSTERS)))
|
||||
|
@ -274,7 +274,7 @@ bool FLevelLocals::EV_Thing_Projectile (int tid, AActor *source, int type, const
|
|||
}
|
||||
|
||||
// Handle decorate replacements.
|
||||
kind = kind->GetReplacement();
|
||||
kind = kind->GetReplacement(this);
|
||||
|
||||
defflags3 = GetDefaultByType(kind)->flags3;
|
||||
if ((defflags3 & MF3_ISMONSTER) &&
|
||||
|
|
|
@ -127,9 +127,14 @@ void P_Ticker (void)
|
|||
P_ResetSightCounters (false);
|
||||
R_ClearInterpolationPath();
|
||||
|
||||
// Since things will be moving, it's okay to interpolate them in the renderer.
|
||||
r_NoInterpolate = false;
|
||||
|
||||
// Reset all actor interpolations on all levels before the current thinking turn so that indirect actor movement gets properly interpolated.
|
||||
for (auto Level : AllLevels())
|
||||
{
|
||||
// todo: set up a sandbox for secondary levels here.
|
||||
|
||||
auto it = Level->GetThinkerIterator<AActor>();
|
||||
AActor *ac;
|
||||
|
||||
|
@ -138,22 +143,13 @@ void P_Ticker (void)
|
|||
ac->ClearInterpolation();
|
||||
}
|
||||
P_ThinkParticles(Level); // [RH] make the particles think
|
||||
}
|
||||
|
||||
// Since things will be moving, it's okay to interpolate them in the renderer.
|
||||
r_NoInterpolate = false;
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
if (Level->PlayerInGame(i))
|
||||
P_PlayerThink(Level->Players[i]);
|
||||
|
||||
|
||||
for (i = 0; i<MAXPLAYERS; i++)
|
||||
if (playeringame[i])
|
||||
P_PlayerThink (&players[i]);
|
||||
|
||||
// [ZZ] call the WorldTick hook
|
||||
eventManager.WorldTick();
|
||||
StatusBar->CallTick (); // [RH] moved this here
|
||||
for (auto Level : AllLevels())
|
||||
{
|
||||
// todo: set up a sandbox for secondary levels here.
|
||||
// [ZZ] call the WorldTick hook
|
||||
Level->localEventManager->WorldTick();
|
||||
Level->Tick(); // [RH] let the level tick
|
||||
Level->Thinkers.RunThinkers(Level);
|
||||
|
||||
|
@ -169,4 +165,5 @@ void P_Ticker (void)
|
|||
Level->maptime++;
|
||||
Level->totaltime++;
|
||||
}
|
||||
StatusBar->CallTick(); // Status bar should tick AFTER the thinkers to properly reflect the level's state at this time.
|
||||
}
|
||||
|
|
|
@ -654,8 +654,7 @@ bool player_t::Resurrect()
|
|||
|
||||
// player is now alive.
|
||||
// fire E_PlayerRespawned and start the ACS SCRIPT_Respawn.
|
||||
eventManager.PlayerRespawned(pnum);
|
||||
//
|
||||
mo->Level->localEventManager->PlayerRespawned(pnum);
|
||||
mo->Level->Behaviors.StartTypedScripts(SCRIPT_Respawn, mo, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1232,26 +1232,26 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpriteIndex, ZS_GetSpriteIndex)
|
|||
|
||||
static PClassActor *ZS_GetReplacement(PClassActor *c)
|
||||
{
|
||||
return c->GetReplacement();
|
||||
return c->GetReplacement(currentVMLevel);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetReplacement, ZS_GetReplacement)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_POINTER(c, PClassActor);
|
||||
ACTION_RETURN_POINTER(c->GetReplacement());
|
||||
ACTION_RETURN_POINTER(ZS_GetReplacement(c));
|
||||
}
|
||||
|
||||
static PClassActor *ZS_GetReplacee(PClassActor *c)
|
||||
{
|
||||
return c->GetReplacee();
|
||||
return c->GetReplacee(currentVMLevel);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetReplacee, ZS_GetReplacee)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_POINTER(c, PClassActor);
|
||||
ACTION_RETURN_POINTER(c->GetReplacee());
|
||||
ACTION_RETURN_POINTER(ZS_GetReplacee(c));
|
||||
}
|
||||
|
||||
static void DrawSplash(AActor *self, int count, double angle, int kind)
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
#include "events.h"
|
||||
#include "doomerrors.h"
|
||||
#include "i_system.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
// Prototypes and declarations.
|
||||
#include "rawinput.h"
|
||||
|
@ -177,7 +178,7 @@ static void I_CheckGUICapture ()
|
|||
}
|
||||
|
||||
// [ZZ] check active event handlers that want the UI processing
|
||||
if (!wantCapt && eventManager.CheckUiProcessors())
|
||||
if (!wantCapt && primaryLevel->localEventManager->CheckUiProcessors())
|
||||
wantCapt = true;
|
||||
|
||||
if (wantCapt != GUICapture)
|
||||
|
@ -781,7 +782,7 @@ void I_StartTic ()
|
|||
BlockMouseMove--;
|
||||
ResetButtonTriggers ();
|
||||
I_CheckGUICapture ();
|
||||
EventHandlerResultForNativeMouse = eventManager.CheckRequireMouse();
|
||||
EventHandlerResultForNativeMouse = primaryLevel->localEventManager->CheckRequireMouse();
|
||||
I_CheckNativeMouse (false, EventHandlerResultForNativeMouse);
|
||||
I_GetEvent ();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue