summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-24 20:07:32 +0000
committerrubidium <rubidium@openttd.org>2010-10-24 20:07:32 +0000
commitf24c91c4876e44ff9bed04bc5065f7966406bb87 (patch)
treedfa72debbfa17c4913b0f29fb2ff60cd949ec026 /src
parent2cd67a51acc71b08e52c94fefa44fe665977396f (diff)
downloadopenttd-f24c91c4876e44ff9bed04bc5065f7966406bb87.tar.xz
(svn r21030) -Codechange: move ClientStatus into the network server socket class
Diffstat (limited to 'src')
-rw-r--r--src/network/core/tcp_game.h15
-rw-r--r--src/network/network.cpp4
-rw-r--r--src/network/network_command.cpp2
-rw-r--r--src/network/network_server.cpp10
-rw-r--r--src/network/network_server.h15
5 files changed, 23 insertions, 23 deletions
diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h
index 6fd5649c1..a2e0226be 100644
--- a/src/network/core/tcp_game.h
+++ b/src/network/core/tcp_game.h
@@ -147,21 +147,6 @@ public:
uint Count() const { return this->count; }
};
-/** Status of a client */
-enum ClientStatus {
- STATUS_INACTIVE, ///< The client is not connected nor active
- STATUS_NEWGRFS_CHECK, ///< The client is checking NewGRFs
- STATUS_AUTH_GAME, ///< The client is authorizing with game (server) password
- STATUS_AUTH_COMPANY, ///< The client is authorizing with company password
- STATUS_AUTHORIZED, ///< The client is authorized
- STATUS_MAP_WAIT, ///< The client is waiting as someone else is downloading the map
- 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 active within in the game
- STATUS_END ///< Must ALWAYS be on the end of this list!! (period)
-};
-
#define DECLARE_GAME_RECEIVE_COMMAND(type) virtual NetworkRecvStatus NetworkPacketReceive_## type ##_command(Packet *p)
#define DEF_GAME_RECEIVE_COMMAND(cls, type) NetworkRecvStatus cls ##NetworkGameSocketHandler::NetworkPacketReceive_ ## type ## _command(Packet *p)
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 7d3dbbe13..69c238e25 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -343,7 +343,7 @@ static uint NetworkCountActiveClients()
uint count = 0;
FOR_ALL_CLIENT_SOCKETS(cs) {
- if (cs->status != STATUS_ACTIVE) continue;
+ if (cs->status != NetworkClientSocket::STATUS_ACTIVE) continue;
if (!Company::IsValidID(cs->GetInfo()->client_playas)) continue;
count++;
}
@@ -372,7 +372,7 @@ static bool NetworkHasJoiningClient()
{
const NetworkClientSocket *cs;
FOR_ALL_CLIENT_SOCKETS(cs) {
- if (cs->status >= STATUS_AUTHORIZED && cs->status < STATUS_ACTIVE) return true;
+ if (cs->status >= NetworkClientSocket::STATUS_AUTHORIZED && cs->status < NetworkClientSocket::STATUS_ACTIVE) return true;
}
return false;
diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp
index ab752455e..ccdee89d6 100644
--- a/src/network/network_command.cpp
+++ b/src/network/network_command.cpp
@@ -227,7 +227,7 @@ static void DistributeCommandPacket(CommandPacket cp, const NetworkClientSocket
NetworkClientSocket *cs;
FOR_ALL_CLIENT_SOCKETS(cs) {
- if (cs->status >= STATUS_MAP) {
+ if (cs->status >= NetworkClientSocket::STATUS_MAP) {
/* Callbacks are only send back to the client who sent them in the
* first place. This filters that out. */
cp.callback = (cs != owner) ? NULL : callback;
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index a7dc9daed..3d853a2c7 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1514,7 +1514,7 @@ void NetworkServer_Tick(bool send_frame)
* do their frame! */
FOR_ALL_CLIENT_SOCKETS(cs) {
/* Check if the speed of the client is what we can expect from a client */
- if (cs->status == STATUS_ACTIVE) {
+ if (cs->status == NetworkClientSocket::STATUS_ACTIVE) {
/* 1 lag-point per day */
uint lag = NetworkCalculateLag(cs) / DAY_TICKS;
if (lag > 0) {
@@ -1534,13 +1534,13 @@ void NetworkServer_Tick(bool send_frame)
} else {
cs->lag_test = 0;
}
- } else if (cs->status == STATUS_PRE_ACTIVE) {
+ } else if (cs->status == NetworkClientSocket::STATUS_PRE_ACTIVE) {
uint lag = NetworkCalculateLag(cs);
if (lag > _settings_client.network.max_join_time) {
IConsolePrintF(CC_ERROR,"Client #%d is dropped because it took longer than %d ticks for him to join", cs->client_id, _settings_client.network.max_join_time);
cs->CloseConnection(NETWORK_RECV_STATUS_SERVER_ERROR);
}
- } else if (cs->status == STATUS_INACTIVE) {
+ } else if (cs->status == NetworkClientSocket::STATUS_INACTIVE) {
uint lag = NetworkCalculateLag(cs);
if (lag > 4 * DAY_TICKS) {
IConsolePrintF(CC_ERROR,"Client #%d is dropped because it took longer than %d ticks to start the joining process", cs->client_id, 4 * DAY_TICKS);
@@ -1548,7 +1548,7 @@ void NetworkServer_Tick(bool send_frame)
}
}
- if (cs->status >= STATUS_PRE_ACTIVE) {
+ if (cs->status >= NetworkClientSocket::STATUS_PRE_ACTIVE) {
/* Check if we can send command, and if we have anything in the queue */
NetworkHandleCommandQueue(cs);
@@ -1607,7 +1607,7 @@ void NetworkServerShowStatusToConsole()
"ready",
"active"
};
- assert_compile(lengthof(stat_str) == STATUS_END);
+ assert_compile(lengthof(stat_str) == NetworkClientSocket::STATUS_END);
NetworkClientSocket *cs;
FOR_ALL_CLIENT_SOCKETS(cs) {
diff --git a/src/network/network_server.h b/src/network/network_server.h
index c5bc049f1..7c5b175bf 100644
--- a/src/network/network_server.h
+++ b/src/network/network_server.h
@@ -50,6 +50,21 @@ protected:
NetworkRecvStatus SendNeedCompanyPassword();
public:
+ /** Status of a client */
+ enum ClientStatus {
+ STATUS_INACTIVE, ///< The client is not connected nor active.
+ STATUS_NEWGRFS_CHECK, ///< The client is checking NewGRFs.
+ STATUS_AUTH_GAME, ///< The client is authorizing with game (server) password.
+ STATUS_AUTH_COMPANY, ///< The client is authorizing with company password.
+ STATUS_AUTHORIZED, ///< The client is authorized.
+ STATUS_MAP_WAIT, ///< The client is waiting as someone else is downloading the map.
+ 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 active within in the game.
+ STATUS_END ///< Must ALWAYS be on the end of this list!! (period).
+ };
+
byte lag_test; ///< Byte used for lag-testing the client
ClientStatus status; ///< Status of this client
CommandQueue outgoing_queue; ///< The command-queue awaiting delivery