forked from mirror/openmw-tes3mp
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.
44 lines
1 KiB
C++
44 lines
1 KiB
C++
#include "PacketPlayerStatsDynamic.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketPlayerStatsDynamic::PacketPlayerStatsDynamic(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
{
|
|
packetID = ID_PLAYER_STATS_DYNAMIC;
|
|
}
|
|
|
|
void PacketPlayerStatsDynamic::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
PlayerPacket::Packet(bs, send);
|
|
|
|
RW(player->exchangeFullInfo, send);
|
|
|
|
if (player->exchangeFullInfo)
|
|
{
|
|
RW(player->creatureStats.mDynamic, send);
|
|
}
|
|
else
|
|
{
|
|
uint32_t count;
|
|
|
|
if (send)
|
|
count = static_cast<uint32_t>(player->statsDynamicIndexChanges.size());
|
|
|
|
RW(count, send);
|
|
|
|
if (!send)
|
|
{
|
|
player->statsDynamicIndexChanges.clear();
|
|
player->statsDynamicIndexChanges.resize(count);
|
|
}
|
|
|
|
for (auto &&statsDynamicIndex : player->statsDynamicIndexChanges)
|
|
{
|
|
RW(statsDynamicIndex, send);
|
|
|
|
RW(player->creatureStats.mDynamic[statsDynamicIndex], send);
|
|
}
|
|
}
|
|
}
|