[VisionFile] Fix ill-defined loop or something

This commit is contained in:
Diavolo 2022-06-30 23:57:23 +02:00
parent 562cac3a99
commit aa6a8a29be
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5

View File

@ -9,22 +9,14 @@ namespace Components
void VisionFile::ApplyExemptDvar(const std::string& dvarName, const char* buffer, const std::string& fileName) void VisionFile::ApplyExemptDvar(const std::string& dvarName, const char* buffer, const std::string& fileName)
{ {
for (std::size_t i = 0; i < std::extent_v<decltype(DvarExceptions)>; ++i) for (std::size_t i = 0; i < ARRAYSIZE(DvarExceptions); ++i)
{ {
if (dvarName == DvarExceptions[i]) if (dvarName == DvarExceptions[i])
{ {
const auto* dvar = Game::Dvar_FindVar(dvarName.data()); const auto* dvar = Game::Dvar_FindVar(dvarName.data());
assert(dvar != nullptr);
const auto* currentVal = Game::Dvar_DisplayableValue(dvar);
const auto* parsedValue = Game::Com_ParseOnLine(&buffer); const auto* parsedValue = Game::Com_ParseOnLine(&buffer);
if (std::strcmp(parsedValue, currentVal) == 0) assert(dvar != nullptr);
{
// The dvar is already set to the value we want
return;
}
Game::Dvar_SetFromStringFromSource(dvar, parsedValue, Game::DvarSetSource::DVAR_SOURCE_INTERNAL); Game::Dvar_SetFromStringFromSource(dvar, parsedValue, Game::DvarSetSource::DVAR_SOURCE_INTERNAL);
Logger::Print("Overriding '{}' from '{}'\n", dvarName, fileName); Logger::Print("Overriding '{}' from '{}'\n", dvarName, fileName);