summaryrefslogtreecommitdiffstats
path: root/src/Entities/Pawn.cpp
diff options
context:
space:
mode:
authorFabian Stein <fenstein12@googlemail.com>2016-12-29 15:21:41 +0100
committerMattes D <github@xoft.cz>2016-12-29 15:21:41 +0100
commit4170ab62c0931fd38d0fe7ed7ff521642eb3dda7 (patch)
treefaaf427aff56b3bd10be724a1422fb39d50cdfcb /src/Entities/Pawn.cpp
parentWorld: Add check for unknown RedstoneSimulator (#3496) (diff)
downloadcuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.tar
cuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.tar.gz
cuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.tar.bz2
cuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.tar.lz
cuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.tar.xz
cuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.tar.zst
cuberite-4170ab62c0931fd38d0fe7ed7ff521642eb3dda7.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Pawn.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index a073dc9a7..b7fab31c3 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -48,6 +48,8 @@ void cPawn::Destroyed()
void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ std::vector<cEntityEffect *> EffectsToTick;
+
// Iterate through this entity's applied effects
for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
{
@@ -55,7 +57,8 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
cEntityEffect::eType EffectType = iter->first;
cEntityEffect * Effect = iter->second;
- Effect->OnTick(*this);
+ // Call OnTick later to make sure the iterator won't be invalid
+ EffectsToTick.push_back(Effect);
// Iterates (must be called before any possible erasure)
++iter;
@@ -69,6 +72,12 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// TODO: Check for discrepancies between client and server effect values
}
+
+ for (auto * Effect : EffectsToTick)
+ {
+ Effect->OnTick(*this);
+ }
+
class Pusher : public cEntityCallback
{
public: