| 172 | } |
| 173 | |
| 174 | void UnhookCommand(ConCommandBase *pBase) |
| 175 | { |
| 176 | if (!pBase->IsCommand()) |
| 177 | return; |
| 178 | |
| 179 | ConCommand *cmd = (ConCommand*)pBase; |
| 180 | void **vtable = GetVirtualTable(cmd); |
| 181 | |
| 182 | size_t index; |
| 183 | if (!FindVtable(vtable, index)) |
| 184 | { |
| 185 | logger->LogError("Console detour tried to unhook command \"%s\" but it wasn't found", pBase->GetName()); |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | assert(vtables[index].refcount > 0); |
| 190 | vtables[index].refcount--; |
| 191 | if (vtables[index].refcount == 0) |
| 192 | { |
| 193 | SH_REMOVE_HOOK_ID(vtables[index].hook); |
| 194 | vtables.erase(vtables.iterAt(index)); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | public: |
| 199 | GenericCommandHooker() : enabled(false) |