1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-22 10:53:53 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerSkill.cpp
David Cernat ef79a98544 [General] Rework PlayerSkill packets so they are of minimal size
Previously, whenever a single skill value changed for a player, that player then sent a PlayerSkill packet with all values for all 27 skills, plus the player's progress towards the next level and the bonuses to each attribute on the next level up as the result of sklll increases thus far.

This commit makes PlayerSkill contain only the values of specific skills, moves the player's progress towards the next level to PlayerLevel packets, and moves the bonuses to each attribute on the next level up to PlayerAttribute packets.

Players now also send a PlayerSkill packet whenever their progress towards a new point in a skill changes. This was previously avoided so as to not have massive packet spam.
2017-11-24 12:38:42 +02:00

38 lines
912 B
C++

//
// Created by koncord on 17.03.16.
//
#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);
if (send)
player->skillChanges.count = (unsigned int)(player->skillChanges.skillIndexes.size());
else
player->skillChanges.skillIndexes.clear();
RW(player->skillChanges.count, send);
for (unsigned int i = 0; i < player->skillChanges.count; i++)
{
int skillId;
if (send)
skillId = player->skillChanges.skillIndexes.at(i);
RW(skillId, send);
RW(player->npcStats.mSkills[skillId], send);
}
}