Skip to content

Commit

Permalink
Fix the issue with capturing a driver killed CV.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Feb 20, 2018
1 parent 8df3f09 commit 68b4856
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class ProductionQueue : IResolveOrder, ITick, ITechTreeElement, INotifyOw
public string Faction { get; private set; }
[Sync] public bool IsValidFaction { get; private set; }

bool anyEnabledProduction = false;
bool anyUnpausedProduction = false;

public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
{
self = init.Self;
Expand Down Expand Up @@ -252,16 +255,30 @@ void ITick.Tick(Actor self)
protected virtual void Tick(Actor self)
{
// PERF: Avoid LINQ when checking whether all production traits are disabled/paused
var anyEnabledProduction = false;
var anyUnpausedProduction = false;
var wasDisabled = !anyEnabledProduction;

anyEnabledProduction = false;
anyUnpausedProduction = false;
foreach (var p in productionTraits)
{
anyEnabledProduction |= !p.IsTraitDisabled;
anyUnpausedProduction |= !p.IsTraitPaused;
}

if (wasDisabled && anyEnabledProduction)
{
self.World.AddFrameEndTask(_ =>
{
self.Owner.PlayerActor.Trait<TechTree>().Update();
CacheProducibles(self.Owner.PlayerActor);
});
}

if (!anyEnabledProduction)
{
self.Owner.PlayerActor.Trait<TechTree>().Remove(this);
ClearQueue();
}

Enabled = IsValidFaction && anyEnabledProduction;

Expand Down

0 comments on commit 68b4856

Please sign in to comment.