openmw-tes3coop/components/openmw-mp/Packets/Player/PacketPlayerMap.cpp

35 lines
793 B
C++
Raw Normal View History

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerMap.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerMap::PacketPlayerMap(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_MAP;
}
void PacketPlayerMap::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
2017-11-28 13:37:46 +00:00
uint32_t count;
if (send)
2017-11-28 13:37:46 +00:00
count = static_cast<uint32_t>(player->mapChanges.cellsExplored.size());
2017-11-28 13:37:46 +00:00
RW(count, send);
2017-11-28 13:37:46 +00:00
if(!send)
{
2017-11-28 13:37:46 +00:00
player->mapChanges.cellsExplored.clear();
player->mapChanges.cellsExplored.resize(count);
}
2017-11-28 13:37:46 +00:00
for (auto &&cellExplored : player->mapChanges.cellsExplored)
{
RW(cellExplored.mData, send, true);
RW(cellExplored.mName, send, true);
}
}