1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 07:19:54 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp
David Cernat 78f29302ef [General] Fix PlayerJournal logic by sending only refIds for its actors
Additionally, make the refIds for actors usable in script functions.
2017-06-23 08:12:32 +03:00

42 lines
1.1 KiB
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);
if (send)
player->journalChanges.count = (unsigned int)(player->journalChanges.journalItems.size());
else
player->journalChanges.journalItems.clear();
RW(player->journalChanges.count, send);
for (unsigned int i = 0; i < player->journalChanges.count; i++)
{
JournalItem journalItem;
if (send)
journalItem = player->journalChanges.journalItems.at(i);
RW(journalItem.type, send);
RW(journalItem.quest, send, 1);
RW(journalItem.index, send);
if (journalItem.type == JournalItem::ENTRY)
{
RW(journalItem.actorRefId, send, 1);
}
if (!send)
player->journalChanges.journalItems.push_back(journalItem);
}
}