Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved autosave semantics #9

Merged
merged 5 commits into from
Jan 16, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ bool game::do_turn()
u.get_sick(this);
// Auto-save on the half-hour if autosave is enabled
if (OPTIONS[OPT_AUTOSAVE])
save();
autosave();
}
// Update the weather, if it's time.
if (turn >= nextweather)
Expand All @@ -665,28 +665,12 @@ bool game::do_turn()
cleanup_dead();
if (!u.has_disease(DI_SLEEP) && u.activity.type == ACT_NULL)
draw();
if( get_input(autosave_timeout()) == IR_TIMEOUT && !u.in_vehicle)
{
autosave();
return false;
}
if (is_game_over()) {
if (uquit == QUIT_DIED)
popup_top("Game over! Press spacebar...");
if (uquit == QUIT_DIED || uquit == QUIT_SUICIDE)
death_screen();
if (uquit == QUIT_DIED || uquit == QUIT_SUICIDE)
{
if (OPTIONS[OPT_DELETE_WORLD] == 1)
uquit = QUIT_DELETE_WORLD;
else if (OPTIONS[OPT_DELETE_WORLD] == 2)
if (query_yn("Delete the world and all saves?"))
uquit = QUIT_DELETE_WORLD;
}
return true;
}

if (get_input(autosave_timeout()) == IR_GOOD)
++moves_since_last_save;

return false;
}
++moves_since_last_save;
update_scent();
m.vehmove(this);
m.process_fields(this);
Expand Down Expand Up @@ -7892,11 +7876,13 @@ int game::autosave_timeout()

void game::autosave()
{
if (!moves_since_last_save && !item_exchanges_since_save)
return;
MAPBUFFER.save();
moves_since_last_save = 0;
item_exchanges_since_save = 0;
if (u.in_vehicle || !moves_since_last_save && !item_exchanges_since_save)
return;

save();

moves_since_last_save = 0;
item_exchanges_since_save = 0;
}

void intro()
Expand Down