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

More resilient syncing of bill repeat mode #522

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mibac138
Copy link

The current approach of injecting watching into lambdas is fine as long as there aren't any mods adding additional options. This approach breaks down once there are more repeat modes (as added by Everybody Gets One). The EGO mod desyncs upon the first completion of a bill with a new repeat mode set ("Desnycs after the first item is made with a"x per colonists" bill." - copied from Modlist spreadsheet).
The desync was caused by the custom repeat modes not being synchronized. The mod adds it's own options into the FloatMenuOption list, but Multiplayer doesn't realize that (as it only monitors the 3 lambdas, not the whole list of options). After the client resyncs, the bill is redownloaded by the client and then it can see the real repeat mode configured (at least until it's re-changed again to a new repeat mode). The new approach works by injecting code at the very end of constructing menu options, just before they are passed to Find.WindowStack. This way any mod that adds custom repeat modes will have bill modes synchronized properly. Once merged, Everybody Gets One can have it's status upgraded from 1 to 2 (custom repeat modes will work, editing who counts as a person will not).

@SokyranTheDragon
Copy link
Member

If I may nitpick a little, I'd change how the success is checked by counting the amount of times call to Find.WindowStack was intercepted, and displaying an appropriate error if it happened more than once. Not sure if an exception would be warranted there (only if not patched at all).

@SokyranTheDragon SokyranTheDragon added enhancement New feature or request. 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). labels Mar 27, 2025
@mibac138
Copy link
Author

That's a fair point. I have adjusted the code and expanded some more on the error messages to be a bit more helpful. Also, thanks for the quick review! :)

@SokyranTheDragon
Copy link
Member

Also, a slight side note: it may take a while before before this gets merged in and released, so if you'd like to see it in the game anytime soon - your best bet is to make a PR with temporary patch in MP Compat. Which wouldn't be too unfitting, especially since (barring any future vanilla changes) this currently only affects mods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly). enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants