Please send a <server> message when a side is changed to AI control
This commit is contained in:
parent
076084d2a2
commit
f795258e77
1 changed files with 10 additions and 5 deletions
|
@ -203,8 +203,7 @@ bool game::take_side(network::connection player, const config& cfg)
|
|||
return false;
|
||||
} else { //else take the current side
|
||||
//if the owner have transfer side to an ai or an human in game
|
||||
//fake a "change_controller" command so other player update controler name
|
||||
//and set controler to the type owner have set
|
||||
//fake a "change_controller" command so other player update controller name
|
||||
if (player == owner_ && started_ && !cfg["controller"].empty()) {
|
||||
config fake;
|
||||
config& change = fake.add_child("change_controller");
|
||||
|
@ -212,8 +211,10 @@ bool game::take_side(network::connection player, const config& cfg)
|
|||
change["player"] = cfg["name"];
|
||||
change["controller"] = "network";
|
||||
send_data(fake, owner_); //send change to all except owner
|
||||
//send a server message displaying new controller name
|
||||
send_data(construct_server_message(cfg["name"] + " takes control of side " + side));
|
||||
|
||||
//upade level so observer who join display the good player name
|
||||
//update level_ so observer who join display the good player name
|
||||
config::child_itors it = level_.child_range("side");
|
||||
it.first += side_index;
|
||||
wassert(it.first != it.second);
|
||||
|
@ -722,12 +723,12 @@ void game::remove_player(network::connection player, bool notify_creator)
|
|||
|
||||
//check for ai sides first and drop them, too, if the host left
|
||||
if (host){
|
||||
bool ai_transfer = false;
|
||||
//can't do this with an iterator, because it doesn't know the side_index
|
||||
for (size_t side = 0; side < side_controllers_.size(); ++side){
|
||||
//send the host a notification of removal of this side
|
||||
if(notify_creator && players_.empty() == false && side_controllers_[side] == "ai") {
|
||||
std::string msg = "AI side " + lexical_cast<std::string, size_t>(side + 1) + " is transferred to new host";
|
||||
send_data(construct_server_message(msg));
|
||||
ai_transfer = true;
|
||||
config drop;
|
||||
drop["side_drop"] = lexical_cast<std::string, size_t>(side + 1);
|
||||
drop["controller"] = "ai";
|
||||
|
@ -736,6 +737,10 @@ void game::remove_player(network::connection player, bool notify_creator)
|
|||
observer = false;
|
||||
}
|
||||
}
|
||||
if (ai_transfer) {
|
||||
std::string msg = "AI transferred to new host";
|
||||
send_data(construct_server_message(msg));
|
||||
}
|
||||
}
|
||||
|
||||
//look for all sides the player controlled and drop them
|
||||
|
|
Loading…
Add table
Reference in a new issue