summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-09-30 20:39:50 +0000
committerrubidium <rubidium@openttd.org>2008-09-30 20:39:50 +0000
commitf56e630e5cb839b307f04bf52465c4db4d1ad904 (patch)
tree69fb7ae1d9bdadb9e7386cb70b0a26621ad9b57f /src/network
parentdba193d4a54707a19d8f3c2f42a1ac10ff544c5c (diff)
downloadopenttd-f56e630e5cb839b307f04bf52465c4db4d1ad904.tar.xz
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/config.h4
-rw-r--r--src/network/core/game.h2
-rw-r--r--src/network/core/tcp.h4
-rw-r--r--src/network/network.cpp68
-rw-r--r--src/network/network.h4
-rw-r--r--src/network/network_chat_gui.cpp4
-rw-r--r--src/network/network_client.cpp102
-rw-r--r--src/network/network_data.cpp16
-rw-r--r--src/network/network_func.h14
-rw-r--r--src/network/network_gui.cpp114
-rw-r--r--src/network/network_gui.h2
-rw-r--r--src/network/network_internal.h2
-rw-r--r--src/network/network_server.cpp258
-rw-r--r--src/network/network_type.h24
-rw-r--r--src/network/network_udp.cpp28
15 files changed, 322 insertions, 324 deletions
diff --git a/src/network/core/config.h b/src/network/core/config.h
index 7d9672036..c41190cce 100644
--- a/src/network/core/config.h
+++ b/src/network/core/config.h
@@ -29,8 +29,8 @@ enum {
NETWORK_UNIQUE_ID_LENGTH = 33, ///< The maximum length of the unique id of the clients, in bytes including '\0'
NETWORK_REVISION_LENGTH = 15, ///< The maximum length of the revision, in bytes including '\0'
NETWORK_PASSWORD_LENGTH = 33, ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_UNIQUE_ID_LENGTH)
- NETWORK_PLAYERS_LENGTH = 200, ///< The maximum length for the list of players that controls a company, in bytes including '\0'
- NETWORK_CLIENT_NAME_LENGTH = 25, ///< The maximum length of a player, in bytes including '\0'
+ NETWORK_CLIENTS_LENGTH = 200, ///< The maximum length for the list of clients that controls a company, in bytes including '\0'
+ NETWORK_CLIENT_NAME_LENGTH = 25, ///< The maximum length of a client's name, in bytes including '\0'
NETWORK_RCONCOMMAND_LENGTH = 500, ///< The maximum length of a rconsole command, in bytes including '\0'
NETWORK_CHAT_LENGTH = 900, ///< The maximum length of a chat message, in bytes including '\0'
diff --git a/src/network/core/game.h b/src/network/core/game.h
index 6b8e989b3..714711fe4 100644
--- a/src/network/core/game.h
+++ b/src/network/core/game.h
@@ -17,7 +17,7 @@
/**
* This is the struct used by both client and server
* some fields will be empty on the client (like game_password) by default
- * and only filled with data a player enters.
+ * and only filled with data a client enters.
*/
struct NetworkServerGameInfo {
byte clients_on; ///< Current count of clients on server
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index 16a795e28..6af0d17f8 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -61,7 +61,7 @@ enum {
/** Packet that wraps a command */
struct CommandPacket {
CommandPacket *next; ///< the next command packet (if in queue)
- PlayerByte player; ///< player that is executing the command
+ CompanyByte company; ///< company that is executing the command
uint32 cmd; ///< command being executed
uint32 p1; ///< parameter p1
uint32 p2; ///< parameter p2
@@ -81,7 +81,7 @@ enum ClientStatus {
STATUS_MAP, ///< The client is downloading the map
STATUS_DONE_MAP, ///< The client has downloaded the map
STATUS_PRE_ACTIVE, ///< The client is catching up the delayed frames
- STATUS_ACTIVE, ///< The client is an active player in the game
+ STATUS_ACTIVE, ///< The client is active within in the game
};
/** Base socket handler for all TCP sockets */
diff --git a/src/network/network.cpp b/src/network/network.cpp
index e2b355c6f..0033f4030 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -47,7 +47,7 @@ bool _network_available; ///< is network mode available?
bool _network_dedicated; ///< are we a dedicated server?
bool _is_network_server; ///< Does this client wants to be a network-server?
NetworkServerGameInfo _network_game_info;
-NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
+NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
uint16 _network_own_client_index;
uint16 _redirect_console_to_client;
@@ -155,7 +155,7 @@ byte NetworkSpectatorCount()
byte count = 0;
FOR_ALL_CLIENTS(cs) {
- if (DEREF_CLIENT_INFO(cs)->client_playas == PLAYER_SPECTATOR) count++;
+ if (DEREF_CLIENT_INFO(cs)->client_playas == COMPANY_SPECTATOR) count++;
}
return count;
@@ -335,54 +335,54 @@ char* GetNetworkErrorMsg(char* buf, NetworkErrorCode err, const char* last)
}
/* Count the number of active clients connected */
-static uint NetworkCountPlayers()
+static uint NetworkCountActiveClients()
{
NetworkTCPSocketHandler *cs;
uint count = 0;
FOR_ALL_CLIENTS(cs) {
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas)) count++;
+ if (IsValidCompanyID(ci->client_playas)) count++;
}
return count;
}
-static bool _min_players_paused = false;
+static bool _min_active_clients_paused = false;
-/* Check if the minimum number of players has been reached and pause or unpause the game as appropriate */
-void CheckMinPlayers()
+/* Check if the minimum number of active clients has been reached and pause or unpause the game as appropriate */
+void CheckMinActiveClients()
{
if (!_network_dedicated) return;
- if (NetworkCountPlayers() < _settings_client.network.min_players) {
- if (_min_players_paused) return;
+ if (NetworkCountActiveClients() < _settings_client.network.min_active_clients) {
+ if (_min_active_clients_paused) return;
- _min_players_paused = true;
+ _min_active_clients_paused = true;
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (not enough players)", NETWORK_SERVER_INDEX);
} else {
- if (!_min_players_paused) return;
+ if (!_min_active_clients_paused) return;
- _min_players_paused = false;
+ _min_active_clients_paused = false;
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (enough players)", NETWORK_SERVER_INDEX);
}
}
-/** Converts a string to ip/port/player
- * Format: IP#player:port
+/** Converts a string to ip/port/company
+ * Format: IP#company:port
*
- * connection_string will be re-terminated to seperate out the hostname, and player and port will
- * be set to the player and port strings given by the user, inside the memory area originally
+ * connection_string will be re-terminated to seperate out the hostname, and company and port will
+ * be set to the company and port strings given by the user, inside the memory area originally
* occupied by connection_string. */
-void ParseConnectionString(const char **player, const char **port, char *connection_string)
+void ParseConnectionString(const char **company, const char **port, char *connection_string)
{
char *p;
for (p = connection_string; *p != '\0'; p++) {
switch (*p) {
case '#':
- *player = p + 1;
+ *company = p + 1;
*p = '\0';
break;
case ':':
@@ -421,7 +421,7 @@ static NetworkTCPSocketHandler *NetworkAllocClient(SOCKET s)
cs->index = _network_client_index++;
ci->client_index = cs->index;
- ci->client_playas = PLAYER_INACTIVE_CLIENT;
+ ci->client_playas = COMPANY_INACTIVE_CLIENT;
ci->join_date = _date;
InvalidateWindow(WC_CLIENT_LIST, 0);
@@ -495,7 +495,7 @@ void NetworkCloseClient(NetworkTCPSocketHandler *cs)
cs->index = NETWORK_EMPTY_INDEX;
ci->client_index = NETWORK_EMPTY_INDEX;
- CheckMinPlayers();
+ CheckMinActiveClients();
}
// A client wants to connect to a server
@@ -688,7 +688,7 @@ static void NetworkInitialize()
// Clean the client_info memory
memset(&_network_client_info, 0, sizeof(_network_client_info));
- memset(&_network_player_info, 0, sizeof(_network_player_info));
+ memset(&_network_company_info, 0, sizeof(_network_company_info));
_sync_frame = 0;
_network_first_time = true;
@@ -729,7 +729,7 @@ void NetworkAddServer(const char *b)
{
if (*b != '\0') {
const char *port = NULL;
- const char *player = NULL;
+ const char *company = NULL;
char host[NETWORK_HOSTNAME_LENGTH];
uint16 rport;
@@ -738,7 +738,7 @@ void NetworkAddServer(const char *b)
ttd_strlcpy(_settings_client.network.connect_to_ip, b, lengthof(_settings_client.network.connect_to_ip));
rport = NETWORK_DEFAULT_PORT;
- ParseConnectionString(&player, &port, host);
+ ParseConnectionString(&company, &port, host);
if (port != NULL) rport = atoi(port);
NetworkUDPQueryServer(host, rport, true);
@@ -812,9 +812,9 @@ static void NetworkInitGameInfo()
memset(ci, 0, sizeof(*ci));
ci->client_index = NETWORK_SERVER_INDEX;
- ci->client_playas = _network_dedicated ? PLAYER_SPECTATOR : _local_player;
+ ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : _local_company;
- ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
+ ttd_strlcpy(ci->client_name, _settings_client.network.client_name, sizeof(ci->client_name));
ttd_strlcpy(ci->unique_id, _settings_client.network.network_id, sizeof(ci->unique_id));
}
@@ -841,8 +841,8 @@ bool NetworkServerStart()
_last_sync_frame = 0;
_network_own_client_index = NETWORK_SERVER_INDEX;
- /* Non-dedicated server will always be player #1 */
- if (!_network_dedicated) _network_playas = PLAYER_FIRST;
+ /* Non-dedicated server will always be company #1 */
+ if (!_network_dedicated) _network_playas = COMPANY_FIRST;
_network_clients_connected = 0;
@@ -853,8 +853,8 @@ bool NetworkServerStart()
// if the server is dedicated ... add some other script
if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
- _min_players_paused = false;
- CheckMinPlayers();
+ _min_active_clients_paused = false;
+ CheckMinActiveClients();
/* Try to register us to the master server */
_network_last_advertise_frame = 0;
@@ -1077,7 +1077,7 @@ void NetworkGameLoop()
while (f != NULL && !feof(f)) {
if (cp != NULL && _date == next_date && _date_fract == next_date_fract) {
- _current_player = cp->player;
+ _current_company = cp->company;
_cmd_text = cp->text;
DoCommandP(cp->tile, cp->p1, cp->p2, NULL, cp->cmd);
free(cp);
@@ -1090,9 +1090,9 @@ void NetworkGameLoop()
if (fgets(buff, lengthof(buff), f) == NULL) break;
if (strncmp(buff, "ddc:cmd:", 8) != 0) continue;
cp = MallocT<CommandPacket>(1);
- int player;
- sscanf(&buff[8], "%d;%d;%d;%d;%d;%d;%d;%s", &next_date, &next_date_fract, &player, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
- cp->player = (Owner)player;
+ int company;
+ sscanf(&buff[8], "%d;%d;%d;%d;%d;%d;%d;%s", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
+ cp->company = (CompanyID)company;
}
#endif /* DEBUG_DUMP_COMMANDS */
@@ -1238,4 +1238,4 @@ bool IsNetworkCompatibleVersion(const char *other)
#endif /* ENABLE_NETWORK */
/* NOTE: this variable needs to be always available */
-PlayerID _network_playas;
+CompanyID _network_playas;
diff --git a/src/network/network.h b/src/network/network.h
index 9c913ceb6..441378563 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -34,7 +34,7 @@ static inline void NetworkDrawChatMessage() {}
#endif /* ENABLE_NETWORK */
-/** As which player do we play? */
-extern PlayerID _network_playas;
+/** As which company do we play? */
+extern CompanyID _network_playas;
#endif /* NETWORK_H */
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index fe9a85289..552095ec9 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -27,7 +27,7 @@
#include "table/strings.h"
-/* The draw buffer must be able to contain the chat message, player name and the "[All]" message,
+/* The draw buffer must be able to contain the chat message, client name and the "[All]" message,
* some spaces and possible translations of [All] to other languages. */
assert_compile((int)DRAW_STRING_BUFFER >= (int)NETWORK_CHAT_LENGTH + NETWORK_NAME_LENGTH + 40);
@@ -99,7 +99,7 @@ void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *messa
ChatMessage *cmsg = &_chatmsg_list[msg_count++];
ttd_strlcpy(cmsg->message, bufp, sizeof(cmsg->message));
- /* The default colour for a message is player colour. Replace this with
+ /* The default colour for a message is company colour. Replace this with
* white for any additional lines */
cmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR;
cmsg->end_date = _date + duration;
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 0b07e7da0..d7eeb515b 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -77,17 +77,17 @@ static const char *GenerateCompanyPasswordHash(const char *password)
}
/**
- * Hash the current company password; used when the server 'player' sets his/her password.
+ * Hash the current company password; used when the server 'company' sets his/her password.
*/
void HashCurrentCompanyPassword()
{
- if (StrEmpty(_network_player_info[_local_player].password)) return;
+ if (StrEmpty(_network_company_info[_local_company].password)) return;
_password_game_seed = _settings_game.game_creation.generation_seed;
ttd_strlcpy(_password_server_unique_id, _settings_client.network.network_id, sizeof(_password_server_unique_id));
- const char *new_pw = GenerateCompanyPasswordHash(_network_player_info[_local_player].password);
- ttd_strlcpy(_network_player_info[_local_player].password, new_pw, sizeof(_network_player_info[_local_player].password));
+ const char *new_pw = GenerateCompanyPasswordHash(_network_company_info[_local_company].password);
+ ttd_strlcpy(_network_company_info[_local_company].password, new_pw, sizeof(_network_company_info[_local_company].password));
}
@@ -119,10 +119,10 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
// Function: Try to join the server
// Data:
// String: OpenTTD Revision (norev000 if no revision)
- // String: Player Name (max NETWORK_NAME_LENGTH)
- // uint8: Play as Player id (1..MAX_PLAYERS)
+ // String: Client Name (max NETWORK_NAME_LENGTH)
+ // uint8: Play as Company id (1..MAX_COMPANIES)
// uint8: Language ID
- // String: Unique id to find the player back in server-listing
+ // String: Unique id to find the client back in server-listing
//
Packet *p;
@@ -131,7 +131,7 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
p = NetworkSend_Init(PACKET_CLIENT_JOIN);
p->Send_string(_openttd_revision);
- p->Send_string(_settings_client.network.player_name); // Player name
+ p->Send_string(_settings_client.network.client_name); // Client name
p->Send_uint8 (_network_playas); // PlayAs
p->Send_uint8 (NETLANG_ANY); // Language
p->Send_string(_settings_client.network.network_id);
@@ -213,7 +213,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(CommandPacket *cp)
// Packet: CLIENT_COMMAND
// Function: Send a DoCommand to the Server
// Data:
- // uint8: PlayerID (0..MAX_PLAYERS-1)
+ // uint8: CompanyID (0..MAX_COMPANIES-1)
// uint32: CommandID (see command.h)
// uint32: P1 (free variables used in DoCommand)
// uint32: P2
@@ -224,7 +224,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(CommandPacket *cp)
Packet *p = NetworkSend_Init(PACKET_CLIENT_COMMAND);
- p->Send_uint8 (cp->player);
+ p->Send_uint8 (cp->company);
p->Send_uint32(cp->cmd);
p->Send_uint32(cp->p1);
p->Send_uint32(cp->p2);
@@ -244,7 +244,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType
// Data:
// uint8: ActionID (see network_data.h, NetworkAction)
// uint8: Destination Type (see network_data.h, DestType);
- // uint16: Destination Player
+ // uint16: Destination Company/Client
// String: Message (max NETWORK_CHAT_LENGTH)
//
@@ -290,7 +290,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_NAME)(const char *name)
{
//
// Packet: PACKET_CLIENT_SET_NAME
- // Function: Gives the player a new name
+ // Function: Gives the client a new name
// Data:
// String: Name
//
@@ -359,7 +359,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
if (!MY_CLIENT->has_quit && company_info_version == NETWORK_COMPANY_INFO_VERSION) {
byte total;
- PlayerID current;
+ CompanyID current;
total = p->Recv_uint8();
@@ -367,21 +367,21 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
if (total == 0) return NETWORK_RECV_STATUS_CLOSE_QUERY;
current = (Owner)p->Recv_uint8();
- if (current >= MAX_PLAYERS) return NETWORK_RECV_STATUS_CLOSE_QUERY;
-
- p->Recv_string(_network_player_info[current].company_name, sizeof(_network_player_info[current].company_name));
- _network_player_info[current].inaugurated_year = p->Recv_uint32();
- _network_player_info[current].company_value = p->Recv_uint64();
- _network_player_info[current].money = p->Recv_uint64();
- _network_player_info[current].income = p->Recv_uint64();
- _network_player_info[current].performance = p->Recv_uint16();
- _network_player_info[current].use_password = p->Recv_bool();
+ if (current >= MAX_COMPANIES) return NETWORK_RECV_STATUS_CLOSE_QUERY;
+
+ p->Recv_string(_network_company_info[current].company_name, sizeof(_network_company_info[current].company_name));
+ _network_company_info[current].inaugurated_year = p->Recv_uint32();
+ _network_company_info[current].company_value = p->Recv_uint64();
+ _network_company_info[current].money = p->Recv_uint64();
+ _network_company_info[current].income = p->Recv_uint64();
+ _network_company_info[current].performance = p->Recv_uint16();
+ _network_company_info[current].use_password = p->Recv_bool();
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++)
- _network_player_info[current].num_vehicle[i] = p->Recv_uint16();
+ _network_company_info[current].num_vehicle[i] = p->Recv_uint16();
for (i = 0; i < NETWORK_STATION_TYPES; i++)
- _network_player_info[current].num_station[i] = p->Recv_uint16();
+ _network_company_info[current].num_station[i] = p->Recv_uint16();
- p->Recv_string(_network_player_info[current].players, sizeof(_network_player_info[current].players));
+ p->Recv_string(_network_company_info[current].clients, sizeof(_network_company_info[current].clients));
InvalidateWindow(WC_NETWORK_WINDOW, 0);
@@ -398,7 +398,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
{
NetworkClientInfo *ci;
uint16 index = p->Recv_uint16();
- PlayerID playas = (Owner)p->Recv_uint8();
+ CompanyID playas = (CompanyID)p->Recv_uint8();
char name[NETWORK_NAME_LENGTH];
p->Recv_string(name, sizeof(name));
@@ -414,7 +414,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
// Client name changed, display the change
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", name);
} else if (playas != ci->client_playas) {
- // The player changed from client-player..
+ // The client changed from client-player..
// Do not display that for now
}
@@ -451,7 +451,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_ERROR)
/* We made an error in the protocol, and our connection is closed.... */
case NETWORK_ERROR_NOT_AUTHORIZED:
case NETWORK_ERROR_NOT_EXPECTED:
- case NETWORK_ERROR_PLAYER_MISMATCH:
+ case NETWORK_ERROR_COMPANY_MISMATCH:
_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_ERROR;
break;
case NETWORK_ERROR_FULL:
@@ -622,21 +622,21 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
// Say we received the map and loaded it correctly!
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
- /* 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)) {
- SetLocalPlayer(PLAYER_SPECTATOR);
+ /* New company/spectator (invalid company) or company we want to join is not active
+ * Switch local company to spectator and await the server's judgement */
+ if (_network_playas == COMPANY_NEW_COMPANY || !IsValidCompanyID(_network_playas)) {
+ SetLocalCompany(COMPANY_SPECTATOR);
- if (_network_playas != PLAYER_SPECTATOR) {
- /* We have arrived and ready to start playing; send a command to make a new player;
+ if (_network_playas != COMPANY_SPECTATOR) {
+ /* We have arrived and ready to start playing; send a command to make a new company;
* the server will give us a client-id and let us in */
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
ShowJoinStatusWindow();
- NetworkSend_Command(0, 0, 0, CMD_PLAYER_CTRL, NULL);
+ NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL);
}
} else {
// take control over an existing company
- SetLocalPlayer(_network_playas);
+ SetLocalCompany(_network_playas);
}
}
@@ -685,7 +685,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SYNC)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND)
{
CommandPacket *cp = MallocT<CommandPacket>(1);
- cp->player = (PlayerID)p->Recv_uint8();
+ cp->company = (CompanyID)p->Recv_uint8();
cp->cmd = p->Recv_uint32();
cp->p1 = p->Recv_uint32();
cp->p2 = p->Recv_uint32();
@@ -733,12 +733,12 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
break;
- /* For speaking to company or giving money, we need the player-name */
+ /* For speaking to company or giving money, we need the company-name */
case NETWORK_ACTION_GIVE_MONEY:
- if (!IsValidPlayerID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
+ if (!IsValidCompanyID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
/* fallthrough */
case NETWORK_ACTION_CHAT_COMPANY: {
- StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
+ StringID str = IsValidCompanyID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
GetString(name, str, lastof(name));
@@ -754,7 +754,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
}
if (ci != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), self_send, name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), self_send, name, "%s", msg);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -831,10 +831,10 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEWGAME)
{
// To trottle the reconnects a bit, every clients waits
- // his _local_player value before reconnecting
- // PLAYER_SPECTATOR is currently 255, so to avoid long wait periods
+ // his _local_company value before reconnecting
+ // COMPANY_SPECTATOR is currently 255, so to avoid long wait periods
// set the max to 10.
- _network_reconnect = min(_local_player + 1, 10);
+ _network_reconnect = min(_local_company + 1, 10);
_switch_mode_errorstr = STR_NETWORK_SERVER_REBOOT;
return NETWORK_RECV_STATUS_SERVER_ERROR;
@@ -938,20 +938,20 @@ void NetworkClientSendRcon(const char *password, const char *command)
SEND_COMMAND(PACKET_CLIENT_RCON)(password, command);
}
-void NetworkUpdatePlayerName()
+void NetworkUpdateClientName()
{
NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
if (ci == NULL) return;
/* Don't change the name if it is the same as the old name */
- if (strcmp(ci->client_name, _settings_client.network.player_name) != 0) {
+ if (strcmp(ci->client_name, _settings_client.network.client_name) != 0) {
if (!_network_server) {
- SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_settings_client.network.player_name);
+ SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_settings_client.network.client_name);
} else {
- if (NetworkFindName(_settings_client.network.player_name)) {
- NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.player_name);
- ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
+ if (NetworkFindName(_settings_client.network.client_name)) {
+ NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.client_name);
+ ttd_strlcpy(ci->client_name, _settings_client.network.client_name, sizeof(ci->client_name));
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
}
@@ -965,7 +965,7 @@ void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const
void NetworkClientSetPassword()
{
- SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
+ SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_company_info[_local_company].password);
}
#endif /* ENABLE_NETWORK */
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index b24b2e498..914f6d40c 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -36,12 +36,12 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
{
CommandPacket c;
- c.player = _local_player;
- c.next = NULL;
- c.tile = tile;
- c.p1 = p1;
- c.p2 = p2;
- c.cmd = cmd;
+ c.company = _local_company;
+ c.next = NULL;
+ c.tile = tile;
+ c.p1 = p1;
+ c.p2 = p2;
+ c.cmd = cmd;
c.callback = 0;
while (c.callback < _callback_table_count && _callback_table[c.callback] != callback) {
@@ -95,7 +95,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
// Execute a DoCommand we received from the network
void NetworkExecuteCommand(CommandPacket *cp)
{
- _current_player = cp->player;
+ _current_company = cp->company;
_cmd_text = cp->text;
/* cp->callback is unsigned. so we don't need to do lower bounds checking. */
if (cp->callback > _callback_table_count) {
@@ -103,7 +103,7 @@ void NetworkExecuteCommand(CommandPacket *cp)
cp->callback = 0;
}
- DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->player, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
+ DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND, cp->my_cmd);
}
diff --git a/src/network/network_func.h b/src/network/network_func.h
index cd1a5aa5d..fac321506 100644
--- a/src/network/network_func.h
+++ b/src/network/network_func.h
@@ -11,7 +11,7 @@
#include "../console_type.h"
extern NetworkServerGameInfo _network_game_info;
-extern NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
+extern NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
extern uint16 _network_own_client_index;
@@ -23,16 +23,16 @@ extern char *_network_host_list[10];
extern char *_network_ban_list[25];
byte NetworkSpectatorCount();
-void CheckMinPlayers();
-void NetworkUpdatePlayerName();
-bool NetworkCompanyHasPlayers(PlayerID company);
+void CheckMinActiveClients();
+void NetworkUpdateClientName();
+bool NetworkCompanyHasClients(CompanyID company);
bool NetworkChangeCompanyPassword(byte argc, char *argv[]);
void NetworkReboot();
void NetworkDisconnect();
void NetworkGameLoop();
void NetworkUDPGameLoop();
void NetworkUDPCloseAll();
-void ParseConnectionString(const char **player, const char **port, char *connection_string);
+void ParseConnectionString(const char **company, const char **port, char *connection_string);
void NetworkStartDebugLog(const char *hostname, uint16 port);
void NetworkPopulateCompanyInfo();
@@ -45,13 +45,13 @@ void NetworkClientSetPassword();
/*** Commands ran by the server ***/
void NetworkServerMonthlyLoop();
void NetworkServerYearlyLoop();
-void NetworkServerChangeOwner(PlayerID current_player, PlayerID new_player);
+void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
void NetworkServerShowStatusToConsole();
bool NetworkServerStart();
NetworkClientInfo *NetworkFindClientInfoFromIndex(uint16 client_index);
NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
-const char* GetPlayerIP(const NetworkClientInfo *ci);
+const char* GetClientIP(const NetworkClientInfo *ci);
void NetworkServerSendRcon(uint16 client_index, ConsoleColour colour_code, const char *string);
void NetworkServerSendError(uint16 client_index, NetworkErrorCode error);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 2340bbd0b..3cc9e17b8 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -87,7 +87,7 @@ enum NetworkGameWindowWidgets {
NGWW_CONNECTION, ///< Label in from of connection droplist
NGWW_CONN_BTN, ///< 'Connection' droplist button
- NGWW_PLAYER, ///< Panel with editbox to set player name
+ NGWW_CLIENT, ///< Panel with editbox to set client name
NGWW_NAME, ///< 'Name' button
NGWW_CLIENTS, ///< 'Clients' button
@@ -286,7 +286,7 @@ protected:
public:
NetworkGameWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_NAME_LENGTH, desc)
{
- ttd_strlcpy(this->edit_str_buf, _settings_client.network.player_name, this->edit_str_size);
+ ttd_strlcpy(this->edit_str_buf, _settings_client.network.client_name, this->edit_str_size);
this->afilter = CS_ALPHANUMERAL;
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 120);
@@ -295,7 +295,7 @@ public:
this->vscroll.cap = 11;
this->resize.step_height = NET_PRC__SIZE_OF_ROW;
- this->field = NGWW_PLAYER;
+ this->field = NGWW_CLIENT;
this->server = NULL;
this->servers.SetListing(this->last_sorting);
@@ -339,10 +339,10 @@ public:
SetDParam(1, _lan_internet_types_dropdown[_settings_client.network.lan_internet]);
this->DrawWidgets();
- /* Edit box to set player name */
- this->DrawEditBox(NGWW_PLAYER);
+ /* Edit box to set client name */
+ this->DrawEditBox(NGWW_CLIENT);
- DrawString(this->widget[NGWW_PLAYER].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
+ DrawString(this->widget[NGWW_CLIENT].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
/* Sort based on widgets: name, clients, compatibility */
switch (this->servers.SortType()) {
@@ -446,8 +446,8 @@ public:
{
this->field = widget;
switch (widget) {
- case NGWW_PLAYER:
- ShowOnScreenKeyboard(this, NGWW_PLAYER, 0, 0);
+ case NGWW_CLIENT:
+ ShowOnScreenKeyboard(this, NGWW_CLIENT, 0, 0);
break;
case NGWW_CANCEL: // Cancel button
@@ -554,7 +554,7 @@ public:
virtual void OnMouseLoop()
{
- if (this->field == NGWW_PLAYER) this->HandleEditBox(NGWW_PLAYER);
+ if (this->field == NGWW_CLIENT) this->HandleEditBox(NGWW_CLIENT);
}
virtual void OnInvalidateData(int data)
@@ -567,7 +567,7 @@ public:
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
EventState state = ES_NOT_HANDLED;
- if (this->field != NGWW_PLAYER) {
+ if (this->field != NGWW_CLIENT) {
if (this->server != NULL) {
if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
NetworkGameListRemoveItem(this->server);
@@ -578,13 +578,13 @@ public:
return state;
}
- if (this->HandleEditBoxKey(NGWW_PLAYER, key, keycode, state) == 1) return state; // enter pressed
+ if (this->HandleEditBoxKey(NGWW_CLIENT, key, keycode, state) == 1) return state; // enter pressed
/* The name is only allowed when it starts with a letter! */
if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
- ttd_strlcpy(_settings_client.network.player_name, this->edit_str_buf, lengthof(_settings_client.network.player_name));
+ ttd_strlcpy(_settings_client.network.client_name, this->edit_str_buf, lengthof(_settings_client.network.client_name));
} else {
- ttd_strlcpy(_settings_client.network.player_name, "Player", lengthof(_settings_client.network.player_name));
+ ttd_strlcpy(_settings_client.network.client_name, "Player", lengthof(_settings_client.network.client_name));
}
return state;
}
@@ -670,7 +670,7 @@ static const Widget _network_game_window_widgets[] = {
{ WWT_TEXT, RESIZE_NONE, COLOUR_LIGHT_BLUE, 9, 85, 23, 35, STR_NETWORK_CONNECTION, STR_NULL}, // NGWW_CONNECTION
{ WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 90, 181, 22, 33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NGWW_CONN_BTN
-{ WWT_EDITBOX, RESIZE_LR, COLOUR_LIGHT_BLUE, 290, 440, 22, 33, STR_NETWORK_PLAYER_NAME_OSKTITLE, STR_NETWORK_ENTER_NAME_TIP}, // NGWW_PLAYER
+{ WWT_EDITBOX, RESIZE_LR, COLOUR_LIGHT_BLUE, 290, 440, 22, 33, STR_NETWORK_PLAYER_NAME_OSKTITLE, STR_NETWORK_ENTER_NAME_TIP}, // NGWW_CLIENT
/* LEFT SIDE */
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_WHITE, 10, 70, 42, 53, STR_NETWORK_GAME_NAME, STR_NETWORK_GAME_NAME_TIP}, // NGWW_NAME
@@ -864,7 +864,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
_settings_client.network.max_clients = Clamp(_settings_client.network.max_clients + widget - NSSW_CLIENTS_TXT, 2, MAX_CLIENTS);
break;
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU:
- _settings_client.network.max_companies = Clamp(_settings_client.network.max_companies + widget - NSSW_COMPANIES_TXT, 1, MAX_PLAYERS);
+ _settings_client.network.max_companies = Clamp(_settings_client.network.max_companies + widget - NSSW_COMPANIES_TXT, 1, MAX_COMPANIES);
break;
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU:
_settings_client.network.max_spectators = Clamp(_settings_client.network.max_spectators + widget - NSSW_SPECTATORS_TXT, 0, MAX_CLIENTS);
@@ -874,7 +874,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
_left_button_clicked = false;
break;
- case NSSW_CLIENTS_TXT: // Click on number of players
+ case NSSW_CLIENTS_TXT: // Click on number of clients
this->widget_id = NSSW_CLIENTS_TXT;
SetDParam(0, _settings_client.network.max_clients);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS, 3, 50, this, CS_NUMERAL, QSF_NONE);
@@ -977,7 +977,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
switch (this->widget_id) {
default: NOT_REACHED();
case NSSW_CLIENTS_TXT: _settings_client.network.max_clients = Clamp(value, 2, MAX_CLIENTS); break;
- case NSSW_COMPANIES_TXT: _settings_client.network.max_companies = Clamp(value, 1, MAX_PLAYERS); break;
+ case NSSW_COMPANIES_TXT: _settings_client.network.max_companies = Clamp(value, 1, MAX_COMPANIES); break;
case NSSW_SPECTATORS_TXT: _settings_client.network.max_spectators = Clamp(value, 0, MAX_CLIENTS); break;
}
}
@@ -1046,16 +1046,16 @@ static void ShowNetworkStartServerWindow()
new NetworkStartServerWindow(&_network_start_server_window_desc);
}
-static PlayerID NetworkLobbyFindCompanyIndex(byte pos)
+static CompanyID NetworkLobbyFindCompanyIndex(byte pos)
{
- /* Scroll through all _network_player_info and get the 'pos' item that is not empty */
- for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
- if (_network_player_info[i].company_name[0] != '\0') {
+ /* Scroll through all _network_company_info and get the 'pos' item that is not empty */
+ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
+ if (!StrEmpty(_network_company_info[i].company_name)) {
if (pos-- == 0) return i;
}
}
- return PLAYER_FIRST;
+ return COMPANY_FIRST;
}
/** Enum for NetworkLobbyWindow, referring to _network_lobby_window_widgets */
@@ -1071,11 +1071,11 @@ enum NetworkLobbyWindowWidgets {
};
struct NetworkLobbyWindow : public Window {
- PlayerID company; ///< Select company
+ CompanyID company; ///< Select company
NetworkGameList *server; ///< Selected server
NetworkLobbyWindow(const WindowDesc *desc, NetworkGameList *ngl) :
- Window(desc), company(INVALID_PLAYER), server(ngl)
+ Window(desc), company(INVALID_COMPANY), server(ngl)
{
this->vscroll.cap = 10;
@@ -1088,7 +1088,7 @@ struct NetworkLobbyWindow : public Window {
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos;
/* Join button is disabled when no company is selected */
- this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_PLAYER);
+ this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_COMPANY);
/* Cannot start new company if there are too many */
this->SetWidgetDisabledState(NLWW_NEW, gi->companies_on >= gi->companies_max);
/* Cannot spectate if there are too many spectators */
@@ -1107,11 +1107,11 @@ struct NetworkLobbyWindow : public Window {
GfxFillRect(11, y - 1, 154, y + 10, 10); // show highlighted item with a different colour
}
- DoDrawStringTruncated(_network_player_info[company].company_name, 13, y, TC_BLACK, 135 - 13);
- if (_network_player_info[company].use_password != 0) DrawSprite(SPR_LOCK, PAL_NONE, 135, y);
+ DoDrawStringTruncated(_network_company_info[company].company_name, 13, y, TC_BLACK, 135 - 13);
+ if (_network_company_info[company].use_password != 0) DrawSprite(SPR_LOCK, PAL_NONE, 135, y);
/* If the company's income was positive puts a green dot else a red dot */
- if (_network_player_info[company].income >= 0) income = true;
+ if (_network_company_info[company].income >= 0) income = true;
DrawSprite(SPR_BLOT, income ? PALETTE_TO_GREEN : PALETTE_TO_RED, 145, y);
pos++;
@@ -1122,7 +1122,7 @@ struct NetworkLobbyWindow : public Window {
/* Draw info about selected company when it is selected in the left window */
GfxFillRect(174, 39, 403, 75, 157);
DrawStringCentered(290, 50, STR_NETWORK_COMPANY_INFO, TC_FROMSTRING);
- if (this->company != INVALID_PLAYER) {
+ if (this->company != INVALID_COMPANY) {
const uint x = 183;
const uint trunc_width = this->widget[NLWW_DETAILS].right - x;
y = 80;
@@ -1134,47 +1134,47 @@ struct NetworkLobbyWindow : public Window {
DrawString(x, y, STR_NETWORK_CLIENTS, TC_GOLD);
y += 10;
- SetDParamStr(0, _network_player_info[this->company].company_name);
+ SetDParamStr(0, _network_company_info[this->company].company_name);
DrawStringTruncated(x, y, STR_NETWORK_COMPANY_NAME, TC_GOLD, trunc_width);
y += 10;
- SetDParam(0, _network_player_info[this->company].inaugurated_year);
+ SetDParam(0, _network_company_info[this->company].inaugurated_year);
DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, TC_GOLD); // inauguration year
y += 10;
- SetDParam(0, _network_player_info[this->company].company_value);
+ SetDParam(0, _network_company_info[this->company].company_value);
DrawString(x, y, STR_NETWORK_VALUE, TC_GOLD); // company value
y += 10;
- SetDParam(0, _network_player_info[this->company].money);
+ SetDParam(0, _network_company_info[this->company].money);
DrawString(x, y, STR_NETWORK_CURRENT_BALANCE, TC_GOLD); // current balance
y += 10;
- SetDParam(0, _network_player_info[this->company].income);
+ SetDParam(0, _network_company_info[this->company].income);
DrawString(x, y, STR_NETWORK_LAST_YEARS_INCOME, TC_GOLD); // last year's income
y += 10;
- SetDParam(0, _network_player_info[this->company].performance);
+ SetDParam(0, _network_company_info[this->company].performance);
DrawString(x, y, STR_NETWORK_PERFORMANCE, TC_GOLD); // performance
y += 10;
- SetDParam(0, _network_player_info[this->company].num_vehicle[0]);
- SetDParam(1, _network_player_info[this->company].num_vehicle[1]);
- SetDParam(2, _network_player_info[this->company].num_vehicle[2]);
- SetDParam(3, _network_player_info[this->company].num_vehicle[3]);
- SetDParam(4, _network_player_info[this->company].num_vehicle[4]);
+ SetDParam(0, _network_company_info[this->company].num_vehicle[0]);
+ SetDParam(1, _network_company_info[this->company].num_vehicle[1]);
+ SetDParam(2, _network_company_info[this->company].num_vehicle[2]);
+ SetDParam(3, _network_company_info[this->company].num_vehicle[3]);
+ SetDParam(4, _network_company_info[this->company].num_vehicle[4]);
DrawString(x, y, STR_NETWORK_VEHICLES, TC_GOLD); // vehicles
y += 10;
- SetDParam(0, _network_player_info[this->company].num_station[0]);
- SetDParam(1, _network_player_info[this->company].num_station[1]);
- SetDParam(2, _network_player_info[this->company].num_station[2]);
- SetDParam(3, _network_player_info[this->company].num_station[3]);
- SetDParam(4, _network_player_info[this->company].num_station[4]);
+ SetDParam(0, _network_company_info[this->company].num_station[0]);
+ SetDParam(1, _network_company_info[this->company].num_station[1]);
+ SetDParam(2, _network_company_info[this->company].num_station[2]);
+ SetDParam(3, _network_company_info[this->company].num_station[3]);
+ SetDParam(4, _network_company_info[this->company].num_station[4]);
DrawString(x, y, STR_NETWORK_STATIONS, TC_GOLD); // stations
y += 10;
- SetDParamStr(0, _network_player_info[this->company].players);
+ SetDParamStr(0, _network_company_info[this->company].clients);
DrawStringTruncated(x, y, STR_NETWORK_PLAYERS, TC_GOLD, trunc_width); // players
}
}
@@ -1193,7 +1193,7 @@ struct NetworkLobbyWindow : public Window {
if (id_v >= this->vscroll.cap) break;
id_v += this->vscroll.pos;
- this->company = (id_v >= this->server->info.companies_on) ? INVALID_PLAYER : NetworkLobbyFindCompanyIndex(id_v);
+ this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
this->SetDirty();
} break;
@@ -1204,12 +1204,12 @@ struct NetworkLobbyWindow : public Window {
break;
case NLWW_NEW: // New company
- _network_playas = PLAYER_NEW_COMPANY;
+ _network_playas = COMPANY_NEW_COMPANY;
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
break;
case NLWW_SPECTATE: // Spectate game
- _network_playas = PLAYER_SPECTATOR;
+ _network_playas = COMPANY_SPECTATOR;
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
break;
@@ -1240,7 +1240,7 @@ static const Widget _network_lobby_window_widgets[] = {
{ WWT_MATRIX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 10, 155, 50, 190, (10 << 8) + 1, STR_NETWORK_COMPANY_LIST_TIP}, // NLWW_MATRIX
{ WWT_SCROLLBAR, RESIZE_NONE, COLOUR_LIGHT_BLUE, 156, 167, 38, 190, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-/* company/player info */
+/* company info */
{ WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 173, 404, 38, 190, 0x0, STR_NULL}, // NLWW_DETAILS
/* buttons */
@@ -1276,7 +1276,7 @@ static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
// and also makes able to give money to them, kick them (if server)
// and stuff like that.
-extern void DrawPlayerIcon(PlayerID pid, int x, int y);
+extern void DrawCompanyIcon(CompanyID cid, int x, int y);
// Every action must be of this form
typedef void ClientList_Action_Proc(byte client_no);
@@ -1326,7 +1326,7 @@ static const NetworkClientInfo *NetworkFindClientInfo(byte client_no)
// Here we start to define the options out of the menu
static void ClientList_Kick(byte client_no)
{
- if (client_no < MAX_PLAYERS)
+ if (client_no < MAX_COMPANIES)
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
}
@@ -1341,7 +1341,7 @@ static void ClientList_Ban(byte client_no)
}
}
- if (client_no < MAX_PLAYERS) {
+ if (client_no < MAX_COMPANIES) {
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
}
}
@@ -1402,7 +1402,7 @@ struct NetworkClientListPopupWindow : Window {
this->proc[i++] = &ClientList_SpeakToClient;
}
- if (IsValidPlayerID(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
+ if (IsValidCompanyID(ci->client_playas) || ci->client_playas == COMPANY_SPECTATOR) {
GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(this->action[i]));
this->proc[i++] = &ClientList_SpeakToCompany;
}
@@ -1410,8 +1410,8 @@ struct NetworkClientListPopupWindow : Window {
this->proc[i++] = &ClientList_SpeakToAll;
if (_network_own_client_index != ci->client_index) {
- /* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */
- if (IsValidPlayerID(_network_playas) && IsValidPlayerID(ci->client_playas) && _settings_game.economy.give_money) {
+ /* We are no spectator and the company we want to give money to is no spectator and money gifts are allowed */
+ if (IsValidCompanyID(_network_playas) && IsValidCompanyID(ci->client_playas) && _settings_game.economy.give_money) {
GetString(this->action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY, lastof(this->action[i]));
this->proc[i++] = &ClientList_GiveMoney;
}
@@ -1600,7 +1600,7 @@ struct NetworkClientListWindow : Window
}
/* Filter out spectators */
- if (IsValidPlayerID(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
+ if (IsValidCompanyID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, 64, y + 1);
DoDrawString(ci->client_name, 81, y, colour);
diff --git a/src/network/network_gui.h b/src/network/network_gui.h
index 77276a8fb..d0a5b4996 100644
--- a/src/network/network_gui.h
+++ b/src/network/network_gui.h
@@ -11,7 +11,7 @@
#include "network_type.h"
void ShowNetworkNeedPassword(NetworkPasswordType npt);
-void ShowNetworkGiveMoneyWindow(PlayerID player); // PlayerID
+void ShowNetworkGiveMoneyWindow(CompanyID company);
void ShowNetworkChatQueryWindow(DestType type, int dest);
void ShowJoinStatusWindow();
void ShowNetworkGameWindow();
diff --git a/src/network/network_internal.h b/src/network/network_internal.h
index 42c7f66be..37354cb5e 100644
--- a/src/network/network_internal.h
+++ b/src/network/network_internal.h
@@ -91,7 +91,7 @@ enum NetworkLanguage {
NETLANG_COUNT
};
-extern NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
+extern NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
extern uint32 _frame_counter_max; // To where we may go with our clients
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index d1e1614f6..e99ef8bc1 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -47,7 +47,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CLIENT_INFO)(NetworkTCPSocketHandler
// Function: Sends info about a client
// Data:
// uint16: The index of the client (always unique on a server. 1 = server)
- // uint8: As which player the client is playing
+ // uint8: As which company the client is playing
// String: The name of the client
//
@@ -71,10 +71,10 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
int i;
- Player *player;
+ Company *company;
Packet *p;
- byte active = ActivePlayerCount();
+ byte active = ActiveCompanyCount();
if (active == 0) {
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
@@ -88,35 +88,35 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
NetworkPopulateCompanyInfo();
- FOR_ALL_PLAYERS(player) {
+ FOR_ALL_COMPANIES(company) {
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
p->Send_uint8 (active);
- p->Send_uint8 (player->index);
+ p->Send_uint8 (company->index);
- p->Send_string(_network_player_info[player->index].company_name);
- p->Send_uint32(_network_player_info[player->index].inaugurated_year);
- p->Send_uint64(_network_player_info[player->index].company_value);
- p->Send_uint64(_network_player_info[player->index].money);
- p->Send_uint64(_network_player_info[player->index].income);
- p->Send_uint16(_network_player_info[player->index].performance);
+ p->Send_string(_network_company_info[company->index].company_name);
+ p->Send_uint32(_network_company_info[company->index].inaugurated_year);
+ p->Send_uint64(_network_company_info[company->index].company_value);
+ p->Send_uint64(_network_company_info[company->index].money);
+ p->Send_uint64(_network_company_info[company->index].income);
+ p->Send_uint16(_network_company_info[company->index].performance);
/* Send 1 if there is a passord for the company else send 0 */
- p->Send_bool(!StrEmpty(_network_player_info[player->index].password));
+ p->Send_bool(!StrEmpty(_network_company_info[company->index].password));
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
- p->Send_uint16(_network_player_info[player->index].num_vehicle[i]);
+ p->Send_uint16(_network_company_info[company->index].num_vehicle[i]);
}
for (i = 0; i < NETWORK_STATION_TYPES; i++) {
- p->Send_uint16(_network_player_info[player->index].num_station[i]);
+ p->Send_uint16(_network_company_info[company->index].num_station[i]);
}
- if (_network_player_info[player->index].players[0] == '\0') {
+ if (StrEmpty(_network_company_info[company->index].clients)) {
p->Send_string("<none>");
} else {
- p->Send_string(_network_player_info[player->index].players);
+ p->Send_string(_network_company_info[company->index].clients);
}
cs->Send_Packet(p);
@@ -276,7 +276,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
NetworkTCPSocketHandler *new_cs;
Packet *p;
- // Count how many players are waiting in the queue
+ // Count how many clients are waiting in the queue
FOR_ALL_CLIENTS(new_cs) {
if (new_cs->status == STATUS_MAP_WAIT) waiting++;
}
@@ -300,9 +300,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
// if MAP_PACKET_NORMAL:
// piece of the map (till max-size of packet)
// if MAP_PACKET_END:
- // uint32: seed0 of player
- // uint32: seed1 of player
- // last 2 are repeated MAX_PLAYERS time
+ // nothing
//
static FILE *file_pointer;
@@ -476,7 +474,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkTCPSocketHandler *cs
// Packet: SERVER_COMMAND
// Function: Sends a DoCommand to the client
// Data:
- // uint8: PlayerID (0..MAX_PLAYERS-1)
+ // uint8: CompanyID (0..MAX_COMPANIES-1)
// uint32: CommandID (see command.h)
// uint32: P1 (free variables used in DoCommand)
// uint32: P2
@@ -488,7 +486,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkTCPSocketHandler *cs
Packet *p = NetworkSend_Init(PACKET_SERVER_COMMAND);
- p->Send_uint8 (cp->player);
+ p->Send_uint8 (cp->company);
p->Send_uint32(cp->cmd);
p->Send_uint32(cp->p1);
p->Send_uint32(cp->p2);
@@ -619,7 +617,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)
if (!StrEmpty(_settings_client.network.server_password)) {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD);
} else {
- if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ if (IsValidCompanyID(ci->client_playas) && _network_company_info[ci->client_playas].password[0] != '\0') {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
} else {
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
@@ -638,7 +636,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
char name[NETWORK_CLIENT_NAME_LENGTH];
char unique_id[NETWORK_UNIQUE_ID_LENGTH];
NetworkClientInfo *ci;
- PlayerID playas;
+ CompanyID playas;
NetworkLanguage client_lang;
char client_revision[NETWORK_REVISION_LENGTH];
@@ -660,31 +658,31 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
// join another company does not affect these values
switch (playas) {
- case PLAYER_NEW_COMPANY: /* New company */
- if (ActivePlayerCount() >= _settings_client.network.max_companies) {
+ case COMPANY_NEW_COMPANY: /* New company */
+ if (ActiveCompanyCount() >= _settings_client.network.max_companies) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;
}
break;
- case PLAYER_SPECTATOR: /* Spectator */
+ case COMPANY_SPECTATOR: /* Spectator */
if (NetworkSpectatorCount() >= _settings_client.network.max_spectators) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;
}
break;
default: /* Join another company (companies 1-8 (index 0-7)) */
- if (!IsValidPlayerID(playas)) {
- SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
+ if (!IsValidCompanyID(playas)) {
+ SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_COMPANY_MISMATCH);
return;
}
break;
}
// We need a valid name.. make it Player
- if (*name == '\0') ttd_strlcpy(name, "Player", sizeof(name));
+ if (StrEmpty(name)) ttd_strlcpy(name, "Player", sizeof(name));
if (!NetworkFindName(name)) { // Change name if duplicate
- // We could not create a name for this player
+ // We could not create a name for this client
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NAME_IN_USE);
return;
}
@@ -697,7 +695,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
ci->client_lang = client_lang;
/* Make sure companies to which people try to join are not autocleaned */
- if (IsValidPlayerID(playas)) _network_player_info[playas].months_empty = 0;
+ if (IsValidCompanyID(playas)) _network_company_info[playas].months_empty = 0;
if (_grfconfig == NULL) {
RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)(cs, NULL);
@@ -725,7 +723,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ if (IsValidCompanyID(ci->client_playas) && _network_company_info[ci->client_playas].password[0] != '\0') {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
return;
}
@@ -736,7 +734,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
} else if (cs->status == STATUS_AUTHORIZING && type == NETWORK_COMPANY_PASSWORD) {
ci = DEREF_CLIENT_INFO(cs);
- if (strcmp(password, _network_player_info[ci->client_playas].password) != 0) {
+ if (strcmp(password, _network_company_info[ci->client_playas].password) != 0) {
// Password is invalid
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
return;
@@ -828,17 +826,17 @@ static bool CheckCommandFlags(const CommandPacket *cp, const NetworkClientInfo *
byte flags = GetCommandFlags(cp->cmd);
if (flags & CMD_SERVER && ci->client_index != NETWORK_SERVER_INDEX) {
- IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_index, GetClientIP(ci));
return false;
}
if (flags & CMD_OFFLINE) {
- IConsolePrintF(CC_ERROR, "WARNING: offline only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: offline only command from client %d (IP: %s), kicking...", ci->client_index, GetClientIP(ci));
return false;
}
- if (cp->cmd != CMD_PLAYER_CTRL && !IsValidPlayerID(cp->player) && ci->client_index != NETWORK_SERVER_INDEX) {
- IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ if (cp->cmd != CMD_COMPANY_CTRL && !IsValidCompanyID(cp->company) && ci->client_index != NETWORK_SERVER_INDEX) {
+ IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetClientIP(ci));
return false;
}
@@ -863,11 +861,11 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
}
CommandPacket *cp = MallocT<CommandPacket>(1);
- cp->player = (Owner)p->Recv_uint8();
- cp->cmd = p->Recv_uint32();
- cp->p1 = p->Recv_uint32();
- cp->p2 = p->Recv_uint32();
- cp->tile = p->Recv_uint32();
+ cp->company = (CompanyID)p->Recv_uint8();
+ cp->cmd = p->Recv_uint32();
+ cp->p1 = p->Recv_uint32();
+ cp->p2 = p->Recv_uint32();
+ cp->tile = p->Recv_uint32();
p->Recv_string(cp->text, lengthof(cp->text));
callback = p->Recv_uint8();
@@ -881,7 +879,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
/* Check if cp->cmd is valid */
if (!IsValidCommand(cp->cmd)) {
- IConsolePrintF(CC_ERROR, "WARNING: invalid command from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: invalid command from client %d (IP: %s).", ci->client_index, GetClientIP(ci));
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
free(cp);
return;
@@ -893,35 +891,35 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
return;
}
- /** Only CMD_PLAYER_CTRL is always allowed, for the rest, playas needs
- * to match the player in the packet. If it doesn't, the client has done
+ /** Only CMD_COMPANY_CTRL is always allowed, for the rest, playas needs
+ * to match the company in the packet. If it doesn't, the client has done
* something pretty naughty (or a bug), and will be kicked
*/
- if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0 && ci->client_playas == PLAYER_NEW_COMPANY) && ci->client_playas != cp->player) {
- IConsolePrintF(CC_ERROR, "WARNING: player %d (IP: %s) tried to execute a command as player %d, kicking...",
- ci->client_playas + 1, GetPlayerIP(ci), cp->player + 1);
- SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
+ if (!(cp->cmd == CMD_COMPANY_CTRL && cp->p1 == 0 && ci->client_playas == COMPANY_NEW_COMPANY) && ci->client_playas != cp->company) {
+ IConsolePrintF(CC_ERROR, "WARNING: client %d (IP: %s) tried to execute a command as company %d, kicking...",
+ ci->client_playas + 1, GetClientIP(ci), cp->company + 1);
+ SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_COMPANY_MISMATCH);
free(cp);
return;
}
- /** @todo CMD_PLAYER_CTRL with p1 = 0 announces a new player to the server. To give the
- * player the correct ID, the server injects p2 and executes the command. Any other p1
+ /** @todo CMD_COMPANY_CTRL with p1 = 0 announces a new company to the server. To give the
+ * company the correct ID, the server injects p2 and executes the command. Any other p1
* is prohibited. Pretty ugly and should be redone together with its function.
- * @see CmdPlayerCtrl() players.c:655
+ * @see CmdCompanyCtrl()
*/
- if (cp->cmd == CMD_PLAYER_CTRL) {
+ if (cp->cmd == CMD_COMPANY_CTRL) {
if (cp->p1 != 0) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_CHEATER);
free(cp);
return;
}
- /* XXX - Execute the command as a valid player. Normally this would be done by a
+ /* XXX - Execute the command as a valid company. Normally this would be done by a
* spectator, but that is not allowed any commands. So do an impersonation. The drawback
* of this is that the first company's last_built_tile is also updated... */
- cp->player = OWNER_BEGIN;
- cp->p2 = cs - _clients; // XXX - UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl
+ cp->company = OWNER_BEGIN;
+ cp->p2 = cs - _clients; // XXX - UGLY! p2 is mis-used to get the client-id in CmdCompanyCtrl
}
// The frame can be executed in the same frame as the next frame-packet
@@ -1038,7 +1036,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (client connected)", NETWORK_SERVER_INDEX);
}
- CheckMinPlayers();
+ CheckMinActiveClients();
/* Execute script for, e.g. MOTD */
IConsoleCmdExec("exec scripts/on_server_connect.scr 0");
@@ -1064,7 +1062,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkFindClientInfoFromIndex(from_index);
/* Display the text locally, and that is it */
if (ci != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), false, ci->client_name, "%s", msg);
} else {
/* Else find the client to send the message to */
FOR_ALL_CLIENTS(cs) {
@@ -1081,7 +1079,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkFindClientInfoFromIndex(from_index);
ci_to = NetworkFindClientInfoFromIndex(dest);
if (ci != NULL && ci_to != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), true, ci_to->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), true, ci_to->client_name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {
if (cs->index == from_index) {
@@ -1095,7 +1093,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
case DESTTYPE_TEAM: {
bool show_local = true; // If this is false, the message is already displayed
// on the client who did sent it.
- /* Find all clients that belong to this player */
+ /* Find all clients that belong to this company */
ci_to = NULL;
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
@@ -1109,22 +1107,22 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkFindClientInfoFromIndex(from_index);
ci_own = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), false, ci->client_name, "%s", msg);
if (from_index == NETWORK_SERVER_INDEX) show_local = false;
ci_to = ci_own;
}
- /* There is no such player */
+ /* There is no such client */
if (ci_to == NULL) break;
// Display the message locally (so you know you have sent it)
if (ci != NULL && show_local) {
if (from_index == NETWORK_SERVER_INDEX) {
char name[NETWORK_NAME_LENGTH];
- StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
+ StringID str = IsValidCompanyID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
GetString(name, str, lastof(name));
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci_own->client_playas), true, name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci_own->client_playas), true, name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {
if (cs->index == from_index) {
@@ -1144,7 +1142,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
}
ci = NetworkFindClientInfoFromIndex(from_index);
if (ci != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), false, ci->client_name, "%s", msg);
break;
}
}
@@ -1167,7 +1165,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT)
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
switch (action) {
case NETWORK_ACTION_GIVE_MONEY:
- if (!IsValidPlayerID(ci->client_playas)) break;
+ if (!IsValidCompanyID(ci->client_playas)) break;
/* Fall-through */
case NETWORK_ACTION_CHAT:
case NETWORK_ACTION_CHAT_CLIENT:
@@ -1175,7 +1173,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT)
NetworkServerSendChat(action, desttype, dest, msg, cs->index);
break;
default:
- IConsolePrintF(CC_ERROR, "WARNING: invalid chat action from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: invalid chat action from client %d (IP: %s).", ci->client_index, GetClientIP(ci));
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
break;
}
@@ -1195,8 +1193,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD)
p->Recv_string(password, sizeof(password));
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas)) {
- ttd_strlcpy(_network_player_info[ci->client_playas].password, password, sizeof(_network_player_info[0].password));
+ if (IsValidCompanyID(ci->client_playas)) {
+ ttd_strlcpy(_network_company_info[ci->client_playas].password, password, sizeof(_network_company_info[0].password));
}
}
@@ -1301,7 +1299,7 @@ assert_compile(lengthof(_network_server_packet) == PACKET_END);
void NetworkPopulateCompanyInfo()
{
char password[NETWORK_PASSWORD_LENGTH];
- const Player *p;
+ const Company *c;
const Vehicle *v;
const Station *s;
NetworkTCPSocketHandler *cs;
@@ -1309,44 +1307,44 @@ void NetworkPopulateCompanyInfo()
uint i;
uint16 months_empty;
- for (PlayerID pid = PLAYER_FIRST; pid < MAX_PLAYERS; pid++) {
- if (!IsValidPlayerID(pid)) memset(&_network_player_info[pid], 0, sizeof(NetworkPlayerInfo));
+ for (CompanyID cid = COMPANY_FIRST; cid < MAX_COMPANIES; cid++) {
+ if (!IsValidCompanyID(cid)) memset(&_network_company_info[cid], 0, sizeof(NetworkCompanyInfo));
}
- FOR_ALL_PLAYERS(p) {
+ FOR_ALL_COMPANIES(c) {
// 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;
- memset(&_network_player_info[p->index], 0, sizeof(NetworkPlayerInfo));
- _network_player_info[p->index].months_empty = months_empty;
- ttd_strlcpy(_network_player_info[p->index].password, password, sizeof(_network_player_info[p->index].password));
+ ttd_strlcpy(password, _network_company_info[c->index].password, sizeof(password));
+ months_empty = _network_company_info[c->index].months_empty;
+ memset(&_network_company_info[c->index], 0, sizeof(NetworkCompanyInfo));
+ _network_company_info[c->index].months_empty = months_empty;
+ ttd_strlcpy(_network_company_info[c->index].password, password, sizeof(_network_company_info[c->index].password));
// Grap the company name
- SetDParam(0, p->index);
- GetString(_network_player_info[p->index].company_name, STR_COMPANY_NAME, lastof(_network_player_info[p->index].company_name));
+ SetDParam(0, c->index);
+ GetString(_network_company_info[c->index].company_name, STR_COMPANY_NAME, lastof(_network_company_info[c->index].company_name));
// Check the income
- if (_cur_year - 1 == p->inaugurated_year) {
- // The player is here just 1 year, so display [2], else display[1]
- for (i = 0; i < lengthof(p->yearly_expenses[2]); i++) {
- _network_player_info[p->index].income -= p->yearly_expenses[2][i];
+ if (_cur_year - 1 == c->inaugurated_year) {
+ // The company is here just 1 year, so display [2], else display[1]
+ for (i = 0; i < lengthof(c->yearly_expenses[2]); i++) {
+ _network_company_info[c->index].income -= c->yearly_expenses[2][i];
}
} else {
- for (i = 0; i < lengthof(p->yearly_expenses[1]); i++) {
- _network_player_info[p->index].income -= p->yearly_expenses[1][i];
+ for (i = 0; i < lengthof(c->yearly_expenses[1]); i++) {
+ _network_company_info[c->index].income -= c->yearly_expenses[1][i];
}
}
// Set some general stuff
- _network_player_info[p->index].inaugurated_year = p->inaugurated_year;
- _network_player_info[p->index].company_value = p->old_economy[0].company_value;
- _network_player_info[p->index].money = p->player_money;
- _network_player_info[p->index].performance = p->old_economy[0].performance_history;
+ _network_company_info[c->index].inaugurated_year = c->inaugurated_year;
+ _network_company_info[c->index].company_value = c->old_economy[0].company_value;
+ _network_company_info[c->index].money = c->money;
+ _network_company_info[c->index].performance = c->old_economy[0].performance_history;
}
// Go through all vehicles and count the type of vehicles
FOR_ALL_VEHICLES(v) {
- if (!IsValidPlayerID(v->owner) || !v->IsPrimaryVehicle()) continue;
+ if (!IsValidCompanyID(v->owner) || !v->IsPrimaryVehicle()) continue;
byte type = 0;
switch (v->type) {
case VEH_TRAIN: type = 0; break;
@@ -1355,13 +1353,13 @@ void NetworkPopulateCompanyInfo()
case VEH_SHIP: type = 4; break;
default: continue;
}
- _network_player_info[v->owner].num_vehicle[type]++;
+ _network_company_info[v->owner].num_vehicle[type]++;
}
// Go through all stations and count the types of stations
FOR_ALL_STATIONS(s) {
- if (IsValidPlayerID(s->owner)) {
- NetworkPlayerInfo *npi = &_network_player_info[s->owner];
+ if (IsValidCompanyID(s->owner)) {
+ NetworkCompanyInfo *npi = &_network_company_info[s->owner];
if (s->facilities & FACIL_TRAIN) npi->num_station[0]++;
if (s->facilities & FACIL_TRUCK_STOP) npi->num_station[1]++;
@@ -1372,9 +1370,9 @@ void NetworkPopulateCompanyInfo()
}
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- // Register local player (if not dedicated)
- if (ci != NULL && IsValidPlayerID(ci->client_playas))
- ttd_strlcpy(_network_player_info[ci->client_playas].players, ci->client_name, sizeof(_network_player_info[0].players));
+ // Register local company (if not dedicated)
+ if (ci != NULL && IsValidCompanyID(ci->client_playas))
+ ttd_strlcpy(_network_company_info[ci->client_playas].clients, ci->client_name, sizeof(_network_company_info[0].clients));
FOR_ALL_CLIENTS(cs) {
char client_name[NETWORK_CLIENT_NAME_LENGTH];
@@ -1382,12 +1380,12 @@ void NetworkPopulateCompanyInfo()
NetworkGetClientName(client_name, sizeof(client_name), cs);
ci = DEREF_CLIENT_INFO(cs);
- if (ci != NULL && IsValidPlayerID(ci->client_playas)) {
- if (!StrEmpty(_network_player_info[ci->client_playas].players)) {
- ttd_strlcat(_network_player_info[ci->client_playas].players, ", ", lengthof(_network_player_info[0].players));
+ if (ci != NULL && IsValidCompanyID(ci->client_playas)) {
+ if (!StrEmpty(_network_company_info[ci->client_playas].clients)) {
+ ttd_strlcat(_network_company_info[ci->client_playas].clients, ", ", lengthof(_network_company_info[0].clients));
}
- ttd_strlcat(_network_player_info[ci->client_playas].players, client_name, lengthof(_network_player_info[0].players));
+ ttd_strlcat(_network_company_info[ci->client_playas].clients, client_name, lengthof(_network_company_info[0].clients));
}
}
}
@@ -1424,8 +1422,8 @@ static void NetworkAutoCleanCompanies()
{
NetworkTCPSocketHandler *cs;
const NetworkClientInfo *ci;
- const Player *p;
- bool clients_in_company[MAX_PLAYERS];
+ const Company *c;
+ bool clients_in_company[MAX_COMPANIES];
if (!_settings_client.network.autoclean_companies) return;
@@ -1434,39 +1432,39 @@ static void NetworkAutoCleanCompanies()
/* Detect the active companies */
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
+ if (IsValidCompanyID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
}
if (!_network_dedicated) {
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
+ if (IsValidCompanyID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
}
/* Go through all the comapnies */
- FOR_ALL_PLAYERS(p) {
+ FOR_ALL_COMPANIES(c) {
/* Skip the non-active once */
- if (p->is_ai) continue;
+ if (c->is_ai) continue;
- if (!clients_in_company[p->index]) {
+ if (!clients_in_company[c->index]) {
/* The company is empty for one month more */
- _network_player_info[p->index].months_empty++;
+ _network_company_info[c->index].months_empty++;
/* Is the company empty for autoclean_unprotected-months, and is there no protection? */
- if (_settings_client.network.autoclean_unprotected != 0 && _network_player_info[p->index].months_empty > _settings_client.network.autoclean_unprotected && _network_player_info[p->index].password[0] == '\0') {
+ if (_settings_client.network.autoclean_unprotected != 0 && _network_company_info[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_info[c->index].password)) {
/* Shut the company down */
- DoCommandP(0, 2, p->index, NULL, CMD_PLAYER_CTRL);
- IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", p->index + 1);
+ DoCommandP(0, 2, c->index, NULL, CMD_COMPANY_CTRL);
+ IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", c->index + 1);
}
- /* Is the compnay empty for autoclean_protected-months, and there is a protection? */
- if (_settings_client.network.autoclean_protected != 0 && _network_player_info[p->index].months_empty > _settings_client.network.autoclean_protected && _network_player_info[p->index].password[0] != '\0') {
+ /* Is the company empty for autoclean_protected-months, and there is a protection? */
+ if (_settings_client.network.autoclean_protected != 0 && _network_company_info[c->index].months_empty > _settings_client.network.autoclean_protected && !StrEmpty(_network_company_info[c->index].password)) {
/* Unprotect the company */
- _network_player_info[p->index].password[0] = '\0';
- IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", p->index+1);
- _network_player_info[p->index].months_empty = 0;
+ _network_company_info[c->index].password[0] = '\0';
+ IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", c->index + 1);
+ _network_company_info[c->index].months_empty = 0;
}
} else {
/* It is not empty, reset the date */
- _network_player_info[p->index].months_empty = 0;
+ _network_company_info[c->index].months_empty = 0;
}
}
}
@@ -1625,30 +1623,30 @@ void NetworkServerMonthlyLoop()
NetworkAutoCleanCompanies();
}
-void NetworkServerChangeOwner(PlayerID current_player, PlayerID new_player)
+void NetworkServerChangeOwner(Owner current_owner, Owner new_owner)
{
/* The server has to handle all administrative issues, for example
* updating and notifying all clients of what has happened */
NetworkTCPSocketHandler *cs;
NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- /* The server has just changed from player */
- if (current_player == ci->client_playas) {
- ci->client_playas = new_player;
+ /* The server has just changed from owner */
+ if (current_owner == ci->client_playas) {
+ ci->client_playas = new_owner;
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
- /* Find all clients that were in control of this company, and mark them as new_player */
+ /* Find all clients that were in control of this company, and mark them as new_owner */
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
- if (current_player == ci->client_playas) {
- ci->client_playas = new_player;
+ if (current_owner == ci->client_playas) {
+ ci->client_playas = new_owner;
NetworkUpdateClientInfo(ci->client_index);
}
}
}
-const char* GetPlayerIP(const NetworkClientInfo* ci)
+const char* GetClientIP(const NetworkClientInfo* ci)
{
struct in_addr addr;
@@ -1678,8 +1676,8 @@ void NetworkServerShowStatusToConsole()
status = (cs->status < (ptrdiff_t)lengthof(stat_str) ? stat_str[cs->status] : "unknown");
IConsolePrintF(CC_INFO, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
cs->index, ci->client_name, status, lag,
- ci->client_playas + (IsValidPlayerID(ci->client_playas) ? 1 : 0),
- GetPlayerIP(ci), ci->unique_id);
+ ci->client_playas + (IsValidCompanyID(ci->client_playas) ? 1 : 0),
+ GetClientIP(ci), ci->unique_id);
}
}
@@ -1693,7 +1691,7 @@ void NetworkServerSendError(uint16 client_index, NetworkErrorCode error)
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(client_index), error);
}
-bool NetworkCompanyHasPlayers(PlayerID company)
+bool NetworkCompanyHasClients(CompanyID company)
{
const NetworkTCPSocketHandler *cs;
const NetworkClientInfo *ci;
diff --git a/src/network/network_type.h b/src/network/network_type.h
index 880a8ffae..b0258a37a 100644
--- a/src/network/network_type.h
+++ b/src/network/network_type.h
@@ -14,11 +14,11 @@
enum {
/**
- * How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of
- * players that can really play.. so.. a max of 4 spectators.. gives us..
- * MAX_PLAYERS + 3
+ * How many clients can we have? Like.. MAX_COMPANIES is the amount of
+ * companies that can really play.. so.. a max of 3 spectators.. gives us..
+ * MAX_COMPANIES + 3
*/
- MAX_CLIENTS = MAX_PLAYERS + 3,
+ MAX_CLIENTS = MAX_COMPANIES + 3,
/** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */
MAX_CLIENT_INFO = MAX_CLIENTS + 1,
@@ -34,9 +34,9 @@ enum {
NETWORK_EMPTY_INDEX = 0,
};
-struct NetworkPlayerInfo {
+struct NetworkCompanyInfo {
char company_name[NETWORK_COMPANY_NAME_LENGTH]; ///< Company name
- char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the player
+ char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the company
Year inaugurated_year; ///< What year the company started in
Money company_value; ///< The company value
Money money; ///< The amount of money the company has
@@ -45,7 +45,7 @@ struct NetworkPlayerInfo {
bool use_password; ///< Is there a password
uint16 num_vehicle[NETWORK_VEHICLE_TYPES]; ///< How many vehicles are there of this type?
uint16 num_station[NETWORK_STATION_TYPES]; ///< How many stations are there of this type?
- char players[NETWORK_PLAYERS_LENGTH]; ///< The players that control this company (Name1, name2, ..)
+ char clients[NETWORK_CLIENTS_LENGTH]; ///< The clients that control this company (Name1, name2, ..)
uint16 months_empty; ///< How many months the company is empty
};
@@ -53,9 +53,9 @@ struct NetworkClientInfo {
uint16 client_index; ///< Index of the client (same as ClientState->index)
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client
byte client_lang; ///< The language of the client
- PlayerID client_playas; ///< As which player is this client playing (PlayerID)
+ CompanyID client_playas; ///< As which company is this client playing (CompanyID)
uint32 client_ip; ///< IP-address of the client (so he can be banned)
- Date join_date; ///< Gamedate the player has joined
+ Date join_date; ///< Gamedate the client has joined
char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him
};
@@ -65,9 +65,9 @@ enum NetworkPasswordType {
};
enum DestType {
- DESTTYPE_BROADCAST, ///< Send message/notice to all players (All)
+ DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team)
- DESTTYPE_CLIENT, ///< Send message/notice to only a certain player (Private)
+ DESTTYPE_CLIENT, ///< Send message/notice to only a certain client (Private)
};
/** Actions that can be used for NetworkTextMessage */
@@ -98,7 +98,7 @@ enum NetworkErrorCode {
NETWORK_ERROR_WRONG_REVISION,
NETWORK_ERROR_NAME_IN_USE,
NETWORK_ERROR_WRONG_PASSWORD,
- NETWORK_ERROR_PLAYER_MISMATCH, // Happens in CLIENT_COMMAND
+ NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
NETWORK_ERROR_KICKED,
NETWORK_ERROR_CHEATER,
NETWORK_ERROR_FULL,
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 7e27ecd4e..c2b0aba8c 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -83,7 +83,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
ngi.server_lang = _settings_client.network.server_lang;
ngi.use_password = !StrEmpty(_settings_client.network.server_password);
ngi.clients_max = _settings_client.network.max_clients;
- ngi.companies_on = ActivePlayerCount();
+ ngi.companies_on = ActiveCompanyCount();
ngi.companies_max = _settings_client.network.max_companies;
ngi.spectators_on = NetworkSpectatorCount();
ngi.spectators_max = _settings_client.network.max_spectators;
@@ -116,36 +116,36 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
/* Send the amount of active companies */
packet.Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
- packet.Send_uint8 (ActivePlayerCount());
+ packet.Send_uint8 (ActiveCompanyCount());
/* Fetch the latest version of everything */
NetworkPopulateCompanyInfo();
- Player *player;
+ Company *company;
byte current = 0;
- /* Go through all the players */
- FOR_ALL_PLAYERS(player) {
+ /* Go through all the companies */
+ FOR_ALL_COMPANIES(company) {
current++;
/* Send the information */
packet.Send_uint8 (current);
- packet.Send_string(_network_player_info[player->index].company_name);
- packet.Send_uint32(_network_player_info[player->index].inaugurated_year);
- packet.Send_uint64(_network_player_info[player->index].company_value);
- packet.Send_uint64(_network_player_info[player->index].money);
- packet.Send_uint64(_network_player_info[player->index].income);
- packet.Send_uint16(_network_player_info[player->index].performance);
+ packet.Send_string(_network_company_info[company->index].company_name);
+ packet.Send_uint32(_network_company_info[company->index].inaugurated_year);
+ packet.Send_uint64(_network_company_info[company->index].company_value);
+ packet.Send_uint64(_network_company_info[company->index].money);
+ packet.Send_uint64(_network_company_info[company->index].income);
+ packet.Send_uint16(_network_company_info[company->index].performance);
/* Send 1 if there is a passord for the company else send 0 */
- packet.Send_bool (!StrEmpty(_network_player_info[player->index].password));
+ packet.Send_bool (!StrEmpty(_network_company_info[company->index].password));
for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
- packet.Send_uint16(_network_player_info[player->index].num_vehicle[i]);
+ packet.Send_uint16(_network_company_info[company->index].num_vehicle[i]);
}
for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
- packet.Send_uint16(_network_player_info[player->index].num_station[i]);
+ packet.Send_uint16(_network_company_info[company->index].num_station[i]);
}
}