feat: Clean deterministic math fixes for review (v2.2-clean)#3
feat: Clean deterministic math fixes for review (v2.2-clean)#3Okladnoj wants to merge 4 commits into
Conversation
… check isPlayerConnected expects a Network slot index, but was receiving a PlayerList index. Added proper mapping to avoid spurious mismatches at low CRC intervals.
…rModule Hardcode m_availableOnFrame to 0 to simplify initialization and ensure deterministic behavior regardless of the CRC macro.
130c532 to
c40d248
Compare
| // TheSuperHackers @bugfix Caball009 14/06/2026 Check if player is still connected, | ||
| // to avoid spurious mismatches at low CRC intervals, e.g. every frame. | ||
| if (!TheNetwork->isPlayerConnected(it->first)) | ||
| // @fix 08/07/2026 okladnoj: it->first is the PlayerList index, but isPlayerConnected expects Network slot index! |
There was a problem hiding this comment.
ConnectionManager::getPlayerName returns an empty string once the connection is quitting (same condition isPlayerConnected checks), so for the player who just disconnected, the loop finds nothing, slotIndex stays -1, and the stale CRC gets included again. 2796 was fixing this. Maybe do the mapping at cache time? The map could be keyed by slot and this loop calls isPlayerConnected(it->first) unchanged. That also avoids the duplicate-display-name
| { | ||
|
|
||
| #if RETAIL_COMPATIBLE_CRC | ||
|
|
There was a problem hiding this comment.
I hit this bug on my fork too (Strategy Center battle plans never become ready with CRC=0). I'm not sure about removing the 0xFFFFFFFF init though, could hit a null issue. What worked for me was to keep the init and charge any power still at 0xFFFFFFFF in Player::onStructureConstructionComplete. This fixes the never-ready issue without reopening the crash that Mauller fixed.
| { | ||
| #if USE_DETERMINISTIC_MATH | ||
| return gm_atan(x); | ||
| return (double) gm_atanf((float)x); |
There was a problem hiding this comment.
This matches what I found on my fork. IMHO the long term fix is GameMath compiling the double kernels pure SSE2, or win64 with no x87 at all. This should work as is though
There was a problem hiding this comment.
Outside of VC6 even 32bit builds from MSVC use SSE2 unless that is specifically disabled in TSH? This basically violates the implied contract of the double math variants and you might as well just remove them or rename them so they can be used specifically where required. IMO, we should just support FLT_EVAL_METHOD == 0 from the float.h header and anything else just accept it will desync.
This PR merges the clean deterministic math fixes (without debug instrumentation) to the
okji/feat/deterministic-math-v2branch for team review.Key Changes:
WWMath::AtanandWWMath::Atan2double overloads to their single-precisiongm_atan*fvariants. This forces 24-bit precision and avoids the 53-bit vs 24-bit divergence between ARM64 and x86.SpecialPowerModule.RETAIL_COMPATIBLE_CRCback to0.Note: There might be more controversial fixes ahead (like patching
DumbProjectileBehaviorNaN casts andPartitionManagerradius math), so this PR serves as a stable checkpoint for the team to review.