Skip to content

Commit

Permalink
Option abort -> Option Save and Abort
Browse files Browse the repository at this point in the history
When a player disconnects from an mp game, the host option which
formerly was "abort" is now a "save and abort". The interactive
in game save dialog is launched to determine name of save, with
a cancel option as well.
  • Loading branch information
cbeck88 committed Feb 21, 2014
1 parent cbbad01 commit 3d65f97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/playturn.cpp
Expand Up @@ -29,6 +29,7 @@
#include "whiteboard/manager.hpp"
#include "formula_string_utils.hpp"
#include "play_controller.hpp"
#include "savegame.hpp"

#include <boost/foreach.hpp>

Expand Down Expand Up @@ -103,6 +104,14 @@ void turn_info::handle_turn(
}
}

void turn_info::do_save()
{
savegame::ingame_savegame save(*resources::state_of_game, *resources::screen,
resources::controller->to_config(),
preferences::save_compression_format());
save.save_game_interactive(resources::screen->video(), "", gui::OK_CANCEL);
}

turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg,
network::connection /*from*/, std::deque<config>& backlog, bool skip_replay)
{
Expand Down Expand Up @@ -244,7 +253,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
utils::string_map t_vars;
options.push_back(_("Replace with AI"));
options.push_back(_("Replace with local player"));
options.push_back(_("Abort game"));
options.push_back(_("Save and Abort game"));

//get all observers in as options to transfer control
BOOST_FOREACH(const std::string &ob, resources::screen->observers())
Expand Down Expand Up @@ -302,6 +311,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
case 2:
//The user pressed "end game". Don't throw a network error here or he will get
//thrown back to the title screen.
do_save();
throw end_level_exception(QUIT);
default:
if (action > 2) {
Expand Down
2 changes: 2 additions & 0 deletions src/playturn.hpp
Expand Up @@ -61,6 +61,8 @@ class turn_info
const bool skip_replay,
std::deque<config>& backlog);

void do_save();

unsigned int team_num_;

replay_network_sender& replay_sender_;
Expand Down

0 comments on commit 3d65f97

Please sign in to comment.