Skip to content

Fix desyncs for GloomForest, Lava and fish in multifaction#600

Merged
notfood merged 4 commits intorwmt:devfrom
Tick-git:Fix-Multifaction-Fish-Lava-Desync
Jul 23, 2025
Merged

Fix desyncs for GloomForest, Lava and fish in multifaction#600
notfood merged 4 commits intorwmt:devfrom
Tick-git:Fix-Multifaction-Fish-Lava-Desync

Conversation

@Tick-git
Copy link
Copy Markdown
Contributor

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 ShouldSpawnMotesAt internally checks:

map == Find.CurrentMap

However, 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.

Tick-git added 4 commits July 23, 2025 23:17
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
@notfood notfood merged commit 830b027 into rwmt:dev Jul 23, 2025
1 check passed
@notfood notfood added fix Fixes for a bug or desync. desync Bug that specifically causes a desynced state. multifaction Bugs or issues only in multifaction mode. 1.6 Fixes or bugs relating to 1.6 (Not Odyssey). labels Jul 23, 2025
@notfood notfood moved this to Done in 1.6 and Odyssey Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6 Fixes or bugs relating to 1.6 (Not Odyssey). desync Bug that specifically causes a desynced state. fix Fixes for a bug or desync. multifaction Bugs or issues only in multifaction mode.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants