More resilient syncing of bill repeat mode#522
Conversation
|
If I may nitpick a little, I'd change how the success is checked by counting the amount of times call to |
|
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! :) |
|
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. |
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 Onecan have it's status upgraded from 1 to 2 (custom repeat modes will work, editing who counts as a person will not).