MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GraphicsSetLoadConfig

Function GraphicsSetLoadConfig

src/settings.cpp:1007–1051  ·  view source on GitHub ↗

* Load BaseGraphics set selection and configuration. */

Source from the content-addressed store, hash-verified

1005 * Load BaseGraphics set selection and configuration.
1006 */
1007static void GraphicsSetLoadConfig(IniFile &ini)
1008{
1009 if (const IniGroup *group = ini.GetGroup("misc"); group != nullptr) {
1010 /* Load old setting first. */
1011 if (const IniItem *item = group->GetItem("graphicsset"); item != nullptr && item->value) BaseGraphics::ini_data.name = *item->value;
1012 }
1013
1014 if (const IniGroup *group = ini.GetGroup("graphicsset"); group != nullptr) {
1015 /* Load new settings. */
1016 if (const IniItem *item = group->GetItem("name"); item != nullptr && item->value) BaseGraphics::ini_data.name = *item->value;
1017
1018 if (const IniItem *item = group->GetItem("shortname"); item != nullptr && item->value && item->value->size() == 8) {
1019 auto val = ParseInteger<uint32_t>(*item->value, 16);
1020 if (val.has_value()) {
1021 BaseGraphics::ini_data.shortname = std::byteswap<uint32_t>(*val);
1022 } else {
1023 ShowErrorMessage(GetEncodedString(STR_CONFIG_ERROR),
1024 GetEncodedString(STR_CONFIG_ERROR_INVALID_VALUE, *item->value, BaseGraphics::ini_data.name),
1025 WL_CRITICAL);
1026 }
1027 }
1028
1029 if (const IniItem *item = group->GetItem("extra_version"); item != nullptr && item->value) {
1030 auto val = ParseInteger<uint32_t>(*item->value);
1031 if (val.has_value()) {
1032 BaseGraphics::ini_data.extra_version = *val;
1033 } else {
1034 ShowErrorMessage(GetEncodedString(STR_CONFIG_ERROR),
1035 GetEncodedString(STR_CONFIG_ERROR_INVALID_VALUE, *item->value, BaseGraphics::ini_data.name),
1036 WL_CRITICAL);
1037 }
1038 }
1039
1040 if (const IniItem *item = group->GetItem("extra_params"); item != nullptr && item->value) {
1041 auto params = ParseIntList(*item->value);
1042 if (params.has_value()) {
1043 BaseGraphics::ini_data.extra_params = params.value();
1044 } else {
1045 ShowErrorMessage(GetEncodedString(STR_CONFIG_ERROR),
1046 GetEncodedString(STR_CONFIG_ERROR_ARRAY, BaseGraphics::ini_data.name),
1047 WL_CRITICAL);
1048 }
1049 }
1050 }
1051}
1052
1053/**
1054 * Load a GRF configuration

Callers 1

LoadFromConfigFunction · 0.85

Calls 7

ShowErrorMessageFunction · 0.85
ParseIntListFunction · 0.85
GetGroupMethod · 0.80
GetItemMethod · 0.80
GetEncodedStringFunction · 0.70
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected