diff options
author | rubidium <rubidium@openttd.org> | 2008-07-18 16:40:29 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-07-18 16:40:29 +0000 |
commit | 3a799389ebf915cc59b6e85346d837621ebe771a (patch) | |
tree | 82319a3d42401c6d6fa4944e99863807f05c6f5f /src/network | |
parent | 891bec7e23a0a077df93b8fd1fe156ef059df8b4 (diff) | |
download | openttd-3a799389ebf915cc59b6e85346d837621ebe771a.tar.xz |
(svn r13731) -Codechange: make a pool of the array of players.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network.cpp | 1 | ||||
-rw-r--r-- | src/network/network_client.cpp | 4 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 1 | ||||
-rw-r--r-- | src/network/network_server.cpp | 11 | ||||
-rw-r--r-- | src/network/network_udp.cpp | 3 |
5 files changed, 6 insertions, 14 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index e824f4406..7a0cb2ce0 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -40,6 +40,7 @@ #include "../core/alloc_func.hpp" #endif /* DEBUG_DUMP_COMMANDS */ #include "table/strings.h" +#include "../player_base.h" bool _network_server; ///< network-server is active bool _network_available; ///< is network mode available? diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 5a3c7dab6..cc8e746f5 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -624,9 +624,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) /* New company/spectator (invalid player) or company we want to join is not active * Switch local player to spectator and await the server's judgement */ - if (_network_playas == PLAYER_NEW_COMPANY || !IsValidPlayerID(_network_playas) || - !GetPlayer(_network_playas)->is_active) { - + if (_network_playas == PLAYER_NEW_COMPANY || !IsValidPlayerID(_network_playas)) { SetLocalPlayer(PLAYER_SPECTATOR); if (_network_playas != PLAYER_SPECTATOR) { diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e238b94e2..84ce21e0a 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -31,6 +31,7 @@ #include "../widgets/dropdown_func.h" #include "../querystring_gui.h" #include "../sortlist_type.h" +#include "../player_base.h" #include "table/strings.h" #include "../table/sprites.h" diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 21c179877..986b56784 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -89,8 +89,6 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO) NetworkPopulateCompanyInfo(); FOR_ALL_PLAYERS(player) { - if (!player->is_active) continue; - p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO); p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION); @@ -1299,12 +1297,9 @@ void NetworkPopulateCompanyInfo() uint i; uint16 months_empty; - FOR_ALL_PLAYERS(p) { - if (!p->is_active) { - memset(&_network_player_info[p->index], 0, sizeof(NetworkPlayerInfo)); - continue; - } + memset(_network_player_info, 0, sizeof(_network_player_info)); + FOR_ALL_PLAYERS(p) { // Clean the info but not the password ttd_strlcpy(password, _network_player_info[p->index].password, sizeof(password)); months_empty = _network_player_info[p->index].months_empty; @@ -1436,7 +1431,7 @@ static void NetworkAutoCleanCompanies() /* Go through all the comapnies */ FOR_ALL_PLAYERS(p) { /* Skip the non-active once */ - if (!p->is_active || p->is_ai) continue; + if (p->is_ai) continue; if (!clients_in_company[p->index]) { /* The company is empty for one month more */ diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 1a85d3d98..a89e0e5ca 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -124,9 +124,6 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO) byte current = 0; /* Go through all the players */ FOR_ALL_PLAYERS(player) { - /* Skip non-active players */ - if (!player->is_active) continue; - current++; /* Send the information */ |