mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
reset last autosave time on game start / load
This commit is contained in:
@@ -796,6 +796,7 @@ int game_load_sv6(SDL_RWops* rw)
|
||||
// #2407: Resetting screen time to not open a save prompt shortly after loading a park.
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0;
|
||||
|
||||
gLastAutoSaveTick = SDL_GetTicks();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -901,6 +902,7 @@ int game_load_network(SDL_RWops* rw)
|
||||
reset_0x69EBE4();
|
||||
openrct2_reset_object_tween_locations();
|
||||
game_convert_strings_to_utf8();
|
||||
gLastAutoSaveTick = SDL_GetTicks();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ static const char *_scenarioFileName = "";
|
||||
|
||||
char gScenarioSavePath[MAX_PATH];
|
||||
int gFirstTimeSave = 1;
|
||||
uint32 gLastAutoSaveTick = 0;
|
||||
|
||||
static int scenario_create_ducks();
|
||||
static void scenario_objective_check();
|
||||
@@ -185,6 +186,7 @@ int scenario_load(const char *path)
|
||||
game_convert_strings_to_utf8();
|
||||
game_fix_save_vars(); // OpenRCT2 fix broken save games
|
||||
|
||||
gLastAutoSaveTick = SDL_GetTicks();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -481,34 +483,30 @@ void scenario_entrance_fee_too_high_check()
|
||||
|
||||
void scenario_autosave_check()
|
||||
{
|
||||
// Timestamp in milliseconds
|
||||
static uint32 last_save = 0;
|
||||
|
||||
bool shouldSave = 0;
|
||||
|
||||
// Milliseconds since last save
|
||||
uint32_t time_since_save = SDL_GetTicks() - last_save;
|
||||
uint32 timeSinceSave = SDL_GetTicks() - gLastAutoSaveTick;
|
||||
|
||||
bool shouldSave = false;
|
||||
switch (gConfigGeneral.autosave_frequency) {
|
||||
case AUTOSAVE_EVERY_MINUTE:
|
||||
shouldSave = time_since_save >= 1 * 60 * 1000;
|
||||
shouldSave = timeSinceSave >= 1 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_5MINUTES:
|
||||
shouldSave = time_since_save >= 5 * 60 * 1000;
|
||||
shouldSave = timeSinceSave >= 5 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_15MINUTES:
|
||||
shouldSave = time_since_save >= 15 * 60 * 1000;
|
||||
shouldSave = timeSinceSave >= 15 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_30MINUTES:
|
||||
shouldSave = time_since_save >= 30 * 60 * 1000;
|
||||
shouldSave = timeSinceSave >= 30 * 60 * 1000;
|
||||
break;
|
||||
case AUTOSAVE_EVERY_HOUR:
|
||||
shouldSave = time_since_save >= 60 * 60 * 1000;
|
||||
shouldSave = timeSinceSave >= 60 * 60 * 1000;
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldSave) {
|
||||
last_save = SDL_GetTicks();
|
||||
gLastAutoSaveTick = SDL_GetTicks();
|
||||
game_autosave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,6 +471,7 @@ extern scenario_index_entry *gScenarioList;
|
||||
|
||||
extern char gScenarioSavePath[MAX_PATH];
|
||||
extern int gFirstTimeSave;
|
||||
extern uint32 gLastAutoSaveTick;
|
||||
|
||||
bool scenario_scores_save();
|
||||
void scenario_load_list();
|
||||
|
||||
Reference in New Issue
Block a user