summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/company_cmd.cpp5
-rw-r--r--src/network/network.cpp6
-rw-r--r--src/network/network_base.h6
-rw-r--r--src/network/network_chat_gui.cpp10
-rw-r--r--src/network/network_type.h4
5 files changed, 15 insertions, 16 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 16c2610bf..8a36945a6 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -812,7 +812,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Has the network client a correct ClientIndex? */
if (!(flags & DC_EXEC)) return CommandCost();
- if (cid >= MAX_CLIENT_INFO) return CommandCost();
+ NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(cid);
+ if (ci != NULL) return CommandCost();
/* Delete multiplayer progress bar */
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
@@ -822,7 +823,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* A new company could not be created, revert to being a spectator */
if (c == NULL) {
if (_network_server) {
- NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(cid);
ci->client_playas = COMPANY_SPECTATOR;
NetworkUpdateClientInfo(ci->client_id);
} else if (_local_company == COMPANY_SPECTATOR) {
@@ -858,7 +858,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
* server-side in network_server.c:838, function
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
- NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(cid);
ci->client_playas = c->index;
NetworkUpdateClientInfo(ci->client_id);
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 58826e1e3..eed479a1e 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -50,7 +50,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;
-NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
+NetworkClientInfo _network_client_info[MAX_CLIENT_SLOTS];
NetworkCompanyState *_network_company_states = NULL;
ClientID _network_own_client_id;
ClientID _redirect_console_to_client;
@@ -827,9 +827,9 @@ static void NetworkInitGameInfo()
_network_game_info.clients_on = _network_dedicated ? 0 : 1;
_network_game_info.start_date = ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
- // We use _network_client_info[MAX_CLIENT_INFO - 1] to store the server-data in it
+ // We use _network_client_info[MAX_CLIENT_SLOTS - 1] to store the server-data in it
// The client identifier is CLIENT_ID_SERVER ( = 1)
- ci = &_network_client_info[MAX_CLIENT_INFO - 1];
+ ci = &_network_client_info[MAX_CLIENT_SLOTS - 1];
memset(ci, 0, sizeof(*ci));
ci->client_id = CLIENT_ID_SERVER;
diff --git a/src/network/network_base.h b/src/network/network_base.h
index 225528852..e8171a027 100644
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -23,16 +23,16 @@ struct NetworkClientInfo {
static NetworkClientInfo *GetNetworkClientInfo(int ci)
{
- extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
+ extern NetworkClientInfo _network_client_info[MAX_CLIENT_SLOTS];
return &_network_client_info[ci];
}
static inline bool IsValidNetworkClientInfoIndex(ClientIndex index)
{
- return (uint)index < MAX_CLIENT_INFO && GetNetworkClientInfo(index)->IsValid();
+ return (uint)index < MAX_CLIENT_SLOTS && GetNetworkClientInfo(index)->IsValid();
}
-#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (ci = GetNetworkClientInfo(start); ci != GetNetworkClientInfo(MAX_CLIENT_INFO); ci++) if (ci->IsValid())
+#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (ci = GetNetworkClientInfo(start); ci != GetNetworkClientInfo(MAX_CLIENT_SLOTS); ci++) if (ci->IsValid())
#define FOR_ALL_CLIENT_INFOS(d) FOR_ALL_CLIENT_INFOS_FROM(d, 0)
#endif /* ENABLE_NETWORK */
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 739ef6454..fc36bec53 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -299,19 +299,19 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
static char chat_tab_temp_buffer[64];
/* First, try clients */
- if (*item < MAX_CLIENT_INFO) {
+ if (*item < MAX_CLIENT_SLOTS) {
/* Skip inactive clients */
- while (GetNetworkClientInfo(*item)->client_id == INVALID_CLIENT_ID && *item < MAX_CLIENT_INFO) (*item)++;
- if (*item < MAX_CLIENT_INFO) return GetNetworkClientInfo(*item)->client_name;
+ while (GetNetworkClientInfo(*item)->client_id == INVALID_CLIENT_ID && *item < MAX_CLIENT_SLOTS) (*item)++;
+ if (*item < MAX_CLIENT_SLOTS) return GetNetworkClientInfo(*item)->client_name;
}
/* Then, try townnames */
/* Not that the following assumes all town indices are adjacent, ie no
* towns have been deleted. */
- if (*item <= (uint)MAX_CLIENT_INFO + GetMaxTownIndex()) {
+ if (*item <= (uint)MAX_CLIENT_SLOTS + GetMaxTownIndex()) {
const Town *t;
- FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) {
+ FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_SLOTS) {
/* Get the town-name via the string-system */
SetDParam(0, t->index);
GetString(chat_tab_temp_buffer, STR_TOWN, lastof(chat_tab_temp_buffer));
diff --git a/src/network/network_type.h b/src/network/network_type.h
index 5302e2542..c04fd1f5a 100644
--- a/src/network/network_type.h
+++ b/src/network/network_type.h
@@ -37,8 +37,8 @@ enum ClientID {
/** Indices into the client tables */
enum ClientIndex {
- /** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */
- MAX_CLIENT_INFO = MAX_CLIENTS + 1,
+ /** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1. This due to the (dedicated) server taking one slot. */
+ MAX_CLIENT_SLOTS = MAX_CLIENTS + 1,
};
/** Simple calculated statistics of a company */