Don't modify game::level_ in load_next_scenario()
level_ should be the initial gamestate from an observer point of view, so this shouldn't be edited when a player advances to the next scenario.
This commit is contained in:
parent
1b9c72d319
commit
99416763f8
6 changed files with 37 additions and 40 deletions
|
@ -205,6 +205,7 @@ void game_board::side_drop_to(int side_num, team::CONTROLLER ctrl, team::PROXY_C
|
|||
|
||||
tm.change_controller(ctrl);
|
||||
tm.change_proxy(proxy);
|
||||
tm.set_local(true);
|
||||
|
||||
tm.set_current_player(lexical_cast<std::string> (ctrl) + lexical_cast<std::string> (side_num));
|
||||
|
||||
|
|
|
@ -1011,10 +1011,10 @@ config side_engine::new_config() const
|
|||
}
|
||||
|
||||
res["controller"] = controller_names[controller_];
|
||||
// the hosts rveices the serversided controller tweaks after the start event, but
|
||||
// the hosts recieves the serversided controller tweaks after the start event, but
|
||||
// for mp sync it's very important that the controller types are correct
|
||||
// during the start/prestart event (otherwse random unit creation during prestart fails).
|
||||
res["is_local"] = player_id_ == preferences::login();
|
||||
res["is_local"] = player_id_ == preferences::login() || controller_ == CNTR_COMPUTER;
|
||||
|
||||
std::string desc = user_description();
|
||||
if(!desc.empty()) {
|
||||
|
|
|
@ -614,15 +614,6 @@ void wait::generate_menu()
|
|||
}
|
||||
}
|
||||
|
||||
bool wait::has_level_data() const
|
||||
{
|
||||
if (first_scenario_) {
|
||||
return level_.has_attribute("version") && get_scenario().has_child("side");
|
||||
} else {
|
||||
return level_.has_child("next_scenario");
|
||||
}
|
||||
}
|
||||
|
||||
bool wait::download_level_data()
|
||||
{
|
||||
DBG_MP << "download_level_data()\n";
|
||||
|
@ -630,24 +621,37 @@ bool wait::download_level_data()
|
|||
// Ask for the next scenario data.
|
||||
network::send_data(config("load_next_scenario"), 0);
|
||||
}
|
||||
|
||||
while (!has_level_data()) {
|
||||
bool has_scenario_and_controllers = false;
|
||||
while (!has_scenario_and_controllers) {
|
||||
config revc;
|
||||
network::connection data_res = dialogs::network_receive_dialog(
|
||||
disp(), _("Getting game data..."), level_);
|
||||
disp(), _("Getting game data..."), revc);
|
||||
|
||||
if (!data_res) {
|
||||
DBG_MP << "download_level_data bad results\n";
|
||||
return false;
|
||||
}
|
||||
check_response(data_res, level_);
|
||||
if (level_.child("leave_game")) {
|
||||
check_response(data_res, revc);
|
||||
if (revc.child("leave_game")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!first_scenario_) {
|
||||
config cfg = level_.child("next_scenario");
|
||||
level_ = cfg;
|
||||
else if(config& next_scenario = revc.child("next_scenario")) {
|
||||
level_.swap(next_scenario);
|
||||
}
|
||||
else if(revc.has_attribute("version")) {
|
||||
level_.swap(revc);
|
||||
has_scenario_and_controllers = true;
|
||||
}
|
||||
else if(config& controllers = revc.child("controllers")) {
|
||||
int index = 0;
|
||||
BOOST_FOREACH(const config& controller, controllers.child_range("controller")) {
|
||||
if(config& side = get_scenario().child("side", index)) {
|
||||
side["is_local"] = controller["is_local"];
|
||||
}
|
||||
++index;
|
||||
}
|
||||
has_scenario_and_controllers = true;
|
||||
}
|
||||
}
|
||||
|
||||
DBG_MP << "download_level_data() success.\n";
|
||||
|
|
|
@ -65,7 +65,6 @@ private:
|
|||
};
|
||||
|
||||
void generate_menu();
|
||||
bool has_level_data() const;
|
||||
bool download_level_data();
|
||||
config& get_scenario();
|
||||
const config& get_scenario() const;
|
||||
|
|
|
@ -2694,6 +2694,9 @@ void console_handler::do_controller()
|
|||
if (!menu_handler_.teams()[side_num - 1].is_proxy_human()) {
|
||||
report += " (" + menu_handler_.teams()[side_num - 1].proxy_controller().to_string() + ")";
|
||||
}
|
||||
if (!menu_handler_.teams()[side_num - 1].is_network()) {
|
||||
report += " (networked)";
|
||||
}
|
||||
|
||||
print(get_cmd(), report);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "player_network.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "util.hpp"
|
||||
#include "utils\foreach.tpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
@ -1370,27 +1371,16 @@ void game::load_next_scenario(const player_map::const_iterator user) {
|
|||
// here), and then we send that side an automatic controller
|
||||
// change later.
|
||||
//
|
||||
for(simple_wml::node::child_list::const_iterator s = sides.begin(); s != sides.end(); ++s) {
|
||||
if ((**s)["controller"] != "null") {
|
||||
const size_t side_index = s - sides.begin();
|
||||
if(side_index >= sides_.size()) {
|
||||
LOG_GAME << "found an invalid side number (" << side_index - 1 << ")\n";
|
||||
}
|
||||
else if (sides_[side_index] == 0) {
|
||||
sides_[side_index] = owner_;
|
||||
std::stringstream msg;
|
||||
msg << "Side " << side_index + 1 << " had no controller while a client was loading next scenario! The host was assigned control.";
|
||||
LOG_GAME << msg.str() << " (game id: " << id_ << ")\n";
|
||||
send_and_record_server_message(msg.str());
|
||||
} else if (sides_[side_index] == user->first) {
|
||||
(*s)->set_attr("is_local", "yes");
|
||||
} else {
|
||||
(*s)->set_attr("is_local", "no");
|
||||
}
|
||||
}
|
||||
simple_wml::document doc_controllers;
|
||||
simple_wml::node & cfg_controllers = doc_controllers.root().add_child("controllers");
|
||||
|
||||
FOREACH(const AUTO& side_user, sides_) {
|
||||
simple_wml::node & cfg_controller = cfg_controllers.add_child("controller");
|
||||
cfg_controller.set_attr("is_local", side_user == user->first ? "yes" : "no");
|
||||
}
|
||||
|
||||
if (!wesnothd::send_to_one(cfg_scenario, user->first)) return;
|
||||
if (!wesnothd::send_to_one(doc_controllers, user->first)) return;
|
||||
// Send the player the history of the game to-date.
|
||||
send_history(user->first);
|
||||
// Send observer join of all the observers in the game to the user.
|
||||
|
|
Loading…
Add table
Reference in a new issue