bugfix(pathfinder): Fix uninitialized variable in Pathfinder::tightenPathCallback to prevent mismatches#2309
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | Initializes previously uninitialized pos variable in tightenPathCallback to prevent undefined behavior and match retail determinism; clarifies return statement comments |
Last reviewed commit: 51919b3
|
Did you mean to do the fix in Generals/ not GeneralsMD/? |
Oops, yeah, that's silly of me. Not sure how that happened. |
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. |
cc871b4 to
3eb91ef
Compare
|
Considering how varied the value of Pos was, from what you showed me, maybe we can't set it to anything specific but take the non retail stuff? |
What do you mean? |
2fa625d to
da544e9
Compare
|
I was able to find a way to initialize this variable without introducing new mismatches. I checked more than 3500 replays to verify that. Unfortunately, the mismatch in the original replay did not go away. |
…PathCallback to prevent mismatches.
d945477 to
51919b3
Compare
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. I checked more than 3500 replays and this change did not introduce new mismatches. Unfortunately, the mismatch in the above replay did not go away.
TODO:
Thanks to @Mauller and @DrGoldFish1 for their help.