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.
44 lines
991 B
C++
44 lines
991 B
C++
#include "PacketPlayerSkill.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include <components/esm/creaturestats.hpp>
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketPlayerSkill::PacketPlayerSkill(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
{
|
|
packetID = ID_PLAYER_SKILL;
|
|
}
|
|
|
|
void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
PlayerPacket::Packet(bs, send);
|
|
|
|
RW(player->exchangeFullInfo, send);
|
|
|
|
if (player->exchangeFullInfo)
|
|
{
|
|
RW(player->npcStats.mSkills, send);
|
|
}
|
|
else
|
|
{
|
|
uint32_t count;
|
|
|
|
if (send)
|
|
count = static_cast<uint32_t>(player->skillIndexChanges.size());
|
|
|
|
RW(count, send);
|
|
|
|
if (!send)
|
|
{
|
|
player->skillIndexChanges.clear();
|
|
player->skillIndexChanges.resize(count);
|
|
}
|
|
|
|
for (auto &&skillId : player->skillIndexChanges)
|
|
{
|
|
RW(skillId, send);
|
|
RW(player->npcStats.mSkills[skillId], send);
|
|
}
|
|
}
|
|
}
|