HomeWildfire Games

Delete sheep corpses when starting to build a foundation,


Delete sheep corpses when starting to build a foundation,

so that units don't try to gather forever while not being able to reach it and
so that the sheep corpse can't be selected and seen anymore.

Differential Revision: https://code.wildfiregames.com/D21
Fixes #4268
Based On Patch By: wraitii
Reviewed By: temple
Previously Reviewed By: Itms

Event Timeline

rP21600 gg replay of a 1v1 borg- vs nani where some foundations never started progress, for example the storehouse at 3min 17s at nani.

temple added a subscriber: temple.Mar 21 2018, 9:43 PM

This happened when the foundation was placed in the fog of war, then the foundation collided with its mirage! So construction could never get started.
Instead we should only check against entities that block construction, and then make the resource filter (used for carcasses) block construction.

Index: binaries/data/mods/public/simulation/templates/special/filter/resource.xml
--- binaries/data/mods/public/simulation/templates/special/filter/resource.xml	(revision 21597)
+++ binaries/data/mods/public/simulation/templates/special/filter/resource.xml	(working copy)
@@ -14,7 +14,7 @@
-    <BlockConstruction>false</BlockConstruction>
+    <BlockConstruction>true</BlockConstruction>
     <Static width="2.0" depth="2.0"/>
Index: source/simulation2/components/CCmpObstruction.cpp
--- source/simulation2/components/CCmpObstruction.cpp	(revision 21597)
+++ source/simulation2/components/CCmpObstruction.cpp	(working copy)
@@ -650,8 +650,10 @@
 		if (!cmpObstructionManager)
 			return ret; // error
+		flags_t flags = ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION;
 		// Ignore collisions within the same control group.
-		SkipControlGroupsRequireFlagObstructionFilter filter(true, m_ControlGroup, m_ControlGroup2, 0);
+		SkipControlGroupsRequireFlagObstructionFilter filter(false, m_ControlGroup, m_ControlGroup2, flags);
 		ICmpObstructionManager::ObstructionSquare square;
 		if (!GetObstructionSquare(square))

Oh temple, that patch fixes it!
That BlockConstruction came a bit unexpected, since setting it to true does the opposite than blocking the construction :P
I thought it would require the player go gather the corpse before the placed foundation can be constructed (that were bad as it would still result in idle but non-Idle units).
But the feature works identically as it does currently (in the non-bugged case).
The flag variable can be inlined, the comment should be updated.
It should also rename the function GetEntityCollisions as it is now more selective, maybe GetEntitiesBlockingConstruction.

But we should also consider alternative fixes and decide for the best.
With the destruction of the foundation, the mirage of the foundation must have been destroyed as well I suppose.
So maybe we could also change Foundation.prototype.Build to delete mirages?
Should check for unintended consequences then.

I think we should just have one function, since Gate is the only thing that still uses GetUnitCollisions and that probably should do the same thing with foundations here, i.e. if a carcass then it should delete it when locking the gate. The only problem with that is that the Iberian starting walls still overlap with resources, so e.g. you can have a tree on top of a gate and not be able to close it. So we should wait to replace GetUnitCollisions with GetEntitiesBlockingConstruction in Gate until that's been fixed.

With the destruction of the foundation, the mirage of the foundation must have been destroyed as well I suppose.

For the builder, yes, but other players may still have a mirage of that building, and theirs are only destroyed when they visit the area again.