From 3360b1196239b9ca237984fd1e07a145139e2181 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 7 Oct 2014 18:27:31 +1300 Subject: [PATCH] WithMuzzleFlash: fix loop variable in closure hazard This fixes a real bug -- if the actor had multiple armaments, we'd end up placing the muzzle flashes all based on the offsets of the last one. --- OpenRA.Mods.RA/Render/WithMuzzleFlash.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index 0621331604..c5d7e4e028 100644 --- a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -38,6 +38,8 @@ namespace OpenRA.Mods.RA.Render foreach (var arm in self.TraitsImplementing()) { + var armClosure = arm; // closure hazard in AnimationWithOffset + // Skip armaments that don't define muzzles if (arm.Info.MuzzleSequence == null) continue; @@ -55,7 +57,7 @@ namespace OpenRA.Mods.RA.Render visible.Add(barrel, false); anims.Add(barrel, new AnimationWithOffset(muzzleFlash, - () => info.IgnoreOffset ? WVec.Zero : arm.MuzzleOffset(self, barrel), + () => info.IgnoreOffset ? WVec.Zero : armClosure.MuzzleOffset(self, barrel), () => !visible[barrel], () => false, p => WithTurret.ZOffsetFromCenter(self, p, 2)));