mirror of https://github.com/OpenRCT2/OpenRCT2.git
Change autosave system to use wall-clock time based frequencies
The autosave system will now use frequencies based on wall-clock time rather than in-game time, for example every 15 minutes. This frequency is not affected by pausing the game or changing the game speed. The default frequency is every 5 minutes.
This commit is contained in:
parent
3cd51f6aa5
commit
377650d9f5
|
@ -2706,11 +2706,11 @@ STR_2697 :???
|
|||
STR_2698 :???
|
||||
STR_2699 :???
|
||||
STR_2700 :Autosave frequency:
|
||||
STR_2701 :Every week
|
||||
STR_2702 :Every 2 weeks
|
||||
STR_2703 :Every month
|
||||
STR_2704 :Every 4 months
|
||||
STR_2705 :Every year
|
||||
STR_2701 :Every minute
|
||||
STR_2702 :Every 5 minutes
|
||||
STR_2703 :Every 15 minutes
|
||||
STR_2704 :Every 30 minutes
|
||||
STR_2705 :Every hour
|
||||
STR_2706 :Never
|
||||
STR_2707 :Open new window
|
||||
STR_2708 :{WINDOW_COLOUR_1}Are you sure you want to overwrite {STRINGID}?
|
||||
|
|
|
@ -157,7 +157,7 @@ config_enum_definition _dateFormatEnum[] = {
|
|||
|
||||
config_property_definition _generalDefinitions[] = {
|
||||
{ offsetof(general_configuration, always_show_gridlines), "always_show_gridlines", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, autosave_frequency), "autosave", CONFIG_VALUE_TYPE_UINT8, AUTOSAVE_EVERY_MONTH, NULL },
|
||||
{ offsetof(general_configuration, autosave_frequency), "autosave", CONFIG_VALUE_TYPE_UINT8, AUTOSAVE_EVERY_5MINUTES, NULL },
|
||||
{ offsetof(general_configuration, confirmation_prompt), "confirmation_prompt", CONFIG_VALUE_TYPE_UINT8, 0, NULL },
|
||||
{ offsetof(general_configuration, construction_marker_colour), "construction_marker_colour", CONFIG_VALUE_TYPE_UINT8, false, NULL },
|
||||
{ offsetof(general_configuration, currency_format), "currency_format", CONFIG_VALUE_TYPE_UINT8, CURRENCY_POUNDS, _currencyEnum },
|
||||
|
|
10
src/config.h
10
src/config.h
|
@ -98,11 +98,11 @@ enum {
|
|||
};
|
||||
|
||||
enum {
|
||||
AUTOSAVE_EVERY_WEEK,
|
||||
AUTOSAVE_EVERY_2_WEEKS,
|
||||
AUTOSAVE_EVERY_MONTH,
|
||||
AUTOSAVE_EVERY_4_MONTHS,
|
||||
AUTOSAVE_EVERY_YEAR,
|
||||
AUTOSAVE_EVERY_MINUTE,
|
||||
AUTOSAVE_EVERY_5MINUTES,
|
||||
AUTOSAVE_EVERY_15MINUTES,
|
||||
AUTOSAVE_EVERY_30MINUTES,
|
||||
AUTOSAVE_EVERY_HOUR,
|
||||
AUTOSAVE_NEVER
|
||||
};
|
||||
|
||||
|
|
|
@ -296,6 +296,9 @@ void game_update()
|
|||
}
|
||||
}
|
||||
|
||||
// Always perform autosave check, even when paused
|
||||
scenario_autosave_check();
|
||||
|
||||
network_update();
|
||||
news_item_update_current();
|
||||
window_dispatch_update_all();
|
||||
|
|
|
@ -1393,6 +1393,13 @@ enum {
|
|||
|
||||
STR_CHEAT_TIP_LARGE_TRAM_GUESTS = 2684,
|
||||
|
||||
STR_SAVE_EVERY_MINUTE = 2701,
|
||||
STR_SAVE_EVERY_5MINUTES = 2702,
|
||||
STR_SAVE_EVERY_15MINUTES = 2703,
|
||||
STR_SAVE_EVERY_30MINUTES = 2704,
|
||||
STR_SAVE_EVERY_HOUR = 2705,
|
||||
STR_SAVE_NEVER = 2706,
|
||||
|
||||
STR_DATE_FORMAT_DMY = 2737,
|
||||
|
||||
STR_ROLLERCOASTER_TYCOON_1_DROPDOWN = 2740,
|
||||
|
|
|
@ -514,34 +514,38 @@ void scenario_entrance_fee_too_high_check()
|
|||
}
|
||||
}
|
||||
|
||||
static void scenario_autosave_check()
|
||||
void scenario_autosave_check()
|
||||
{
|
||||
uint32 next_month_tick = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) + 4;
|
||||
uint16 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
||||
// Timestamp in milliseconds
|
||||
static uint32 last_save = 0;
|
||||
|
||||
bool shouldSave = 0;
|
||||
|
||||
// Milliseconds since last save
|
||||
uint32_t time_since_save = SDL_GetTicks() - last_save;
|
||||
|
||||
switch (gConfigGeneral.autosave_frequency) {
|
||||
case AUTOSAVE_EVERY_WEEK:
|
||||
shouldSave = (next_month_tick % 0x4000 == 0);
|
||||
case AUTOSAVE_EVERY_MINUTE:
|
||||
shouldSave = time_since_save >= 1 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_2_WEEKS:
|
||||
shouldSave = (next_month_tick % 0x8000 == 0);
|
||||
case AUTOSAVE_EVERY_5MINUTES:
|
||||
shouldSave = time_since_save >= 5 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_MONTH:
|
||||
shouldSave = (next_month_tick >= 0x10000);
|
||||
case AUTOSAVE_EVERY_15MINUTES:
|
||||
shouldSave = time_since_save >= 15 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_4_MONTHS:
|
||||
if (next_month_tick >= 0x10000)
|
||||
shouldSave = (((month + 1) & 3) == 0);
|
||||
case AUTOSAVE_EVERY_30MINUTES:
|
||||
shouldSave = time_since_save >= 30 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_YEAR:
|
||||
if (next_month_tick >= 0x10000)
|
||||
shouldSave = (((month + 1) & 7) == 0);
|
||||
case AUTOSAVE_EVERY_HOUR:
|
||||
shouldSave = time_since_save >= 60 * 60 * 1000;
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldSave)
|
||||
if (shouldSave) {
|
||||
last_save = SDL_GetTicks();
|
||||
game_autosave();
|
||||
}
|
||||
}
|
||||
|
||||
static void scenario_day_update()
|
||||
|
@ -636,7 +640,6 @@ void scenario_update()
|
|||
uint8 currentMonth = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7;
|
||||
uint8 currentDaysInMonth = (uint8)days_in_month[currentMonth];
|
||||
|
||||
scenario_autosave_check();
|
||||
if ((currentDaysInMonth * nextMonthTick) >> 16 != (currentDaysInMonth * currentMonthTick) >> 16) {
|
||||
scenario_day_update();
|
||||
}
|
||||
|
|
|
@ -434,5 +434,6 @@ void scenario_set_filename(const char *value);
|
|||
void scenario_failure();
|
||||
void scenario_success();
|
||||
void scenario_success_submit_name(const char *name);
|
||||
void scenario_autosave_check();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -869,10 +869,11 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
|||
case WINDOW_OPTIONS_PAGE_MISC:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_AUTOSAVE_DROPDOWN:
|
||||
for (i = AUTOSAVE_EVERY_WEEK; i <= AUTOSAVE_NEVER; i++) {
|
||||
for (i = AUTOSAVE_EVERY_MINUTE; i <= AUTOSAVE_NEVER; i++) {
|
||||
gDropdownItemsFormat[i] = 1142;
|
||||
gDropdownItemsArgs[i] = 2701 + i;
|
||||
gDropdownItemsArgs[i] = STR_SAVE_EVERY_MINUTE + i;
|
||||
}
|
||||
|
||||
window_options_show_dropdown(w, widget, AUTOSAVE_NEVER + 1);
|
||||
gDropdownItemsChecked = 1 << gConfigGeneral.autosave_frequency;
|
||||
break;
|
||||
|
@ -1371,7 +1372,7 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
gfx_draw_string_left(dpi, 2700, w, w->colours[1], w->x + 10, w->y + window_options_misc_widgets[WIDX_AUTOSAVE].top + 1);
|
||||
gfx_draw_string_left(
|
||||
dpi,
|
||||
2701 + gConfigGeneral.autosave_frequency,
|
||||
STR_SAVE_EVERY_MINUTE + gConfigGeneral.autosave_frequency,
|
||||
NULL,
|
||||
w->colours[1],
|
||||
w->x + window_options_misc_widgets[WIDX_AUTOSAVE].left + 1,
|
||||
|
|
Loading…
Reference in New Issue