New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2k: setting a primary building resets the primary building flag on all other factories #14699

Closed
obrakmann opened this Issue Jan 9, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@obrakmann
Contributor

obrakmann commented Jan 9, 2018

This is due to all production buildings providing the Upgrade queue.

Suggested fix:

diff --git a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs
index 089d2dd..5968a81 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs
@@ -35,6 +35,9 @@ public class PrimaryBuildingInfo : ITraitInfo
                [Desc("The speech notification to play when selecting a primary building.")]
                public readonly string SelectionNotification = "PrimaryBuildingSelected";
 
+               [Desc("Skip setting the primary production building for the queues mentioned here.")]
+               public readonly string[] IgnoreProductionQueues = { };
+
                public object Create(ActorInitializer init) { return new PrimaryBuilding(init.Self, this); }
        }
 
@@ -86,7 +89,7 @@ public void SetPrimaryProducer(Actor self, bool isPrimary)
                        {
                                // Cancel existing primaries
                                // TODO: THIS IS SHIT
-                               foreach (var p in self.Info.TraitInfo<ProductionInfo>().Produces)
+                               foreach (var p in self.Info.TraitInfo<ProductionInfo>().Produces.Except(info.IgnoreProductionQueues))
                                {
                                        foreach (var b in self.World
                                                        .ActorsWithTrait<PrimaryBuilding>()
diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml
index 0e28300..e26ab12 100644
--- a/mods/d2k/rules/structures.yaml
+++ b/mods/d2k/rules/structures.yaml
@@ -102,6 +102,7 @@ construction_yard:
                Palette: d2k
        PrimaryBuilding:
                PrimaryCondition: primary
+               IgnoreProductionQueues: Upgrade
        ProvidesPrerequisite@buildingname:
        GrantConditionOnPrerequisite:
                Prerequisites: upgrade.conyard
@@ -209,6 +210,7 @@ barracks:
                Produces: Infantry, Upgrade
        PrimaryBuilding:
                PrimaryCondition: primary
+               IgnoreProductionQueues: Upgrade
        ProductionBar:
        ProvidesPrerequisite@atreides:
                Prerequisite: barracks.atreides
@@ -408,6 +410,7 @@ light_factory:
                Produces: Vehicle, Upgrade
        PrimaryBuilding:
                PrimaryCondition: primary
+               IgnoreProductionQueues: Upgrade
        ProductionBar:
        ProvidesPrerequisite@atreides:
                Prerequisite: light.atreides
@@ -492,6 +495,7 @@ heavy_factory:
                Produces: Armor, Upgrade
        PrimaryBuilding:
                PrimaryCondition: primary
+               IgnoreProductionQueues: Upgrade
        ProductionBar:
        ProvidesPrerequisite@atreides:
                Prerequisite: heavy.atreides
@@ -905,6 +909,7 @@ high_tech_factory:
        ProductionBar:
        PrimaryBuilding:
                PrimaryCondition: primary
+               IgnoreProductionQueues: Upgrade
        Exit:
                SpawnOffset: 0,0,728
                ExitCell: 0,0

@pchote pchote added this to the Next release milestone Jan 9, 2018

@pchote pchote added the Regression label Jan 9, 2018

@pchote

This comment has been minimized.

Show comment
Hide comment
@pchote

pchote Jan 9, 2018

Member

Allowing (but not forcing) PrimaryBuilding to define a queue type (and then defaulting to any if null) might be a cleaner approach.

Member

pchote commented Jan 9, 2018

Allowing (but not forcing) PrimaryBuilding to define a queue type (and then defaulting to any if null) might be a cleaner approach.

@alercah

This comment has been minimized.

Show comment
Hide comment
@alercah

alercah Jan 9, 2018

Contributor

That was my thought as well.

Contributor

alercah commented Jan 9, 2018

That was my thought as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment