diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index b238b9081..489ff7887 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -172,7 +172,7 @@ namespace MWGui Send an ID_PLAYER_SPELLBOOK packet every time a player buys a spell */ - mwmp::Main::get().getLocalPlayer()->sendSpellAddition(mSpellsWidgetMap.find(_sender)->second); + mwmp::Main::get().getLocalPlayer()->sendSpellChange(mSpellsWidgetMap.find(_sender)->second, mwmp::SpellbookChanges::ADD); /* End of tes3mp addition */ diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index 295ecde53..15b8f756e 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -229,7 +229,7 @@ namespace MWGui Send an ID_PLAYER_SPELLBOOK packet every time a player deletes one of their spells */ - mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(mSpellToDelete); + mwmp::Main::get().getLocalPlayer()->sendSpellChange(mSpellToDelete, mwmp::SpellbookChanges::REMOVE); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 1b3c12d24..6c4763f58 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1425,9 +1425,10 @@ void LocalPlayer::sendCellStates() getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send(); } -void LocalPlayer::sendSpellAddition(std::string id) +void LocalPlayer::sendSpellChange(std::string id, unsigned int action) { - if (id.find("$dynamic") != string::npos) // skip custom spells + // Skip any bugged spells that somehow have clientside-only dynamic IDs + if (id.find("$dynamic") != string::npos) return; spellbookChanges.spells.clear(); @@ -1436,23 +1437,7 @@ void LocalPlayer::sendSpellAddition(std::string id) spell.mId = id; spellbookChanges.spells.push_back(spell); - spellbookChanges.action = SpellbookChanges::ADD; - getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this); - getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(); -} - -void LocalPlayer::sendSpellRemoval(std::string id) -{ - if (id.find("$dynamic") != string::npos) // skip custom spells - return; - - spellbookChanges.spells.clear(); - - ESM::Spell spell; - spell.mId = id; - spellbookChanges.spells.push_back(spell); - - spellbookChanges.action = SpellbookChanges::REMOVE; + spellbookChanges.action = action; getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(); } diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index a96fa0c4c..43670001a 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -73,8 +73,7 @@ namespace mwmp void sendInventory(); void sendSpellbook(); void sendCellStates(); - void sendSpellAddition(std::string id); - void sendSpellRemoval(std::string id); + void sendSpellChange(std::string id, unsigned int action); void sendQuickKey(unsigned short slot, int type, const std::string& itemId = ""); void sendJournalEntry(const std::string& quest, int index, const MWWorld::Ptr& actor); void sendJournalIndex(const std::string& quest, int index); diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 32b25ba69..fd688fd4b 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -479,7 +479,7 @@ namespace MWScript through a script */ if (ptr == MWMechanics::getPlayer()) - mwmp::Main::get().getLocalPlayer()->sendSpellAddition(id); + mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::ADD); /* End of tes3mp addition */ @@ -515,7 +515,7 @@ namespace MWScript through a script */ if (ptr == MWMechanics::getPlayer()) - mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(id); + mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::REMOVE); /* End of tes3mp addition */