2017-02-05 07:01:33 +00:00
|
|
|
#include "PacketPlayerEquipment.hpp"
|
2018-04-26 18:56:14 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
PacketPlayerEquipment::PacketPlayerEquipment(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-02-05 07:01:33 +00:00
|
|
|
packetID = ID_PLAYER_EQUIPMENT;
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 08:17:33 +00:00
|
|
|
void PacketPlayerEquipment::Packet(RakNet::BitStream *newBitstream, bool send)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
PlayerPacket::Packet(newBitstream, send);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->exchangeFullInfo, send);
|
2018-04-20 19:46:16 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
if (player->exchangeFullInfo)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2018-04-26 18:56:14 +00:00
|
|
|
for (auto &&equipmentItem : player->equipmentItems)
|
|
|
|
{
|
|
|
|
ExchangeItemInformation(equipmentItem, send);
|
|
|
|
}
|
2018-04-20 19:46:16 +00:00
|
|
|
}
|
2018-04-26 18:56:14 +00:00
|
|
|
else
|
2018-04-20 19:46:16 +00:00
|
|
|
{
|
2018-04-26 18:56:14 +00:00
|
|
|
uint32_t count;
|
|
|
|
if (send)
|
|
|
|
count = static_cast<uint32_t>(player->equipmentIndexChanges.size());
|
|
|
|
|
|
|
|
RW(count, send);
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
player->equipmentIndexChanges.clear();
|
|
|
|
player->equipmentIndexChanges.resize(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &&equipmentIndex : player->equipmentIndexChanges)
|
|
|
|
{
|
|
|
|
RW(equipmentIndex, send);
|
|
|
|
ExchangeItemInformation(player->equipmentItems[equipmentIndex], send);
|
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-26 18:56:14 +00:00
|
|
|
|
|
|
|
void PacketPlayerEquipment::ExchangeItemInformation(Item &item, bool send)
|
|
|
|
{
|
2018-07-27 22:50:44 +00:00
|
|
|
RW(item.refId, send, true);
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(item.count, send);
|
|
|
|
RW(item.charge, send);
|
|
|
|
RW(item.enchantmentCharge, send);
|
|
|
|
}
|
|
|
|
|