mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-06 15:51:35 +00:00
[Client] Don't send SpellsActive packets for spells received from server
This commit is contained in:
parent
ad3cd5e5fa
commit
a4b180f65a
5 changed files with 26 additions and 20 deletions
|
@ -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;
|
||||
|
||||
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
|
||||
|
|
|
@ -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…
Reference in a new issue