openmw-tes3coop/components/openmw-mp/Packets/Player/PacketPlayerBook.cpp
2017-11-28 21:38:45 +08:00

33 lines
707 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.books.size());
RW(count, send);
if(!send)
{
player->bookChanges.books.clear();
player->bookChanges.books.resize(count);
}
for (auto &&book : player->bookChanges.books)
{
RW(book.bookId, send, true);
}
}