summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-12-23 11:55:46 +0000
committerrubidium <rubidium@openttd.org>2008-12-23 11:55:46 +0000
commitf8f7febe41311ff3562c57a10672e3a62174104b (patch)
tree0e0f56357371c5504e04f2c93c6baebc89f00607 /src/network
parent52fb6b7d7cec0734fb341939adce5199eeca7db6 (diff)
downloadopenttd-f8f7febe41311ff3562c57a10672e3a62174104b.tar.xz
(svn r14725) -Change: make it clearer why (and that) MAX_CLIENTS isn't the amount of slots in the array, but one less as a dedicated server takes a slot too.
Diffstat (limited to 'src/network')
-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
4 files changed, 13 insertions, 13 deletions
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 */