forked from mirror/openmw-tes3mp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
8 years ago
|
//
|
||
|
// Created by koncord on 22.10.16.
|
||
|
//
|
||
|
|
||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||
8 years ago
|
#include "PacketPlayerInventory.hpp"
|
||
8 years ago
|
|
||
|
using namespace std;
|
||
|
using namespace mwmp;
|
||
|
|
||
8 years ago
|
PacketPlayerInventory::PacketPlayerInventory(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||
8 years ago
|
{
|
||
8 years ago
|
packetID = ID_PLAYER_INVENTORY;
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
void PacketPlayerInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
||
8 years ago
|
{
|
||
8 years ago
|
PlayerPacket::Packet(bs, player, send);
|
||
8 years ago
|
|
||
8 years ago
|
RW(player->inventoryChanges.action, send);
|
||
8 years ago
|
|
||
8 years ago
|
if (!send)
|
||
8 years ago
|
player->inventoryChanges.items.clear();
|
||
8 years ago
|
else
|
||
8 years ago
|
player->inventoryChanges.count = (unsigned int) (player->inventoryChanges.items.size());
|
||
8 years ago
|
|
||
8 years ago
|
RW(player->inventoryChanges.count, send);
|
||
8 years ago
|
|
||
8 years ago
|
for (unsigned int i = 0; i < player->inventoryChanges.count; i++)
|
||
8 years ago
|
{
|
||
|
Item item;
|
||
8 years ago
|
|
||
8 years ago
|
if (send)
|
||
|
{
|
||
8 years ago
|
item = player->inventoryChanges.items[i];
|
||
8 years ago
|
RW(item.refId, send);
|
||
8 years ago
|
RW(item.count, send);
|
||
|
RW(item.health, send);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
8 years ago
|
RW(item.refId, send);
|
||
8 years ago
|
RW(item.count, send);
|
||
|
RW(item.health, send);
|
||
8 years ago
|
player->inventoryChanges.items.push_back(item);
|
||
8 years ago
|
}
|
||
|
}
|
||
|
}
|