mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 18:13:52 +00:00
fix and use the predicate version of send_to_many
This commit is contained in:
parent
1fdb4c2df8
commit
24e2efabba
@ -22,6 +22,8 @@
|
||||
#include "game.hpp"
|
||||
#include "player_network.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#ifndef __func__
|
||||
#ifdef __FUNCTION__
|
||||
#define __func__ __FUNCTION__
|
||||
@ -1159,16 +1161,12 @@ void game::send_data_team(simple_wml::document& data,
|
||||
std::string packet_type) const
|
||||
{
|
||||
DBG_GAME << __func__ << "...\n";
|
||||
if (packet_type.empty())
|
||||
packet_type = data.root().first_child().to_string();
|
||||
simple_wml::string_span s = data.output_compressed();
|
||||
for(user_vector::const_iterator i = players_.begin(); i != players_.end(); ++i) {
|
||||
if(*i != exclude && is_on_team(team,*i)) {
|
||||
network::send_raw_data(s.begin(), s.size(), *i, packet_type);
|
||||
}
|
||||
}
|
||||
wesnothd::send_to_many(data, players_,
|
||||
boost::bind(&game::is_on_team, this, boost::ref(team), _1),
|
||||
exclude, packet_type);
|
||||
}
|
||||
|
||||
|
||||
bool game::is_on_team(const simple_wml::string_span& team, const network::connection player) const {
|
||||
const simple_wml::node::child_list& side_list = level_.root().children("side");
|
||||
for (side_vector::const_iterator side = sides_.begin(); side != sides_.end(); ++side) {
|
||||
|
@ -36,13 +36,14 @@ void send_to_many(simple_wml::document& data, const connection_vector& vec,
|
||||
}
|
||||
|
||||
void send_to_many(simple_wml::document& data, const connection_vector& vec,
|
||||
boost::function<bool (network::connection)> except_pred, std::string packet_type)
|
||||
boost::function<bool (network::connection)> except_pred,
|
||||
const network::connection exclude, std::string packet_type)
|
||||
{
|
||||
if (packet_type.empty())
|
||||
packet_type = data.root().first_child().to_string();
|
||||
simple_wml::string_span s = data.output_compressed();
|
||||
for(connection_vector::const_iterator i = vec.begin(); i != vec.end(); ++i) {
|
||||
if (!except_pred(*i)) {
|
||||
if ((*i != exclude) && !except_pred(*i)) {
|
||||
network::send_raw_data(s.begin(), s.size(), *i, packet_type);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ void send_to_many(simple_wml::document& data,
|
||||
void send_to_many(simple_wml::document& data,
|
||||
const connection_vector& vec,
|
||||
boost::function<bool (network::connection)> except_pred,
|
||||
std::string packet_type);
|
||||
const network::connection exclude = 0,
|
||||
std::string packet_type = "");
|
||||
} //end namespace wesnothd
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user