summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-30 11:51:21 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-13 10:26:58 +0200
commitbf500c39c9b6c7359204c5454aefa0dc7f51dae5 (patch)
tree41ce9700b545189ee990e4ce132b96a24d70d5e3 /src
parente588923bff12e0c46aaab72fdca3e8b5cb211081 (diff)
downloadopenttd-bf500c39c9b6c7359204c5454aefa0dc7f51dae5.tar.xz
Codechange: make the name of SettingDesc a std::string
Diffstat (limited to 'src')
-rw-r--r--src/gamelog.cpp4
-rw-r--r--src/gamelog.h2
-rw-r--r--src/script/api/script_gamesettings.cpp2
-rw-r--r--src/settings.cpp8
-rw-r--r--src/settings_internal.h18
-rw-r--r--src/table/settings/settings.ini10
6 files changed, 22 insertions, 22 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 1a4998e40..8965ea55f 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -483,14 +483,14 @@ void GamelogOldver()
* @param oldval old setting value
* @param newval new setting value
*/
-void GamelogSetting(const char *name, int32 oldval, int32 newval)
+void GamelogSetting(const std::string &name, int32 oldval, int32 newval)
{
assert(_gamelog_action_type == GLAT_SETTING);
LoggedChange *lc = GamelogChange(GLCT_SETTING);
if (lc == nullptr) return;
- lc->setting.name = stredup(name);
+ lc->setting.name = stredup(name.c_str());
lc->setting.oldval = oldval;
lc->setting.newval = newval;
}
diff --git a/src/gamelog.h b/src/gamelog.h
index e7951c50c..d9e0dd529 100644
--- a/src/gamelog.h
+++ b/src/gamelog.h
@@ -48,7 +48,7 @@ bool GamelogTestEmergency();
void GamelogRevision();
void GamelogMode();
void GamelogOldver();
-void GamelogSetting(const char *name, int32 oldval, int32 newval);
+void GamelogSetting(const std::string &name, int32 oldval, int32 newval);
void GamelogGRFUpdate(const GRFConfig *oldg, const GRFConfig *newg);
void GamelogGRFAddList(const GRFConfig *newg);
diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp
index 458545226..35277e303 100644
--- a/src/script/api/script_gamesettings.cpp
+++ b/src/script/api/script_gamesettings.cpp
@@ -37,7 +37,7 @@
if ((sd->flags & SF_NO_NETWORK_SYNC) != 0) return false;
- return ScriptObject::DoCommand(0, 0, value, CMD_CHANGE_SETTING, sd->name);
+ return ScriptObject::DoCommand(0, 0, value, CMD_CHANGE_SETTING, sd->name.c_str());
}
/* static */ bool ScriptGameSettings::IsDisabledVehicleType(ScriptVehicle::VehicleType vehicle_type)
diff --git a/src/settings.cpp b/src/settings.cpp
index 26f6d8fd2..7ec5112fd 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1980,13 +1980,13 @@ void IConsoleGetSetting(const char *name, bool force_newgame)
const void *object = (_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game;
if (sd->IsStringSetting()) {
- IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", name, sd->AsStringSetting()->Read(object).c_str());
+ IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", sd->name.c_str(), sd->AsStringSetting()->Read(object).c_str());
} else if (sd->IsIntSetting()) {
char value[20];
sd->FormatValue(value, lastof(value), object);
const IntSettingDesc *int_setting = sd->AsIntSetting();
IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s' (min: %s%d, max: %u)",
- name, value, (sd->flags & SF_GUI_0_IS_SPECIAL) ? "(0) " : "", int_setting->min, int_setting->max);
+ sd->name.c_str(), value, (sd->flags & SF_GUI_0_IS_SPECIAL) ? "(0) " : "", int_setting->min, int_setting->max);
}
}
@@ -2001,10 +2001,10 @@ void IConsoleListSettings(const char *prefilter)
for (auto &sd : _settings) {
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
- if (prefilter != nullptr && strstr(sd->name, prefilter) == nullptr) continue;
+ if (prefilter != nullptr && sd->name.find(prefilter) == std::string::npos) continue;
char value[80];
sd->FormatValue(value, lastof(value), &GetGameSettings());
- IConsolePrintF(CC_DEFAULT, "%s = %s", sd->name, value);
+ IConsolePrintF(CC_DEFAULT, "%s = %s", sd->name.c_str(), value);
}
IConsolePrintF(CC_WARNING, "Use 'setting' command to change a value");
diff --git a/src/settings_internal.h b/src/settings_internal.h
index e1b3b75a7..5ba7ca454 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -69,11 +69,11 @@ struct IniItem;
/** Properties of config file settings. */
struct SettingDesc {
- SettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup) :
+ SettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup) :
name(name), flags(flags), startup(startup), save(save) {}
virtual ~SettingDesc() {}
- const char *name; ///< Name of the setting. Used in configuration file and for console.
+ std::string name; ///< Name of the setting. Used in configuration file and for console.
SettingFlag flags; ///< Handles how a setting would show up in the GUI (text/currency, etc.).
bool startup; ///< Setting has to be loaded directly at startup?.
SaveLoad save; ///< Internal structure (going to savegame, parts to config).
@@ -140,7 +140,7 @@ struct IntSettingDesc : SettingDesc {
*/
typedef void PostChangeCallback(int32 value);
- IntSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, int32 def,
+ IntSettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup, int32 def,
int32 min, uint32 max, int32 interval, StringID str, StringID str_help, StringID str_val,
SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback) :
SettingDesc(save, name, flags, startup), def(def), min(min), max(max), interval(interval),
@@ -182,7 +182,7 @@ private:
/** Boolean setting. */
struct BoolSettingDesc : IntSettingDesc {
- BoolSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, bool def,
+ BoolSettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup, bool def,
StringID str, StringID str_help, StringID str_val, SettingCategory cat,
PreChangeCheck pre_check, PostChangeCallback post_callback) :
IntSettingDesc(save, name, flags, startup, def, 0, 1, 0, str, str_help, str_val, cat,
@@ -198,7 +198,7 @@ struct BoolSettingDesc : IntSettingDesc {
struct OneOfManySettingDesc : IntSettingDesc {
typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error
- OneOfManySettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, int32 def,
+ OneOfManySettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup, int32 def,
int32 max, StringID str, StringID str_help, StringID str_val, SettingCategory cat,
PreChangeCheck pre_check, PostChangeCallback post_callback,
std::initializer_list<const char *> many, OnConvert *many_cnvt) :
@@ -222,7 +222,7 @@ struct OneOfManySettingDesc : IntSettingDesc {
/** Many of many setting. */
struct ManyOfManySettingDesc : OneOfManySettingDesc {
- ManyOfManySettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup,
+ ManyOfManySettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup,
int32 def, StringID str, StringID str_help, StringID str_val, SettingCategory cat,
PreChangeCheck pre_check, PostChangeCallback post_callback,
std::initializer_list<const char *> many, OnConvert *many_cnvt) :
@@ -251,7 +251,7 @@ struct StringSettingDesc : SettingDesc {
*/
typedef void PostChangeCallback(const std::string &value);
- StringSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, const char *def,
+ StringSettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup, const char *def,
uint32 max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) :
SettingDesc(save, name, flags, startup), def(def == nullptr ? "" : def), max_length(max_length),
pre_check(pre_check), post_callback(post_callback) {}
@@ -277,7 +277,7 @@ private:
/** List/array settings. */
struct ListSettingDesc : SettingDesc {
- ListSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, const char *def) :
+ ListSettingDesc(SaveLoad save, const std::string &name, SettingFlag flags, bool startup, const char *def) :
SettingDesc(save, name, flags, startup), def(def) {}
virtual ~ListSettingDesc() {}
@@ -291,7 +291,7 @@ struct ListSettingDesc : SettingDesc {
/** Placeholder for settings that have been removed, but might still linger in the savegame. */
struct NullSettingDesc : SettingDesc {
NullSettingDesc(SaveLoad save) :
- SettingDesc(save, "", SF_NOT_IN_CONFIG, false) {}
+ SettingDesc(save, {}, SF_NOT_IN_CONFIG, false) {}
virtual ~NullSettingDesc() {}
void FormatValue(char *buf, const char *last, const void *object) const override { NOT_REACHED(); }
diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini
index 17a4b3025..7c5cac886 100644
--- a/src/table/settings/settings.ini
+++ b/src/table/settings/settings.ini
@@ -1002,14 +1002,14 @@ post_cb = MaxVehiclesChanged
cat = SC_BASIC
[SDTG_BOOL]
-name = nullptr
+name = {}
flags = SF_NO_NETWORK
var = _old_vds.servint_ispercent
def = false
to = SLV_120
[SDTG_VAR]
-name = nullptr
+name = {}
type = SLE_UINT16
flags = SF_GUI_0_IS_SPECIAL
var = _old_vds.servint_trains
@@ -1019,7 +1019,7 @@ max = 800
to = SLV_120
[SDTG_VAR]
-name = nullptr
+name = {}
type = SLE_UINT16
flags = SF_GUI_0_IS_SPECIAL
var = _old_vds.servint_roadveh
@@ -1029,7 +1029,7 @@ max = 800
to = SLV_120
[SDTG_VAR]
-name = nullptr
+name = {}
type = SLE_UINT16
flags = SF_GUI_0_IS_SPECIAL
var = _old_vds.servint_ships
@@ -1039,7 +1039,7 @@ max = 800
to = SLV_120
[SDTG_VAR]
-name = nullptr
+name = {}
type = SLE_UINT16
flags = SF_GUI_0_IS_SPECIAL
var = _old_vds.servint_aircraft