Skip to content

Commit

Permalink
Fixed non-host players being unnotified about next_scenario data.
Browse files Browse the repository at this point in the history
The players being unnotified resulted in them being able to press "End
Turn/End Scenario" button and downloading the current scenario data
instead of the next one.

Related code, which was marked as "deprecated", has been removed due to
not actually affecting anything.
  • Loading branch information
andrius-sil committed Sep 20, 2013
1 parent e3ceed9 commit 2932d30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
10 changes: 1 addition & 9 deletions src/server/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ std::string game::list_users(user_vector users, const std::string& func) const
}

void game::start_game(const player_map::const_iterator starter) {
// If the game was already started we're actually advancing.
const bool advance = started_;
started_ = true;
// Prevent inserting empty keys when reading.
const simple_wml::node& s = level_.root();
const bool save = s["savegame"].to_bool();
LOG_GAME << network::ip_address(starter->first) << "\t"
<< starter->second.name() << "\t" << (advance ? "advanced" : "started")
<< starter->second.name() << "\t" << "started"
<< (save ? " reloaded" : "") << " game:\t\"" << name_ << "\" (" << id_
<< ") with: " << list_users(players_, __func__) << ". Settings: map: " << s["id"]
<< "\tera: " << (s.child("era") ? (*s.child("era"))["id"] : "")
Expand Down Expand Up @@ -213,12 +211,6 @@ void game::start_game(const player_map::const_iterator starter) {
end_turn_ = (turn - 1) * nsides_ + side - 1;
end_turn();
clear_history();
if (advance) {
// When the host advances tell everyone that the next scenario data is
// available.
static simple_wml::document notify_next_scenario("[notify_next_scenario]\n[/notify_next_scenario]\n", simple_wml::INIT_COMPRESSED);
send_data(notify_next_scenario, starter->first);
}
// Send [observer] tags for all observers that are already in the game.
send_observerjoins();
}
Expand Down
13 changes: 7 additions & 6 deletions src/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2515,15 +2515,16 @@ void server::process_data_game(const network::connection sock,
desc.set_attr("require_era", "no");
}
}

// Tell everyone that the next scenario data is available.
static simple_wml::document notify_next_scenario(
"[notify_next_scenario]\n[/notify_next_scenario]\n",
simple_wml::INIT_COMPRESSED);
g->send_data(notify_next_scenario, sock);

// Send the update of the game description to the lobby.
update_game_in_lobby(g);

return;
// If a player advances to the next scenario of a mp campaign. (deprecated)
///@deprecated r22619 a player advances to the next scenario of a mp campaign (notify_next_scenario)
} else if(data.child("notify_next_scenario")) {
//g->send_data(g->construct_server_message(pl->second.name()
// + " advanced to the next scenario."), sock);
return;
// A mp client sends a request for the next scenario of a mp campaign.
} else if (data.child("load_next_scenario")) {
Expand Down

0 comments on commit 2932d30

Please sign in to comment.