diff options
author | Darkvater <darkvater@openttd.org> | 2006-01-31 22:16:15 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-01-31 22:16:15 +0000 |
commit | f2448ebfd4324b0c914e36b81801fc1ffa04da94 (patch) | |
tree | 763ef198108c0320af48fbac22bf9c998430da2d /network_udp.c | |
parent | 9d07426a29817fbaddcb8f8c726e16a32bb123d0 (diff) | |
download | openttd-f2448ebfd4324b0c914e36b81801fc1ffa04da94.tar.xz |
(svn r3500) - Workaround the inaccurate count of spectators/companies that can happen in certain border-cases. For now just dynamically get this value when requested so it is always right. To do properly all player/client creation/destruction needs a hook for networking.
Diffstat (limited to 'network_udp.c')
-rw-r--r-- | network_udp.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/network_udp.c b/network_udp.c index 154214621..06b5b83de 100644 --- a/network_udp.c +++ b/network_udp.c @@ -64,7 +64,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER) /* NETWORK_GAME_INFO_VERSION = 2 */ NetworkSend_uint8 (packet, _network_game_info.companies_max); - NetworkSend_uint8 (packet, _network_game_info.companies_on); + NetworkSend_uint8 (packet, ActivePlayerCount()); NetworkSend_uint8 (packet, _network_game_info.spectators_max); /* NETWORK_GAME_INFO_VERSION = 1 */ @@ -74,7 +74,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER) NetworkSend_uint8 (packet, _network_game_info.use_password); NetworkSend_uint8 (packet, _network_game_info.clients_max); NetworkSend_uint8 (packet, _network_game_info.clients_on); - NetworkSend_uint8 (packet, _network_game_info.spectators_on); + NetworkSend_uint8 (packet, NetworkSpectatorCount()); NetworkSend_uint16(packet, _network_game_info.game_date); NetworkSend_uint16(packet, _network_game_info.start_date); NetworkSend_string(packet, _network_game_info.map_name); @@ -162,7 +162,6 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO) NetworkClientInfo *ci; Packet *packet; Player *player; - byte active = 0; byte current = 0; int i; @@ -172,14 +171,9 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO) packet = NetworkSend_Init(PACKET_UDP_SERVER_DETAIL_INFO); - FOR_ALL_PLAYERS(player) { - if (player->is_active) - active++; - } - /* Send the amount of active companies */ NetworkSend_uint8 (packet, NETWORK_COMPANY_INFO_VERSION); - NetworkSend_uint8 (packet, active); + NetworkSend_uint8 (packet, ActivePlayerCount()); /* Fetch the latest version of everything */ NetworkPopulateCompanyInfo(); |