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

39 lines
937 B
C++
Raw Normal View History

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerInventory.hpp"
using namespace mwmp;
PacketPlayerInventory::PacketPlayerInventory(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_INVENTORY;
}
void PacketPlayerInventory::Packet(RakNet::BitStream *newBitstream, bool send)
{
PlayerPacket::Packet(newBitstream, send);
RW(player->inventoryChanges.action, send);
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->inventoryChanges.items.size());
2016-11-21 21:40:50 +00:00
RW(count, send);
2016-11-21 21:40:50 +00:00
if (!send)
{
player->inventoryChanges.items.clear();
player->inventoryChanges.items.resize(count);
}
for (auto &&item : player->inventoryChanges.items)
{
RW(item.refId, send, true);
RW(item.count, send);
RW(item.charge, send);
RW(item.enchantmentCharge, send);
RW(item.soul, send, true);
}
}