| 537 | } |
| 538 | |
| 539 | void 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 | |
| 576 | QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char *name, IPluginFunction *pCallback, Handle_t hndl) |
| 577 | { |
no test coverage detected