1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 06:19:55 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketInventory.cpp

49 lines
1.2 KiB
C++
Raw Normal View History

//
// Created by koncord on 22.10.16.
//
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketInventory.hpp"
using namespace std;
using namespace mwmp;
2016-10-23 06:05:12 +00:00
PacketInventory::PacketInventory(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_INVENTORY;
}
void PacketInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
2016-10-23 06:05:12 +00:00
PlayerPacket::Packet(bs, player, send);
RW(player->inventoryChanges.action, send);
if (!send)
player->inventoryChanges.items.clear();
else
player->inventoryChanges.count = (unsigned int) (player->inventoryChanges.items.size());
2016-11-21 21:40:50 +00:00
RW(player->inventoryChanges.count, send);
2016-11-21 21:40:50 +00:00
for (unsigned int i = 0; i < player->inventoryChanges.count; i++)
{
Item item;
if (send)
{
item = player->inventoryChanges.items[i];
RW(item.refid, send);
RW(item.count, send);
RW(item.health, send);
}
else
{
RW(item.refid, send);
RW(item.count, send);
RW(item.health, send);
player->inventoryChanges.items.push_back(item);
}
}
}