1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 21:19:57 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerBook.cpp
2019-10-23 02:02:27 +03:00

33 lines
684 B
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerBook.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerBook::PacketPlayerBook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_BOOK;
}
void PacketPlayerBook::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->bookChanges.size());
RW(count, send);
if (!send)
{
player->bookChanges.clear();
player->bookChanges.resize(count);
}
for (auto &&book : player->bookChanges)
{
RW(book.bookId, send, true);
}
}