Skip to content
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

Fix two blocking issues #17773

Merged
merged 4 commits into from Mar 11, 2020
Merged

Fix two blocking issues #17773

merged 4 commits into from Mar 11, 2020

Conversation

@pchote
Copy link
Member

pchote commented Mar 6, 2020

The second commit fixes #17769.
The third and fourth commits fix #17618 (comment) and other issues where groups of infantry block each other while moving

@pchote pchote added this to the Next Release milestone Mar 6, 2020
@pchote pchote requested a review from teinarss Mar 6, 2020
@pchote pchote force-pushed the pchote:fix-blocking branch from d85e7cd to 2bcb94d Mar 7, 2020
@pchote

This comment has been minimized.

Copy link
Member Author

pchote commented Mar 7, 2020

Fixed.

@matjaeck

This comment has been minimized.

Copy link

matjaeck commented Mar 8, 2020

I did some testing and added the logging below to see when when in Locomotor.GetAvailableSubCell the path for blocked units would be used. Although I might be misunderstanding the code and thus my logging could be wrong, I was surprised that even only with one infantry soldier moving from a free cell to another free cell, the output very very often showed that the engine considers the path to be blocked (Infantry blocked! ...). It looks like it is blocking itself.

Another thing I noticed is that when you send two 5-stacks of infantry on paths so that they collide with the other 5-stack, the moment they collide they wait for some seconds before re-pathing around each other (they don't give up). The logging output shows that they can't find any subcell to go. Lastly the ..., use default Subcell case never appears in logging output.

diff --git a/OpenRA.Mods.Common/Traits/World/ActorMap.cs b/OpenRA.Mods.Common/Traits/World/ActorMap.cs
index 92491d758d..7617de98f0 100644
--- a/OpenRA.Mods.Common/Traits/World/ActorMap.cs
+++ b/OpenRA.Mods.Common/Traits/World/ActorMap.cs
@@ -277,29 +277,54 @@ public bool HasFreeSubCell(CPos cell, bool checkTransient = true)
 		public SubCell FreeSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, bool checkTransient = true)
 		{
 			if (preferredSubCell != SubCell.Any && !AnyActorsAt(cell, preferredSubCell, checkTransient))
+			{
+				Console.WriteLine("Not blocked, preferred SubCell is {0}", preferredSubCell);
 				return preferredSubCell;
+			}
 
 			if (!AnyActorsAt(cell))
+			{
+				Console.WriteLine("Not blocked, use default Subcell {0}", map.Grid.DefaultSubCell);
 				return map.Grid.DefaultSubCell;
+			}
 
 			for (var i = (int)SubCell.First; i < map.Grid.SubCellOffsets.Length; i++)
+			{
 				if (i != (int)preferredSubCell && !AnyActorsAt(cell, (SubCell)i, checkTransient))
+				{
+					Console.WriteLine("Not blocked, found free subcell {0}", (SubCell)i);
 					return (SubCell)i;
-
+				}
+			}
+				
+			Console.WriteLine("Not blocked, no free subcell found!");
 			return SubCell.Invalid;
 		}
 
 		public SubCell FreeSubCell(CPos cell, SubCell preferredSubCell, Func<Actor, bool> checkIfBlocker)
 		{
 			if (preferredSubCell != SubCell.Any && !AnyActorsAt(cell, preferredSubCell, checkIfBlocker))
+			{
+				Console.WriteLine("Infantry blocked! Preferred SubCell is {0}", preferredSubCell);
 				return preferredSubCell;
+			}
 
 			if (!AnyActorsAt(cell))
+			{
+				Console.WriteLine("Infantry blocked! Use default Subcell {0}", map.Grid.DefaultSubCell);
 				return map.Grid.DefaultSubCell;
+			}
 
 			for (var i = (byte)SubCell.First; i < map.Grid.SubCellOffsets.Length; i++)
+			{
 				if (i != (byte)preferredSubCell && !AnyActorsAt(cell, (SubCell)i, checkIfBlocker))
+				{
+					Console.WriteLine("Infantry blocked! Found free subcell {0}", (SubCell)i);
 					return (SubCell)i;
+				}
+			}
+			
+			Console.WriteLine("Infantry blocked! No free subcell found!");
 			return SubCell.Invalid;
 		}
 
Copy link

matjaeck left a comment

Fixes for #17769 and #17618 (comment) work.

@abcdefg30 abcdefg30 merged commit 416713d into OpenRA:bleed Mar 11, 2020
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@abcdefg30

This comment has been minimized.

Copy link
Member

abcdefg30 commented Mar 11, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.