2017-05-29 01:43:52 +00:00
|
|
|
#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);
|
|
|
|
|
2018-05-08 02:57:04 +00:00
|
|
|
uint32_t changesCount;
|
|
|
|
|
2017-07-03 06:28:27 +00:00
|
|
|
if (send)
|
2018-05-08 02:57:04 +00:00
|
|
|
changesCount = static_cast<uint32_t>(player->mapChanges.mapTiles.size());
|
2017-07-03 06:28:27 +00:00
|
|
|
|
2018-05-08 02:57:04 +00:00
|
|
|
RW(changesCount, send);
|
2017-07-03 06:28:27 +00:00
|
|
|
|
2018-05-08 02:57:04 +00:00
|
|
|
if (!send)
|
2017-07-03 06:28:27 +00:00
|
|
|
{
|
2018-05-08 02:57:04 +00:00
|
|
|
player->mapChanges.mapTiles.clear();
|
|
|
|
player->mapChanges.mapTiles.resize(changesCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &&mapTile : player->mapChanges.mapTiles)
|
|
|
|
{
|
|
|
|
RW(mapTile.x, send);
|
|
|
|
RW(mapTile.y, send);
|
|
|
|
|
|
|
|
uint32_t imageDataCount;
|
2017-07-03 06:28:27 +00:00
|
|
|
|
|
|
|
if (send)
|
2018-05-08 02:57:04 +00:00
|
|
|
imageDataCount = static_cast<uint32_t>(mapTile.imageData.size());
|
2017-07-03 06:28:27 +00:00
|
|
|
|
2018-05-08 02:57:04 +00:00
|
|
|
RW(imageDataCount, send);
|
2017-07-03 06:28:27 +00:00
|
|
|
|
|
|
|
if (!send)
|
2018-05-08 02:57:04 +00:00
|
|
|
{
|
|
|
|
mapTile.imageData.clear();
|
|
|
|
mapTile.imageData.resize(imageDataCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &&imageChar : mapTile.imageData)
|
|
|
|
{
|
|
|
|
RW(imageChar, send);
|
|
|
|
}
|
2017-07-03 06:28:27 +00:00
|
|
|
}
|
2017-05-29 01:43:52 +00:00
|
|
|
}
|