mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Made map-section handlers in MAPINFO not static. Static now unambiguously means 'global from GameInfo'.
This commit is contained in:
parent
26d38e6527
commit
6ada9c0291
1 changed files with 24 additions and 5 deletions
|
@ -119,15 +119,22 @@ static void E_InitStaticHandler(PClass* type, FString typestring, bool map)
|
||||||
{
|
{
|
||||||
if (type == nullptr)
|
if (type == nullptr)
|
||||||
{
|
{
|
||||||
Printf("%cGWarning: unknown event handler class %s in MAPINFO!\n", TEXTCOLOR_ESCAPE, typestring.GetChars());
|
I_Error("Fatal: unknown event handler class %s in MAPINFO!\n", TEXTCOLOR_ESCAPE, typestring.GetChars());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!E_IsStaticType(type))
|
if (E_IsStaticType(type) && map)
|
||||||
|
{
|
||||||
|
I_Error("Fatal: invalid event handler class %s in MAPINFO!\nMap-specific event handlers cannot be static.\n", typestring.GetChars());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (!E_IsStaticType(type) && !map)
|
||||||
{
|
{
|
||||||
Printf("%cGWarning: invalid event handler class %s in MAPINFO!\nMAPINFO event handlers should inherit Static* directly!\n", TEXTCOLOR_ESCAPE, typestring.GetChars());
|
Printf("%cGWarning: invalid event handler class %s in MAPINFO!\nMAPINFO event handlers should inherit Static* directly!\n", TEXTCOLOR_ESCAPE, typestring.GetChars());
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// check if type already exists, don't add twice.
|
// check if type already exists, don't add twice.
|
||||||
bool typeExists = false;
|
bool typeExists = false;
|
||||||
|
@ -153,13 +160,23 @@ void E_InitStaticHandlers(bool 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 map static handlers if any.
|
// delete old handlers if any.
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||||
{
|
{
|
||||||
if (handler->IsStatic() && handler->isMapScope)
|
if (!handler->IsStatic())
|
||||||
handler->Destroy();
|
handler->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load non-static handlers from gameinfo
|
||||||
|
for (unsigned int i = 0; i < gameinfo.EventHandlers.Size(); i++)
|
||||||
|
{
|
||||||
|
FString typestring = gameinfo.EventHandlers[i];
|
||||||
|
PClass* type = PClass::FindClass(typestring);
|
||||||
|
if (!type || E_IsStaticType(type)) // don't init the really global stuff here.
|
||||||
|
continue;
|
||||||
|
E_InitStaticHandler(type, typestring, false);
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < level.info->EventHandlers.Size(); i++)
|
for (unsigned int i = 0; i < level.info->EventHandlers.Size(); i++)
|
||||||
{
|
{
|
||||||
FString typestring = level.info->EventHandlers[i];
|
FString typestring = level.info->EventHandlers[i];
|
||||||
|
@ -180,6 +197,8 @@ void E_InitStaticHandlers(bool map)
|
||||||
{
|
{
|
||||||
FString typestring = gameinfo.EventHandlers[i];
|
FString typestring = gameinfo.EventHandlers[i];
|
||||||
PClass* type = PClass::FindClass(typestring);
|
PClass* type = PClass::FindClass(typestring);
|
||||||
|
if (!type || !E_IsStaticType(type)) // don't init map-local global stuff here.
|
||||||
|
continue;
|
||||||
E_InitStaticHandler(type, typestring, false);
|
E_InitStaticHandler(type, typestring, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue