2017-03-05 08:46:11 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 05.03.17.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
#include "PacketPreInit.hpp"
|
|
|
|
|
|
|
|
mwmp::PacketPreInit::PacketPreInit(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_GAME_PREINIT;
|
|
|
|
}
|
|
|
|
|
2017-03-06 10:40:53 +00:00
|
|
|
void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send)
|
2017-03-05 08:46:11 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
BasePacket::Packet(bs, send);
|
2017-03-05 08:46:11 +00:00
|
|
|
|
2017-05-02 15:31:30 +00:00
|
|
|
size_t size = checksums->size();
|
2017-03-05 08:46:11 +00:00
|
|
|
RW(size, send);
|
2017-05-02 15:31:30 +00:00
|
|
|
|
2017-05-02 19:47:58 +00:00
|
|
|
for (size_t i = 0; i < size; i++)
|
2017-03-05 08:46:11 +00:00
|
|
|
{
|
2017-05-02 15:31:30 +00:00
|
|
|
PluginPair ppair;
|
2017-05-02 19:47:58 +00:00
|
|
|
if (send)
|
2017-05-02 15:31:30 +00:00
|
|
|
ppair = (*checksums)[i];
|
|
|
|
|
|
|
|
RW(ppair.first, send);
|
|
|
|
|
|
|
|
size_t hashSize = ppair.second.size();
|
|
|
|
RW(hashSize, send);
|
2017-05-02 19:47:58 +00:00
|
|
|
for (size_t j = 0; j < hashSize; j++)
|
2017-03-05 08:46:11 +00:00
|
|
|
{
|
2017-05-02 15:31:30 +00:00
|
|
|
unsigned hash;
|
2017-05-02 19:47:58 +00:00
|
|
|
if (send)
|
2017-05-02 15:31:30 +00:00
|
|
|
hash = ppair.second[j];
|
|
|
|
RW(hash, send);
|
2017-05-02 19:47:58 +00:00
|
|
|
if (!send)
|
2017-05-02 15:31:30 +00:00
|
|
|
ppair.second.push_back(hash);
|
2017-03-05 08:46:11 +00:00
|
|
|
}
|
2017-05-02 19:47:58 +00:00
|
|
|
if (!send)
|
2017-05-02 15:31:30 +00:00
|
|
|
checksums->push_back(ppair);
|
2017-03-05 08:46:11 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-06 10:40:53 +00:00
|
|
|
|
|
|
|
void mwmp::PacketPreInit::setChecksums(mwmp::PacketPreInit::PluginContainer *checksums)
|
|
|
|
{
|
|
|
|
this->checksums = checksums;
|
|
|
|
}
|