Fixed SDKTools not cleaning up its handle types on shutdown (but 2753).
This commit is contained in:
parent
ef62e3d665
commit
09ea2e13aa
@ -82,6 +82,8 @@ extern sp_nativeinfo_t g_TeamNatives[];
|
|||||||
|
|
||||||
bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||||
{
|
{
|
||||||
|
HandleError err;
|
||||||
|
|
||||||
if (!gameconfs->LoadGameConfigFile(SDKTOOLS_GAME_FILE, &g_pGameConf, error, maxlength))
|
if (!gameconfs->LoadGameConfigFile(SDKTOOLS_GAME_FILE, &g_pGameConf, error, maxlength))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -102,14 +104,26 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
SM_GET_IFACE(GAMEHELPERS, g_pGameHelpers);
|
SM_GET_IFACE(GAMEHELPERS, g_pGameHelpers);
|
||||||
|
|
||||||
playerhelpers->AddClientListener(&g_SdkTools);
|
playerhelpers->AddClientListener(&g_SdkTools);
|
||||||
g_CallHandle = handlesys->CreateType("ValveCall", this, 0, NULL, NULL, myself->GetIdentity(), NULL);
|
g_CallHandle = handlesys->CreateType("ValveCall", this, 0, NULL, NULL, myself->GetIdentity(), &err);
|
||||||
|
if (g_CallHandle == 0)
|
||||||
|
{
|
||||||
|
snprintf(error, maxlength, "Could not create call handle type (err: %d)", err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
TypeAccess TraceAccess;
|
TypeAccess TraceAccess;
|
||||||
handlesys->InitAccessDefaults(&TraceAccess, NULL);
|
handlesys->InitAccessDefaults(&TraceAccess, NULL);
|
||||||
TraceAccess.ident = myself->GetIdentity();
|
TraceAccess.ident = myself->GetIdentity();
|
||||||
TraceAccess.access[HTypeAccess_Create] = true;
|
TraceAccess.access[HTypeAccess_Create] = true;
|
||||||
TraceAccess.access[HTypeAccess_Inherit] = true;
|
TraceAccess.access[HTypeAccess_Inherit] = true;
|
||||||
g_TraceHandle = handlesys->CreateType("TraceRay", this, 0, &TraceAccess, NULL, myself->GetIdentity(), NULL);
|
g_TraceHandle = handlesys->CreateType("TraceRay", this, 0, &TraceAccess, NULL, myself->GetIdentity(), &err);
|
||||||
|
if (g_TraceHandle == 0)
|
||||||
|
{
|
||||||
|
handlesys->RemoveType(g_CallHandle, myself->GetIdentity());
|
||||||
|
g_CallHandle = 0;
|
||||||
|
snprintf(error, maxlength, "Could not create traceray handle type (err: %d)", err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined ORANGEBOX_BUILD
|
#if defined ORANGEBOX_BUILD
|
||||||
g_pCVar = icvar;
|
g_pCVar = icvar;
|
||||||
@ -186,6 +200,23 @@ void SDKTools::SDK_OnUnload()
|
|||||||
SH_RELEASE_CALLCLASS(enginesoundPatch);
|
SH_RELEASE_CALLCLASS(enginesoundPatch);
|
||||||
enginesoundPatch = NULL;
|
enginesoundPatch = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool err;
|
||||||
|
if (g_CallHandle != 0)
|
||||||
|
{
|
||||||
|
if ((err = handlesys->RemoveType(g_CallHandle, myself->GetIdentity())) != true)
|
||||||
|
{
|
||||||
|
g_pSM->LogError(myself, "Could not remove call handle (type=%x, err=%d)", g_CallHandle, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_TraceHandle != 0)
|
||||||
|
{
|
||||||
|
if ((err = handlesys->RemoveType(g_TraceHandle, myself->GetIdentity())) != true)
|
||||||
|
{
|
||||||
|
g_pSM->LogError(myself, "Could not remove trace handle (type=%x, err=%d)", g_TraceHandle, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||||
|
Loading…
Reference in New Issue
Block a user