diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 800295318..46be0a48e 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -178,10 +178,12 @@ namespace MWMechanics /* Start of tes3mp change (major) - Add a timestamp argument so spells received from other clients can have the same timestamps they had there + Add a timestamp argument so spells received from other clients can have the same timestamps they had there, + as well as a sendPacket argument used to prevent packets from being sent back to the server when we've just + received them from it */ void ActiveSpells::addSpell(const std::string &id, bool stack, std::vector effects, - const std::string &displayName, int casterActorId, MWWorld::TimeStamp timestamp) + const std::string &displayName, int casterActorId, MWWorld::TimeStamp timestamp, bool sendPacket) /* End of tes3mp change (major) */ @@ -220,22 +222,26 @@ namespace MWMechanics /* Start of tes3mp addition - Whenever a player gains an active spell, send an ID_PLAYER_SPELLS_ACTIVE packet to the server with it + Whenever a player gains an active spell as a result of gameplay, 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; - esmParams.mCasterActorId = casterActorId; - - if (this == &MWMechanics::getPlayer().getClass().getCreatureStats(MWMechanics::getPlayer()).getActiveSpells()) + if (sendPacket) { - mwmp::Main::get().getLocalPlayer()->sendSpellsActiveAddition(id, isStackingSpell, esmParams, params.mTimeStamp); - } - else if (mwmp::Main::get().getCellController()->isLocalActor(MechanicsHelper::getCurrentActor())) - { - mwmp::Main::get().getCellController()->getLocalActor(MechanicsHelper::getCurrentActor())->sendSpellsActiveAddition(id, isStackingSpell, esmParams, params.mTimeStamp); + bool isStackingSpell = it == end() || stack; + + ESM::ActiveSpells::ActiveSpellParams esmParams; + esmParams.mEffects = effects; + esmParams.mDisplayName = displayName; + esmParams.mCasterActorId = casterActorId; + + if (this == &MWMechanics::getPlayer().getClass().getCreatureStats(MWMechanics::getPlayer()).getActiveSpells()) + { + mwmp::Main::get().getLocalPlayer()->sendSpellsActiveAddition(id, isStackingSpell, esmParams, params.mTimeStamp); + } + else if (mwmp::Main::get().getCellController()->isLocalActor(MechanicsHelper::getCurrentActor())) + { + mwmp::Main::get().getCellController()->getLocalActor(MechanicsHelper::getCurrentActor())->sendSpellsActiveAddition(id, isStackingSpell, esmParams, params.mTimeStamp); + } } /* End of tes3mp addition diff --git a/apps/openmw/mwmechanics/activespells.hpp b/apps/openmw/mwmechanics/activespells.hpp index dedec5f68..0d4fd78e7 100644 --- a/apps/openmw/mwmechanics/activespells.hpp +++ b/apps/openmw/mwmechanics/activespells.hpp @@ -83,7 +83,7 @@ namespace MWMechanics Add a separate addSpell() with a timestamp argument */ void addSpell (const std::string& id, bool stack, std::vector effects, - const std::string& displayName, int casterActorId, MWWorld::TimeStamp timestamp); + const std::string& displayName, int casterActorId, MWWorld::TimeStamp timestamp, bool sendPacket = true); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index 0140a787d..06af17f58 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -368,7 +368,7 @@ void DedicatedActor::addSpellsActive() MWWorld::TimeStamp timestamp = MWWorld::TimeStamp(activeSpell.timestampHour, activeSpell.timestampDay); // 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.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1, timestamp); + activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1, timestamp, false); } reloadPtr(); diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 287fbeee2..a78ba7428 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -493,7 +493,7 @@ void DedicatedPlayer::addSpellsActive() MWWorld::TimeStamp timestamp = MWWorld::TimeStamp(activeSpell.timestampHour, activeSpell.timestampDay); // 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.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1, timestamp); + activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1, timestamp, false); } } diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 99d8406f1..b5a162cd2 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -721,7 +721,7 @@ void LocalPlayer::addSpellsActive() MWWorld::TimeStamp timestamp = MWWorld::TimeStamp(activeSpell.timestampHour, activeSpell.timestampDay); // 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.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1, timestamp); + activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, 1, timestamp, false); } }