From aa38226337ef08b3ea38c4e7a4684b3840c2e796 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 30 Dec 2014 20:56:28 -0500 Subject: [PATCH] Fix SDKHooks causing crash on plugin load/unload or player connect/disconnect if missing gamedata. --- extensions/sdkhooks/extension.cpp | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index d24c1527..1cfd27ab 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -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 *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 *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