1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 12:39:11 +00:00

(svn r13731) -Codechange: make a pool of the array of players.

This commit is contained in:
rubidium
2008-07-18 16:40:29 +00:00
parent 891bec7e23
commit 3a799389eb
38 changed files with 173 additions and 242 deletions

View File

@@ -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?

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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 */

View File

@@ -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 */