diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 7ec1224db..7e863a825 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4864,14 +4864,15 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc while (cls != RUNTIME_CLASS(AActor)) { FActorInfo *ai = cls->ActorInfo; + int checked_advance = advance; if (ai->OwnsState(th->SpawnState)) { - for (; advance > 0; --advance) + for (; checked_advance > 0; --checked_advance) { // [RH] Do not set to a state we do not own. - if (!ai->OwnsState(th->SpawnState + advance)) + if (ai->OwnsState(th->SpawnState + checked_advance)) { - th->SetState(th->SpawnState + advance); + th->SetState(th->SpawnState + checked_advance); goto statedone; } }