bugfix: Fix delays when requesting paths too quickly#2455
bugfix: Fix delays when requesting paths too quickly#2455Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp | Wraps 4 path request delay blocks with #if RETAIL_COMPATIBLE_CRC guards to disable the 1-2 second delay imposed when paths are requested within 3 frames of the previous request. Clean, symmetric changes across requestPath, requestAttackPath, requestApproachPath, and requestSafePath. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp | Mirror of the Generals changes for Zero Hour. Same 4 functions guarded. Note: requestAttackPath in GeneralsMD additionally had a setLocomotorGoalNone() call inside the delay block (not present in Generals), which is also disabled by this change. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Unit requests path] --> B{RETAIL_COMPATIBLE_CRC?}
B -->|Yes - Retail mode| C{Path requested within 3 frames?}
C -->|Yes| D[Delay 1-2 seconds via setQueueForPathTime]
D --> E[Return without queuing path]
C -->|No| F[Queue path immediately]
B -->|No - Fixed mode| F
F --> G[pathfinder->queueForPath]
Last reviewed commit: a0d8a4b
|
I suggest test this in Network matches too. Perhaps it has relevance when issuing many paths requests in the network. |
Skyaero42
left a comment
There was a problem hiding this comment.
Based on the comment Requesting path very quickly. Can cause a spin. it looks like this code was used to prevent a potential bug.
Additionally, it looks like, it is also an identifier for a unit that is stuck - for which it temporarily disables collision detection.
The pathfinding code is very complex and extremely fragile. Imho, this needs significantly more testing as well as obtaining an understanding why this code is here.
|
I agree that this code looks very deliberate with the comments and placement at multiple locations. Maybe there is a specific reason for it. I suggest give it to Goldfish too for testing. |
|
The pathfinder only has a limited queue size and if multiple units get repeated calls to repath then the list will quickly fill with multiple redundant path requests for the same unit. At the moment there is no mechanism to cancel a pathing request if it is still queued and has not been fulfilled yet. Edit - just looked and the pathfind queue code will search the list to see if the unit has already queued a request and will ignore subsequent checks, but it has to possibly search the entire list to check. |
|
@DrGoldFish1 Could you do some testing on this? |
|
@Skyaero42 i can try and test it out tomorrow. Will be a bit busy today. |
|
I think you need a slowed game and very fast unit pathing and then see if anything goes wrong when commanding units. Test in Network match. To simulate slow game, you can perhaps change the Network logic tick from 30 to 10 or so. |
This change fixes an issue where a path request that is issued within 3 frames of the previous one is delayed by up to 2 seconds. This issue is most notable and impactful when rapidly commanding Terrorists, which conspicuously moonwalk when this occurs, though the issue is apparent with all units. I imagine most players have probably experienced this behaviour at some point but do not consciously recall it.
The code comments left by the original developers indicate that the logic to delay rapidly requested paths is intentional, however the resulting unresponsiveness appears as a bug to players.
It is not yet clear what issues rapid path requests may cause, or whether it was just a precaution or a lazy performance optimisation. I've played several skirmish matches with many units and have not encountered any regressions or performance issues. Ideally any performance issues are addressed at a higher level rather than via an ungraceful workaround placed directly within the path request logic.
Demonstrations of the issue
A rapid succession of force-fire commands leave these units temporarily catatonic
DELAY_2.mp4
The classic two-second terrorist moonwalk
DELAY_1.mp4
Easily reproduced by stepping frames
DELAY_3.mp4
It's particularly bad when it comes to jets
DELAY_4.mp4