Codechange: use the shortname as unique id to identify the base graphics in openttd.cfg.

This commit is contained in:
frosch
2023-10-02 14:17:32 +02:00
committed by frosch
parent 97df27e41f
commit 0b7ecf6102
6 changed files with 62 additions and 16 deletions

View File

@@ -995,6 +995,10 @@ static void GraphicsSetLoadConfig(IniFile &ini)
if (const IniGroup *group = ini.GetGroup("graphicsset"); group != nullptr) {
/* Load new settings. */
if (const IniItem *item = group->GetItem("name"); item != nullptr && item->value) BaseGraphics::ini_data.name = *item->value;
if (const IniItem *item = group->GetItem("shortname"); item != nullptr && item->value && item->value->size() == 8) {
BaseGraphics::ini_data.shortname = BSWAP32(std::strtoul(item->value->c_str(), nullptr, 16));
}
}
}
@@ -1182,6 +1186,7 @@ static void GraphicsSetSaveConfig(IniFile &ini)
group.Clear();
group.GetOrCreateItem("name").SetValue(used_set->name);
group.GetOrCreateItem("shortname").SetValue(fmt::format("{:08X}", BSWAP32(used_set->shortname)));
}
/* Save a GRF configuration to the given group name */