2020-01-26 08:58:22 +00:00
|
|
|
#include "PacketPlayerSpellsActive.hpp"
|
2016-12-03 15:38:14 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2020-01-26 08:58:22 +00:00
|
|
|
PacketPlayerSpellsActive::PacketPlayerSpellsActive(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-12-03 15:38:14 +00:00
|
|
|
{
|
2020-01-26 08:58:22 +00:00
|
|
|
packetID = ID_PLAYER_SPELLS_ACTIVE;
|
2016-12-03 15:38:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 08:58:22 +00:00
|
|
|
void PacketPlayerSpellsActive::Packet(RakNet::BitStream *newBitstream, bool send)
|
2016-12-03 15:38:14 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
PlayerPacket::Packet(newBitstream, send);
|
2016-12-03 15:38:14 +00:00
|
|
|
|
2020-07-10 00:09:11 +00:00
|
|
|
RW(player->spellsActiveChanges.action, send);
|
|
|
|
|
|
|
|
uint32_t count;
|
2016-12-03 15:38:14 +00:00
|
|
|
|
|
|
|
if (send)
|
2020-07-10 00:09:11 +00:00
|
|
|
count = static_cast<uint32_t>(player->spellsActiveChanges.activeSpells.size());
|
2016-12-03 15:38:14 +00:00
|
|
|
|
2020-07-10 00:09:11 +00:00
|
|
|
RW(count, send);
|
2016-12-03 15:38:14 +00:00
|
|
|
|
2020-07-10 00:09:11 +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
|
|
|
|
2020-07-10 00:09:11 +00:00
|
|
|
RW(effectCount, send);
|
2016-12-03 15:38:14 +00:00
|
|
|
|
2020-07-10 00:09:11 +00:00
|
|
|
if (effectCount > maxEffects)
|
|
|
|
{
|
|
|
|
return;
|
2016-12-03 15:38:14 +00:00
|
|
|
}
|
2020-07-10 00:09:11 +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
|
|
|
{
|
2020-07-10 00:09:11 +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
|
|
|
}
|
2020-07-10 00:09:11 +00:00
|
|
|
}
|
2017-01-26 04:17:29 +00:00
|
|
|
}
|