openmw-tes3coop/components/openmw-mp/Packets/PacketPreInit.cpp

56 lines
1.1 KiB
C++
Raw Normal View History

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
{
BasePacket::Packet(bs, send);
2017-03-05 08:46:11 +00:00
uint16_t size = checksums->size();
2017-03-05 08:46:11 +00:00
RW(size, send);
2017-05-02 15:31:30 +00:00
if(!send)
2017-03-05 08:46:11 +00:00
{
if(size > 256)
return;
checksums->clear();
checksums->resize(size);
}
2017-05-02 15:31:30 +00:00
for (auto &&ppair : *checksums)
{
2017-05-02 15:31:30 +00:00
RW(ppair.first, send);
uint8_t hashSize = ppair.second.size();
2017-05-02 15:31:30 +00:00
RW(hashSize, send);
if(!send)
{
if(hashSize > 16)
return;
ppair.second.resize(hashSize);
}
for (auto &&hash :ppair.second)
2017-03-05 08:46:11 +00:00
{
2017-05-02 15:31:30 +00:00
RW(hash, send);
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;
}