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

34 lines
707 B
C++
Raw Normal View History

#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);
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->bookChanges.books.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->bookChanges.books.clear();
player->bookChanges.books.resize(count);
}
2017-11-28 13:37:46 +00:00
for (auto &&book : player->bookChanges.books)
{
RW(book.bookId, send, true);
}
}