More resilient syncing of bill repeat mode #522
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.
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).