Those 2 functions need to be here, else we have to make some stuff non-static * and besides, it is also better to keep stuff like this at the same place */
| 1924 | /* Those 2 functions need to be here, else we have to make some stuff non-static |
| 1925 | * and besides, it is also better to keep stuff like this at the same place */ |
| 1926 | void IConsoleSetSetting(std::string_view name, std::string_view value, bool force_newgame) |
| 1927 | { |
| 1928 | const SettingDesc *sd = GetSettingFromName(name); |
| 1929 | /* Company settings are not in "list_settings", so don't try to modify them. */ |
| 1930 | if (sd == nullptr || sd->flags.Test(SettingFlag::PerCompany)) { |
| 1931 | IConsolePrint(CC_ERROR, "'{}' is an unknown setting.", name); |
| 1932 | return; |
| 1933 | } |
| 1934 | |
| 1935 | bool success = true; |
| 1936 | if (sd->IsStringSetting()) { |
| 1937 | success = SetSettingValue(sd->AsStringSetting(), value, force_newgame); |
| 1938 | } else if (sd->IsIntSetting()) { |
| 1939 | const IntSettingDesc *isd = sd->AsIntSetting(); |
| 1940 | size_t val = isd->ParseValue(value); |
| 1941 | if (!_settings_error_list.empty()) { |
| 1942 | IConsolePrint(CC_ERROR, "'{}' is not a valid value for this setting.", value); |
| 1943 | _settings_error_list.clear(); |
| 1944 | return; |
| 1945 | } |
| 1946 | success = SetSettingValue(isd, (int32_t)val, force_newgame); |
| 1947 | } |
| 1948 | |
| 1949 | if (!success) { |
| 1950 | if (_network_server) { |
| 1951 | IConsolePrint(CC_ERROR, "This command/variable is not available during network games."); |
| 1952 | } else { |
| 1953 | IConsolePrint(CC_ERROR, "This command/variable is only available to a network server."); |
| 1954 | } |
| 1955 | } |
| 1956 | } |
| 1957 | |
| 1958 | void IConsoleSetSetting(std::string_view name, int value) |
| 1959 | { |
no test coverage detected