mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 21:29:06 +00:00
reformat side_drop network message.
it is now in a [side_drop] tag instead of on toplevel. this make it easier process. In paarticular a workaround in playturn_network_adapter is no longer needed and should be removed after 1.13.9
This commit is contained in:
parent
8e5a73270a
commit
8abb21e707
@ -605,11 +605,11 @@ std::pair<bool, bool> connect_engine::process_network_data(const config& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A side has been dropped.
|
// A side has been dropped.
|
||||||
if(!data["side_drop"].empty()) {
|
if(const config& side_drop = data.child("side_drop")) {
|
||||||
unsigned side_drop = data["side_drop"].to_int() - 1;
|
unsigned side_index = side_drop["side_num"].to_int() - 1;
|
||||||
|
|
||||||
if(side_drop < side_engines_.size()) {
|
if(side_index < side_engines_.size()) {
|
||||||
side_engine_ptr side_to_drop = side_engines_[side_drop];
|
side_engine_ptr side_to_drop = side_engines_[side_index];
|
||||||
|
|
||||||
// Remove user, whose side was dropped.
|
// Remove user, whose side was dropped.
|
||||||
connected_users_rw().erase(side_to_drop->player_id());
|
connected_users_rw().erase(side_to_drop->player_id());
|
||||||
|
@ -49,6 +49,7 @@ void playturn_network_adapter::read_from_network()
|
|||||||
}
|
}
|
||||||
assert(!data_.back().empty());
|
assert(!data_.back().empty());
|
||||||
|
|
||||||
|
// TODO: remove this after 1.13.9
|
||||||
if(back.has_attribute("side_drop"))
|
if(back.has_attribute("side_drop"))
|
||||||
{
|
{
|
||||||
config child;
|
config child;
|
||||||
|
@ -1301,9 +1301,12 @@ bool game::remove_player(const socket_ptr player, const bool disconnect, const b
|
|||||||
|
|
||||||
//send the host a notification of removal of this side
|
//send the host a notification of removal of this side
|
||||||
const std::string side_drop = lexical_cast_default<std::string, size_t>(side_index + 1);
|
const std::string side_drop = lexical_cast_default<std::string, size_t>(side_index + 1);
|
||||||
|
|
||||||
simple_wml::document drop;
|
simple_wml::document drop;
|
||||||
drop.root().set_attr("side_drop", side_drop.c_str());
|
auto& node_side_drop = drop.root().add_child("side_drop");
|
||||||
drop.root().set_attr("controller", side_controllers_[side_index].to_cstring());
|
|
||||||
|
node_side_drop.set_attr("side_num", side_drop.c_str());
|
||||||
|
node_side_drop.set_attr("controller", side_controllers_[side_index].to_cstring());
|
||||||
|
|
||||||
DBG_GAME << "*** sending side drop: \n" << drop.output() << std::endl;
|
DBG_GAME << "*** sending side drop: \n" << drop.output() << std::endl;
|
||||||
|
|
||||||
|
@ -1559,7 +1559,6 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||||||
} else if (data.child("error")
|
} else if (data.child("error")
|
||||||
|| data.child("side_secured")
|
|| data.child("side_secured")
|
||||||
|| data.root().has_attr("failed")
|
|| data.root().has_attr("failed")
|
||||||
|| data.root().has_attr("side_drop")
|
|
||||||
|| data.root().has_attr("side")) {
|
|| data.root().has_attr("side")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user