Fix SDKHooks causing crash on plugin load/unload or player connect/disconnect if missing gamedata.
This commit is contained in:
parent
5961ed2e4a
commit
aa38226337
@ -219,6 +219,26 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer[0] = '\0';
|
||||
if (!gameconfs->LoadGameConfigFile("sdkhooks.games", &g_pGameConf, buffer, sizeof(buffer)))
|
||||
{
|
||||
if (buffer[0])
|
||||
{
|
||||
g_pSM->Format(error, maxlength, "Could not read sdkhooks.games gamedata: %s", buffer);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CUtlVector<IEntityListener *> *entListeners = EntListeners();
|
||||
if (!entListeners)
|
||||
{
|
||||
g_pSM->Format(error, maxlength, "Failed to setup entity listeners");
|
||||
return false;
|
||||
}
|
||||
|
||||
entListeners->AddToTail(this);
|
||||
|
||||
sharesys->AddDependency(myself, "bintools.ext", true, true);
|
||||
sharesys->AddNatives(myself, g_Natives);
|
||||
sharesys->RegisterLibrary(myself, "sdkhooks");
|
||||
@ -237,26 +257,6 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
#endif
|
||||
g_pOnLevelInit = forwards->CreateForward("OnLevelInit", ET_Hook, 2, NULL, Param_String, Param_String);
|
||||
|
||||
buffer[0] = '\0';
|
||||
if (!gameconfs->LoadGameConfigFile("sdkhooks.games", &g_pGameConf, buffer, sizeof(buffer)))
|
||||
{
|
||||
if (buffer[0])
|
||||
{
|
||||
g_pSM->Format(error, maxlength, "Could not read sdkhooks.games gamedata: %s", buffer);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CUtlVector<IEntityListener *> *entListeners = EntListeners();
|
||||
if (!entListeners)
|
||||
{
|
||||
g_pSM->Format(error, maxlength, "Failed to setup entity listeners");
|
||||
return false;
|
||||
}
|
||||
|
||||
entListeners->AddToTail(this);
|
||||
|
||||
SetupHooks();
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
|
Loading…
Reference in New Issue
Block a user