bugfix(pathfinder): Fix uninitialized variable in Pathfinder::tightenPathCallback to prevent mismatches#2309
Conversation
|
|
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
There was a problem hiding this comment.
i don't think d->destPos is initialised properly by using zero for non retail compatible use.
destPos could be externally initialised with the initial destination position in the calling function.
or as we did before, pos could just be set to the to position by using the adjust cell to world function in non retail code like we did on a first attempt.
477c448 to
a7cb4fa
Compare
|
I made a couple of changes to the initialization logic. The intended initialization for retail is still: Coord3D pos = (!d->foundNewDest) ? Coord3D(0.0f, 0.0f, 0.0f) : d->newDestPos;The new changes are probably an improvement to the code, but I'm not sure if the code comment still makes sense without context. |
There was a problem hiding this comment.
Looks good to me, i guess this still passes all the same replays?
| info.foundNewDest = false; | ||
| info.orgDestPos = *to; | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| info.newDestPos.zero(); |
There was a problem hiding this comment.
newDestPost could be zero initialied here anyway regardless of retail compat for cleanliness.
I don't think it matters if it is left uninitialised for non-retail since it's only ever assigned to then read from when foundNewDest is true etc.
There was a problem hiding this comment.
I don't have a strong opinion on it, either way.
The current code should effectively still be the same as what I tested with. I did a quick check just now with the fastest replays and those are still fine. I happened to be doing some unrelated replay testing with the latest weekly release (2026-02-27), and noticed 30+ / 2000 new mismatches, e.g. for replays like this one 1v1 (25.11.18) [rank] vendetta zh v1 SR_MaD^(gla) vs Penguin(tox).zip These replays don't mismatch with the previous weekly release (2026-02-20), and I tracked it down to https://github.com/TheSuperHackers/GeneralsGameCode/pull/2327/changes The mismatches are gone with this PR :) |
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.
The retail compatible code uses effectively this initialization logic:
TODO:
Thanks to @Mauller and @DrGoldFish1 for their help.