[General] Minor fixes in Master packets

pull/367/head
Koncord 7 years ago
parent 2f6e3b4cda
commit 647661daf9

@ -35,7 +35,7 @@ void PacketMasterAnnounce::SetServer(QueryData *_server)
server = _server; server = _server;
} }
void PacketMasterAnnounce::SetFunc(int _func) void PacketMasterAnnounce::SetFunc(uint32_t _func)
{ {
func = _func; func = _func;
} }

@ -15,12 +15,12 @@ namespace mwmp
{ {
friend class ProxyMasterPacket; friend class ProxyMasterPacket;
public: 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 SetServer(QueryData *server);
void SetFunc(int keep); void SetFunc(uint32_t keep);
int GetFunc(); int GetFunc();
enum Func enum Func
@ -31,7 +31,7 @@ namespace mwmp
}; };
private: private:
QueryData *server; QueryData *server;
int func; uint32_t func;
}; };
} }

@ -26,7 +26,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send)
if (send) if (send)
bs->Write(packetID); bs->Write(packetID);
int serversCount = servers->size(); int32_t serversCount = servers->size();
RW(serversCount, send); RW(serversCount, send);
@ -36,7 +36,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send)
QueryData server; QueryData server;
string addr; string addr;
unsigned short port; uint16_t port;
while (serversCount--) while (serversCount--)
{ {
if (send) if (send)
@ -50,6 +50,12 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send)
ProxyMasterPacket::addServer(this, server, send); ProxyMasterPacket::addServer(this, server, send);
if(addr.empty())
{
cout << "Address empty. Aborting PacketMasterQuery::Packet" << endl;
return;
}
if (send) if (send)
serverIt++; serverIt++;
else else

@ -15,9 +15,9 @@ namespace mwmp
{ {
friend class ProxyMasterPacket; friend class ProxyMasterPacket;
public: 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<RakNet::SystemAddress, QueryData> *serverMap); void SetServers(std::map<RakNet::SystemAddress, QueryData> *serverMap);
private: private:

@ -24,7 +24,7 @@ void PacketMasterUpdate::Packet(RakNet::BitStream *bs, bool send)
bs->Write(packetID); bs->Write(packetID);
string addr = server->first.ToString(false); string addr = server->first.ToString(false);
unsigned short port = server->first.GetPort(); uint16_t port = server->first.GetPort();
RW(addr, send); RW(addr, send);
RW(port, send); RW(port, send);

@ -15,9 +15,9 @@ namespace mwmp
{ {
friend class ProxyMasterPacket; friend class ProxyMasterPacket;
public: 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<RakNet::SystemAddress, QueryData> *serverPair); void SetServer(std::pair<RakNet::SystemAddress, QueryData> *serverPair);
private: private:

@ -14,9 +14,8 @@ namespace mwmp
class ProxyMasterPacket : public BasePacket class ProxyMasterPacket : public BasePacket
{ {
private: private:
ProxyMasterPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) explicit ProxyMasterPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
{ {
} }
public: public:
@ -25,8 +24,7 @@ namespace mwmp
{ {
using namespace std; using namespace std;
int rulesSize = server.rules.size(); int32_t rulesSize = server.rules.size();
packet->RW(rulesSize, send); packet->RW(rulesSize, send);
if (rulesSize > 2000) if (rulesSize > 2000)
@ -38,7 +36,7 @@ namespace mwmp
while (rulesSize--) while (rulesSize--)
{ {
ServerRule *rule = 0; ServerRule *rule = nullptr;
string key; string key;
if (send) if (send)
{ {
@ -71,9 +69,8 @@ namespace mwmp
else else
server.players.clear(); server.players.clear();
int playersCount = server.players.size(); int32_t playersCount = server.players.size();
packet->RW(playersCount, send); packet->RW(playersCount, send);
if (playersCount > 2000) if (playersCount > 2000)
playersCount = 0; playersCount = 0;
@ -91,7 +88,7 @@ namespace mwmp
plIt++; plIt++;
} }
int pluginsCount = server.plugins.size(); int32_t pluginsCount = server.plugins.size();
packet->RW(pluginsCount, send); packet->RW(pluginsCount, send);
if (pluginsCount > 2000) if (pluginsCount > 2000)

Loading…
Cancel
Save