summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubidium <rubidium@openttd.org>2021-07-11 22:41:04 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-07-11 23:11:05 +0200
commitc71f06e59b57f256ee8089f44bc8a5f14234db29 (patch)
tree1b89fda9c8aa13618119ed0015e16402ac24c2aa
parentdd7f69be6ed6ea90ec806c86957f10332206bcd6 (diff)
downloadopenttd-c71f06e59b57f256ee8089f44bc8a5f14234db29.tar.xz
Feature: parse the console settings the same way as config settings
Now you can use things like `set server_game_type public` instead of having to guess the number, which would not be written into the configuration file nor would it be shown when doing `set server_game_type`.
-rw-r--r--docs/multiplayer.md2
-rw-r--r--src/settings.cpp13
2 files changed, 7 insertions, 8 deletions
diff --git a/docs/multiplayer.md b/docs/multiplayer.md
index ece0c04df..c7e1839cf 100644
--- a/docs/multiplayer.md
+++ b/docs/multiplayer.md
@@ -117,7 +117,7 @@ Last updated: 2011-02-16
- If you want to be on the server-list, make your server public. You can do
this either from the Start Server GUI, via the in-game Online Players GUI,
or by typing in the console:
- 'set server_game_type 1'.
+ 'set server_game_type public'.
- You can protect your server with a password via the console: 'set server_pw',
or via the Start Server menu.
diff --git a/src/settings.cpp b/src/settings.cpp
index d7a855065..0d379778b 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1635,15 +1635,14 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame)
if (sd->IsStringSetting()) {
success = SetSettingValue(sd->AsStringSetting(), value, force_newgame);
} else if (sd->IsIntSetting()) {
- uint32 val;
- extern bool GetArgumentInteger(uint32 *value, const char *arg);
- success = GetArgumentInteger(&val, value);
- if (!success) {
- IConsolePrint(CC_ERROR, "'{}' is not an integer.", value);
+ const IntSettingDesc *isd = sd->AsIntSetting();
+ size_t val = isd->ParseValue(value);
+ if (!_settings_error_list.empty()) {
+ IConsolePrint(CC_ERROR, "'{}' is not a valid value for this setting.", value);
+ _settings_error_list.clear();
return;
}
-
- success = SetSettingValue(sd->AsIntSetting(), val, force_newgame);
+ success = SetSettingValue(isd, (int32)val, force_newgame);
}
if (!success) {