1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:15:32 +00:00

[General] Improve PacketPreInit

This commit is contained in:
Koncord 2017-05-02 23:31:30 +08:00
parent f00c4dc107
commit 931a5896ec
2 changed files with 22 additions and 16 deletions

View file

@ -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) 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++)
{ {
RW(checksum.first, true); unsigned hash;
RW(checksum.second, true); if(send)
} hash = ppair.second[j];
} RW(hash, send);
else if(!send)
{ ppair.second.push_back(hash);
for(unsigned int i = 0; i < size; i++)
{
PluginPair checksum;
RW(checksum.first, false);
RW(checksum.second, false);
checksums->push_back(checksum);
} }
if(!send)
checksums->push_back(ppair);
} }
} }

View file

@ -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);