Fix bug #6534, and being able to join started games.

This commit is contained in:
Dominic Bolin 2006-08-08 16:21:53 +00:00
parent 5b049d3a61
commit 8ac54337b0
2 changed files with 21 additions and 26 deletions

View File

@ -448,18 +448,16 @@ const std::string& game::transfer_side_control(const config& cfg)
size_t game::available_slots() const
{
size_t n_sides = level_.get_children("side").size();
size_t available_slots = 0;
const config::child_list& sides = level_.get_children("side");
for(config::child_list::const_iterator i = sides.begin(); i != sides.end(); ++i) {
//std::cerr << "side controller: '" << (**i)["controller"] << "'\n";
//std::cerr << "description: '" << (**i)["description"] << "'\n";
if((**i)["controller"] == "network" || (**i)["controller"] == "human") {
++available_slots;
for(int s = 0; s < n_sides; ++s) {
if(! sides_taken_[s]) {
available_slots++;
}
}
return available_slots - players_.size();
return available_slots;
}
bool game::describe_slots()

View File

@ -1130,30 +1130,27 @@ void server::process_data_from_player_in_game(const network::connection sock, co
const string_map::const_iterator side = data.values.find("side");
if(side != data.values.end()) {
if (g->is_observer(sock)){
const bool res = g->take_side(sock,data);
config response;
if(res) {
std::cerr << "player joined side\n";
response["side_secured"] = side->second;
//update the number of available slots
const bool res = g->describe_slots();
if(res) {
lobby_players_.send_data(sync_initial_response());
}
} else if (g->is_observer(sock)) {
const config& p_msg = construct_server_message("Sorry " + g->find_player(sock)->name() + ", someone else entered before you.",*g);
network::send_data(p_msg, sock);
return;
} else {
response["failed"] = "yes";
}
else{
const bool res = g->take_side(sock,data);
config response;
if(res) {
std::cerr << "player joined side\n";
response["side_secured"] = side->second;
//update the number of available slots
const bool res = g->describe_slots();
if(res) {
lobby_players_.send_data(sync_initial_response());
}
} else {
response["failed"] = "yes";
}
network::send_data(response,sock);
return;
}
network::send_data(response,sock);
return;
}
if(data.child("start_game")) {