| 949 | } |
| 950 | |
| 951 | static 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 | |
| 980 | static void GameLoadConfig(const IniFile &ini, std::string_view grpname) |
| 981 | { |
no test coverage detected