diff --git a/apps/openmw-mp/Script/Functions/Books.hpp b/apps/openmw-mp/Script/Functions/Books.hpp index 9fb2672ff..3c1b7e89d 100644 --- a/apps/openmw-mp/Script/Functions/Books.hpp +++ b/apps/openmw-mp/Script/Functions/Books.hpp @@ -38,7 +38,7 @@ public: * \brief Add a new book to the book changes for a player. * * \param pid The player ID whose book changes should be used. - * \param topicId The bookId of the book. + * \param bookId The bookId of the book. * \return void */ static void AddBook(unsigned short pid, const char* bookId) noexcept; diff --git a/apps/openmw-mp/Script/Functions/Spells.cpp b/apps/openmw-mp/Script/Functions/Spells.cpp index 248a44195..2375fe591 100644 --- a/apps/openmw-mp/Script/Functions/Spells.cpp +++ b/apps/openmw-mp/Script/Functions/Spells.cpp @@ -12,7 +12,6 @@ void SpellFunctions::InitializeSpellbookChanges(unsigned short pid) noexcept GET_PLAYER(pid, player, ); player->spellbookChanges.spells.clear(); - player->spellbookChanges.action = SpellbookChanges::SET; } unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcept @@ -23,7 +22,7 @@ unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcep return player->spellbookChanges.count; } -unsigned int SpellFunctions::GetSpellbookAction(unsigned short pid) noexcept +unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -31,6 +30,14 @@ unsigned int SpellFunctions::GetSpellbookAction(unsigned short pid) noexcept return player->spellbookChanges.action; } +void SpellFunctions::SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->spellbookChanges.action = action; +} + void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept { Player *player; @@ -40,19 +47,6 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept spell.mId = spellId; player->spellbookChanges.spells.push_back(spell); - player->spellbookChanges.action = SpellbookChanges::ADD; -} - -void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexcept -{ - Player *player; - GET_PLAYER(pid, player, ); - - ESM::Spell spell; - spell.mId = spellId; - - player->spellbookChanges.spells.push_back(spell); - player->spellbookChanges.action = SpellbookChanges::REMOVE; } const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept diff --git a/apps/openmw-mp/Script/Functions/Spells.hpp b/apps/openmw-mp/Script/Functions/Spells.hpp index 1ce9c5a5a..bf3e1d307 100644 --- a/apps/openmw-mp/Script/Functions/Spells.hpp +++ b/apps/openmw-mp/Script/Functions/Spells.hpp @@ -5,10 +5,10 @@ {"InitializeSpellbookChanges", SpellFunctions::InitializeSpellbookChanges},\ \ {"GetSpellbookChangesSize", SpellFunctions::GetSpellbookChangesSize},\ - {"GetSpellbookAction", SpellFunctions::GetSpellbookAction},\ + {"GetSpellbookChangesAction", SpellFunctions::GetSpellbookChangesAction},\ \ + {"SetSpellbookChangesAction", SpellFunctions::SetSpellbookChangesAction},\ {"AddSpell", SpellFunctions::AddSpell},\ - {"RemoveSpell", SpellFunctions::RemoveSpell},\ \ {"GetSpellId", SpellFunctions::GetSpellId},\ \ @@ -42,13 +42,19 @@ public: * \param pid The player ID whose faction changes should be used. * \return The action type (0 for SET, 1 for ADD, 2 for REMOVE). */ - static unsigned int GetSpellbookAction(unsigned short pid) noexcept; + static unsigned int GetSpellbookChangesAction(unsigned short pid) noexcept; /** - * \brief Prepare the addition of a spell to a player. + * \brief Set the action type in a player's spellbook changes. * - * In practice, this changes the action type of the PlayerSpellbook packet to - * ADD and adds this spell to it. + * \param pid The player ID whose spellbook changes should be used. + * \param action The action (0 for SET, 1 for ADD, 2 for REMOVE). + * \return void + */ + static void SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept; + + /** + * \brief Add a new spell to the spellbook changes for a player. * * \param pid The player ID whose spellbook changes should be used. * \param topicId The spellId of the spell. @@ -56,18 +62,6 @@ public: */ static void AddSpell(unsigned short pid, const char* spellId) noexcept; - /** - * \brief Prepare the removal of a spell from a player. - * - * In practice, this changes the action type of the PlayerSpellbook packet to - * REMOVE and adds this spell to it. - * - * \param pid The player ID whose spellbook changes should be used. - * \param topicId The spellId of the spell. - * \return void - */ - static void RemoveSpell(unsigned short pid, const char* spellId) noexcept; - /** * \brief Get the spellId at a certain index in a player's latest spellbook changes. *