#include "PacketPlayerSpellsActive.hpp" #include using namespace mwmp; PacketPlayerSpellsActive::PacketPlayerSpellsActive(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) { packetID = ID_PLAYER_SPELLS_ACTIVE; } void PacketPlayerSpellsActive::Packet(RakNet::BitStream *newBitstream, bool send) { PlayerPacket::Packet(newBitstream, send); RW(player->spellsActiveChanges.action, send); uint32_t count; if (send) count = static_cast(player->spellsActiveChanges.activeSpells.size()); RW(count, send); 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(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); } } }