Conversation
- UniqueIDsManagerGuard: Snapshot and restore UniqueIDsManager counters across UIRootOnGUI via compiled expression delegates to prevent off-tick UI passes from desyncing simulation IDs - ShuttlePatches: Null-coalesce CompShuttle required collections and guard SendLaunchedSignals to prevent infinite takeoff NRE loop - DeferredStackTracingImpl: Add bounds check in TraceImpl to prevent IndexOutOfRangeException on deep or inlined stack traces - DeferredStackTracing: Guard Postfix with try-catch to prevent tracing exceptions from breaking Rand getters - SourceGen: Align Microsoft.CodeAnalysis version with SDK compiler
…interferes with map generation
…UI with LongEventHandler & Scribe guards
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.
Summary
This pull request addresses three critical core and engine stability issues:
UIRoot_Play.UIRootOnGUI).IndexOutOfRangeExceptionin the desync stack tracing subsystem (DeferredStackTracingImpl.TraceImpl).NullReferenceExceptiontick-loop during shuttle departures in Royalty.🛠️ Changes
1.
UniqueIDsManagerGuard(Source/Client/Patches/UniqueIDsManagerGuard.cs)UIRoot_Play.UIRootOnGUI) often instantiate temporary items, jobs, or preview pawns off-tick. This consumes sequential IDs fromFind.UniqueIDsManageron the local client only, leaving ID counters divergent between host and peers and causing immediate desyncs on subsequent ticks.next*integer fields inFind.UniqueIDsManagerbeforeUIRootOnGUIand restores them via[HarmonyFinalizer]when the pass completes.System.Linq.Expressionsdelegates, generating 0 heap allocations / 0 boxing per frame inOnGUI. Active simulation ticks and synchronized commands bypass the rollback.2. Stack Tracing Bounds Check (
Source/Common/DeferredStackTracingImpl.cs&Source/Client/Desyncs/DeferredStackTracing.cs)DeferredStackTracingImpl.TraceImpl,traceInhas a fixed capacity of 32. In heavily modded stacks or when encountering dynamic Harmony wrappers (nameHash == 0),depthwas not incremented whileindexcontinued incrementing, causingtraceIn[index]to throwSystem.IndexOutOfRangeExceptioninside the postfix onRand.Int/Rand.Value.if (index >= traceIn.Length) break;inTraceImpl, and guardsDeferredStackTracing.Postfixwith a try-catch to isolate core RNG from any tracing errors.3. Shuttle Departure Loop Fix (
Source/Client/Patches/ShuttlePatches.cs)requiredPawnsorrequiredItemsdeserialize asnullduring save transfer or despawn,CompShuttle.SendLaunchedSignalsthrows an NRE insideShipJob_FlyAway.TryStart. BecauseTryStartreturns false, the shuttle re-attempts launch every tick, locking the game in an infinite exception loop.CompShuttle.PostExposeDataand suppresses departure exceptions with a finalizer so the shuttle can take off cleanly.✅ Verification
dotnet build Source/Multiplayer.slncompletes with 0 errors.