diff options
author | rubidium <rubidium@openttd.org> | 2009-04-07 18:23:14 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-04-07 18:23:14 +0000 |
commit | 22d93068890b758ac7d54256fdc24e0c3169504e (patch) | |
tree | de0bc2023bce888ef3480f009231e3c8bb85eebb /src/network/core | |
parent | 3fdb8a62c4867e14417ac92119c3acb0c3fd2d5a (diff) | |
download | openttd-22d93068890b758ac7d54256fdc24e0c3169504e.tar.xz |
(svn r15967) -Codechange: do not access NetworkSocketHandler::has_quit directly
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/core.h | 10 | ||||
-rw-r--r-- | src/network/core/tcp.cpp | 2 | ||||
-rw-r--r-- | src/network/core/udp.cpp | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/network/core/core.h b/src/network/core/core.h index c1605d46d..bc348255d 100644 --- a/src/network/core/core.h +++ b/src/network/core/core.h @@ -36,10 +36,9 @@ struct Packet; * SocketHandler for all network sockets in OpenTTD. */ class NetworkSocketHandler { -public: - /* TODO: make socket & has_quit protected once the TCP stuff - *is in a real class too */ bool has_quit; ///< Whether the current client has quit/send a bad packet +public: + /* TODO: make socket protected once the TCP stuff is in a real class too */ SOCKET sock; ///< The socket currently connected to public: /** Create a new unbound socket */ @@ -72,6 +71,11 @@ public: */ bool HasClientQuit() const { return this->has_quit; } + /** + * Reopen the socket so we can send/receive stuff again. + */ + void Reopen() { this->has_quit = false; } + void Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf); void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf); void Send_CompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats); diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index 963257847..1ed8b618c 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -29,7 +29,7 @@ NetworkTCPSocketHandler::~NetworkTCPSocketHandler() NetworkRecvStatus NetworkTCPSocketHandler::CloseConnection() { this->writable = false; - this->has_quit = true; + NetworkSocketHandler::CloseConnection(); /* Free all pending and partially received packets */ while (this->packet_queue != NULL) { diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index b2bc7b220..df5a68cb5 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -54,7 +54,7 @@ void NetworkUDPSocketHandler::Close() NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection() { - this->has_quit = true; + NetworkSocketHandler::CloseConnection(); return NETWORK_RECV_STATUS_OKAY; } @@ -264,7 +264,7 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_ PacketUDPType type; /* New packet == new client, which has not quit yet */ - this->has_quit = false; + this->Reopen(); type = (PacketUDPType)p->Recv_uint8(); |