LevelUpCrateAction: fix loop variable in closure bug
This was a real bug -- if there were multiple recipients, we'd apply the levels N times to the last recipient rather than once to each.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user