Skip to content

Change how Odyssey's ShouldSpawnMotesAt fixes are handled#665

Merged
notfood merged 1 commit intorwmt:devfrom
SokyranTheDragon:change-how-odyssey-shouldspawnmotesat-is-handled
Sep 3, 2025
Merged

Change how Odyssey's ShouldSpawnMotesAt fixes are handled#665
notfood merged 1 commit intorwmt:devfrom
SokyranTheDragon:change-how-odyssey-shouldspawnmotesat-is-handled

Conversation

@SokyranTheDragon
Copy link
Copy Markdown
Member

The issue with those methods calling ShouldSpawnMotesAt is that they use RNG, changing the state of RNG depending on player-specific info (current map).

Currently, the methods spawning flecks are handled in OdysseyMultifaction class. Those patches ensure that the flecks will always spawn, regardless of the map the player is on.

However, we generally handle desyncs due to fleck/mote spawning like this using a prefix/finalizer and pushing/popping the RNG state, so even if the methods themselves use RNG depending on the player-specific info they'll all be safe. Since motes/flecks are visual only effect with no impact on gameplay itself, Multiplayer doesn't require those to be synchronized between the players (but as this example shows, it may still cause issues if it accesses something like RNG).

Handling it by using Rand.PushState and Rand.PopState is generally going to be better performance-wise, since we won't be spawning motes/flecks on maps the players isn't currently looking at. On top of that, the patches themselves are also going to be much simpler now.

@Tick-git pinging you since you were the one who made this fix originally. Any objections to the changes I've made here?

Changes:

  • Added 3 Odyssey fleck methods using ShouldSpawnMotesAt to list of methods that are patched with Push/Pop State
  • Removed OdysseyMultifaction.cs, as it's no longer needed

The issue with those methods calling `ShouldSpawnMotesAt` is that they use RNG, changing the state of RNG depending on player-specific info (current map).

Currently, the methods spawning flecks are handled in OdysseyMultifaction class. Those patches ensure that the flecks will always spawn, regardless of the map the player is on.

However, we generally handle desyncs due to fleck/mote spawning like this using a prefix/finalizer and pushin/popping the RNG state, so even if the methods themselves use RNG depending on the player-specific info they'll all be safe.

Handling it by using `Rand.PushState` and `Rand.PopState` is generally going to be better performance-wise, since we won't be spawning motes/flecks on maps the players isn't currently looking at. On top of that, the patches themselves are also going to be much simpler now.

Changes:
- Added 3 Odyssey fleck methods using `ShouldSpawnMotesAt` to list of methods that are patched with Push/Pop State
- Removed OdysseyMultifaction.cs, as it's no longer needed
@SokyranTheDragon SokyranTheDragon added enhancement New feature or request. odyssey Fix or bugs relating to Odyssey (Not 1.6) labels Sep 2, 2025
@notfood notfood added the 1.6 Fixes or bugs relating to 1.6 (Not Odyssey). label Sep 3, 2025
@notfood notfood moved this to In review in 1.6 and Odyssey Sep 3, 2025
@Tick-git
Copy link
Copy Markdown
Contributor

Tick-git commented Sep 3, 2025

No objections - I love cleaner solutions that work with less code! 😀 #636 can be closed when merged.

@notfood notfood linked an issue Sep 3, 2025 that may be closed by this pull request
@notfood notfood merged commit ab5062a into rwmt:dev Sep 3, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In review to Done in 1.6 and Odyssey Sep 3, 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). enhancement New feature or request. odyssey Fix or bugs relating to Odyssey (Not 1.6)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Implement Fix For GenView.ShouldSpawnMotesAt Correctly

3 participants