mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 17:52:00 +00:00
implemented feature to tell observers when a new player has arrived in the lobby
This commit is contained in:
parent
799810a178
commit
6062b614d2
@ -359,6 +359,15 @@ void game::send_data_team(const config& data, const std::string& team, network::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void game::send_data_observers(const config& data)
|
||||||
|
{
|
||||||
|
for(std::vector<network::connection>::const_iterator i = players_.begin(); i != players_.end(); ++i) {
|
||||||
|
if(is_observer(*i)) {
|
||||||
|
network::queue_data(data,*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void game::record_data(const config& data)
|
void game::record_data(const config& data)
|
||||||
{
|
{
|
||||||
history_.append(data);
|
history_.append(data);
|
||||||
|
@ -47,6 +47,8 @@ public:
|
|||||||
|
|
||||||
void send_data(const config& data, network::connection exclude=0);
|
void send_data(const config& data, network::connection exclude=0);
|
||||||
void send_data_team(const config& data, const std::string& team, network::connection exclude=0);
|
void send_data_team(const config& data, const std::string& team, network::connection exclude=0);
|
||||||
|
void send_data_observers(const config& data);
|
||||||
|
|
||||||
void record_data(const config& data);
|
void record_data(const config& data);
|
||||||
|
|
||||||
//the full scenario data
|
//the full scenario data
|
||||||
|
@ -26,6 +26,18 @@ config construct_error(const std::string& msg)
|
|||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config construct_system_message(const std::string& message)
|
||||||
|
{
|
||||||
|
config turn;
|
||||||
|
config& cmd = turn.add_child("turn");
|
||||||
|
config& cfg = cmd.add_child("command");
|
||||||
|
config& msg = cfg.add_child("speak");
|
||||||
|
msg["description"] = "system";
|
||||||
|
msg["message"] = message;
|
||||||
|
|
||||||
|
return turn;
|
||||||
|
}
|
||||||
|
|
||||||
class server
|
class server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -171,6 +183,11 @@ void server::run()
|
|||||||
|
|
||||||
std::cerr << "'" << username << "' (" << network::ip_address(sock) << ") has logged on\n";
|
std::cerr << "'" << username << "' (" << network::ip_address(sock) << ") has logged on\n";
|
||||||
|
|
||||||
|
const config msg(construct_system_message(username + " has logged into the lobby"));
|
||||||
|
for(std::vector<game>::iterator g = games_.begin(); g != games_.end(); ++g) {
|
||||||
|
g->send_data_observers(msg);
|
||||||
|
}
|
||||||
|
|
||||||
} else if(lobby_players_.is_member(sock)) {
|
} else if(lobby_players_.is_member(sock)) {
|
||||||
const config* const create_game = data.child("create_game");
|
const config* const create_game = data.child("create_game");
|
||||||
if(create_game != NULL) {
|
if(create_game != NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user