Skip to content

Commit

Permalink
Fix a bug preventing quick replay when joining MP games
Browse files Browse the repository at this point in the history
  • Loading branch information
madmax28 committed Jan 29, 2017
1 parent 973edcc commit 5428737
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/game_initialization/multiplayer.cpp
Expand Up @@ -354,8 +354,9 @@ static std::unique_ptr<wesnothd_connection> open_connection(CVideo& video, const
// The functions enter_(screen)_mode are simple functions that take care of
// creating the dialogs, then, according to the dialog result, of calling other
// of those screen functions.
static void enter_wait_mode(CVideo& video, const config& game_config, saved_game& state, wesnothd_connection* connection,
mp::lobby_info& li, bool observe, int current_turn = 0)
static void enter_wait_mode(CVideo& video, const config& game_config,
saved_game& state, wesnothd_connection* connection,
mp::lobby_info& li, bool observe)
{
DBG_MP << "entering wait mode" << std::endl;

Expand All @@ -364,7 +365,7 @@ static void enter_wait_mode(CVideo& video, const config& game_config, saved_game
campaign_info.reset(new mp_campaign_info(*connection));
campaign_info->is_host = false;
if(preferences::skip_mp_replay() || preferences::blindfold_replay()) {
campaign_info->skip_replay_until_turn = current_turn;
campaign_info->skip_replay = true;
campaign_info->skip_replay_blindfolded = preferences::blindfold_replay();
}

Expand Down Expand Up @@ -471,7 +472,6 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
assert(connection);
DBG_MP << "entering lobby mode" << std::endl;

int current_turn = 0;
while (true) {
const config &cfg = game_config.child("lobby_music");
if (cfg) {
Expand Down Expand Up @@ -505,7 +505,7 @@ static void enter_lobby_mode(CVideo& video, const config& game_config,
case gui2::dialogs::lobby_main::JOIN:
case gui2::dialogs::lobby_main::OBSERVE:
try {
enter_wait_mode(video, game_config, state, connection, li, dlg.get_retval() == gui2::dialogs::lobby_main::OBSERVE, current_turn);
enter_wait_mode(video, game_config, state, connection, li, dlg.get_retval() == gui2::dialogs::lobby_main::OBSERVE);
} catch(config::error& error) {
if(!error.message.empty()) {
gui2::show_error_message(video, error.message);
Expand Down
4 changes: 2 additions & 2 deletions src/game_initialization/playcampaign.hpp
Expand Up @@ -40,7 +40,7 @@ struct mp_campaign_info
mp_campaign_info(wesnothd_connection& wdc)
: connected_players()
, is_host()
, skip_replay_until_turn(0)
, skip_replay(false)
, skip_replay_blindfolded(false)
, connection(wdc)
{
Expand All @@ -49,7 +49,7 @@ struct mp_campaign_info
/// players and observers
std::set<std::string> connected_players;
bool is_host;
int skip_replay_until_turn;
bool skip_replay;
bool skip_replay_blindfolded;
wesnothd_connection& connection;
};
Expand Down
12 changes: 2 additions & 10 deletions src/playmp_controller.cpp
Expand Up @@ -43,8 +43,8 @@ playmp_controller::playmp_controller(const config& level,
saved_game& state_of_game, const config& game_config,
const ter_data_cache & tdata, CVideo& video,
mp_campaign_info* mp_info)
: playsingle_controller(level, state_of_game,
game_config, tdata, video, mp_info && mp_info->skip_replay_until_turn != 0) //this || means that if blindfold is enabled, quick replays will be on.
: playsingle_controller(level, state_of_game, game_config, tdata, video,
mp_info && mp_info->skip_replay)
, network_processing_stopped_(false)
, blindfold_(*gui_, mp_info && mp_info->skip_replay_blindfolded)
, mp_info_(mp_info)
Expand All @@ -53,11 +53,6 @@ playmp_controller::playmp_controller(const config& level,

//turn_data_.set_host(is_host);
turn_data_.host_transfer().attach_handler(this);
// We stop quick replay if play isn't yet past turn 1
if (!mp_info_ || mp_info_->skip_replay_until_turn > 0)
{
skip_replay_ = false;
}
}

playmp_controller::~playmp_controller() {
Expand Down Expand Up @@ -334,9 +329,6 @@ void playmp_controller::play_network_turn(){
{
if (!network_processing_stopped_) {
process_network_data();
if (!mp_info_ || mp_info_->skip_replay_until_turn > 0) {
skip_replay_ = false;
}
}

play_slice_catch();
Expand Down

0 comments on commit 5428737

Please sign in to comment.