diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index f6fcd47cb..bf90b5c9d 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -10027,9 +10027,14 @@ scriptwait: else { auto iterator = Level->GetActorIterator(tag); - AActor *actor; + TArray actorsToMorph; - while ( (actor = iterator.Next ()) ) + while (AActor *actor = iterator.Next()) + { + actorsToMorph.Push(actor); + } + + for (AActor *actor : actorsToMorph) { changes += P_MorphActor(activator, actor, playerclass, monsterclass, duration, style, morphflash, unmorphflash); } @@ -10053,9 +10058,14 @@ scriptwait: else { auto iterator = Level->GetActorIterator(tag); - AActor *actor; + TArray actorsToUnmorph; - while ( (actor = iterator.Next ()) ) + while (AActor *actor = iterator.Next()) + { + actorsToUnmorph.Push(actor); + } + + for (AActor *actor : actorsToUnmorph) { changes += P_UnmorphActor(activator, actor, 0, force); }