diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 78d366daa..0a47e9ab4 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -202,6 +202,8 @@ namespace MWMechanics Whenever a player gains an active spell, send an ID_PLAYER_SPELLS_ACTIVE packet to the server with it */ + bool isStackingSpell = it == end() || stack; + ESM::ActiveSpells::ActiveSpellParams esmParams; esmParams.mEffects = effects; esmParams.mDisplayName = displayName; @@ -209,11 +211,11 @@ namespace MWMechanics if (this == &MWMechanics::getPlayer().getClass().getCreatureStats(MWMechanics::getPlayer()).getActiveSpells()) { - mwmp::Main::get().getLocalPlayer()->sendSpellsActiveAddition(id, esmParams); + mwmp::Main::get().getLocalPlayer()->sendSpellsActiveAddition(id, isStackingSpell, esmParams); } else if (mwmp::Main::get().getCellController()->isLocalActor(MechanicsHelper::getCurrentActor())) { - mwmp::Main::get().getCellController()->getLocalActor(MechanicsHelper::getCurrentActor())->sendSpellsActiveAddition(id, esmParams); + mwmp::Main::get().getCellController()->getLocalActor(MechanicsHelper::getCurrentActor())->sendSpellsActiveAddition(id, isStackingSpell, esmParams); } /* End of tes3mp addition diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index c45a75fa7..625593b18 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -366,7 +366,7 @@ void DedicatedActor::addSpellsActive() for (const auto& activeSpell : spellsActiveChanges.activeSpells) { // Don't do a check for a spell's existence, because active effects from potions need to be applied here too - activeSpells.addSpell(activeSpell.id, false, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1); + activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1); } reloadPtr(); diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 452e284fd..f4e9a6b90 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -491,7 +491,7 @@ void DedicatedPlayer::addSpellsActive() for (const auto& activeSpell : spellsActiveChanges.activeSpells) { // Don't do a check for a spell's existence, because active effects from potions need to be applied here too - activeSpells.addSpell(activeSpell.id, activeSpell.shouldStack, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1); + activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1); } } diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index c01a40b9f..24483527b 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -285,7 +285,7 @@ void LocalActor::sendEquipment() Main::get().getNetworking()->getActorPacket(ID_ACTOR_EQUIPMENT)->Send(); } -void LocalActor::sendSpellsActiveAddition(const std::string id, ESM::ActiveSpells::ActiveSpellParams params) +void LocalActor::sendSpellsActiveAddition(const std::string id, bool isStackingSpell, ESM::ActiveSpells::ActiveSpellParams params) { // Skip any bugged spells that somehow have clientside-only dynamic IDs if (id.find("$dynamic") != std::string::npos) @@ -295,6 +295,7 @@ void LocalActor::sendSpellsActiveAddition(const std::string id, ESM::ActiveSpell mwmp::ActiveSpell spell; spell.id = id; + spell.isStackingSpell = isStackingSpell; spell.params = params; spellsActiveChanges.activeSpells.push_back(spell); diff --git a/apps/openmw/mwmp/LocalActor.hpp b/apps/openmw/mwmp/LocalActor.hpp index bbb362430..c77deafef 100644 --- a/apps/openmw/mwmp/LocalActor.hpp +++ b/apps/openmw/mwmp/LocalActor.hpp @@ -26,7 +26,7 @@ namespace mwmp void updateAttackOrCast(); void sendEquipment(); - void sendSpellsActiveAddition(const std::string id, ESM::ActiveSpells::ActiveSpellParams params); + void sendSpellsActiveAddition(const std::string id, bool isStackingSpell, ESM::ActiveSpells::ActiveSpellParams params); void sendSpellsActiveRemoval(const std::string id); void sendDeath(char newDeathState); diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index a76b3bb5f..4b97d0617 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -719,7 +719,7 @@ void LocalPlayer::addSpellsActive() for (const auto& activeSpell : spellsActiveChanges.activeSpells) { // Don't do a check for a spell's existence, because active effects from potions need to be applied here too - activeSpells.addSpell(activeSpell.id, false, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1); + activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1); } } @@ -1589,7 +1589,7 @@ void LocalPlayer::sendSpellsActive() getNetworking()->getPlayerPacket(ID_PLAYER_SPELLS_ACTIVE)->Send(); } -void LocalPlayer::sendSpellsActiveAddition(const std::string id, ESM::ActiveSpells::ActiveSpellParams params) +void LocalPlayer::sendSpellsActiveAddition(const std::string id, bool isStackingSpell, ESM::ActiveSpells::ActiveSpellParams params) { // Skip any bugged spells that somehow have clientside-only dynamic IDs if (id.find("$dynamic") != std::string::npos) @@ -1599,6 +1599,7 @@ void LocalPlayer::sendSpellsActiveAddition(const std::string id, ESM::ActiveSpel mwmp::ActiveSpell spell; spell.id = id; + spell.isStackingSpell = isStackingSpell; spell.params = params; spellsActiveChanges.activeSpells.push_back(spell); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 1d2ee0ebb..628e9abb6 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -91,7 +91,7 @@ namespace mwmp void sendSpellbook(); void sendSpellChange(std::string id, unsigned int action); void sendSpellsActive(); - void sendSpellsActiveAddition(const std::string id, ESM::ActiveSpells::ActiveSpellParams params); + void sendSpellsActiveAddition(const std::string id, bool isStackingSpell, ESM::ActiveSpells::ActiveSpellParams params); void sendSpellsActiveRemoval(const std::string id); void sendQuickKey(unsigned short slot, int type, const std::string& itemId = ""); void sendJournalEntry(const std::string& quest, int index, const MWWorld::Ptr& actor); diff --git a/components/openmw-mp/Base/BaseStructs.hpp b/components/openmw-mp/Base/BaseStructs.hpp index 5b965693e..706c1d9ee 100644 --- a/components/openmw-mp/Base/BaseStructs.hpp +++ b/components/openmw-mp/Base/BaseStructs.hpp @@ -160,6 +160,7 @@ namespace mwmp struct ActiveSpell { std::string id; + bool isStackingSpell; ESM::ActiveSpells::ActiveSpellParams params; }; diff --git a/components/openmw-mp/Packets/Actor/PacketActorSpellsActive.cpp b/components/openmw-mp/Packets/Actor/PacketActorSpellsActive.cpp index 066c20b6b..5b823ebd5 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorSpellsActive.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorSpellsActive.cpp @@ -29,6 +29,7 @@ void PacketActorSpellsActive::Actor(BaseActor &actor, bool send) for (auto&& activeSpell : actor.spellsActiveChanges.activeSpells) { RW(activeSpell.id, send, true); + RW(activeSpell.isStackingSpell, send); RW(activeSpell.params.mDisplayName, send, true); uint32_t effectCount; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpellsActive.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSpellsActive.cpp index 585a190b1..5c7e84526 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpellsActive.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpellsActive.cpp @@ -30,6 +30,7 @@ void PacketPlayerSpellsActive::Packet(RakNet::BitStream *newBitstream, bool send for (auto&& activeSpell : player->spellsActiveChanges.activeSpells) { RW(activeSpell.id, send, true); + RW(activeSpell.isStackingSpell, send); RW(activeSpell.params.mDisplayName, send, true); uint32_t effectCount;