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-05-24 19:09:35 +00:00
|
|
|
if (send)
|
2017-01-20 10:43:05 +00:00
|
|
|
player->spellbookChanges.count = (unsigned int) (player->spellbookChanges.spells.size());
|
2017-05-24 19:09:35 +00:00
|
|
|
else
|
|
|
|
player->spellbookChanges.spells.clear();
|
2016-11-21 21:40:50 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
RW(player->spellbookChanges.count, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
for (unsigned int i = 0; i < player->spellbookChanges.count; i++)
|
2016-11-21 04:07:29 +00:00
|
|
|
{
|
2016-12-29 13:19:26 +00:00
|
|
|
ESM::Spell spell;
|
2016-11-21 04:07:29 +00:00
|
|
|
|
|
|
|
if (send)
|
2017-02-05 17:01:06 +00:00
|
|
|
spell = player->spellbookChanges.spells.at(i);
|
2017-02-05 12:56:27 +00:00
|
|
|
|
2017-06-02 18:23:23 +00:00
|
|
|
RW(spell.mId, send, 1);
|
2017-02-05 12:56:27 +00:00
|
|
|
|
2017-07-30 17:45:47 +00:00
|
|
|
if(spell.mId.find("$dynamic") != string::npos)
|
|
|
|
{
|
|
|
|
RW(spell.mName, send, 1);
|
|
|
|
|
|
|
|
RW(spell.mData.mType, send, 1);
|
|
|
|
RW(spell.mData.mCost, send, 1);
|
|
|
|
RW(spell.mData.mFlags, send, 1);
|
|
|
|
|
|
|
|
int effectCount = 0;
|
|
|
|
if (send)
|
|
|
|
effectCount = spell.mEffects.mList.size();
|
|
|
|
|
|
|
|
RW(effectCount, send, 1);
|
|
|
|
|
|
|
|
for (unsigned int j = 0; j < effectCount; j++)
|
|
|
|
{
|
|
|
|
ESM::ENAMstruct effect;
|
|
|
|
if (send)
|
|
|
|
effect = spell.mEffects.mList.at(j);
|
|
|
|
|
|
|
|
RW(effect.mEffectID, send, 1);
|
|
|
|
RW(effect.mSkill, send, 1);
|
|
|
|
RW(effect.mAttribute, send, 1);
|
|
|
|
RW(effect.mRange, send, 1);
|
|
|
|
RW(effect.mArea, send, 1);
|
|
|
|
RW(effect.mDuration, send, 1);
|
|
|
|
RW(effect.mMagnMin, send, 1);
|
|
|
|
RW(effect.mMagnMax, send, 1);
|
|
|
|
|
|
|
|
if(!send)
|
|
|
|
spell.mEffects.mList.push_back(effect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-05 12:56:27 +00:00
|
|
|
if (!send)
|
2017-01-20 10:43:05 +00:00
|
|
|
player->spellbookChanges.spells.push_back(spell);
|
2016-11-21 04:07:29 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|