1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-24 20:54:08 +01:00

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

View File

@@ -191,7 +191,7 @@ static void LoadSpriteTables()
/* Baseset extra graphics */
GRFConfig *extra = new GRFConfig(used_set->GetOrCreateExtraConfig());
if (extra->num_params == 0) extra->SetParameterDefaults();
if (extra->param.empty()) extra->SetParameterDefaults();
ClrBit(extra->flags, GCF_INIT_ONLY);
extra->next = top;
@@ -397,7 +397,7 @@ bool GraphicsSet::IsConfigurable() const
void GraphicsSet::CopyCompatibleConfig(const GraphicsSet &src)
{
const GRFConfig *src_cfg = src.GetExtraConfig();
if (src_cfg == nullptr || src_cfg->num_params == 0) return;
if (src_cfg == nullptr || src_cfg->param.empty()) return;
GRFConfig &dest_cfg = this->GetOrCreateExtraConfig();
if (dest_cfg.IsCompatible(src_cfg->version)) return;
dest_cfg.CopyParams(*src_cfg);