Skip to content

Fix CommonSense meditation desync: host-authoritative sync#562

Open
sviyh wants to merge 1 commit intorwmt:masterfrom
sviyh:fix/commonsense-meditation-desync
Open

Fix CommonSense meditation desync: host-authoritative sync#562
sviyh wants to merge 1 commit intorwmt:masterfrom
sviyh:fix/commonsense-meditation-desync

Conversation

@sviyh
Copy link
Copy Markdown
Contributor

@sviyh sviyh commented Apr 4, 2026

Summary

  • Fixes desync caused by CommonSense's JobDriver_MeditationTick_CommonSensePatch postfix evaluating joy.CurLevel >= 0.98f differently on host vs client due to floating point drift
  • Instead of disabling the feature, replaces it with a host-authoritative version: host evaluates the joy/psyfocus thresholds and syncs the EndJobWith decision to all clients via RegisterSyncMethod
  • The original postfix is canceled in MP via a Harmony prefix, and a new postfix on JobDriver_Meditate.MeditationTick runs only on the host

Root cause

Observed in desync log (map 19): CommonSense ended a reign/meditation job on the host (joy hit 0.98), triggering PickUpAndHaul's CheckIfPawnShouldUnloadInventory which created a new job and consumed extra RNG state. The client's joy was slightly below threshold, so the job continued — permanent RNG divergence from that tick forward.

Test plan

  • Load MP game with CommonSense active, verify meditation economy still works (pawns stop meditating when joy is full)
  • Verify no desync occurs during extended play with meditating/reigning pawns
  • Verify single-player is unaffected (original CommonSense postfix runs normally)

🤖 Generated with Claude Code

Instead of disabling the meditation economy feature entirely in MP,
replace it with a host-authoritative version. The host evaluates the
joy/psyfocus thresholds and syncs the EndJobWith decision to all
clients via RegisterSyncMethod, ensuring deterministic execution.

The original postfix checked joy.CurLevel >= 0.98f directly on each
client, but floating point drift caused divergent job endings that
cascaded into full desyncs through PickUpAndHaul job creation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sviyh sviyh force-pushed the fix/commonsense-meditation-desync branch from d0c9195 to fa43e72 Compare April 4, 2026 05:41
@Zetrith
Copy link
Copy Markdown
Member

Zetrith commented Apr 4, 2026

Some issues:

  • Floating point drift isn't an issue AFAIK, is this an AI hallucination?
  • SyncMethods only execute from code called in the interface, a call during ticking won't be replicated

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.

2 participants