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

Function AILoadConfig

src/settings.cpp:951–978  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949}
950
951static void AILoadConfig(const IniFile &ini, std::string_view grpname)
952{
953 const IniGroup *group = ini.GetGroup(grpname);
954
955 /* Clean any configured AI */
956 for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
957 AIConfig::GetConfig(c, AIConfig::SSS_FORCE_NEWGAME)->Change(std::nullopt);
958 }
959
960 /* If no group exists, return */
961 if (group == nullptr) return;
962
963 CompanyID c = CompanyID::Begin();
964 for (const IniItem &item : group->items) {
965 AIConfig *config = AIConfig::GetConfig(c, AIConfig::SSS_FORCE_NEWGAME);
966
967 config->Change(item.name);
968 if (!config->HasScript()) {
969 if (item.name != "none") {
970 Debug(script, 0, "The AI by the name '{}' was no longer found, and removed from the list.", item.name);
971 continue;
972 }
973 }
974 if (item.value.has_value()) config->StringToSettings(*item.value);
975 ++c;
976 if (c >= MAX_COMPANIES) break;
977 }
978}
979
980static void GameLoadConfig(const IniFile &ini, std::string_view grpname)
981{

Callers 1

LoadFromConfigFunction · 0.85

Calls 6

BeginFunction · 0.85
GetConfigFunction · 0.85
GetGroupMethod · 0.80
StringToSettingsMethod · 0.80
ChangeMethod · 0.45
HasScriptMethod · 0.45

Tested by

no test coverage detected