Kenix3/libultraship

`ConsoleVariable::SetColor24` doesn't properly save

briaguya-ai opened this issue · 0 comments

when we set using SetColor24 the Color24 variable is set

void ConsoleVariable::SetColor24(const char* name, Color_RGB8 value) {
auto& variable = mVariables[name];
if (!variable) {
variable = std::make_shared<CVar>();
}
variable->Type = ConsoleVariableType::Color24;
variable->Color24 = value;
}

but then when we go to save the Color variable is read

} else if (variable.second->Type == ConsoleVariableType::Color ||
variable.second->Type == ConsoleVariableType::Color24) {
auto keyStr = key.c_str();
Color_RGBA8 clr = variable.second->Color;
conf->SetUInt(StringHelper::Sprintf("%s.R", keyStr), clr.r);
conf->SetUInt(StringHelper::Sprintf("%s.G", keyStr), clr.g);
conf->SetUInt(StringHelper::Sprintf("%s.B", keyStr), clr.b);
if (variable.second->Type == ConsoleVariableType::Color) {
conf->SetUInt(StringHelper::Sprintf("%s.A", keyStr), clr.a);
conf->SetString(StringHelper::Sprintf("%s.Type", keyStr), "RGBA");
} else {
conf->SetString(StringHelper::Sprintf("%s.Type", keyStr), "RGB");
}
}

leading to {0, 0, 0} always being saved for Color24