Fix desyncs for GloomForest, Lava and fish in multifaction#600
Merged
Fix desyncs for GloomForest, Lava and fish in multifaction#600
Conversation
The `SpawnFishFleck` method spawns a small visual effect. This method is guarded by `ShouldSpawnMotesAt`. `ShouldSpawnMotesAt` uses `Find.CurrentMap` and compares it to the provided map. In multi-faction gameplay - and possibly in multi-map gameplay - `CurrentMap` is not updated while ticking. Therefore, for the map that is not spawning the visual effect, the comparison returns `false`, while on the other map it returns `true`, leading to a desync. In this commit, `CurrentMap` is temporarily swapped to the target map within the `SpawnFishFleck` call to ensure proper behavior.
The `ThrowLavaSmoke ` method spawns a small visual effect. This method is guarded by `ShouldSpawnMotesAt`. `ShouldSpawnMotesAt` uses `Find.CurrentMap` and compares it to the provided map. In multi-faction gameplay - and possibly in multi-map gameplay - `CurrentMap` is not updated while ticking. Therefore, for the map that is not spawning the visual effect, the comparison returns `false`, while on the other map it returns `true`, leading to a desync. In this commit, `CurrentMap` is temporarily swapped to the target map within the `ThrowLavaSmoke ` call to ensure proper behavior.
Fix visual Glowforest desync by swapping CurrentMap The `EmissionTick` method spawns a small visual effect. This process is guarded by `ShouldSpawnMotesAt`. `ShouldSpawnMotesAt` uses `Find.CurrentMap` and compares it to the provided map. In multi-faction gameplay - and possibly in multi-map gameplay - `CurrentMap` is not updated while ticking. Therefore, for the map that is not spawning the visual effect, the comparison returns `false`, while on the other map it returns `true`, leading to a desync. In this commit, `CurrentMap` is temporarily swapped to the target map around the `ShouldSpawnMotesAt` call to ensure proper behavior.
WaterBodyHash now returns value of the orginal method when in singleplayer
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.
Label: Multifaction, 1.6, desync
This PR fixes a visual desync caused by
ShouldSpawnMotesAt(map, ...) returning inconsistent results across clients in multifaction or multimap games.RimWorld's
ShouldSpawnMotesAtinternally checks:map == Find.CurrentMapHowever, during our ticking system the map is not changed like in cmd's.
This leads to:
- One client passing the ShouldSpawnMotesAt check (e.g. on map A),
- Another client failing it (e.g. still focused on map B),
- Result: Visual-only effects (like glow, smoke, or fish flecks) spawn on one client but not the other -> desync.