HomeWildfire Games

fix obstruction of target entity not taken into account in short pathfinder…

Description

fix obstruction of target entity not taken into account in short pathfinder, closes #3539

Details

Committed
mimoOct 31 2015, 2:37 PM
Parents
rP17153: only decay towards connected tiles, fixes #3558
Branches
Unknown
Tags
Unknown

Event Timeline

@mimo When debugging the issue in the gif of #4473 (easily reproduce by trying to garrison a wall turret in a bad angle of the iberian starting walls), I observed that CCmpUnitMotion::TryGoingStraightToTargetEntity returns true, because it ignores the wallpiece as it has the controlgroup of the wall turret. But the unit can never reach the garrison range of the turret because the entity does collide with the wall and that is detected later.

In comment:4 of #3539 you had described an inconsistency which sounds identical to the one found here.

Maybe the shortrange pathfinder was changed to not ignore the target obstruction anymore and TryGoingStraightToTargetEntity was forgotton to be adapted for this?

(After performing the mentioned revert and the revert of rP17146, I still can't reproduce #3530 anymore.)

/ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
905

This detects a wall collision and prevents the unit from progressing.

1153

This ignores the wall when testing for collisions and thus suggests the unit to keep running against the wall.

1263

TryGoingStraightToTargetEntity is the only function with noTarget = true and is the only case introduced ever.
Reverting this function to always return GetGroup() seems to fix the inconsistency and the bug described on first sight.
But I don't know if it's correct.

mimo added a comment.Mar 27 2018, 7:49 PM

@mimo When debugging the issue in the gif of #4473 (easily reproduce by trying to garrison a wall turret in a bad angle of the iberian starting walls), I observed that CCmpUnitMotion::TryGoingStraightToTargetEntity returns true, because it ignores the wallpiece as it has the controlgroup of the wall turret. But the unit can never reach the garrison range of the turret because the entity does collide with the wall and that is detected later.
In comment:4 of #3539 you had described an inconsistency which sounds identical to the one found here.
Maybe the shortrange pathfinder was changed to not ignore the target obstruction anymore and TryGoingStraightToTargetEntity was forgotton to be adapted for this?
(After performing the mentioned revert and the revert of rP17146, I still can't reproduce #3530 anymore.)

It's quite old, and i don't really remember that code. But see my inline comments. And when you say you don't reproduce it, you mean #3539? not #3530

/ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
905

As target is the nearestPointOnGoal, there should be no collision.

1153

Yes, but it put as next waypoint goalPos which the the nearestPointOnGoal which for a wall should be the nearest point on the obstruction square. And there should be no obstruction between the unit and this goalPos.
Except if there is an effect of the clearance, in which case line 1150 should be changed to take that clearance into account.

when you say you don't reproduce it, you mean #3539? not #3530

Yes, the elephant one, not the chicken one. I can't reproduce any issues or regressions when applying this https://trac.wildfiregames.com/raw-attachment/ticket/4473/worksonfirstsight.patch (disclaimer again, I don't know yet if it's correct)

Here the minimal replay with which I tested - only one entity moving on the entire map.

In particular we can observe that currently units starting inside the iberian walls will always try to reach the tower from the inside.
But with the patch, we can see them being smart enough to first leave the city walls and then garrison from the outside if the wall tower is inaccessible from the inside.

Here the debug patch with which I have tested to see what's going on:

/ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
905

At least it currently detects the collision and the silent // Error - path was obstructed case below is triggered.

1153

But the nearestPointOnGoal should be on the target entity (wall tower) and not on the wall segment (which currently blocks the entity from reaching the target).
The wall segment has the adjacent towers as controlgroups, so this line L1153 ignores the obstruction whereas the other line L905 does not ignore the wall segment.

mimo added inline comments.Mar 27 2018, 8:54 PM
/ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
1153

"The wall segment has the adjacent towers as controlgroups, so this line L1153 ignores the obstruction whereas the other line L905 does not ignore the wall segment."

Yes that's the problem if they are in the same control group.

mimo added a comment.Mar 28 2018, 8:04 PM

I did some tests with your patch, and also could not reproduce #3539, nor seeing any bad side-effect.

elexis added inline comments.Mar 31 2018, 3:39 PM
/ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
1153

Yes, but it put as next waypoint goalPos which the the nearestPointOnGoal which for a wall should be the nearest point on the obstruction square. And there should be no obstruction between the unit and this goalPos.

Same here:
https://trac.wildfiregames.com/ticket/3539#comment:4 :

tryGoingStraightToTarget which will never suceed as it will always find the way obstructed by the target itself.

nearestPointOnGoal is the nearest point in the garrisonrange, not the nearest point on the obstruction.
debug_printf outputs confirm that the function does succeed if there are no other obstructions around.

(The only question that remains is if formations should also take the target obstruction into account, i.e. GetGroup() always returning`GetEntityId()`. But perhaps we should investigate that separately.)

(I've checked out this commit and tested, but there are too many other bugfixes and changes since which make it hard to compare.)

@elexis Today, I tested it. When I compiled it with VS2013, there was a mistake:

Error 167 error C2061: syntax error : identifier 'noTarget' D:\trunk\source\simulation2\components\CCmpUnitMotion.cpp 667 1 simulation2
Error 168 error C2259: 'CCmpUnitMotion' : cannot instantiate abstract class D:\trunk\source\simulation2\components\CCmpUnitMotion.cpp 140 1 simulation2
Error 169 error C2660: 'CCmpUnitMotion::GetObstructionFilter' : function does not take 2 arguments D:\trunk\source\simulation2\components\CCmpUnitMotion.cpp 1153 1 simulation2
Error 170 error C2511: 'ControlGroupMovementObstructionFilter CCmpUnitMotion::GetObstructionFilter(bool,bool) const' : overloaded member function not found in 'CCmpUnitMotion' D:\trunk\source\simulation2\components\CCmpUnitMotion.cpp 1262 1 simulation2
Error 171 error C2352: 'CCmpUnitMotion::GetGroup' : illegal call of non-static member function D:\trunk\source\simulation2\components\CCmpUnitMotion.cpp 1263 1 simulation2
Error 172 error C2352: 'CCmpUnitMotion::ShouldAvoidMovingUnits' : illegal call of non-static member function D:\trunk\source\simulation2\components\CCmpUnitMotion.cpp 1264 1 simulation2
Error 173 error C2039: 'IsFloating' : is not a member of 'ICmpPosition' D:\16009\source\simulation2\components\CCmpUnitMotion.cpp 1749 1 simulation2
Error 245 error LNK1181: cannot open input file 'D:\trunk\binaries\system\simulation2.lib' D:\trunk\build\workspaces\vc2013\LINK pyrogenesis
Error 265 error LNK1181: cannot open input file 'D:\trunk\binaries\system\simulation2.lib' D:\trunk\build\workspaces\vc2013\LINK test

IsFloating

gameboy it looks like you have the floating patch applied, try to revert

@elexis I didn't use any patches. I used SVN.

@elexis I didn't use any patches. I used SVN.

We don't have IsFloating in our code currently, but your compiler warns about it.
Revert and do a clean compile.

@elexis How can I download this patch? I want to make full use of your patch, maybe there will be no such mistake. Thank you, please tell me.

elexis added a subscriber: Stan.Apr 11 2018, 3:02 PM

How can I download this patch?

Don't download any patches. Wait for us to fix the described pathfinder issue.
@Stan might tell you on the forums how to do a clean compile with visual studio.

gameboy removed a subscriber: gameboy.Apr 11 2018, 3:08 PM

@elexis I know how to compile it, but I need to apply your patch to help you test it. I have a problem, I don't know if you have fixed it through this patch: the problem is that the army in the wall can attack the enemy outside the wall from the wall, and they should go out of town to attack the enemy outside the wall. The enemy outside the city wall can attack the army and unit within the walls of the city. The enemy outside the wall should destroy the wall to attack the army and the units in the wall.

This patch does not fix #4905. Please report your issue on the forums, not here as it is unrelated.