2016-11-21 00:28:05 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-02-05 07:01:33 +00:00
|
|
|
#include "PacketPlayerSpellbook.hpp"
|
2016-11-21 00:28:05 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
PacketPlayerSpellbook::PacketPlayerSpellbook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-11-21 00:28:05 +00:00
|
|
|
{
|
2017-02-05 07:01:33 +00:00
|
|
|
packetID = ID_PLAYER_SPELLBOOK;
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
|
2016-11-21 00:28:05 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
PlayerPacket::Packet(bs, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
RW(player->spellbookChanges.action, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
uint32_t changesCount;
|
|
|
|
|
2017-05-24 19:09:35 +00:00
|
|
|
if (send)
|
2017-11-28 13:37:46 +00:00
|
|
|
changesCount = static_cast<uint32_t>(player->spellbookChanges.spells.size());
|
2016-11-21 21:40:50 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
RW(changesCount, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-11-29 11:00:22 +00:00
|
|
|
if (!send)
|
2016-11-21 04:07:29 +00:00
|
|
|
{
|
2017-11-28 13:37:46 +00:00
|
|
|
player->spellbookChanges.spells.clear();
|
|
|
|
player->spellbookChanges.spells.resize(changesCount);
|
|
|
|
}
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
for (auto &&spell : player->spellbookChanges.spells)
|
|
|
|
{
|
2017-02-05 12:56:27 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
RW(spell.mId, send, true);
|
2017-02-05 12:56:27 +00:00
|
|
|
|
2017-11-29 11:00:22 +00:00
|
|
|
if (spell.mId.find("$dynamic") != string::npos)
|
2017-07-30 17:45:47 +00:00
|
|
|
{
|
2017-11-28 13:37:46 +00:00
|
|
|
RW(spell.mName, send, true);
|
2017-07-30 17:45:47 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
RW(spell.mData.mType, send, true);
|
|
|
|
RW(spell.mData.mCost, send, true);
|
|
|
|
RW(spell.mData.mFlags, send, true);
|
2017-07-30 17:45:47 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
uint32_t effectCount;
|
2017-07-30 17:45:47 +00:00
|
|
|
if (send)
|
2017-11-28 13:37:46 +00:00
|
|
|
effectCount = static_cast<uint32_t>(spell.mEffects.mList.size());
|
2017-07-30 17:45:47 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
RW(effectCount, send, true);
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
spell.mEffects.mList.resize(effectCount);
|
|
|
|
}
|
2017-07-30 17:45:47 +00:00
|
|
|
|
2017-11-28 13:37:46 +00:00
|
|
|
for (auto &&effect : spell.mEffects.mList)
|
2017-07-30 17:45:47 +00:00
|
|
|
{
|
2017-11-28 13:37:46 +00:00
|
|
|
|
|
|
|
RW(effect.mEffectID, send, true);
|
|
|
|
RW(effect.mSkill, send, true);
|
|
|
|
RW(effect.mAttribute, send, true);
|
|
|
|
RW(effect.mRange, send, true);
|
|
|
|
RW(effect.mArea, send, true);
|
|
|
|
RW(effect.mDuration, send, true);
|
|
|
|
RW(effect.mMagnMin, send, true);
|
|
|
|
RW(effect.mMagnMax, send, true);
|
2017-07-30 17:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-21 04:07:29 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|