mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
Explicit handler deinitizliation in P_Shutdown and P_FreeLevelData
This commit is contained in:
parent
9bb4cf1c03
commit
b45af599c5
3 changed files with 19 additions and 14 deletions
|
@ -200,15 +200,11 @@ void E_InitStaticHandlers(bool map)
|
||||||
if (savegamerestore)
|
if (savegamerestore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// just make sure
|
||||||
|
E_Shutdown(map);
|
||||||
|
|
||||||
if (map) // don't initialize map handlers if restoring from savegame.
|
if (map) // don't initialize map handlers if restoring from savegame.
|
||||||
{
|
{
|
||||||
// delete old handlers if any.
|
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
|
||||||
{
|
|
||||||
if (!handler->IsStatic())
|
|
||||||
handler->Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// load non-static handlers from gameinfo
|
// load non-static handlers from gameinfo
|
||||||
for (unsigned int i = 0; i < gameinfo.EventHandlers.Size(); i++)
|
for (unsigned int i = 0; i < gameinfo.EventHandlers.Size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -228,13 +224,6 @@ void E_InitStaticHandlers(bool map)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// delete old static handlers if any.
|
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
|
||||||
{
|
|
||||||
if (handler->IsStatic())
|
|
||||||
handler->Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < gameinfo.EventHandlers.Size(); i++)
|
for (unsigned int i = 0; i < gameinfo.EventHandlers.Size(); i++)
|
||||||
{
|
{
|
||||||
FString typestring = gameinfo.EventHandlers[i];
|
FString typestring = gameinfo.EventHandlers[i];
|
||||||
|
@ -246,6 +235,16 @@ void E_InitStaticHandlers(bool map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void E_Shutdown(bool map)
|
||||||
|
{
|
||||||
|
// delete handlers.
|
||||||
|
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||||
|
{
|
||||||
|
if (handler->IsStatic() == !map)
|
||||||
|
handler->Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define DEFINE_EVENT_LOOPER(name) void E_##name() \
|
#define DEFINE_EVENT_LOOPER(name) void E_##name() \
|
||||||
{ \
|
{ \
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) \
|
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) \
|
||||||
|
|
|
@ -18,6 +18,8 @@ bool E_CheckHandler(DStaticEventHandler* handler);
|
||||||
bool E_IsStaticType(PClass* type);
|
bool E_IsStaticType(PClass* type);
|
||||||
// init static handlers
|
// init static handlers
|
||||||
void E_InitStaticHandlers(bool map);
|
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)
|
// called right after the map has loaded (approximately same time as OPEN ACS scripts)
|
||||||
void E_WorldLoaded();
|
void E_WorldLoaded();
|
||||||
|
|
|
@ -3424,6 +3424,8 @@ extern polyblock_t **PolyBlockMap;
|
||||||
|
|
||||||
void P_FreeLevelData ()
|
void P_FreeLevelData ()
|
||||||
{
|
{
|
||||||
|
// [ZZ] delete per-map event handlers
|
||||||
|
E_Shutdown(true);
|
||||||
P_FreeMapDataBackup();
|
P_FreeMapDataBackup();
|
||||||
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
||||||
Renderer->CleanLevelData();
|
Renderer->CleanLevelData();
|
||||||
|
@ -4189,6 +4191,8 @@ void P_Init ()
|
||||||
|
|
||||||
static void P_Shutdown ()
|
static void P_Shutdown ()
|
||||||
{
|
{
|
||||||
|
// [ZZ] delete global event handlers
|
||||||
|
E_Shutdown(false);
|
||||||
R_DeinitSpriteData ();
|
R_DeinitSpriteData ();
|
||||||
P_DeinitKeyMessages ();
|
P_DeinitKeyMessages ();
|
||||||
P_FreeLevelData ();
|
P_FreeLevelData ();
|
||||||
|
|
Loading…
Reference in a new issue