mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Don't keep autosave_interval in std::chrono::minutes.
This variable is saved as a setting which requires the variable type to be known, but std::chrono::minutes may vary depending on system type. Instead, keep as uint32_t and convert to std::chrono::minutes only when setting the timer.pull/11545/head
parent
a29766d6cc
commit
54d45a6047
|
@ -1475,7 +1475,7 @@ static IntervalTimer<TimerGameRealtime> _autosave_interval({std::chrono::millise
|
||||||
*/
|
*/
|
||||||
void ChangeAutosaveFrequency(bool reset)
|
void ChangeAutosaveFrequency(bool reset)
|
||||||
{
|
{
|
||||||
_autosave_interval.SetInterval({_settings_client.gui.autosave_interval, TimerGameRealtime::AUTOSAVE}, reset);
|
_autosave_interval.SetInterval({std::chrono::minutes(_settings_client.gui.autosave_interval), TimerGameRealtime::AUTOSAVE}, reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1397,11 +1397,11 @@ void LoadFromConfig(bool startup)
|
||||||
auto old_value = OneOfManySettingDesc::ParseSingleValue(old_item->value->c_str(), old_item->value->size(), _old_autosave_interval);
|
auto old_value = OneOfManySettingDesc::ParseSingleValue(old_item->value->c_str(), old_item->value->size(), _old_autosave_interval);
|
||||||
|
|
||||||
switch (old_value) {
|
switch (old_value) {
|
||||||
case 0: _settings_client.gui.autosave_interval = std::chrono::minutes::zero(); break;
|
case 0: _settings_client.gui.autosave_interval = 0; break;
|
||||||
case 1: _settings_client.gui.autosave_interval = std::chrono::minutes(10); break;
|
case 1: _settings_client.gui.autosave_interval = 10; break;
|
||||||
case 2: _settings_client.gui.autosave_interval = std::chrono::minutes(30); break;
|
case 2: _settings_client.gui.autosave_interval = 30; break;
|
||||||
case 3: _settings_client.gui.autosave_interval = std::chrono::minutes(60); break;
|
case 3: _settings_client.gui.autosave_interval = 60; break;
|
||||||
case 4: _settings_client.gui.autosave_interval = std::chrono::minutes(120); break;
|
case 4: _settings_client.gui.autosave_interval = 120; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,12 +60,12 @@ static const StringID _autosave_dropdown[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Available settings for autosave intervals. */
|
/** Available settings for autosave intervals. */
|
||||||
static const std::chrono::minutes _autosave_dropdown_to_minutes[] = {
|
static const uint32_t _autosave_dropdown_to_minutes[] = {
|
||||||
std::chrono::minutes::zero(), ///< never
|
0, ///< never
|
||||||
std::chrono::minutes(10),
|
10,
|
||||||
std::chrono::minutes(30),
|
30,
|
||||||
std::chrono::minutes(60),
|
60,
|
||||||
std::chrono::minutes(120),
|
120,
|
||||||
};
|
};
|
||||||
|
|
||||||
static Dimension _circle_size; ///< Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
|
static Dimension _circle_size; ///< Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
|
||||||
|
|
|
@ -149,7 +149,7 @@ struct GUISettings {
|
||||||
ZoomLevel zoom_min; ///< minimum zoom out level
|
ZoomLevel zoom_min; ///< minimum zoom out level
|
||||||
ZoomLevel zoom_max; ///< maximum zoom out level
|
ZoomLevel zoom_max; ///< maximum zoom out level
|
||||||
ZoomLevel sprite_zoom_min; ///< maximum zoom level at which higher-resolution alternative sprites will be used (if available) instead of scaling a lower resolution sprite
|
ZoomLevel sprite_zoom_min; ///< maximum zoom level at which higher-resolution alternative sprites will be used (if available) instead of scaling a lower resolution sprite
|
||||||
std::chrono::minutes autosave_interval; ///< how often should we do autosaves?
|
uint32_t autosave_interval; ///< how often should we do autosaves?
|
||||||
bool threaded_saves; ///< should we do threaded saves?
|
bool threaded_saves; ///< should we do threaded saves?
|
||||||
bool keep_all_autosave; ///< name the autosave in a different way
|
bool keep_all_autosave; ///< name the autosave in a different way
|
||||||
bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
|
bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
|
||||||
|
|
Loading…
Reference in New Issue