summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/settings_type.h74
-rw-r--r--src/strings.cpp18
-rw-r--r--src/table/settings.h.preamble3
-rw-r--r--src/table/settings.ini8
4 files changed, 53 insertions, 50 deletions
diff --git a/src/settings_type.h b/src/settings_type.h
index 66e3e38eb..bba95ad96 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -214,16 +214,16 @@ struct MusicSettings {
/** Settings related to currency/unit systems. */
struct LocaleSettings {
- byte currency; ///< currency we currently use
- byte units_velocity; ///< unit system for velocity
- byte units_power; ///< unit system for power
- byte units_weight; ///< unit system for weight
- byte units_volume; ///< unit system for volume
- byte units_force; ///< unit system for force
- byte units_height; ///< unit system for height
- char *digit_group_separator; ///< thousand separator for non-currencies
- char *digit_group_separator_currency; ///< thousand separator for currencies
- char *digit_decimal_separator; ///< decimal separator
+ byte currency; ///< currency we currently use
+ byte units_velocity; ///< unit system for velocity
+ byte units_power; ///< unit system for power
+ byte units_weight; ///< unit system for weight
+ byte units_volume; ///< unit system for volume
+ byte units_force; ///< unit system for force
+ byte units_height; ///< unit system for height
+ std::string digit_group_separator; ///< thousand separator for non-currencies
+ std::string digit_group_separator_currency; ///< thousand separator for currencies
+ std::string digit_decimal_separator; ///< decimal separator
};
/** Settings related to news */
@@ -247,42 +247,42 @@ struct NewsSettings {
/** All settings related to the network. */
struct NetworkSettings {
- uint16 sync_freq; ///< how often do we check whether we are still in-sync
- uint8 frame_freq; ///< how often do we send commands to the clients
- uint16 commands_per_frame; ///< how many commands may be sent each frame_freq frames?
- uint16 max_commands_in_queue; ///< how many commands may there be in the incoming queue before dropping the connection?
- uint16 bytes_per_frame; ///< how many bytes may, over a long period, be received per frame?
- uint16 bytes_per_frame_burst; ///< how many bytes may, over a short period, be received?
- uint16 max_init_time; ///< maximum amount of time, in game ticks, a client may take to initiate joining
- uint16 max_join_time; ///< maximum amount of time, in game ticks, a client may take to sync up during joining
- uint16 max_download_time; ///< maximum amount of time, in game ticks, a client may take to download the map
- uint16 max_password_time; ///< maximum amount of time, in game ticks, a client may take to enter the password
- uint16 max_lag_time; ///< maximum amount of time, in game ticks, a client may be lagging behind the server
- bool pause_on_join; ///< pause the game when people join
- uint16 server_port; ///< port the server listens on
- uint16 server_admin_port; ///< port the server listens on for the admin network
- bool server_admin_chat; ///< allow private chat for the server to be distributed to the admin network
+ uint16 sync_freq; ///< how often do we check whether we are still in-sync
+ uint8 frame_freq; ///< how often do we send commands to the clients
+ uint16 commands_per_frame; ///< how many commands may be sent each frame_freq frames?
+ uint16 max_commands_in_queue; ///< how many commands may there be in the incoming queue before dropping the connection?
+ uint16 bytes_per_frame; ///< how many bytes may, over a long period, be received per frame?
+ uint16 bytes_per_frame_burst; ///< how many bytes may, over a short period, be received?
+ uint16 max_init_time; ///< maximum amount of time, in game ticks, a client may take to initiate joining
+ uint16 max_join_time; ///< maximum amount of time, in game ticks, a client may take to sync up during joining
+ uint16 max_download_time; ///< maximum amount of time, in game ticks, a client may take to download the map
+ uint16 max_password_time; ///< maximum amount of time, in game ticks, a client may take to enter the password
+ uint16 max_lag_time; ///< maximum amount of time, in game ticks, a client may be lagging behind the server
+ bool pause_on_join; ///< pause the game when people join
+ uint16 server_port; ///< port the server listens on
+ uint16 server_admin_port; ///< port the server listens on for the admin network
+ bool server_admin_chat; ///< allow private chat for the server to be distributed to the admin network
std::string server_name; ///< name of the server
std::string server_password; ///< password for joining this server
std::string rcon_password; ///< password for rconsole (server side)
std::string admin_password; ///< password for the admin network
- bool server_advertise; ///< advertise the server to the masterserver
+ bool server_advertise; ///< advertise the server to the masterserver
std::string client_name; ///< name of the player (as client)
std::string default_company_pass; ///< default password for new companies in encrypted form
std::string connect_to_ip; ///< default for the "Add server" query
std::string network_id; ///< network ID for servers
- bool autoclean_companies; ///< automatically remove companies that are not in use
- uint8 autoclean_unprotected; ///< remove passwordless companies after this many months
- uint8 autoclean_protected; ///< remove the password from passworded companies after this many months
- uint8 autoclean_novehicles; ///< remove companies with no vehicles after this many months
- uint8 max_companies; ///< maximum amount of companies
- uint8 max_clients; ///< maximum amount of clients
- uint8 max_spectators; ///< maximum amount of spectators
- Year restart_game_year; ///< year the server restarts
- uint8 min_active_clients; ///< minimum amount of active clients to unpause the game
- bool reload_cfg; ///< reload the config file before restarting
+ bool autoclean_companies; ///< automatically remove companies that are not in use
+ uint8 autoclean_unprotected; ///< remove passwordless companies after this many months
+ uint8 autoclean_protected; ///< remove the password from passworded companies after this many months
+ uint8 autoclean_novehicles; ///< remove companies with no vehicles after this many months
+ uint8 max_companies; ///< maximum amount of companies
+ uint8 max_clients; ///< maximum amount of clients
+ uint8 max_spectators; ///< maximum amount of spectators
+ Year restart_game_year; ///< year the server restarts
+ uint8 min_active_clients; ///< minimum amount of active clients to unpause the game
+ bool reload_cfg; ///< reload the config file before restarting
std::string last_joined; ///< Last joined server
- bool no_http_content_downloads; ///< do not do content downloads over HTTP
+ bool no_http_content_downloads; ///< do not do content downloads over HTTP
};
/** Settings related to the creation of games. */
diff --git a/src/strings.cpp b/src/strings.cpp
index 2b6dbc3ef..3c2c07bde 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -343,8 +343,8 @@ static char *FormatNumber(char *buff, int64 number, const char *last, const char
uint64 tot = 0;
for (int i = 0; i < max_digits; i++) {
if (i == max_digits - fractional_digits) {
- const char *decimal_separator = _settings_game.locale.digit_decimal_separator;
- if (decimal_separator == nullptr) decimal_separator = _langpack.langpack->digit_decimal_separator;
+ const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str();
+ if (StrEmpty(decimal_separator)) decimal_separator = _langpack.langpack->digit_decimal_separator;
buff += seprintf(buff, last, "%s", decimal_separator);
}
@@ -368,8 +368,8 @@ static char *FormatNumber(char *buff, int64 number, const char *last, const char
static char *FormatCommaNumber(char *buff, int64 number, const char *last, int fractional_digits = 0)
{
- const char *separator = _settings_game.locale.digit_group_separator;
- if (separator == nullptr) separator = _langpack.langpack->digit_group_separator;
+ const char *separator = _settings_game.locale.digit_group_separator.c_str();
+ if (StrEmpty(separator)) separator = _langpack.langpack->digit_group_separator;
return FormatNumber(buff, number, last, separator, 1, fractional_digits);
}
@@ -407,8 +407,8 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
id++;
}
- const char *decimal_separator = _settings_game.locale.digit_decimal_separator;
- if (decimal_separator == nullptr) decimal_separator = _langpack.langpack->digit_decimal_separator;
+ const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str();
+ if (StrEmpty(decimal_separator)) decimal_separator = _langpack.langpack->digit_decimal_separator;
if (number < 1024) {
id = 0;
@@ -501,9 +501,9 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
}
}
- const char *separator = _settings_game.locale.digit_group_separator_currency;
- if (separator == nullptr && !StrEmpty(_currency->separator)) separator = _currency->separator;
- if (separator == nullptr) separator = _langpack.langpack->digit_group_separator_currency;
+ const char *separator = _settings_game.locale.digit_group_separator_currency.c_str();
+ if (StrEmpty(separator)) separator = _currency->separator;
+ if (StrEmpty(separator)) separator = _langpack.langpack->digit_group_separator_currency;
buff = FormatNumber(buff, number, last, separator);
buff = strecpy(buff, multiplier, last);
diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble
index d0a3dc177..14eeb9fdc 100644
--- a/src/table/settings.h.preamble
+++ b/src/table/settings.h.preamble
@@ -107,6 +107,9 @@ static size_t ConvertLandscape(const char *value);
#define SDT_STR(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, sizeof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
+#define SDT_SSTR(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
+ SDT_GENERAL(#var, SDT_STDSTRING, SL_STDSTR, type, flags, guiflags, base, var, sizeof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
+
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, load, cat, extra, startup)\
SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, strhelp, strval, proc, load, from, to, cat, extra, startup)
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 5b639e0de..66dc55e9b 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -73,7 +73,7 @@ SDTC_SSTR = SDTC_SSTR( $var, $type, $flags, $guiflags, $def,
SDTC_VAR = SDTC_VAR( $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra, $startup),
-SDT_STR = SDT_STR($base, $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
+SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
SDT_NULL = SDT_NULL($length, $from, $to),
SDT_END = SDT_END()
@@ -2640,7 +2640,7 @@ str = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT
strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_HELPTEXT
strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_IMPERIAL
-[SDT_STR]
+[SDT_SSTR]
base = GameSettings
var = locale.digit_group_separator
type = SLE_STRQ
@@ -2650,7 +2650,7 @@ def = nullptr
proc = RedrawScreen
cat = SC_BASIC
-[SDT_STR]
+[SDT_SSTR]
base = GameSettings
var = locale.digit_group_separator_currency
type = SLE_STRQ
@@ -2660,7 +2660,7 @@ def = nullptr
proc = RedrawScreen
cat = SC_BASIC
-[SDT_STR]
+[SDT_SSTR]
base = GameSettings
var = locale.digit_decimal_separator
type = SLE_STRQ