[General] Improve PacketPreInit

0.6.1
Koncord 8 years ago
parent f00c4dc107
commit 931a5896ec

@ -15,25 +15,30 @@ void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send)
{ {
BasePacket::Packet(bs, send); BasePacket::Packet(bs, send);
unsigned int size = checksums->size(); size_t size = checksums->size();
RW(size, send); RW(size, send);
if(send)
{ for(size_t i = 0; i < size; i++)
BOOST_FOREACH(PluginContainer::value_type & checksum, *checksums)
{
RW(checksum.first, true);
RW(checksum.second, true);
}
}
else
{ {
for(unsigned int i = 0; i < size; i++) PluginPair ppair;
if(send)
ppair = (*checksums)[i];
RW(ppair.first, send);
size_t hashSize = ppair.second.size();
RW(hashSize, send);
for(size_t j = 0; j < hashSize; j++)
{ {
PluginPair checksum; unsigned hash;
RW(checksum.first, false); if(send)
RW(checksum.second, false); hash = ppair.second[j];
checksums->push_back(checksum); RW(hash, send);
if(!send)
ppair.second.push_back(hash);
} }
if(!send)
checksums->push_back(ppair);
} }
} }

@ -14,7 +14,8 @@ namespace mwmp
class PacketPreInit : public BasePacket class PacketPreInit : public BasePacket
{ {
public: public:
typedef std::pair<std::string, unsigned int> PluginPair; typedef std::vector<unsigned> HashList;
typedef std::pair<std::string, HashList> PluginPair;
typedef std::vector<PluginPair> PluginContainer; typedef std::vector<PluginPair> PluginContainer;
PacketPreInit(RakNet::RakPeerInterface *peer); PacketPreInit(RakNet::RakPeerInterface *peer);

Loading…
Cancel
Save