// // Created by koncord on 22.04.17. // #include #include #include "MasterData.hpp" #include "PacketMasterQuery.hpp" #include "ProxyMasterPacket.hpp" using namespace mwmp; using namespace std; using namespace RakNet; PacketMasterQuery::PacketMasterQuery(RakNet::RakPeerInterface *peer) : BasePacket(peer) { packetID = ID_MASTER_QUERY; orderChannel = CHANNEL_MASTER; } void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) { this->bs = bs; if (send) bs->Write(packetID); int serversCount = servers->size(); RW(serversCount, send); map::iterator serverIt; if (send) serverIt = servers->begin(); QueryData server; SystemAddress sa; while(serversCount--) { if (send) { sa = serverIt->first; server = serverIt->second; } RW(sa, send); ProxyMasterPacket::addServer(this, server, send); if (send) serverIt++; else servers->insert(pair(sa, server)); } } void PacketMasterQuery::SetServers(map *serverMap) { servers = serverMap; }