mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 05:53:50 +00:00
66d5109509
Previously, two players entering the same cell only sent and received their latest changes for dynamic stats, attributes, skills and equipment when they started sharing that cell.
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#include "PacketPlayerEquipment.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketPlayerEquipment::PacketPlayerEquipment(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
{
|
|
packetID = ID_PLAYER_EQUIPMENT;
|
|
}
|
|
|
|
void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
PlayerPacket::Packet(bs, send);
|
|
|
|
RW(player->exchangeFullInfo, send);
|
|
|
|
if (player->exchangeFullInfo)
|
|
{
|
|
for (auto &&equipmentItem : player->equipmentItems)
|
|
{
|
|
ExchangeItemInformation(equipmentItem, send);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
void PacketPlayerEquipment::ExchangeItemInformation(Item &item, bool send)
|
|
{
|
|
RW(item.refId, send);
|
|
RW(item.count, send);
|
|
RW(item.charge, send);
|
|
RW(item.enchantmentCharge, send);
|
|
}
|
|
|