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

45 lines
1.1 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->inventory.action, send);
if (!send)
player->inventory.items.clear();
else
player->inventory.count = (unsigned int) (player->inventory.items.size());
RW(player->inventory.count, send);
for (int i = 0; i < player->inventory.count; i++)
{
Item item;
if (send)
{
item = player->inventory.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->inventory.items.push_back(item);
}
}
}