(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.
This commit is contained in:
Darkvater
2006-10-17 22:16:46 +00:00
parent 821df34b6e
commit fbc724c6cb
10 changed files with 79 additions and 83 deletions

View File

@@ -294,7 +294,7 @@ static uint NetworkCountPlayers(void)
FOR_ALL_CLIENTS(cs) {
NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
if (ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS) count++;
if (IsValidPlayer(ci->client_playas)) count++;
}
return count;
@@ -575,6 +575,7 @@ static NetworkClientState *NetworkAllocClient(SOCKET s)
cs->index = _network_client_index++;
ci->client_index = cs->index;
ci->client_playas = PLAYER_INACTIVE_CLIENT;
ci->join_date = _date;
InvalidateWindow(WC_CLIENT_LIST, 0);
@@ -1034,11 +1035,8 @@ static void NetworkInitGameInfo(void)
memset(ci, 0, sizeof(*ci));
ci->client_index = NETWORK_SERVER_INDEX;
if (_network_dedicated) {
ci->client_playas = PLAYER_SPECTATOR;
} else {
ci->client_playas = _local_player + 1;
}
ci->client_playas = _network_dedicated ? PLAYER_SPECTATOR : _local_player;
ttd_strlcpy(ci->client_name, _network_player_name, sizeof(ci->client_name));
ttd_strlcpy(ci->unique_id, _network_unique_id, sizeof(ci->unique_id));
}
@@ -1067,8 +1065,8 @@ bool NetworkServerStart(void)
_last_sync_frame = 0;
_network_own_client_index = NETWORK_SERVER_INDEX;
if (!_network_dedicated)
_network_playas = 1;
/* Non-dedicated server will always be player #1 */
if (!_network_dedicated) _network_playas = 0;
_network_clients_connected = 0;