Permalink
Browse files

fix bug #21916, ready blocked at inappropriate times

the first problem was that the "wait" object and "connect" objects
didn't agree about when the joining player should be choosing their
faction. we follow the mp::wait object's convention, that it happens
exactly when "allow_changes = yes".

the second problem was that params.saved_game was checked by
mp::connect_engine at the wrong time. (specifically the side_engine)

it was checked at the time of making a new config for the side, so
that the config sent to the joining clients would have
allow_changes = no in a save game, but not in the constructor of the
side engine, which would have the default/input value regardless of
the saved game status. the result is that the host and clients are
out of sync about whether allow_changes is true for a given side.
  • Loading branch information...
1 parent 91ac54f commit b745bd756e07a86babbdbaf2a4ccbe9f6d74dc1e @cbeck88 cbeck88 committed Apr 14, 2014
Showing with 6 additions and 6 deletions.
  1. +5 −6 src/multiplayer_connect_engine.cpp
  2. +1 −0 src/multiplayer_connect_engine.hpp
@@ -692,12 +692,11 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data,
LOG_CF << "client has taken a valid position\n";
- bool was_reserved = (side_engines_[side_taken]->controller() == CNTR_RESERVED);
import_user(data, false, side_taken);
- side_engines_[side_taken]->set_waiting_to_choose_status(!was_reserved);
-
update_and_send_diff();
+ side_engines_[side_taken]->set_waiting_to_choose_status(side_engines_[side_taken]->allow_changes()); //wait for them to choose faction if allowed
+ LOG_MP << "waiting to choose status = " << side_engines_[side_taken]->allow_changes() << std::endl;
result.second = false;
LOG_NW << "sent player data\n";
@@ -840,7 +839,7 @@ side_engine::side_engine(const config& cfg, connect_engine& parent_engine,
current_controller_index_(0),
controller_options_(),
allow_player_(cfg["allow_player"].to_bool(true)),
- allow_changes_(cfg["allow_changes"].to_bool(true)),
+ allow_changes_(!parent_.params_.saved_game && cfg["allow_changes"].to_bool(true)),
controller_lock_(cfg["controller_lock"].to_bool(
parent_.force_lock_settings_)),
index_(index),
@@ -851,7 +850,7 @@ side_engine::side_engine(const config& cfg, connect_engine& parent_engine,
current_player_(cfg["current_player"]),
player_id_(cfg["player_id"]),
ai_algorithm_(),
- waiting_to_choose_faction_(allow_changes_ && allow_player_),
+ waiting_to_choose_faction_(allow_changes_),
chose_random_(cfg["chose_random"].to_bool(false)),
flg_(parent_.era_factions_, cfg_, parent_.force_lock_settings_,
parent_.params_.saved_game, color_)
@@ -1016,7 +1015,7 @@ config side_engine::new_config() const
}
res["name"] = res["user_description"];
- res["allow_changes"] = !parent_.params_.saved_game && allow_changes_;
+ res["allow_changes"] = allow_changes_;
res["chose_random"] = chose_random_;
if (!parent_.params_.saved_game) {
@@ -193,6 +193,7 @@ class side_engine
void set_ai_algorithm(const std::string& ai_algorithm)
{ ai_algorithm_ = ai_algorithm; }
bool allow_player() const { return allow_player_; }
+ bool allow_changes() const { return allow_changes_; }
bool waiting_to_choose_faction() const { return waiting_to_choose_faction_; }
void set_waiting_to_choose_status(bool status) { waiting_to_choose_faction_ = status;}
bool chose_random() const { return chose_random_;}

0 comments on commit b745bd7

Please sign in to comment.