From 7460764d91f842789a643e82360d4a4b09bc22b3 Mon Sep 17 00:00:00 2001 From: truelight Date: Mon, 20 Dec 2004 15:26:19 +0000 Subject: [PATCH] (svn r1185) -Fix: [Network] Send to team now results in correct company on the sender --- network_server.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/network_server.c b/network_server.c index dcbd733bac..9c448e12f4 100644 --- a/network_server.c +++ b/network_server.c @@ -945,32 +945,41 @@ void NetworkServer_HandleChat(NetworkAction action, DestType desttype, int dest, bool show_local = true; // If this is false, the message is already displayed // on the client who did sent it. /* Find all clients that belong to this player */ + ci_to = NULL; FOR_ALL_CLIENTS(cs) { ci = DEREF_CLIENT_INFO(cs); if (ci->client_playas == dest) { SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_index, false, msg); - if (cs->index == from_index) + if (cs->index == from_index) { show_local = false; + } + ci_to = ci; // Remember a client that is in the company for company-name } } + ci = NetworkFindClientInfoFromIndex(from_index); ci_own = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX); if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) { NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas-1), false, ci->client_name, "%s", msg); if (from_index == NETWORK_SERVER_INDEX) show_local = false; + ci_to = ci; } + /* There is no such player */ + if (ci_to == NULL) + break; + // Display the message locally (so you know you have sent it) if (ci != NULL && show_local) { if (from_index == NETWORK_SERVER_INDEX) { char name[NETWORK_NAME_LENGTH]; - GetString(name, DEREF_PLAYER(ci->client_playas-1)->name_1); - NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas-1), true, name, "%s", msg); + GetString(name, DEREF_PLAYER(ci_to->client_playas-1)->name_1); + NetworkTextMessage(action, GetDrawStringPlayerColor(ci_own->client_playas-1), true, name, "%s", msg); } else { FOR_ALL_CLIENTS(cs) { if (cs->index == from_index) { - SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_index, true, msg); + SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, dest, true, msg); } } }