MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / UnhookConVarChange

Method UnhookConVarChange

core/ConVarManager.cpp:539–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537}
538
539void ConVarManager::UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFunction)
540{
541 ConVarInfo *pInfo;
542 IChangeableForward *pForward;
543 IPluginContext *pContext = pFunction->GetParentContext();
544
545 /* Find the convar in the lookup trie */
546 if (convar_cache_lookup(pConVar->GetName(), &pInfo))
547 {
548 /* Get the forward */
549 pForward = pInfo->pChangeForward;
550
551 /* If the forward doesn't exist, we can't unhook anything */
552 if (!pForward)
553 {
554 pContext->ThrowNativeError("Convar \"%s\" has no active hook", pConVar->GetName());
555 return;
556 }
557
558 /* Remove the function from the forward's list */
559 if (!pForward->RemoveFunction(pFunction))
560 {
561 pContext->ThrowNativeError("Invalid hook callback specified for convar \"%s\"", pConVar->GetName());
562 return;
563 }
564
565 /* If the forward now has 0 functions in it... */
566 if (pForward->GetFunctionCount() == 0 &&
567 !ConVarReentrancyGuard::IsCvarInChain(pConVar))
568 {
569 /* Free this forward */
570 forwardsys->ReleaseForward(pForward);
571 pInfo->pChangeForward = NULL;
572 }
573 }
574}
575
576QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char *name, IPluginFunction *pCallback, Handle_t hndl)
577{

Callers 1

sm_UnhookConVarChangeFunction · 0.80

Calls 5

convar_cache_lookupFunction · 0.85
RemoveFunctionMethod · 0.80
GetFunctionCountMethod · 0.80
ReleaseForwardMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected