Merge pull request #6704 from chrisforbes/closure-hazards
Closure hazards -- Fixes #6703
This commit is contained in:
@@ -86,14 +86,17 @@ namespace OpenRA.Editor
|
||||
|
||||
// TODO: make this work properly
|
||||
foreach (var init in Program.Rules.Actors[kv.Value.Type].GetInitKeys())
|
||||
apd.AddRow(init.First,
|
||||
{
|
||||
var initName = init.First;
|
||||
apd.AddRow(initName,
|
||||
apd.MakeEditorControl(init.Second,
|
||||
() =>
|
||||
{
|
||||
var nodesDict = objSaved.ToDictionary();
|
||||
return nodesDict.ContainsKey(init.First) ? nodesDict[init.First].Value : null;
|
||||
return nodesDict.ContainsKey(initName) ? nodesDict[initName].Value : null;
|
||||
},
|
||||
_ => { }));
|
||||
}
|
||||
|
||||
apd.ShowDialog();
|
||||
|
||||
|
||||
@@ -199,13 +199,14 @@ namespace OpenRA.FileSystem
|
||||
|
||||
foreach (var ext in exts)
|
||||
{
|
||||
var possibleName = filename + ext;
|
||||
var folder = MountedFolders
|
||||
.Where(x => x.Exists(filename + ext))
|
||||
.Where(x => x.Exists(possibleName))
|
||||
.MaxByOrDefault(x => x.Priority);
|
||||
|
||||
if (folder != null)
|
||||
{
|
||||
s = folder.GetContent(filename + ext);
|
||||
s = folder.GetContent(possibleName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,9 +68,10 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
foreach (var actor in inRange.Append(collector))
|
||||
{
|
||||
actor.World.AddFrameEndTask(w =>
|
||||
var recipient = actor; // loop variable in closure hazard
|
||||
recipient.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var gainsExperience = actor.TraitOrDefault<GainsExperience>();
|
||||
var gainsExperience = recipient.TraitOrDefault<GainsExperience>();
|
||||
if (gainsExperience != null)
|
||||
gainsExperience.GiveLevels(((LevelUpCrateActionInfo)info).Levels);
|
||||
});
|
||||
|
||||
@@ -67,13 +67,16 @@ namespace OpenRA.Mods.RA
|
||||
// TODO: THIS IS SHIT
|
||||
// Cancel existing primaries
|
||||
foreach (var p in self.Info.Traits.Get<ProductionInfo>().Produces)
|
||||
{
|
||||
var productionType = p; // benign closure hazard
|
||||
foreach (var b in self.World
|
||||
.ActorsWithTrait<PrimaryBuilding>()
|
||||
.Where(a =>
|
||||
a.Actor.Owner == self.Owner &&
|
||||
a.Trait.IsPrimary &&
|
||||
a.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(p)))
|
||||
a.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(productionType)))
|
||||
b.Trait.SetPrimaryProducer(b.Actor, false);
|
||||
}
|
||||
|
||||
isPrimary = true;
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
foreach (var arm in self.TraitsImplementing<Armament>())
|
||||
{
|
||||
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)));
|
||||
|
||||
@@ -89,7 +89,8 @@ namespace OpenRA.Mods.RA
|
||||
foreach (var cell in dirtyCells)
|
||||
{
|
||||
// Select all neighbors inside the map boundries
|
||||
var neighbors = CVec.directions.Select(d => d + cell)
|
||||
var thisCell = cell; // benign closure hazard
|
||||
var neighbors = CVec.directions.Select(d => d + thisCell)
|
||||
.Where(c => map.Contains(c));
|
||||
|
||||
var found = false;
|
||||
|
||||
Reference in New Issue
Block a user