mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 20:49:56 +00:00
40 lines
1 KiB
C++
40 lines
1 KiB
C++
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include "PacketPlayerQuickKeys.hpp"
|
|
|
|
using namespace std;
|
|
using namespace mwmp;
|
|
|
|
PacketPlayerQuickKeys::PacketPlayerQuickKeys(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
{
|
|
packetID = ID_PLAYER_QUICKKEYS;
|
|
}
|
|
|
|
void PacketPlayerQuickKeys::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
PlayerPacket::Packet(bs, send);
|
|
|
|
if (send)
|
|
player->quickKeyChanges.count = (unsigned int) (player->quickKeyChanges.quickKeys.size());
|
|
else
|
|
player->quickKeyChanges.quickKeys.clear();
|
|
|
|
RW(player->quickKeyChanges.count, send);
|
|
|
|
for (unsigned int i = 0; i < player->quickKeyChanges.count; i++)
|
|
{
|
|
QuickKey quickKey;
|
|
|
|
if (send)
|
|
quickKey = player->quickKeyChanges.quickKeys.at(i);
|
|
|
|
RW(quickKey.type, send);
|
|
RW(quickKey.slot, send);
|
|
|
|
if (quickKey.type != QuickKey::UNASSIGNED)
|
|
RW(quickKey.itemId, send);
|
|
|
|
if (!send)
|
|
player->quickKeyChanges.quickKeys.push_back(quickKey);
|
|
}
|
|
|
|
}
|