From 647661daf9e834e6f90fee052eeca771a312236c Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 5 Jan 2018 08:36:13 +0800 Subject: [PATCH] [General] Minor fixes in Master packets --- .../openmw-mp/Master/PacketMasterAnnounce.cpp | 2 +- .../openmw-mp/Master/PacketMasterAnnounce.hpp | 8 ++++---- components/openmw-mp/Master/PacketMasterQuery.cpp | 10 ++++++++-- components/openmw-mp/Master/PacketMasterQuery.hpp | 4 ++-- components/openmw-mp/Master/PacketMasterUpdate.cpp | 2 +- components/openmw-mp/Master/PacketMasterUpdate.hpp | 4 ++-- components/openmw-mp/Master/ProxyMasterPacket.hpp | 13 +++++-------- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/components/openmw-mp/Master/PacketMasterAnnounce.cpp b/components/openmw-mp/Master/PacketMasterAnnounce.cpp index ac8b3cecb..ff22b6465 100644 --- a/components/openmw-mp/Master/PacketMasterAnnounce.cpp +++ b/components/openmw-mp/Master/PacketMasterAnnounce.cpp @@ -35,7 +35,7 @@ void PacketMasterAnnounce::SetServer(QueryData *_server) server = _server; } -void PacketMasterAnnounce::SetFunc(int _func) +void PacketMasterAnnounce::SetFunc(uint32_t _func) { func = _func; } diff --git a/components/openmw-mp/Master/PacketMasterAnnounce.hpp b/components/openmw-mp/Master/PacketMasterAnnounce.hpp index 4a3a81be0..5af7ad4e0 100644 --- a/components/openmw-mp/Master/PacketMasterAnnounce.hpp +++ b/components/openmw-mp/Master/PacketMasterAnnounce.hpp @@ -15,12 +15,12 @@ namespace mwmp { friend class ProxyMasterPacket; public: - PacketMasterAnnounce(RakNet::RakPeerInterface *peer); + explicit PacketMasterAnnounce(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, bool send); + void Packet(RakNet::BitStream *bs, bool send) override; void SetServer(QueryData *server); - void SetFunc(int keep); + void SetFunc(uint32_t keep); int GetFunc(); enum Func @@ -31,7 +31,7 @@ namespace mwmp }; private: QueryData *server; - int func; + uint32_t func; }; } diff --git a/components/openmw-mp/Master/PacketMasterQuery.cpp b/components/openmw-mp/Master/PacketMasterQuery.cpp index 1850de6c5..015b36d97 100644 --- a/components/openmw-mp/Master/PacketMasterQuery.cpp +++ b/components/openmw-mp/Master/PacketMasterQuery.cpp @@ -26,7 +26,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) if (send) bs->Write(packetID); - int serversCount = servers->size(); + int32_t serversCount = servers->size(); RW(serversCount, send); @@ -36,7 +36,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) QueryData server; string addr; - unsigned short port; + uint16_t port; while (serversCount--) { if (send) @@ -50,6 +50,12 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) ProxyMasterPacket::addServer(this, server, send); + if(addr.empty()) + { + cout << "Address empty. Aborting PacketMasterQuery::Packet" << endl; + return; + } + if (send) serverIt++; else diff --git a/components/openmw-mp/Master/PacketMasterQuery.hpp b/components/openmw-mp/Master/PacketMasterQuery.hpp index ada4b308d..43eeafee0 100644 --- a/components/openmw-mp/Master/PacketMasterQuery.hpp +++ b/components/openmw-mp/Master/PacketMasterQuery.hpp @@ -15,9 +15,9 @@ namespace mwmp { friend class ProxyMasterPacket; public: - PacketMasterQuery(RakNet::RakPeerInterface *peer); + explicit PacketMasterQuery(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, bool send); + void Packet(RakNet::BitStream *bs, bool send) override; void SetServers(std::map *serverMap); private: diff --git a/components/openmw-mp/Master/PacketMasterUpdate.cpp b/components/openmw-mp/Master/PacketMasterUpdate.cpp index 54f32e266..33ef10ec4 100644 --- a/components/openmw-mp/Master/PacketMasterUpdate.cpp +++ b/components/openmw-mp/Master/PacketMasterUpdate.cpp @@ -24,7 +24,7 @@ void PacketMasterUpdate::Packet(RakNet::BitStream *bs, bool send) bs->Write(packetID); string addr = server->first.ToString(false); - unsigned short port = server->first.GetPort(); + uint16_t port = server->first.GetPort(); RW(addr, send); RW(port, send); diff --git a/components/openmw-mp/Master/PacketMasterUpdate.hpp b/components/openmw-mp/Master/PacketMasterUpdate.hpp index 37adf2216..f3c254dbb 100644 --- a/components/openmw-mp/Master/PacketMasterUpdate.hpp +++ b/components/openmw-mp/Master/PacketMasterUpdate.hpp @@ -15,9 +15,9 @@ namespace mwmp { friend class ProxyMasterPacket; public: - PacketMasterUpdate(RakNet::RakPeerInterface *peer); + explicit PacketMasterUpdate(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, bool send); + void Packet(RakNet::BitStream *bs, bool send) override; void SetServer(std::pair *serverPair); private: diff --git a/components/openmw-mp/Master/ProxyMasterPacket.hpp b/components/openmw-mp/Master/ProxyMasterPacket.hpp index d5d4506b5..01bafa662 100644 --- a/components/openmw-mp/Master/ProxyMasterPacket.hpp +++ b/components/openmw-mp/Master/ProxyMasterPacket.hpp @@ -14,9 +14,8 @@ namespace mwmp class ProxyMasterPacket : public BasePacket { private: - ProxyMasterPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) + explicit ProxyMasterPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) { - } public: @@ -25,8 +24,7 @@ namespace mwmp { using namespace std; - int rulesSize = server.rules.size(); - + int32_t rulesSize = server.rules.size(); packet->RW(rulesSize, send); if (rulesSize > 2000) @@ -38,7 +36,7 @@ namespace mwmp while (rulesSize--) { - ServerRule *rule = 0; + ServerRule *rule = nullptr; string key; if (send) { @@ -71,9 +69,8 @@ namespace mwmp else server.players.clear(); - int playersCount = server.players.size(); + int32_t playersCount = server.players.size(); packet->RW(playersCount, send); - if (playersCount > 2000) playersCount = 0; @@ -91,7 +88,7 @@ namespace mwmp plIt++; } - int pluginsCount = server.plugins.size(); + int32_t pluginsCount = server.plugins.size(); packet->RW(pluginsCount, send); if (pluginsCount > 2000)