From 931a5896ecd69207b42851832bb084ba72d18039 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 2 May 2017 23:31:30 +0800 Subject: [PATCH] [General] Improve PacketPreInit --- .../openmw-mp/Packets/PacketPreInit.cpp | 35 +++++++++++-------- .../openmw-mp/Packets/PacketPreInit.hpp | 3 +- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/components/openmw-mp/Packets/PacketPreInit.cpp b/components/openmw-mp/Packets/PacketPreInit.cpp index 3b8ae4f0b..eb7b8182a 100644 --- a/components/openmw-mp/Packets/PacketPreInit.cpp +++ b/components/openmw-mp/Packets/PacketPreInit.cpp @@ -15,25 +15,30 @@ void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send) { BasePacket::Packet(bs, send); - unsigned int size = checksums->size(); + size_t size = checksums->size(); 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); - RW(checksum.second, true); - } - } - else - { - for(unsigned int i = 0; i < size; i++) - { - PluginPair checksum; - RW(checksum.first, false); - RW(checksum.second, false); - checksums->push_back(checksum); + unsigned hash; + if(send) + hash = ppair.second[j]; + RW(hash, send); + if(!send) + ppair.second.push_back(hash); } + if(!send) + checksums->push_back(ppair); } } diff --git a/components/openmw-mp/Packets/PacketPreInit.hpp b/components/openmw-mp/Packets/PacketPreInit.hpp index 977140bc0..ff1281752 100644 --- a/components/openmw-mp/Packets/PacketPreInit.hpp +++ b/components/openmw-mp/Packets/PacketPreInit.hpp @@ -14,7 +14,8 @@ namespace mwmp class PacketPreInit : public BasePacket { public: - typedef std::pair PluginPair; + typedef std::vector HashList; + typedef std::pair PluginPair; typedef std::vector PluginContainer; PacketPreInit(RakNet::RakPeerInterface *peer);