summaryrefslogtreecommitdiff
path: root/network_gui.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-10-17 22:16:46 +0000
committerDarkvater <Darkvater@openttd.org>2006-10-17 22:16:46 +0000
commitb70e4cefb320a31b9d93295f9759bfaf798639ae (patch)
tree3c5e7e6bcdb563a73452b3392ed9da9e30aa513c /network_gui.c
parent04e55aeacd9d91372af1b59cf43941482d0d8493 (diff)
downloadopenttd-b70e4cefb320a31b9d93295f9759bfaf798639ae.tar.xz
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
correctly handle this ci->client_playas - 1 was used all over the code making it pretty confusing at times. Use proper one-on-one values now. Special handling is only needed for user-output to not to confuse users.
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/network_gui.c b/network_gui.c
index cd6ab6d99..533cc6fc9 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -924,7 +924,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
} break;
case 7: /* Join company */
if (nd->company != (byte)-1) {
- _network_playas = nd->company + 1;
+ _network_playas = nd->company;
NetworkClientConnectGame(_network_last_host, _network_last_port);
}
break;
@@ -1084,7 +1084,7 @@ static void ClientList_Ban(byte client_no)
static void ClientList_GiveMoney(byte client_no)
{
if (NetworkFindClientInfo(client_no) != NULL)
- ShowNetworkGiveMoneyWindow(NetworkFindClientInfo(client_no)->client_playas - 1);
+ ShowNetworkGiveMoneyWindow(NetworkFindClientInfo(client_no)->client_playas);
}
static void ClientList_SpeakToClient(byte client_no)
@@ -1187,7 +1187,7 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y)
_clientlist_proc[i++] = &ClientList_SpeakToClient;
}
- if (ci->client_playas >= 1 && ci->client_playas <= MAX_PLAYERS) {
+ if (IsValidPlayer(ci->client_playas)) {
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY);
_clientlist_proc[i++] = &ClientList_SpeakToPlayer;
}
@@ -1195,12 +1195,10 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y)
_clientlist_proc[i++] = &ClientList_SpeakToAll;
if (_network_own_client_index != ci->client_index) {
- if (IsValidPlayer(_network_playas - 1)) {
- // We are no spectator
- if (ci->client_playas >= 1 && ci->client_playas <= MAX_PLAYERS) {
- GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY);
- _clientlist_proc[i++] = &ClientList_GiveMoney;
- }
+ /* We are no spectator and the player we want to give money to is no spectator */
+ if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas)) {
+ GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY);
+ _clientlist_proc[i++] = &ClientList_GiveMoney;
}
}
@@ -1328,8 +1326,7 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
}
// Filter out spectators
- if (ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS)
- DrawPlayerIcon(ci->client_playas - 1, 64, y + 1);
+ if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
DoDrawString(ci->client_name, 81, y, colour);