diff options
author | Lane Kolbly <lane@rscheme.org> | 2017-08-22 16:16:34 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-08-24 11:19:01 +0200 |
commit | 92ac45d27ea5e97177f7798a48ad562276350b93 (patch) | |
tree | a6415b0bb14d4c5747434ed07d39ae07207c88e0 /src/Entities | |
parent | Fix use after move in cItemBowHandler::OnItemShoot (diff) | |
download | cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.tar cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.tar.gz cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.tar.bz2 cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.tar.lz cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.tar.xz cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.tar.zst cuberite-92ac45d27ea5e97177f7798a48ad562276350b93.zip |
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Pawn.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index a0095a8a4..233cdfa85 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -197,6 +197,13 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, s } a_Duration = static_cast<int>(a_Duration * a_DistanceModifier); + // If we already have the effect, we have to deactivate it or else it will act cumulatively + auto ExistingEffect = m_EntityEffects.find(a_EffectType); + if (ExistingEffect != m_EntityEffects.end()) + { + ExistingEffect->second->OnDeactivate(*this); + } + auto Res = m_EntityEffects.emplace(a_EffectType, cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_DistanceModifier)); m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, static_cast<short>(a_Duration)); cEntityEffect * Effect = Res.first->second.get(); |