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

Method HookConVarChange

core/ConVarManager.cpp:516–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516void ConVarManager::HookConVarChange(ConVar *pConVar, IPluginFunction *pFunction)
517{
518 ConVarInfo *pInfo;
519 IChangeableForward *pForward;
520
521 /* Find the convar in the lookup trie */
522 if (convar_cache_lookup(pConVar->GetName(), &pInfo))
523 {
524 /* Get the forward */
525 pForward = pInfo->pChangeForward;
526
527 /* If forward does not exist, create it */
528 if (!pForward)
529 {
530 pForward = forwardsys->CreateForwardEx(NULL, ET_Ignore, 3, CONVARCHANGE_PARAMS);
531 pInfo->pChangeForward = pForward;
532 }
533
534 /* Add function to forward's list */
535 pForward->AddFunction(pFunction);
536 }
537}
538
539void ConVarManager::UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFunction)
540{

Callers 1

sm_HookConVarChangeFunction · 0.80

Calls 4

convar_cache_lookupFunction · 0.85
CreateForwardExMethod · 0.80
AddFunctionMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected