1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-25 04:23:50 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerSpellsActive.cpp
David Cernat 36a2308acd Add OpenMW commits up to 30 May 2020
# Conflicts:
#	CMakeLists.txt
#	apps/openmw/mwbase/windowmanager.hpp
#	apps/openmw/mwgui/windowmanagerimp.hpp
#	apps/openmw/mwmechanics/actors.cpp
#	apps/openmw/mwmechanics/actors.hpp
#	apps/openmw/mwscript/interpretercontext.cpp
2020-06-09 17:50:26 +03:00

54 lines
1.6 KiB
C++

#include "PacketPlayerSpellsActive.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
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);
uint32_t spells = 0;
if (send)
spells = player->activeSpells.mSpells.size();
RW(spells, send);
if (send)
for (ESM::ActiveSpells::TContainer::const_iterator spell = player->activeSpells.mSpells.begin();
spell != player->activeSpells.mSpells.end(); ++spell)
{
RW(spell->first, true);
//RW(spell->second.mTimeStamp, true);
uint32_t effects = spell->second.mEffects.size();
RW(effects, true);
for (std::vector<ESM::ActiveEffect>::const_iterator effect = spell->second.mEffects.begin();
effect != spell->second.mEffects.end(); ++effect)
RW(effect, true);
}
else
for (uint32_t i = 0; i < spells; i++)
{
ESM::ActiveSpells::TContainer::value_type spell;
RW(spell.first, false);
//RW(spell.second.mTimeStamp, false);
uint32_t effects;
RW(effects, false);
ESM::ActiveEffect effect;
for (uint32_t j = 0; j < effects; j++)
{
RW(effect, false);
spell.second.mEffects.push_back(effect);
}
player->activeSpells.mSpells.insert(spell);
}
}