Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RumbleTrigger Desync #68

Open
LozenChen opened this issue Feb 26, 2024 · 1 comment
Open

RumbleTrigger Desync #68

LozenChen opened this issue Feb 26, 2024 · 1 comment

Comments

@LozenChen
Copy link
Contributor

LozenChen commented Feb 26, 2024

RumbleTrigger, which breaks CrumbleWallOnRumble blocks

...
foreach (CrumbleWallOnRumble crumble in crumbles){
	crumble.Break();
	yield return 0.05f;
}

determines the order of these crumbles when RumbleTrigger.Awake is called. And RumbleTrigger.Awake contains this line of code
crumbles.Sort((CrumbleWallOnRumble a, CrumbleWallOnRumble b) => (!Calc.Random.Chance(0.5f)) ? 1 : (-1));

We know when Level.LoadLevel is called, new Random(Session.LevelData.LoadSeed) is pushed onto the random stack, then all entities/triggers added to the scene, their Awake methods called, then this random is poped
So in most cases, this RumbleTrigger RNG is actually fixed

However, if there's a mod which hooks Level.LoadLevel to add a mod entity,

private static void On_Level_LoadLevel(On.Celeste.Level.orig_LoadLevel orig, Level level, Player.IntroTypes playerIntro, bool isFromLoader){
  level.Add(new ModEntity());
  orig(level, playerIntro, isFromLoader);
}

and the ModEntity calls Calc.Random in its Awake method, then the RNG of RumbleTrigger is affected

And there is such example, e.g. in Gallery Collab HeartSide, if you ever passed flag19, then a MaxHelpingHand.CustomizableGlassBlockController is added to each upcoming level, and this entity, calls Calc.Random. So in this case, if a team cooperate on this tas, each team member responsible for several flags, and no one knows there is such an issue. When they've done their work and try to put their tases together, a desync appears unexpectedly.


Now the issue is, should we fix this "desync"?

We can easily prevent this kind of desync by enclosing RumbleTrigger.Awake with a Push/PopRandom pair. However, this may cause most tases which rely on the order of crumble-blocks-breaking to desync. Or we manually search for all such kind of bad mod entities and patch them?

@LozenChen
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant