| 442 | } |
| 443 | |
| 444 | Handle_t ConVarManager::FindConVar(const char *name) |
| 445 | { |
| 446 | ConVar *pConVar = NULL; |
| 447 | ConVarInfo *pInfo; |
| 448 | Handle_t hndl; |
| 449 | |
| 450 | /* Check convar cache to find out if we already have a handle */ |
| 451 | if (convar_cache_lookup(name, &pInfo)) |
| 452 | { |
| 453 | return pInfo->handle; |
| 454 | } |
| 455 | |
| 456 | /* Couldn't find it in cache, so search for it */ |
| 457 | pConVar = icvar->FindVar(name); |
| 458 | |
| 459 | /* If it doesn't exist, then return an invalid handle */ |
| 460 | if (!pConVar) |
| 461 | { |
| 462 | return BAD_HANDLE; |
| 463 | } |
| 464 | |
| 465 | /* Create and initialize ConVarInfo structure */ |
| 466 | pInfo = new ConVarInfo(); |
| 467 | pInfo->sourceMod = false; |
| 468 | pInfo->pChangeForward = NULL; |
| 469 | pInfo->pVar = pConVar; |
| 470 | |
| 471 | /* If we don't have a handle, then create a new one */ |
| 472 | hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL); |
| 473 | if (hndl == BAD_HANDLE) |
| 474 | { |
| 475 | delete pInfo; |
| 476 | return BAD_HANDLE; |
| 477 | } |
| 478 | |
| 479 | pInfo->handle = hndl; |
| 480 | |
| 481 | /* Insert struct into our caches */ |
| 482 | m_ConVars.push_back(pInfo); |
| 483 | convar_cache.insert(name, pInfo); |
| 484 | TrackConCommandBase(pConVar, this); |
| 485 | |
| 486 | return hndl; |
| 487 | } |
| 488 | |
| 489 | void ConVarManager::AddConVarChangeListener(const char *name, IConVarChangeListener *pListener) |
| 490 | { |
nothing calls this directly
no test coverage detected