Opened 9 years ago

Closed 8 years ago

Last modified 3 years ago

#3410 closed defect (fixed)

[PATCH] Units can go through obstructions

Reported by: elexis Owned by:
Priority: Release Blocker Milestone: Alpha 19
Component: Core engine Keywords:
Cc: Patch:

Description (last modified by elexis)

There are several ways in which units can go into obstructions:

  1. Move a single unit into the building (second gif is #3532, first gif might be different):

https://trac.wildfiregames.com/raw-attachment/ticket/3410/cav_inside_athen_cc.gif https://trac.wildfiregames.com/raw-attachment/ticket/3410/cav_inside_athen_cc3.gif

  1. Units in formation standing at opposite sides of an obstruction and moving somewhere:

https://trac.wildfiregames.com/raw-attachment/ticket/3410/units_in_formation_in_cc.gif

https://trac.wildfiregames.com/raw-attachment/ticket/3410/units_in_formation_through_cc.gif

  1. Moving ships over the shoreline (both #3538 and #3532 allow to enter the land)

https://trac.wildfiregames.com/raw-attachment/ticket/3410/ship.gif

  1. Construct a building and move into it when the construction starts:

https://trac.wildfiregames.com/raw-attachment/ticket/3410/construct_bug.gif

Reproduce construction bug:

  • place a barracks foundation with a man, move him away before he begins to build.
  • move a woman onto the foundation (by clicking behind foundation and stopping her midway)
  • let that guy build
  • order the woman to build. she will leave the foundation, move her back in immediately and stop

Entity IDs in the replay file:

  • woman 7452
  • guy 7456
  • barracks 7501

Attachments (21)

commands.txt (16.0 KB ) - added by elexis 9 years ago.
Almost a minimum set of instructions for r17003, no AI, no random map.
commands.2.txt (216.5 KB ) - added by AlThePhoenix 9 years ago.
As asked, here is the commands.txt of a match where the bug is reproduced. The Map is Siwa Oasis.
commands.3.txt (7.3 KB ) - added by elexis 9 years ago.
r17019, a cavalry of player 1 runs to player 2 and then forces its way into the CC.
commands_r16998.txt (11.5 KB ) - added by elexis 9 years ago.
A replay for r16998 where the bug occurs (uses the same method as in commands.3.txt, where you repeatedly tell a cavalry to move inside (beyond) the athen CC).
commands_r17078_cav_in_athen_cc_bottomright.txt (17.4 KB ) - added by elexis 9 years ago.
Same mechanism as above, repeatedly try to enter an athen CC with a cavalry and eventually make it. Unit got in at the bottom right corner of the cc.
commands_r17078_cav_in_athen_cc_topleft.txt (13.7 KB ) - added by elexis 9 years ago.
Same as above, but unit made it into the CC from the topleft corner.
commands_r17084_cav_inside_athen_cc.txt (15.3 KB ) - added by elexis 9 years ago.
Again it was a corner of the CC that gave way and happened immediately after the cav went around the corner.
corners.patch (25.4 KB ) - added by Itms 9 years ago.
corners-complete.patch (26.4 KB ) - added by Itms 9 years ago.
corners-complete_v2.patch (27.0 KB ) - added by elexis 9 years ago.
Rebased. Diff the patches too see that they are identical, except to the function that was removed in r17103.
commands_patched_r17108_cav_inside_athen_cc.txt (31.2 KB ) - added by elexis 9 years ago.
Here a replay that was created with that patch applied. Just to be sure.
cav_inside_athen_cc.gif (395.2 KB ) - added by elexis 9 years ago.
units_in_formation_through_cc.gif (429.9 KB ) - added by elexis 9 years ago.
construct_bug.gif (764.8 KB ) - added by elexis 9 years ago.
ship.gif (969.6 KB ) - added by elexis 9 years ago.
commands.4.txt (13.8 KB ) - added by elexis 9 years ago.
Replay for r17126. (cav inside CC and units in formation through CC)
cav_inside_athen_cc.2.gif (389.1 KB ) - added by elexis 9 years ago.
Visualization of attachment:commands.4.txt
commands.5.txt (79.6 KB ) - added by elexis 9 years ago.
Also for r17126. Cavalry inside CC. Slightly different from the other cases as it doesn't seem to have to do with the corner.
cav_inside_athen_cc3.gif (620.4 KB ) - added by elexis 9 years ago.
Visualization of attachment:commands.5.txt
units_in_formation_in_cc.gif (197.9 KB ) - added by elexis 9 years ago.
Two units are sufficient to enter buildings in formation. They only must be standing at opposite sites. Maybe those formation issues are related to the clearance being 4.
revert_16998.patch (13.3 KB ) - added by elexis 8 years ago.
Patch by wraitii.

Change History (49)

by elexis, 9 years ago

Attachment: commands.txt added

Almost a minimum set of instructions for r17003, no AI, no random map.

comment:1 by elexis, 9 years ago

Last edited 9 years ago by elexis (previous) (diff)

comment:2 by Stan, 9 years ago

I bet this has to do with Itms last commit then.

comment:3 by Itms, 9 years ago

Milestone: BacklogAlpha 19
Owner: set to Itms
Priority: If Time PermitsMust Have

comment:4 by AlThePhoenix, 9 years ago

I noticed units being inside buildings as well, but for me it happened differently. It happened when I launched an attack on an enemy and ordered my units to move somewhere while they were touching a building. Some of them ended up just passing through the building. You can reproduce this by having about a hundred units (the bug is more likely to happen / easier to reproduce the more units you have) and ordering them to move to a building so they surround it. Then repeatedly give the order to move somewhere else in a random pattern like click south of the building, click west, click north. Don't click too fast, wait so the units get to move a small bit (100 units tend to create some lag, thus spamming the move order ends up in the units not moving at all).

by AlThePhoenix, 9 years ago

Attachment: commands.2.txt added

As asked, here is the commands.txt of a match where the bug is reproduced. The Map is Siwa Oasis.

comment:5 by elexis, 9 years ago

Thanks to Evulant's (AlThePhoenix) research, I could reproduce this error with a single unit and only move-commands too. Indeed the common denominator seems to be

ordered my units to move somewhere while they were touching a building

The file above uses r17014.

by elexis, 9 years ago

Attachment: commands.3.txt added

r17019, a cavalry of player 1 runs to player 2 and then forces its way into the CC.

comment:6 by Itms, 9 years ago

In 17028:

Reenable formations and fix/improve the communication between UnitAI and UnitMotion. With the new pathfinder some path requests can be completed instantaneously, so UnitAI has to handle MoveStarted messages even in the IDLE state.

Please note that this commit makes #3410 really visible. Formation members might pass through buildings.

Refs #3410, #3337.

comment:7 by Itms, 9 years ago

In 17029:

Workaround for a specific case of #3410, where units could stand on a committed foundation. Just check for units and order them to leave during all the building.
Refs #3410.

comment:8 by elexis, 9 years ago

Priority: Must HaveRelease Blocker

Release blocker since it happens very frequently. Notice that also ships can move on land now.

Should be caused by r16998:

With this change, units will not check their movement against all obstructions when moving

Another way to reproduce using formations (which were reenabled in r17028):

  1. Select some units and disable formation
  2. Move units behind a resource (metal/stone)
  3. When close to the resource, enable a formation
  4. Press H for stop

-> units will stop inside the resource

Same can be used to climb impassable mountains.

by elexis, 9 years ago

Attachment: commands_r16998.txt added

A replay for r16998 where the bug occurs (uses the same method as in commands.3.txt, where you repeatedly tell a cavalry to move inside (beyond) the athen CC).

by elexis, 9 years ago

Same mechanism as above, repeatedly try to enter an athen CC with a cavalry and eventually make it. Unit got in at the bottom right corner of the cc.

by elexis, 9 years ago

Same as above, but unit made it into the CC from the topleft corner.

comment:9 by elexis, 9 years ago

Another reliable way to reproduce it is to create a ton of units simultaneously at the CC and then issue a move command. By trying to get into formation they will pass through the CC. Start with deathmatch resources, use the cheats "the hive master" and "i am too busy".

comment:10 by Lionkanzen, 9 years ago

I saw that, with a fortress but I can search the command was the last week.

comment:11 by Itms, 9 years ago

I have a fix idea I'm currently working on, but I'm not sure I can finish it this weekend. I don't think I have any time to spend on programming the upcoming week so if I'm not quick enough that will have to wait for the next weekend.

Just to keep you updated. Sorry for possibly delaying the release with that.

comment:12 by Itms, 9 years ago

In 17084:

Replace the rectangle rasterization algorithm by the original version from Philip's branch.
The current version is flawed (it doesn't handle the partially obstructed cells as it should).

Refs #3410.

by elexis, 9 years ago

Again it was a corner of the CC that gave way and happened immediately after the cav went around the corner.

comment:13 by elexis, 9 years ago

The easiest way to reproduce is by walking through berries. Works everytime.

comment:14 by Itms, 9 years ago

Component: UI & SimulationCore engine
Keywords: patch review added
Summary: Have a unit stand inside a structure[PATCH] Units can go through obstructions

Ok, I did my homework.

The problem we're facing is this one: if a navcell is partially obstructed, it is considered as passable. However, the long-range pathfinder doesn't know about obstructions, it just works with passability. So when creating a path, it computes a list of navcells, then it converts them to real-world coordinates using the center of these navcells. And, of course, the center might be inside an obstruction. Once inside, the short pathfinder won't detect the collision with the obstruction's edge and might lead the unit further inside the obstruction, and at some point the unit will be on an impassable navcell and the long-range pathfinder will allow it to leave the obstructed zone by going through the obstruction.

So the fix is the following: the long-range pathfinder has to know about corners.

This is a big change for a FF. I don't like having that in that late, but well. Attached patch only adds all the corner stuff without using it. So it shouldn't influence the simulation state. If it does, I screwed up somewhere.

When we're sure the patch doesn't change anything, I will only have to make the code use the new system to (hopefully) fix the problem.

by Itms, 9 years ago

Attachment: corners.patch added

comment:15 by Itms, 9 years ago

The patch above doesn't seem to change the sim state, so that's good. Here is the complete patch using that new code. Unfortunately, it doesn't fix the reported problem, so I'm puzzled.

by Itms, 9 years ago

Attachment: corners-complete.patch added

comment:16 by elexis, 9 years ago

Last edited 9 years ago by elexis (previous) (diff)

comment:17 by Itms, 9 years ago

Owner: Itms removed

I won't have time for programming anymore during the upcoming months.

by elexis, 9 years ago

Attachment: corners-complete_v2.patch added

Rebased. Diff the patches too see that they are identical, except to the function that was removed in r17103.

comment:18 by elexis, 9 years ago

Keywords: review removed

Replay attachment:commands_r17084_cav_inside_athen_cc.txt with that patch to see that it is not sufficient.

by elexis, 9 years ago

Here a replay that was created with that patch applied. Just to be sure.

by elexis, 9 years ago

Attachment: cav_inside_athen_cc.gif added

by elexis, 9 years ago

by elexis, 9 years ago

Attachment: construct_bug.gif added

by elexis, 9 years ago

Attachment: ship.gif added

comment:19 by elexis, 9 years ago

Description: modified (diff)

by elexis, 9 years ago

Attachment: commands.4.txt added

Replay for r17126. (cav inside CC and units in formation through CC)

by elexis, 9 years ago

Attachment: cav_inside_athen_cc.2.gif added

Visualization of attachment:commands.4.txt

by elexis, 9 years ago

Attachment: commands.5.txt added

Also for r17126. Cavalry inside CC. Slightly different from the other cases as it doesn't seem to have to do with the corner.

by elexis, 9 years ago

Attachment: cav_inside_athen_cc3.gif added

Visualization of attachment:commands.5.txt

comment:20 by elexis, 9 years ago

Description: modified (diff)

comment:21 by Stan, 9 years ago

Replacing line 802 of CcmpPathfinder.cpp

if (!cmpObstructionManager || cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r))

by

if (!cmpObstructionManager || !cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r))

I cannot get the cavalry into the Civil Centre. Formations on the other side totally ignore the building.

EDIT 1 : Doesn't work so I was trying some other things and came across this removed line in r16998

 m_ShortPath.m_Waypoints.clear();

adding it back seems to remove issues when units are not using formations.

Last edited 9 years ago by Stan (previous) (diff)

comment:22 by elexis, 9 years ago

Description: modified (diff)

by elexis, 9 years ago

Two units are sufficient to enter buildings in formation. They only must be standing at opposite sites. Maybe those formation issues are related to the clearance being 4.

comment:23 by elexis, 9 years ago

Description: modified (diff)

comment:24 by elexis, 9 years ago

Description: modified (diff)

by elexis, 8 years ago

Attachment: revert_16998.patch added

Patch by wraitii.

comment:25 by elexis, 8 years ago

wraitii's patch (reverting r16998) affects the behavior of the bugs:

  • #3532: fixed
  • #3450: tested once, seems fixed
  • #3538: partial fix:
    • prevents the ship from entering the dock / terrain
    • still OOS, since the hierarchical pathfinder induces a different longpath for the rejoined client
    • (goal is still inside the building, since according to the hierarchical pathfinder it's passable for the host)
  • #3410: patial fix:
    • fixed with regards to units not actually getting inside
    • however the units will become stuck by trying to get into the CC without stopping.
  • #3471/#3505: probably not fixed
  • #3559: not fixed

comment:26 by wraitii, 8 years ago

Keywords: patch removed
Resolution: fixed
Status: newclosed

I am marking this ticket as fixed and suggest reopening a new ticket for the formation behavior, but that one is definitely not any higher priority than "should have".

All other behaviors are either fixed or documented elsewhere.

Thanks again Elexis for the magnificent debugging job on this issue.

comment:27 by elexis, 4 years ago

Description: modified (diff)

comment:28 by Freagarach, 3 years ago

In 25198:

Only tell stuff to move from foundation when trying to commit it.

It is wasteful to do and seems not needed anymore.

Differential revision: D3802
Comments by: @Angen, @Stan
Reverts r17029, rP17029
Refs. #3410

Note: See TracTickets for help on using tickets.