Add client desync log to server desync log output
This commit is contained in:
@@ -62,6 +62,9 @@ typedef unsigned long in_addr_t;
|
||||
# define ioctlsocket ioctl
|
||||
# define closesocket close
|
||||
# define GET_LAST_ERROR() (errno)
|
||||
# define SD_RECEIVE SHUT_RD
|
||||
# define SD_SEND SHUT_WR
|
||||
# define SD_BOTH SHUT_RDWR
|
||||
/* Need this for FIONREAD on solaris */
|
||||
# define BSD_COMP
|
||||
|
||||
@@ -102,6 +105,9 @@ typedef unsigned long in_addr_t;
|
||||
# define ioctlsocket ioctl
|
||||
# define closesocket close
|
||||
# define GET_LAST_ERROR() (sock_errno())
|
||||
# define SD_RECEIVE SHUT_RD
|
||||
# define SD_SEND SHUT_WR
|
||||
# define SD_BOTH SHUT_RDWR
|
||||
|
||||
/* Includes needed for OS/2 systems */
|
||||
# include <types.h>
|
||||
@@ -166,6 +172,21 @@ static inline bool SetNonBlocking(SOCKET d)
|
||||
return ioctlsocket(d, FIONBIO, &nonblocking) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to set the socket into blocking mode.
|
||||
* @param d The socket to set the blocking more for.
|
||||
* @return True if setting the blocking mode succeeded, otherwise false.
|
||||
*/
|
||||
static inline bool SetBlocking(SOCKET d)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
u_long nonblocking = 0;
|
||||
#else
|
||||
int nonblocking = 0;
|
||||
#endif
|
||||
return ioctlsocket(d, FIONBIO, &nonblocking) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to set the socket to not delay sending.
|
||||
* @param d The socket to disable the delaying for.
|
||||
@@ -179,6 +200,32 @@ static inline bool SetNoDelay(SOCKET d)
|
||||
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to shutdown the socket in one or both directions.
|
||||
* @param d The socket to disable the delaying for.
|
||||
* @param read Whether to shutdown the read direction.
|
||||
* @param write Whether to shutdown the write direction.
|
||||
* @param linger_timeout The socket linger timeout.
|
||||
* @return True if successful
|
||||
*/
|
||||
static inline bool ShutdownSocket(SOCKET d, bool read, bool write, uint linger_timeout)
|
||||
{
|
||||
if (!read && !write) return true;
|
||||
#ifdef _WIN32
|
||||
LINGER ln = { 1U, (uint16) linger_timeout };
|
||||
#else
|
||||
struct linger ln = { 1, (int) linger_timeout };
|
||||
#endif
|
||||
|
||||
setsockopt(d, SOL_SOCKET, SO_LINGER, (const char*)&ln, sizeof(ln));
|
||||
|
||||
int how = SD_BOTH;
|
||||
if (!read) how = SD_SEND;
|
||||
if (!write) how = SD_RECEIVE;
|
||||
return shutdown(d, how) == 0;
|
||||
}
|
||||
|
||||
/* Make sure these structures have the size we expect them to be */
|
||||
assert_compile(sizeof(in_addr) == 4); ///< IPv4 addresses should be 4 bytes.
|
||||
assert_compile(sizeof(in6_addr) == 16); ///< IPv6 addresses should be 16 bytes.
|
||||
|
@@ -99,6 +99,7 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet *p)
|
||||
case PACKET_CLIENT_SET_NAME: return this->Receive_CLIENT_SET_NAME(p);
|
||||
case PACKET_CLIENT_QUIT: return this->Receive_CLIENT_QUIT(p);
|
||||
case PACKET_CLIENT_ERROR: return this->Receive_CLIENT_ERROR(p);
|
||||
case PACKET_CLIENT_DESYNC_LOG: return this->Receive_CLIENT_DESYNC_LOG(p);
|
||||
case PACKET_SERVER_QUIT: return this->Receive_SERVER_QUIT(p);
|
||||
case PACKET_SERVER_ERROR_QUIT: return this->Receive_SERVER_ERROR_QUIT(p);
|
||||
case PACKET_SERVER_SHUTDOWN: return this->Receive_SERVER_SHUTDOWN(p);
|
||||
@@ -185,6 +186,7 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_SET_PASSWORD(Packet *
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_SET_NAME(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_SET_NAME); }
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_QUIT); }
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_ERROR); }
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_DESYNC_LOG(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_DESYNC_LOG); }
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_QUIT); }
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_ERROR_QUIT); }
|
||||
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_SHUTDOWN(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_SHUTDOWN); }
|
||||
|
@@ -121,6 +121,7 @@ enum PacketGameType {
|
||||
PACKET_SERVER_QUIT, ///< A server tells that a client has quit.
|
||||
PACKET_CLIENT_ERROR, ///< A client reports an error to the server.
|
||||
PACKET_SERVER_ERROR_QUIT, ///< A server tells that a client has hit an error and did quit.
|
||||
PACKET_CLIENT_DESYNC_LOG, ///< A client reports a desync log
|
||||
|
||||
PACKET_END, ///< Must ALWAYS be on the end of this list!! (period)
|
||||
};
|
||||
@@ -426,6 +427,7 @@ protected:
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p);
|
||||
virtual NetworkRecvStatus Receive_CLIENT_DESYNC_LOG(Packet *p);
|
||||
|
||||
/**
|
||||
* Notification that a client left the game:
|
||||
|
Reference in New Issue
Block a user