summaryrefslogtreecommitdiff
path: root/main_gui.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-11-16 20:57:23 +0000
committerDarkvater <darkvater@openttd.org>2006-11-16 20:57:23 +0000
commit40d647ddde652bb8f1c7b4215279cc82d01ca38f (patch)
tree00447739e30c07ac507e9a0098773ca8aa3a5043 /main_gui.c
parent7f45482bbe87de64fc82ef2b23b38fd1634be9e1 (diff)
downloadopenttd-40d647ddde652bb8f1c7b4215279cc82d01ca38f.tar.xz
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
always sending to teammate if the patch is on even if you do not have any allies. So with setting off you always send to 'all players', with setting on you send to teammates if you have any, otherwise to all players.
Diffstat (limited to 'main_gui.c')
-rw-r--r--main_gui.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/main_gui.c b/main_gui.c
index 96d91cd5e..0c759a39d 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -2298,11 +2298,23 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
break;
#ifdef ENABLE_NETWORK
- case WKC_RETURN: case 'T': // send to all players or to your team depending on setting
+ case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
if (_networking) {
- const NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
- ShowNetworkChatQueryWindow(_patches.chat_target ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, ci->client_playas);
- break;
+ const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
+ bool teamchat = false;
+
+ /* Only players actually playing can speak to team. Eg spectators cannot */
+ if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
+ const NetworkClientInfo *ci;
+ FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
+ if (ci->client_playas == cio->client_playas && ci != cio) {
+ teamchat = true;
+ break;
+ }
+ }
+ }
+
+ ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
}
break;