summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
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: