| 283 | } |
| 284 | |
| 285 | void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) |
| 286 | { |
| 287 | int argcount = command->ArgC(); |
| 288 | if (argcount >= 3) |
| 289 | { |
| 290 | bool wantReset = false; |
| 291 | |
| 292 | /* Get plugin index that was passed */ |
| 293 | const char *arg = command->Arg(2); |
| 294 | if (argcount >= 4 && strcmp(arg, "reset") == 0) |
| 295 | { |
| 296 | wantReset = true; |
| 297 | arg = command->Arg(3); |
| 298 | } |
| 299 | |
| 300 | /* Get plugin object */ |
| 301 | IPlugin *plugin = scripts->FindPluginByConsoleArg(arg); |
| 302 | |
| 303 | if (!plugin) |
| 304 | { |
| 305 | UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", arg); |
| 306 | return; |
| 307 | } |
| 308 | |
| 309 | /* Get plugin name */ |
| 310 | const sm_plugininfo_t *plinfo = plugin->GetPublicInfo(); |
| 311 | const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename(); |
| 312 | |
| 313 | ConVarList *pConVarList; |
| 314 | ConVarList::iterator iter; |
| 315 | |
| 316 | /* If no convar list... */ |
| 317 | if (!plugin->GetProperty("ConVarList", (void **)&pConVarList)) |
| 318 | { |
| 319 | UTIL_ConsolePrint("[SM] No convars found for: %s", plname); |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | if (!wantReset) |
| 324 | { |
| 325 | UTIL_ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname); |
| 326 | UTIL_ConsolePrint(" %-32.31s %s", "[Name]", "[Value]"); |
| 327 | } |
| 328 | |
| 329 | /* Iterate convar list and display/reset each one */ |
| 330 | for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++) |
| 331 | { |
| 332 | /*const */ConVar *pConVar = const_cast<ConVar *>(*iter); |
| 333 | if (!wantReset) |
| 334 | { |
| 335 | UTIL_ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString()); |
| 336 | } else { |
| 337 | pConVar->Revert(); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | if (wantReset) |
| 342 | { |
nothing calls this directly
no test coverage detected