From c4a96bc829d12bb0b52871bdd2ed85ac734af256 Mon Sep 17 00:00:00 2001 From: FluffyQuack Date: Tue, 13 Jul 2021 20:36:51 +0200 Subject: [PATCH] :crown: Fix to bug that made spawned monsters overwrite alive ones (cause was monsters not being properly deleted) --- Source/monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index c93ac52a6..15612ced7 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -797,7 +797,7 @@ void LoadDiabMonsts() void DeleteMonster(int i) { ActiveMonsterCount--; - ActiveMonsters[i] = ActiveMonsters[ActiveMonsterCount]; + std::swap(ActiveMonsters[i], ActiveMonsters[ActiveMonsterCount]); // This ensures alive monsters are before ActiveMonsterCount in the array and any deleted monster after } void NewMonsterAnim(MonsterStruct &monster, MonsterGraphic graphic, Direction md, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0)