Changeset - r28261:6c9a0949535f
[Not reviewed]
master
0 4 0
Peter Nelson - 12 months ago 2023-12-07 19:27:00
peter1138@openttd.org
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.
4 files changed with 13 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/openttd.cpp
Show inline comments
 
@@ -1475,7 +1475,7 @@ static IntervalTimer<TimerGameRealtime> 
 
 */
 
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);
 
}
 

	
 
/**
src/settings.cpp
Show inline comments
 
@@ -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);
 

	
 
			switch (old_value) {
 
				case 0: _settings_client.gui.autosave_interval = std::chrono::minutes::zero(); break;
 
				case 1: _settings_client.gui.autosave_interval = std::chrono::minutes(10); break;
 
				case 2: _settings_client.gui.autosave_interval = std::chrono::minutes(30); break;
 
				case 3: _settings_client.gui.autosave_interval = std::chrono::minutes(60); break;
 
				case 4: _settings_client.gui.autosave_interval = std::chrono::minutes(120); break;
 
				case 0: _settings_client.gui.autosave_interval = 0; break;
 
				case 1: _settings_client.gui.autosave_interval = 10; break;
 
				case 2: _settings_client.gui.autosave_interval = 30; break;
 
				case 3: _settings_client.gui.autosave_interval = 60; break;
 
				case 4: _settings_client.gui.autosave_interval = 120; break;
 
				default: break;
 
			}
 
		}
src/settings_gui.cpp
Show inline comments
 
@@ -60,12 +60,12 @@ static const StringID _autosave_dropdown
 
};
 

	
 
/** Available settings for autosave intervals. */
 
static const std::chrono::minutes _autosave_dropdown_to_minutes[] = {
 
	std::chrono::minutes::zero(), ///< never
 
	std::chrono::minutes(10),
 
	std::chrono::minutes(30),
 
	std::chrono::minutes(60),
 
	std::chrono::minutes(120),
 
static const uint32_t _autosave_dropdown_to_minutes[] = {
 
	0, ///< never
 
	10,
 
	30,
 
	60,
 
	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.
src/settings_type.h
Show inline comments
 
@@ -149,7 +149,7 @@ struct GUISettings {
 
	ZoomLevel zoom_min;                      ///< minimum 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
 
	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   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?"
0 comments (0 inline, 0 general)