bugfix(pathfinder): Fix uninitialized variable in Pathfinder::tightenPathCallback to prevent mismatches#2309
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/GameLogic/AIPathfind.h | Made adjustCoordToCell static to allow calling from static callback function |
| Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | Initialized uninitialized pos variable in tightenPathCallback using conditional compilation guard, implemented function as static |
Last reviewed commit: 1d78179
|
Did you mean to do the fix in Generals/ not GeneralsMD/? |
Oops, yeah, that's silly of me. Not sure how that happened. |
…PathCallback to prevent mismatches.
1c744fc to
52d46c5
Compare
I'm not sure if that solves anything. I tried the current main branch with the wwmath.h header from 2856a23 ( the commit before 4bbf0c0 ) and the VC6 replay still mismatches. Harmless changes anywhere can change stack layouts and introduce mismatches that hadn't been noticeable before because of uninitialized variables. |
Another uninitialized variable rears its ugly head; this time in the path finding code. Causes mismatches, which can be reproduced by driving on the terrain around certain bridges.
Reproduction in Sand Serpent:
bridge_mm.mp4
Replay for VC6:
00-04-16_1v1_adapte_Anthony1.zip This replay does not mismatch with retail executable, and first started to mismatch with 4bbf0c0
Map and replay for VS22:
bridge_mm.zip This replay was recorded with a release build, and the mismatch shows when replay is played back with a debug build.
Notes:
I could not see any noticeable issues in-game because of this bug during my testing. The fix cannot be applied unconditionally, because it breaks the golden replay 1 and probably others. It's currently tied to the path-finding fail-over, because that's better than nothing. It needs to be replaced with a proper opt-in mechanism. Adding this fix should be good for GeneralsOnline.
Edit: maybe some other values will work well enough that we can use them for retail.
TODO:
Thanks to @Mauller and @DrGoldFish1 for their help.