diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-18 20:57:44 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-27 18:49:43 +0200 |
commit | 8ffb4122df903393bceca49a25ac81cc42cca3ff (patch) | |
tree | 0e1d390cc284f83e8cde908f33e6d901e2533d0f /src/settings_gui.cpp | |
parent | db54e208256958f721bf74bf058b45039be5b488 (diff) | |
download | openttd-8ffb4122df903393bceca49a25ac81cc42cca3ff.tar.xz |
Codechange: just pass the SettingDesc to SetSettingValue and remove distinction between (non)company
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r-- | src/settings_gui.cpp | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 664cfbd21..b069d2706 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -826,7 +826,6 @@ protected: struct SettingEntry : BaseSettingEntry { const char *name; ///< Name of the setting const SettingDesc *setting; ///< Setting description of the setting - uint index; ///< Index of the setting in the settings table SettingEntry(const char *name); @@ -1021,7 +1020,6 @@ SettingEntry::SettingEntry(const char *name) { this->name = name; this->setting = nullptr; - this->index = 0; } /** @@ -1031,7 +1029,7 @@ SettingEntry::SettingEntry(const char *name) void SettingEntry::Init(byte level) { BaseSettingEntry::Init(level); - this->setting = GetSettingFromName(this->name, &this->index); + this->setting = GetSettingFromName(this->name); assert(this->setting != nullptr); } @@ -1039,7 +1037,7 @@ void SettingEntry::Init(byte level) void SettingEntry::ResetAll() { int32 default_value = ReadValue(&this->setting->desc.def, this->setting->save.conv); - SetSettingValue(this->index, default_value); + SetSettingValue(this->setting, default_value); } /** @@ -2288,11 +2286,7 @@ struct GameSettingsWindow : Window { } if (value != oldvalue) { - if ((sd->desc.flags & SGF_PER_COMPANY) != 0) { - SetCompanySetting(pe->index, value); - } else { - SetSettingValue(pe->index, value); - } + SetSettingValue(sd, value); this->SetDirty(); } } else { @@ -2340,11 +2334,7 @@ struct GameSettingsWindow : Window { value = (int32)(size_t)sd->desc.def; } - if ((sd->desc.flags & SGF_PER_COMPANY) != 0) { - SetCompanySetting(this->valuewindow_entry->index, value); - } else { - SetSettingValue(this->valuewindow_entry->index, value); - } + SetSettingValue(this->valuewindow_entry->setting, value); this->SetDirty(); } @@ -2380,12 +2370,7 @@ struct GameSettingsWindow : Window { const SettingDesc *sd = this->valuedropdown_entry->setting; assert(sd->desc.flags & SGF_MULTISTRING); - if ((sd->desc.flags & SGF_PER_COMPANY) != 0) { - SetCompanySetting(this->valuedropdown_entry->index, index); - } else { - SetSettingValue(this->valuedropdown_entry->index, index); - } - + SetSettingValue(sd, index); this->SetDirty(); } break; |