2017-05-29 01:43:52 +00:00
|
|
|
#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);
|
|
|
|
|
2019-10-22 23:02:27 +00:00
|
|
|
uint32_t count;
|
|
|
|
|
2017-06-27 05:27:14 +00:00
|
|
|
if (send)
|
2019-10-22 23:02:27 +00:00
|
|
|
count = static_cast<uint32_t>(player->bookChanges.size());
|
2017-06-27 05:27:14 +00:00
|
|
|
|
2019-10-22 23:02:27 +00:00
|
|
|
RW(count, send);
|
2017-06-27 05:27:14 +00:00
|
|
|
|
2019-10-22 23:02:27 +00:00
|
|
|
if (!send)
|
2017-06-27 05:27:14 +00:00
|
|
|
{
|
2019-10-22 23:02:27 +00:00
|
|
|
player->bookChanges.clear();
|
|
|
|
player->bookChanges.resize(count);
|
|
|
|
}
|
2017-06-27 05:27:14 +00:00
|
|
|
|
2019-10-22 23:02:27 +00:00
|
|
|
for (auto &&book : player->bookChanges)
|
|
|
|
{
|
2018-07-02 18:50:21 +00:00
|
|
|
RW(book.bookId, send, true);
|
2017-06-27 05:27:14 +00:00
|
|
|
}
|
2017-05-29 01:43:52 +00:00
|
|
|
}
|