[Client] Don't send SpellsActive packets for spells received from server

pull/593/head
David Cernat 4 years ago
parent ad3cd5e5fa
commit a4b180f65a

@ -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<ActiveEffect> 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;
if (sendPacket)
{
bool isStackingSpell = it == end() || stack;
ESM::ActiveSpells::ActiveSpellParams esmParams;
esmParams.mEffects = effects;
esmParams.mDisplayName = displayName;
esmParams.mCasterActorId = casterActorId;
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);
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

@ -83,7 +83,7 @@ namespace MWMechanics
Add a separate addSpell() with a timestamp argument
*/
void addSpell (const std::string& id, bool stack, std::vector<ActiveEffect> 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
*/

@ -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();

@ -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);
}
}

@ -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);
}
}

Loading…
Cancel
Save