| 423 | } |
| 424 | |
| 425 | bool SM_ConfigCheckRegeneration( |
| 426 | const char *file, |
| 427 | ke::HashMap<std::string, std::string, StringPolicy> &existing_cvars, |
| 428 | List<const ConVar *> &convars) |
| 429 | { |
| 430 | FILE *fp = fopen(file, "rt"); |
| 431 | if (!fp) |
| 432 | { |
| 433 | logger->LogError("Failed to read config for checking regeneration, make sure the directory has read permission."); |
| 434 | return true; |
| 435 | } |
| 436 | |
| 437 | SM_ParseConfig(fp, existing_cvars); |
| 438 | fclose(fp); |
| 439 | |
| 440 | /* #1. Check if the plugin's cvar list has a cvar that doesn't exist in the config file. */ |
| 441 | for (List<const ConVar *>::iterator iter = convars.begin(); iter != convars.end(); iter++) |
| 442 | { |
| 443 | const ConVar *cvar = (*iter); |
| 444 | #if SOURCE_ENGINE >= SE_ORANGEBOX |
| 445 | if (cvar->IsFlagSet(FCVAR_DONTRECORD)) |
| 446 | #else |
| 447 | if (cvar->IsBitSet(FCVAR_DONTRECORD)) |
| 448 | #endif |
| 449 | { |
| 450 | continue; |
| 451 | } |
| 452 | |
| 453 | if (!SM_CvarExistsInConfig(existing_cvars, cvar->GetName())) |
| 454 | { |
| 455 | return true; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* #2. Check if the config file has a cvar that doesn't exist in the plugin's cvar list. */ |
| 460 | for (auto it = existing_cvars.iter(); !it.empty(); it.next()) |
| 461 | { |
| 462 | if (!SM_CvarExistsInPlugin(convars, it->key.c_str())) |
| 463 | { |
| 464 | return true; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | return false; |
| 469 | } |
| 470 | |
| 471 | inline void SM_ExecuteConfigFile(const char *file) |
| 472 | { |
no test coverage detected