|
|
|
@ -11,7 +11,7 @@ unsigned int SpellFunctions::GetSpellbookSize(unsigned short pid) noexcept
|
|
|
|
|
Player *player;
|
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
|
|
return player->spellbook.size();
|
|
|
|
|
return player->packetSpells.count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
|
|
|
|
@ -47,26 +47,15 @@ void SpellFunctions::ClearSpellbook(unsigned short pid) noexcept
|
|
|
|
|
player->packetSpellsBuffer.action = PacketSpells::UPDATE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SpellFunctions::HasSpell(unsigned short pid, const char* spellId)
|
|
|
|
|
{
|
|
|
|
|
Player *player;
|
|
|
|
|
GET_PLAYER(pid, player, false);
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < player->spellbook.size(); i++)
|
|
|
|
|
if (Misc::StringUtils::ciEqual(player->spellbook.at(i).mId, spellId))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept
|
|
|
|
|
{
|
|
|
|
|
Player *player;
|
|
|
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
|
|
|
|
|
|
if (i >= player->spellbook.size())
|
|
|
|
|
if (i >= player->packetSpells.count)
|
|
|
|
|
return "invalid";
|
|
|
|
|
|
|
|
|
|
return player->spellbook.at(i).mId.c_str();
|
|
|
|
|
return player->packetSpells.spells.at(i).mId.c_str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellFunctions::SendSpells(unsigned short pid) noexcept
|
|
|
|
@ -74,15 +63,6 @@ void SpellFunctions::SendSpells(unsigned short pid) noexcept
|
|
|
|
|
Player *player;
|
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
|
|
for (auto spell : player->packetSpellsBuffer.spells)
|
|
|
|
|
{
|
|
|
|
|
if (player->packetSpellsBuffer.action == PacketSpells::ADD)
|
|
|
|
|
player->spellbook.push_back(spell);
|
|
|
|
|
else if (player->packetSpells.action == PacketSpells::REMOVE)
|
|
|
|
|
player->spellbook.erase(remove_if(player->spellbook.begin(), player->spellbook.end(), [&spell](ESM::Spell s)->bool
|
|
|
|
|
{return spell.mId == s.mId; }), player->spellbook.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::swap(player->packetSpells, player->packetSpellsBuffer);
|
|
|
|
|
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_SPELLBOOK)->Send(player, false);
|
|
|
|
|
player->packetSpells = std::move(player->packetSpellsBuffer);
|
|
|
|
|