[1.1.52] crc fails on reading production statistics in replay

Bugs that are actually features.
Post Reply
Thiske
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sat Nov 21, 2020 11:53 am
Contact:

[1.1.52] crc fails on reading production statistics in replay

Post by Thiske »

Modifying then control.lua file from a save to extract information, and then rewatching the replay causes the crc to desync.
The line that is causing the problem is

Code: Select all

game.players[1].force.item_production_statistics.input_counts[item]
Somehow reading this table (even though it is read-only) changes the crc.
As an attachment is the save in question and the original save. (The " - kopie" is the modified one)
Attachments
mmp_220118.zip
(13.3 MiB) Downloaded 55 times
mmp_220118 - kopie.zip
(19.69 MiB) Downloaded 59 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.52] crc fails on reading production statistics in replay

Post by boskid »

Thanks for the report, however i am not considering tampering with control.lua of a save file with a replay to be a bug report worthy if there are any issues happening due to script change. In this particular case the issue is that item_production_statistics internally is a "LazyCreatedStatistics" so trying to read LuaForce::item_production_statistics when statistics were not yet created will change game state and a crc difference will happen.

Thiske
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sat Nov 21, 2020 11:53 am
Contact:

Re: [1.1.52] crc fails on reading production statistics in replay

Post by Thiske »

yeah but normally script changes are allowed for this reason. To collect data in the background. (this is at least what the wiki says). That's why I though it was bug report worhty. Is there any way to disable this crc check? Or to read production stats without changes the game state?

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.52] crc fails on reading production statistics in replay

Post by boskid »

script changes of replay are allowed but this is the grey area of "if it works, it works. If it does not work, we are not going to fix it [in most cases]". In order to not desync when all clients in MP are running same code they should produce the same outcome. Replay may be considered as a just another client in MP game which receives input actions not from the network but from a file. We are free to make any optimizations that are deterministic and thats what happens here: item production statistics are not stored or managed until there is anything consumed or crafted. In most cases biters are not crafting anything so enemy force does not need statistics. There are no bugs here: in MP environment, script running on all clients is expected to cause same effects and in this case it would create statistics on all game instances - all of our requirements for determinism are fulfilled. By introducing a script change in the area which changes the game state and requesting us to fix this you are basically trying to force a "this is unusual use case, please no longer do any optimizations because they will cause replay issues when i change a script" and script change is not a intended use case. Item statistics are included in the heuristic crc generator which helps catching early if a client in MP game is diverging from server, but the same mechanism is used by replay. This heuristic crc generator however is checking if statistics are present and if they are not it simply skips including them for a given force (does not force them to exists). This is why by checking item_production_statistics which changes game state you get a crc fail: all of sudden your game instance doing a replay sees there are statistics and computes different crc for a "player" force. You can delay accessing item_production_statistics to a point when you know they exist but there are no api reads to know if given statistics exist already.

Post Reply

Return to “Not a bug”