Merged in vgpowerlord/dhooks2/sdhooks-fix (pull request #1)

Fix for SDKHooks dependency issue
This commit is contained in:
Ruben Gonzalez 2014-06-29 17:07:08 -04:00
commit 36838be6af
2 changed files with 47 additions and 1 deletions

View File

@ -110,3 +110,47 @@ void DHooks::OnPluginUnloaded(IPlugin *plugin)
g_pEntityListener->CleanupListeners(plugin->GetBaseContext()); g_pEntityListener->CleanupListeners(plugin->GetBaseContext());
} }
} }
// The next 3 functions handle cleanup if our interfaces are going to be unloaded
bool DHooks::QueryRunning(char *error, size_t maxlength)
{
SM_CHECK_IFACE(SDKTOOLS, g_pSDKTools);
SM_CHECK_IFACE(BINTOOLS, g_pBinTools);
SM_CHECK_IFACE(SDKHOOKS, g_pSDKHooks);
return true;
}
/*
// The default for this one is *supposed* to be false already
bool DHooks::QueryInterfaceDrop(SMInterface *pInterface)
{
if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKTOOLS_NAME) == 0
|| strcmp(pInterface->GetInterfaceName(), SMINTERFACE_BINTOOL_NAME) == 0)
|| strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKHOOKS_NAME) == 0)
{
return false;
}
return true;
}
*/
void DHooks::NotifyInterfaceDrop(SMInterface *pInterface)
{
if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKHOOKS_NAME) == 0)
{
if (g_pEntityListener)
{
// If this fails, remove this line and just delete the ent listener instead
g_pSDKHooks->RemoveEntityListener(g_pEntityListener);
delete g_pEntityListener;
g_pEntityListener = NULL;
}
g_pSDKHooks = NULL;
}
else if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_BINTOOLS_NAME) == 0)
{
g_pBinTools = NULL;
}
else if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKTOOLS_NAME) == 0)
{
g_pSDKTools = NULL;
}
}

View File

@ -88,7 +88,9 @@ public:
* @param maxlength Size of error message buffer. * @param maxlength Size of error message buffer.
* @return True if working, false otherwise. * @return True if working, false otherwise.
*/ */
//virtual bool QueryRunning(char *error, size_t maxlength); virtual bool QueryRunning(char *error, size_t maxlength);
//virtual bool QueryInterfaceDrop(SMInterface *pInterface);
virtual void NotifyInterfaceDrop(SMInterface *pInterface);
public: public:
#if defined SMEXT_CONF_METAMOD #if defined SMEXT_CONF_METAMOD
/** /**