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

37 lines
848 B
C++
Raw Normal View History

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerQuickKeys.hpp"
using namespace mwmp;
PacketPlayerQuickKeys::PacketPlayerQuickKeys(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_QUICKKEYS;
}
void PacketPlayerQuickKeys::Packet(RakNet::BitStream *newBitstream, bool send)
{
PlayerPacket::Packet(newBitstream, send);
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->quickKeyChanges.size());
RW(count, send);
if (!send)
{
player->quickKeyChanges.clear();
player->quickKeyChanges.resize(count);
}
for (auto &&quickKey : player->quickKeyChanges)
{
RW(quickKey.type, send);
RW(quickKey.slot, send);
if (quickKey.type != QuickKey::UNASSIGNED)
RW(quickKey.itemId, send);
}
}