FactorioScenarioMultiplayerSpawn icon indicating copy to clipboard operation
FactorioScenarioMultiplayerSpawn copied to clipboard

Desync with stored shared energy

Open ArchieBeepBoop opened this issue 3 years ago • 2 comments

It seems there's an occasional desync when the stored energy numbers are relatively large.

This seems to be due to the stored energy values being float points. (At least they look like floats) Perhaps because the numbers are growing a little bit too large, float loses precision and causes a desync.

I've used Hornwitser's factorio tools to identify the differences between the synchronized and desynchronized files and these are the results:

https://pastebin.com/cGiD1kEy

ArchieBeepBoop avatar Sep 21 '21 18:09 ArchieBeepBoop

Thanks for the report! That is definitely interesting... It's been awhile since I've looked into the code at all. Any suggestions for a possible fix based on what you found? I guess I could cap the max or something, but not sure if this means it is something I'm doing wrong or a bug in the game itself.

Oarcinae avatar Oct 01 '21 00:10 Oarcinae

I suppose a cap would be appropriate, yeah. Otherwise a different approach such as rounding the value and sending the value as an integer to clients could possibly help, but I'm not quite sure how lua treats floating point. Regardless, keeping that value uncapped does present the possibility of an overflow, which is also a source of desyncs as far as I know.

ArchieBeepBoop avatar Oct 01 '21 01:10 ArchieBeepBoop

This feature will be removed with the new mod. It will be replaced with the proper cross-surface electric network sharing that other mods use for shared electric networks. You won't be able to limit throughput, but it should stop any other weird bugs like this one and help a lot with UPS issues. I'll close this when I release the updated mod version.

Oarcinae avatar Sep 23 '24 02:09 Oarcinae