Isolate RNG in the gravship launch ritual's reachability check#968
Open
cmlee119 wants to merge 1 commit into
Open
Isolate RNG in the gravship launch ritual's reachability check#968cmlee119 wants to merge 1 commit into
cmlee119 wants to merge 1 commit into
Conversation
Building the gravship launch confirmation dialog decides which pawns can
board in Dialog_BeginRitual's constructor: CreateRitualRoleAssignments ->
RitualRoleAssignments.PawnNotAssignableReason ->
RitualBehaviorWorker_GravshipLaunch.PawnCanFillRole -> CanReachGravship ->
GravshipUtility.TryFindSpotOnGravship -> Region.RandomCell, which consumes
RNG. Building the dialog is UI work opened only by the issuing peer (the
currentExecutingCmdIssuedBySelf gate in CancelDialogBeginRitual), so that
RNG runs on just one peer and advances the shared stream on that peer only.
Spamming the launch button repeats it and the divergence accumulates into a
desync ("Random state from commands doesn't match").
Wrap CanReachGravship in Rand.PushState/PopState, matching the existing
SeedPreceptComp_UnwillingToDo_Chance isolation for RNG that "can be called in
interface". CanReachGravship returns a bool that does not depend on the RNG
(it only searches for any allowed cell), and the real boarding calls
TryFindSpotOnGravship outside this check, so isolating here leaves both the
check result and determinism intact.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #967.
Problem
Building the gravship launch confirmation dialog decides which pawns can board, in
Dialog_BeginRitual's constructor:Building the dialog is UI work opened only by the issuing peer (the
currentExecutingCmdIssuedBySelfgate inCancelDialogBeginRitual), so this RNG runs on just one peer and advances the shared stream there only. Spamming the launch button repeats it and the divergence accumulates into a desync (Random state from commands doesn't match). Measured: with nothing ticking, the gravship map alone was off by +11,617 rand iterations, all on the peer that pressed launch.Fix
Wrap
RitualBehaviorWorker_GravshipLaunch.CanReachGravshipinRand.PushState/PopState, matching the existingSeedPreceptComp_UnwillingToDo_Chanceisolation in the same file for RNG that "can be called in interface".CanReachGravshipreturns a bool that does not depend on the RNG (it only searches for any allowed cell), and the real boarding callsTryFindSpotOnGravshipoutside this check, so isolating here leaves both the check result and determinism intact.Testing
Random state from commands doesn't match.Source/Clientbuilds clean (Release).Investigated and written with the help of Claude (Anthropic).