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

39 lines
960 B
C++
Raw Normal View History

2017-01-20 09:15:10 +00:00
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerJournal.hpp"
2017-01-20 09:15:10 +00:00
using namespace std;
using namespace mwmp;
PacketPlayerJournal::PacketPlayerJournal(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
2017-01-20 09:15:10 +00:00
{
packetID = ID_PLAYER_JOURNAL;
2017-01-20 09:15:10 +00:00
}
void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
2017-01-20 09:15:10 +00:00
{
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->journalChanges.journalItems.size());
2017-11-28 13:37:46 +00:00
RW(count, send);
2017-11-29 11:00:22 +00:00
if (!send)
{
2017-11-28 13:37:46 +00:00
player->journalChanges.journalItems.clear();
player->journalChanges.journalItems.resize(count);
}
2017-11-28 13:37:46 +00:00
for (auto &&journalItem : player->journalChanges.journalItems)
{
RW(journalItem.type, send);
2017-11-28 13:37:46 +00:00
RW(journalItem.quest, send, true);
RW(journalItem.index, send);
if (journalItem.type == JournalItem::Type::Entry)
2017-11-28 13:37:46 +00:00
RW(journalItem.actorRefId, send, true);
}
2017-01-20 09:15:10 +00:00
}