void HolidayManager::UnhookIfNecessary() { // Not hooked if (!m_iHookID) return; // We're still wanted if (m_isHolidayForward->GetFunctionCount() > 0) return; SH_REMOVE_HOOK_ID(m_iHookID); m_iHookID = 0; }
void UnhookCommand(ConCommandBase *pBase) { if (!pBase->IsCommand()) return; ConCommand *cmd = (ConCommand*)pBase; void **vtable = GetVirtualTable(cmd); size_t index; if (!FindVtable(vtable, index)) { logger->LogError("Console detour tried to unhook command \"%s\" but it wasn't found", pBase->GetName()); return; } assert(vtables[index].refcount > 0); vtables[index].refcount--; if (vtables[index].refcount == 0) { SH_REMOVE_HOOK_ID(vtables[index].hook); vtables.erase(vtables.iterAt(index)); } }
CommandHook::~CommandHook() { if(this->hook_id) { SH_REMOVE_HOOK_ID(this->hook_id); } }