1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-24 21:23:51 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerSpellsActive.cpp

63 lines
1.6 KiB
C++
Raw Normal View History

#include "PacketPlayerSpellsActive.hpp"
2016-12-03 15:38:14 +00:00
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketPlayerSpellsActive::PacketPlayerSpellsActive(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
2016-12-03 15:38:14 +00:00
{
packetID = ID_PLAYER_SPELLS_ACTIVE;
2016-12-03 15:38:14 +00:00
}
void PacketPlayerSpellsActive::Packet(RakNet::BitStream *newBitstream, bool send)
2016-12-03 15:38:14 +00:00
{
PlayerPacket::Packet(newBitstream, send);
2016-12-03 15:38:14 +00:00
RW(player->spellsActiveChanges.action, send);
uint32_t count;
2016-12-03 15:38:14 +00:00
if (send)
count = static_cast<uint32_t>(player->spellsActiveChanges.activeSpells.size());
2016-12-03 15:38:14 +00:00
RW(count, send);
2016-12-03 15:38:14 +00:00
if (!send)
{
player->spellsActiveChanges.activeSpells.clear();
player->spellsActiveChanges.activeSpells.resize(count);
}
for (auto&& activeSpell : player->spellsActiveChanges.activeSpells)
{
RW(activeSpell.id, send, true);
RW(activeSpell.params.mDisplayName, send, true);
uint32_t effectCount;
if (send)
effectCount = static_cast<uint32_t>(activeSpell.params.mEffects.size());
2016-12-03 15:38:14 +00:00
RW(effectCount, send);
2016-12-03 15:38:14 +00:00
if (effectCount > maxEffects)
{
return;
2016-12-03 15:38:14 +00:00
}
if (!send)
{
activeSpell.params.mEffects.clear();
activeSpell.params.mEffects.resize(effectCount);
}
for (auto&& effect : activeSpell.params.mEffects)
2016-12-03 15:38:14 +00:00
{
RW(effect.mEffectId, send);
RW(effect.mArg, send);
RW(effect.mMagnitude, send);
RW(effect.mDuration, send);
RW(effect.mTimeLeft, send);
2016-12-03 15:38:14 +00:00
}
}
}