Skip to content

feat(math): integrate deterministic GameMath#176

Open
fbraz3 wants to merge 6 commits into
mainfrom
feature/gamemath-deterministic
Open

feat(math): integrate deterministic GameMath#176
fbraz3 wants to merge 6 commits into
mainfrom
feature/gamemath-deterministic

Conversation

@fbraz3

@fbraz3 fbraz3 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Context

Resolves the issue where multiplayer matches desync (Sync Mismatch / CRC error) when played across different CPU architectures (e.g. macOS ARM64 vs Linux x86_64).

The divergence occurs due to standard floating-point functions (<math.h>) evaluating differently depending on the backend compiler and architecture (especially FMA and trig differences).

Changes

  • Configures CMakeLists to pull GameMath via FetchContent.
  • Hooks wwmath.h to redirect sin, cos, tan, acos, asin, sqrt, and atan2 to use fdlibm-based deterministic functions.
  • Prevents cross-architecture divergence during simulation.

@fbraz3 fbraz3 force-pushed the feature/gamemath-deterministic branch 3 times, most recently from 81d2c79 to 85eca2c Compare June 22, 2026 13:25
Replaces standard CRT trigonometric functions with deterministic
fdlibm equivalents from GameMath via FetchContent.
Ensures multiplayer cross-platform replay determinism.

Resolves cross-platform mismatch disconnects.
@fbraz3 fbraz3 force-pushed the feature/gamemath-deterministic branch from 85eca2c to 8fbb570 Compare June 22, 2026 13:46
fbraz3 added 5 commits June 22, 2026 20:04
This commit addresses remaining naked CRT calls (ceilf, floorf, sqrt) in BaseType.h, Point.h, INI.cpp, and AIPathfind.cpp that were previously missed, enforcing determinism via WWMath and fast_float wrappers to prevent cross-platform replay desyncs.
- Implement ScopedFPUGuard to restore FPU precision mode upon scope exit in MiniAudio and OpenAL audio managers.

- Disable legacy RETAIL_COMPATIBLE_* macros (CRC, PATHFINDING, AIGroup, Networking, etc.) in GameDefines.h to avoid dynamic RNG/memory inconsistencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant