2020-01-26 10:47:49 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <components/openmw-mp/TimedLog.hpp>
|
|
|
|
#include "PacketActorSpellsActive.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
|
|
|
PacketActorSpellsActive::PacketActorSpellsActive(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_ACTOR_SPELLS_ACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketActorSpellsActive::Actor(BaseActor &actor, bool send)
|
|
|
|
{
|
2021-04-20 01:25:14 +00:00
|
|
|
RW(actor.spellsActiveChanges.action, send);
|
|
|
|
|
|
|
|
uint32_t count;
|
|
|
|
|
|
|
|
if (send)
|
|
|
|
count = static_cast<uint32_t>(actor.spellsActiveChanges.activeSpells.size());
|
|
|
|
|
|
|
|
RW(count, send);
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
actor.spellsActiveChanges.activeSpells.clear();
|
|
|
|
actor.spellsActiveChanges.activeSpells.resize(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto&& activeSpell : actor.spellsActiveChanges.activeSpells)
|
|
|
|
{
|
|
|
|
RW(activeSpell.id, send, true);
|
2021-06-10 11:27:52 +00:00
|
|
|
RW(activeSpell.isStackingSpell, send);
|
2021-04-20 01:25:14 +00:00
|
|
|
RW(activeSpell.params.mDisplayName, send, true);
|
|
|
|
|
|
|
|
uint32_t effectCount;
|
|
|
|
|
|
|
|
if (send)
|
|
|
|
effectCount = static_cast<uint32_t>(activeSpell.params.mEffects.size());
|
|
|
|
|
|
|
|
RW(effectCount, send);
|
|
|
|
|
|
|
|
if (effectCount > maxEffects)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
activeSpell.params.mEffects.clear();
|
|
|
|
activeSpell.params.mEffects.resize(effectCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto&& effect : activeSpell.params.mEffects)
|
|
|
|
{
|
|
|
|
RW(effect.mEffectId, send);
|
|
|
|
RW(effect.mArg, send);
|
|
|
|
RW(effect.mMagnitude, send);
|
|
|
|
RW(effect.mDuration, send);
|
|
|
|
RW(effect.mTimeLeft, send);
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 10:47:49 +00:00
|
|
|
}
|