| 623 | } |
| 624 | |
| 625 | void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue) |
| 626 | { |
| 627 | /* If the values are the same, exit early in order to not trigger callbacks */ |
| 628 | if (strcmp(pConVar->GetString(), oldValue) == 0) |
| 629 | { |
| 630 | return; |
| 631 | } |
| 632 | |
| 633 | ConVarInfo *pInfo; |
| 634 | |
| 635 | /* Find the convar in the lookup trie */ |
| 636 | if (!convar_cache_lookup(pConVar->GetName(), &pInfo)) |
| 637 | { |
| 638 | return; |
| 639 | } |
| 640 | |
| 641 | IChangeableForward *pForward = pInfo->pChangeForward; |
| 642 | |
| 643 | if (pInfo->changeListeners.size() != 0) |
| 644 | { |
| 645 | for (auto i = pInfo->changeListeners.begin(); i != pInfo->changeListeners.end(); i++) |
| 646 | (*i)->OnConVarChanged(pConVar, oldValue, flOldValue); |
| 647 | } |
| 648 | |
| 649 | if (pForward != NULL) |
| 650 | { |
| 651 | ConVarReentrancyGuard guard(pConVar); |
| 652 | |
| 653 | /* Copy the new value to a local buffer so it survives reentrant |
| 654 | * ChangeStringValue calls that may delete[] + reallocate m_pszString |
| 655 | * while the forward is still iterating plugin callbacks. */ |
| 656 | char newValue[512]; |
| 657 | ke::SafeStrcpy(newValue, sizeof(newValue), pConVar->GetString()); |
| 658 | |
| 659 | /* Now call forwards in plugins that have hooked this */ |
| 660 | pForward->PushCell(pInfo->handle); |
| 661 | pForward->PushString(oldValue); |
| 662 | pForward->PushString(newValue); |
| 663 | pForward->Execute(NULL); |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | bool ConVarManager::IsQueryingSupported() |
| 668 | { |
nothing calls this directly
no test coverage detected