From 8e8174987230eb298b1b86a225f3c6a175b86751 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 22 Dec 2008 21:15:02 +0000 Subject: (svn r14715) -Codechange: move some network code from the main gui file into one of the the network files. --- src/network/network_client.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/network/network_client.cpp') diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index d1ff4e078..1ef35508b 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -956,4 +956,22 @@ void NetworkClientSetPassword(const char *password) SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(password); } +/** + * Tell whether the client has team members where he/she can chat to. + * @param cio client to check members of. + * @return true if there is at least one team member. + */ +bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio) +{ + /* Only companies actually playing can speak to team. Eg spectators cannot */ + if (!_settings_client.gui.prefer_teamchat || !IsValidCompanyID(cio->client_playas)) return false; + + const NetworkClientInfo *ci; + FOR_ALL_ACTIVE_CLIENT_INFOS(ci) { + if (ci->client_playas == cio->client_playas && ci != cio) return true; + } + + return false; +} + #endif /* ENABLE_NETWORK */ -- cgit v1.2.3-70-g09d2