mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 02:19:55 +00:00
b6099024df
Previously, whenever a single attribute value changed for a player, that player then sent a PlayerAttribute packet with all values for all 8 attributes.
This did not cause anywhere as much packet spam as PlayerSkill used to, but there was no good reason not to fix it as well.
(cherry picked from commit b0965f094a
)
35 lines
964 B
C++
35 lines
964 B
C++
#include "PacketPlayerAttribute.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketPlayerAttribute::PacketPlayerAttribute(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
{
|
|
packetID = ID_PLAYER_ATTRIBUTE;
|
|
}
|
|
|
|
void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
PlayerPacket::Packet(bs, send);
|
|
|
|
if (send)
|
|
player->attributeChanges.count = (unsigned int)(player->attributeChanges.attributeIndexes.size());
|
|
else
|
|
player->attributeChanges.attributeIndexes.clear();
|
|
|
|
RW(player->attributeChanges.count, send);
|
|
|
|
for (unsigned int i = 0; i < player->attributeChanges.count; i++)
|
|
{
|
|
int attributeId;
|
|
|
|
if (send)
|
|
attributeId = player->attributeChanges.attributeIndexes.at(i);
|
|
|
|
RW(attributeId, send);
|
|
|
|
RW(player->creatureStats.mAttributes[attributeId], send);
|
|
RW(player->npcStats.mSkillIncrease[attributeId], send);
|
|
}
|
|
}
|