[0.18.3] Replay desync after a few minutes.

Bugs that are actually features.
Post Reply
nepp95
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Wed Apr 16, 2014 6:48 pm
Contact:

[0.18.3] Replay desync after a few minutes.

Post by nepp95 »

Hello,

I am trying to create a timelapse from replay. For this I have edited the control.lua, so there we go already :roll:
I don't know if this is considered a bug (or just me being stupid.) but I thought I'd report it anyway, and let you be the judge of that.

The only change I made is adding below code to the control.lua.
Load replay. Put in on, say, 4x speed. Wait a few seconds. Error. (I say minutes in the title because it is fast forwarded ;) )

Added to control.lua:

Code: Select all

script.on_event(defines.events.on_tick, function(event)
   if event.tick % 3600 == 0 then --every 60 seconds
	
	local counter = event.tick / 3600
        local x_size = 1024
        local y_size = 1024
        local x_center = 0
        local y_center = 0
        local x_radius = 4
        local y_radius = 4
        local zoom = 0.5
        local anti_alias = false
        local ent_info = true

        game.surfaces[1].daytime = 0

        for j=-y_radius,y_radius do
            for i=-x_radius,x_radius do
                game.take_screenshot{resolution = {x = x_size, y = y_size},
                    zoom = zoom,
                    surface = game.surfaces[1],
                    allow_in_replay = true,
                    position = {i*x_size/32/zoom + x_center, j*y_size/32/zoom + y_center},
                    show_entity_info = ent_info,
                    anti_alias = anti_alias,
                    path = counter.."_image_"..j+y_radius.."_"..i+x_radius..".png"}
            end
        end
   end
end)
Attached save, log and error screenshot.

Kind regards,
Niels
Attachments
2020r.zip
(9.27 MiB) Downloaded 64 times
factorio-current.log
(9.32 KiB) Downloaded 67 times
2020.02.04-23.23.png
2020.02.04-23.23.png (4.32 MiB) Viewed 2361 times

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

Re: [0.18.3] Replay desync after a few minutes.

Post by boskid »

Code: Select all

game.surfaces[1].daytime = 0
This changes game state so during replay, it is no longer same as it was when creating and so crc is different. Not a bug.

nepp95
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Wed Apr 16, 2014 6:48 pm
Contact:

Re: [0.18.3] Replay desync after a few minutes.

Post by nepp95 »

boskid wrote:
Tue Feb 04, 2020 10:37 pm

Code: Select all

game.surfaces[1].daytime = 0
This changes game state so during replay, it is no longer same as it was when creating and so crc is different. Not a bug.
Aha.. So this only works when actually playing, and not in replay?

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

Re: [0.18.3] Replay desync after a few minutes.

Post by boskid »

nepp95 wrote:
Thu Feb 06, 2020 10:27 pm
Aha.. So this only works when actually playing, and not in replay?
Changing control.lua of a save file with replay and then doing replay is undefined behavior, but we silently accept that as long as changes do not produce difference in game state. Your changes in control.lua introduced difference in game state and this is why there is desync. Playing game any further would be pointless since your inputs would no longer align with state of game. Taking screenshot does not change game state. Changing daytime changes game state.

Simple case how changing daytime could desync: lamps could consume less energy, so some assemblers could produce item early (for example ammo) making it in time to turret and biters could be defeated, and differences would cascade everywhere.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.18.3] Replay desync after a few minutes.

Post by Klonan »

Maybe you can change the day time, take the screenshot, and then set it back to what it was

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.3] Replay desync after a few minutes.

Post by posila »

Klonan wrote:
Fri Feb 07, 2020 1:12 pm
Maybe you can change the day time, take the screenshot, and then set it back to what it was
You can't (or you can, but it won't work) ... screenshots are processed after update finishes, before rendering.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.18.3] Replay desync after a few minutes.

Post by Klonan »

posila wrote:
Fri Feb 07, 2020 1:13 pm
Klonan wrote:
Fri Feb 07, 2020 1:12 pm
Maybe you can change the day time, take the screenshot, and then set it back to what it was
You can't (or you can, but it won't work) ... screenshots are processed after update finishes, before rendering.
Hmm, maybe settings surface.min_darkness will work, if its not in the CRC

Or making a script render light over the whole factory

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [0.18.3] Replay desync after a few minutes.

Post by darkfrei »

:idea: Here must be something like player.replay_min_darkness to change the min darkness for player view, but not surface.

nepp95
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Wed Apr 16, 2014 6:48 pm
Contact:

Re: [0.18.3] Replay desync after a few minutes.

Post by nepp95 »

Maybe an option in replay to have a certain lightness (or disable darkness entirely.) But only have this change in the render, not in the update, so everything still does what it needs to do (lights, solar panels etc). Will look weird of course to have lights on while it isn't dark at all, but for people needing this option, I don't think that will be a problem. And even that could be cut out of the render.

Just thinking here. Don't know how you've got the update/render loops built.

Post Reply

Return to “Not a bug”