mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r21030) -Codechange: move ClientStatus into the network server socket class
This commit is contained in:
parent
2cd67a51ac
commit
f24c91c487
|
@ -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)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue