summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-10-24 22:26:20 +0000
committerDarkvater <darkvater@openttd.org>2006-10-24 22:26:20 +0000
commit2b8530507d4b930ecb734ea3c0db8beb5192d6b1 (patch)
treec438df07f9e38fc848f75b85830b01a28ae506f2
parent929cfa6687abff4d7278b9e89798c2d53e074bfe (diff)
downloadopenttd-2b8530507d4b930ecb734ea3c0db8beb5192d6b1.tar.xz
(svn r6933) -Feature: Allow spectators to speak to eachother (team)
-rw-r--r--lang/english.txt1
-rw-r--r--network_client.c13
-rw-r--r--network_gui.c2
-rw-r--r--network_server.c3
4 files changed, 12 insertions, 7 deletions
diff --git a/lang/english.txt b/lang/english.txt
index ce0b0e15e..a5cc32019 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1445,6 +1445,7 @@ STR_NETWORK_SERVER_REBOOT :{WHITE} The ser
STR_NETWORK_SERVER :Server
STR_NETWORK_CLIENT :Client
+STR_NETWORK_SPECTATORS :Spectators
STR_NETWORK_CLIENTLIST_NONE :(none)
STR_NETWORK_CLIENTLIST_KICK :Kick
diff --git a/network_client.c b/network_client.c
index 80dd45b94..b5e9b34c7 100644
--- a/network_client.c
+++ b/network_client.c
@@ -623,14 +623,17 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
snprintf(name, sizeof(name), "%s", ci_to->client_name);
ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
break;
- case NETWORK_ACTION_CHAT_COMPANY:
+
+ /* For speaking to company or giving money, we need the player-name */
case NETWORK_ACTION_GIVE_MONEY:
- /* For speaking to player or give money, we need the player-name */
- if (!IsValidPlayer(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY; // This should never happen
+ if (!IsValidPlayer(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
+ /* fallthrough */
+ case NETWORK_ACTION_CHAT_COMPANY: {
+ StringID str = IsValidPlayer(ci_to->client_playas) ? GetPlayer(ci_to->client_playas)->name_1 : STR_NETWORK_SPECTATORS;
- GetString(name, GetPlayer(ci_to->client_playas)->name_1, lastof(name));
+ GetString(name, str, lastof(name));
ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
- break;
+ } break;
default:
/* This should never happen */
NOT_REACHED();
diff --git a/network_gui.c b/network_gui.c
index a51cc78b0..63e995721 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -1185,7 +1185,7 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y)
_clientlist_proc[i++] = &ClientList_SpeakToClient;
}
- if (IsValidPlayer(ci->client_playas)) {
+ if (IsValidPlayer(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(_clientlist_action[i]));
_clientlist_proc[i++] = &ClientList_SpeakToCompany;
}
diff --git a/network_server.c b/network_server.c
index 61f32335e..af78b95ac 100644
--- a/network_server.c
+++ b/network_server.c
@@ -1044,7 +1044,8 @@ void NetworkServer_HandleChat(NetworkAction action, DestType desttype, int dest,
if (ci != NULL && show_local) {
if (from_index == NETWORK_SERVER_INDEX) {
char name[NETWORK_NAME_LENGTH];
- GetString(name, GetPlayer(ci_to->client_playas)->name_1, lastof(name));
+ StringID str = IsValidPlayer(ci_to->client_playas) ? GetPlayer(ci_to->client_playas)->name_1 : STR_NETWORK_SPECTATORS;
+ GetString(name, str, lastof(name));
NetworkTextMessage(action, GetDrawStringPlayerColor(ci_own->client_playas), true, name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {