1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 11:53:52 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp

38 lines
960 B
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerJournal.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerJournal::PacketPlayerJournal(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_JOURNAL;
}
void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->journalChanges.journalItems.size());
RW(count, send);
if (!send)
{
player->journalChanges.journalItems.clear();
player->journalChanges.journalItems.resize(count);
}
for (auto &&journalItem : player->journalChanges.journalItems)
{
RW(journalItem.type, send);
RW(journalItem.quest, send, true);
RW(journalItem.index, send);
if (journalItem.type == JournalItem::Type::Entry)
RW(journalItem.actorRefId, send, true);
}
}