Add OnMapInit forward and deprecate OnLevelInit
The change in behaviour to the OnLevelInit forward params isn't obvious when compiling a plugin, deprecate it to make it a lot more obvious that something has changed. Some plugins rely just on the timing of OnLevelInit rather than doing anything with the entity lump, for these plugins offer a new OnMapInit forward that is implemented in core rather than sdkhooks. If / when we offer a new entity lump manipulation API in the future this'll be the forward where it can be used to make changes.
This commit is contained in:
parent
70c9a6528a
commit
7f2fdf3fe1
@ -63,7 +63,8 @@ ISourcePawnEngine *g_pSourcePawn = NULL;
|
|||||||
ISourcePawnEngine2 *g_pSourcePawn2 = NULL;
|
ISourcePawnEngine2 *g_pSourcePawn2 = NULL;
|
||||||
ISourcePawnEnvironment *g_pPawnEnv = NULL;
|
ISourcePawnEnvironment *g_pPawnEnv = NULL;
|
||||||
IdentityToken_t *g_pCoreIdent = NULL;
|
IdentityToken_t *g_pCoreIdent = NULL;
|
||||||
IForward *g_pOnMapEnd = NULL;
|
IForward *g_pOnMapInit = nullptr;
|
||||||
|
IForward *g_pOnMapEnd = nullptr;
|
||||||
IGameConfig *g_pGameConf = NULL;
|
IGameConfig *g_pGameConf = NULL;
|
||||||
bool g_Loaded = false;
|
bool g_Loaded = false;
|
||||||
bool sm_show_debug_spew = false;
|
bool sm_show_debug_spew = false;
|
||||||
@ -403,6 +404,11 @@ bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, ch
|
|||||||
pBase = pBase->m_pGlobalClassNext;
|
pBase = pBase->m_pGlobalClassNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!g_pOnMapInit)
|
||||||
|
{
|
||||||
|
g_pOnMapInit = forwardsys->CreateForward("OnMapInit", ET_Ignore, 1, NULL, Param_String);
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_pOnMapEnd)
|
if (!g_pOnMapEnd)
|
||||||
{
|
{
|
||||||
g_pOnMapEnd = forwardsys->CreateForward("OnMapEnd", ET_Ignore, 0, NULL);
|
g_pOnMapEnd = forwardsys->CreateForward("OnMapEnd", ET_Ignore, 0, NULL);
|
||||||
@ -410,6 +416,9 @@ bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, ch
|
|||||||
|
|
||||||
g_LevelEndBarrier = true;
|
g_LevelEndBarrier = true;
|
||||||
|
|
||||||
|
g_pOnMapInit->PushString(pMapName);
|
||||||
|
g_pOnMapInit->Execute();
|
||||||
|
|
||||||
RETURN_META_VALUE(MRES_IGNORED, true);
|
RETURN_META_VALUE(MRES_IGNORED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,10 +433,8 @@ void SourceModBase::LevelShutdown()
|
|||||||
next = next->m_pGlobalClassNext;
|
next = next->m_pGlobalClassNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_pOnMapEnd != NULL)
|
g_pOnMapEnd->Execute();
|
||||||
{
|
|
||||||
g_pOnMapEnd->Execute(NULL);
|
|
||||||
}
|
|
||||||
extsys->CallOnCoreMapEnd();
|
extsys->CallOnCoreMapEnd();
|
||||||
|
|
||||||
g_Timers.RemoveMapChangeTimers();
|
g_Timers.RemoveMapChangeTimers();
|
||||||
@ -548,8 +555,17 @@ void SourceModBase::ShutdownServices()
|
|||||||
/* Unload extensions */
|
/* Unload extensions */
|
||||||
extsys->Shutdown();
|
extsys->Shutdown();
|
||||||
|
|
||||||
|
if (g_pOnMapInit)
|
||||||
|
{
|
||||||
|
forwardsys->ReleaseForward(g_pOnMapInit);
|
||||||
|
g_pOnMapInit = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_pOnMapEnd)
|
if (g_pOnMapEnd)
|
||||||
|
{
|
||||||
forwardsys->ReleaseForward(g_pOnMapEnd);
|
forwardsys->ReleaseForward(g_pOnMapEnd);
|
||||||
|
g_pOnMapEnd = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/* Notify! */
|
/* Notify! */
|
||||||
SMGlobalClass *pBase = SMGlobalClass::head;
|
SMGlobalClass *pBase = SMGlobalClass::head;
|
||||||
|
@ -382,6 +382,7 @@ forward Action OnGetGameDescription(char gameDesc[64]);
|
|||||||
* @param mapEntities Unused, always empty
|
* @param mapEntities Unused, always empty
|
||||||
* @return Unused, return value is ignored
|
* @return Unused, return value is ignored
|
||||||
*/
|
*/
|
||||||
|
#pragma deprecated Use OnMapInit() instead
|
||||||
forward Action OnLevelInit(const char[] mapName, char mapEntities[2097152]);
|
forward Action OnLevelInit(const char[] mapName, char mapEntities[2097152]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,10 +182,14 @@ forward void OnPluginPauseChange(bool pause);
|
|||||||
forward void OnGameFrame();
|
forward void OnGameFrame();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the map is loaded.
|
* Called when the map starts loading.
|
||||||
*
|
*
|
||||||
* @note This used to be OnServerLoad(), which is now deprecated.
|
* @param mapName Name of the map
|
||||||
* Plugins still using the old forward will work.
|
*/
|
||||||
|
forward void OnMapInit(const char[] mapName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the map is loaded.
|
||||||
*/
|
*/
|
||||||
forward void OnMapStart();
|
forward void OnMapStart();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user