Codechange: Store GRFConfig parameters in a vector. (#13137)

All GRFConfigs have space allocated for parameters, but only configured GRFConfigs need them.

Using a vector instead means that space is only used when parameters are used.
This commit is contained in:
Peter Nelson
2024-12-01 15:15:21 +00:00
committed by GitHub
parent e28617fda6
commit 3a310f1802
11 changed files with 76 additions and 57 deletions
+3 -3
View File
@@ -273,8 +273,8 @@ void SurveyConfiguration(nlohmann::json &survey)
if (BaseGraphics::GetUsedSet() != nullptr) {
survey["graphics_set"] = fmt::format("{}.{}", BaseGraphics::GetUsedSet()->name, BaseGraphics::GetUsedSet()->version);
const GRFConfig *extra_cfg = BaseGraphics::GetUsedSet()->GetExtraConfig();
if (extra_cfg != nullptr && extra_cfg->num_params > 0) {
survey["graphics_set_parameters"] = std::span<const uint32_t>(extra_cfg->param.data(), extra_cfg->num_params);
if (extra_cfg != nullptr && !extra_cfg->param.empty()) {
survey["graphics_set_parameters"] = std::span<const uint32_t>(extra_cfg->param);
} else {
survey["graphics_set_parameters"] = std::span<const uint32_t>();
}
@@ -370,7 +370,7 @@ void SurveyGrfs(nlohmann::json &survey)
if ((c->palette & GRFP_BLT_MASK) == GRFP_BLT_32BPP) grf["blitter"] = "32bpp";
grf["is_static"] = HasBit(c->flags, GCF_STATIC);
grf["parameters"] = std::span<const uint32_t>(c->param.data(), c->num_params);
grf["parameters"] = std::span<const uint32_t>(c->param);
}
}