[1.1.59] call on player.character.die() will cause desync

This subforum contains all the issues which we already resolved.
Post Reply
kevinma
Inserter
Inserter
Posts: 33
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

[1.1.59] call on player.character.die() will cause desync

Post by kevinma »

How to reproduce:
1. create a blank scenario
2. add the code below into control.lua
3. host new game with sceanrio
4. in chat: /toggle-heavy-mode
5. drop a copper-plate to trigger player.character.die()
Then a desync will be happened

Code: Select all

script.on_event(defines.events.on_player_created, function(e)
    local player = game.get_player(e.player_index)
    player.insert({name="copper-plate"})
end)
script.on_event(defines.events.on_player_dropped_item, function(e)
    local player = game.get_player(e.player_index)
    if player.character then
        player.character.die()
   end
end)
Here's my scenario for test: (all other code is commented)
https://github.com/kevinmama/PandaAI/tr ... die-desync
截屏2022-06-08 下午2.30.27.png
截屏2022-06-08 下午2.30.27.png (4.07 MiB) Viewed 3226 times

kevinma
Inserter
Inserter
Posts: 33
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

Re: [boskid][1.1.59] call on player.character.die() will cause desync

Post by kevinma »

by the way, when i call entity.die() on spidertron in my scenario will cause desync too. but i can't reproduce it.
Calling player.character.destroy() or entity.destroy() is always safe from desync.

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

Re: [boskid][1.1.59] call on player.character.die() will cause desync

Post by boskid »

I was able to reproduce the behavior but i am not sure if this can actually be considered an issue. The heavy mode diff is obviously unexpected but having one of the scenarios at wrong tick is extremally suspicious. I see the issue comes from `Scenario::handlePlayerDiedTryRespawn()` function because it changes parts of the ScenarioExecutionContext when the game is a not a mulltiplayer, not a replay and not a simulation all at the same time. The issue is basically that the heavy-mode has to create a reference scenario and this reference scenario is not directly linking to the multiplayer game, making this condition to consider the reference scenario to not be part of multiplayer and an observable difference inside of the ScenarioExecutionContext happens between the original (from multiplayer) and the reference (save-loaded) scenario. I tried using `isLoadedInMultiplayer` variable from the game state instead of `multiplayerManagerBase` which seems to make the issue go away but i am not sure if this is a correct solution so i am leaving this bug report for someone else to fix.

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

Re: [1.1.59] call on player.character.die() will cause desync

Post by boskid »

Its now fixed for 1.1.61.

kevinma
Inserter
Inserter
Posts: 33
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

Re: [1.1.59] call on player.character.die() will cause desync

Post by kevinma »

boskid wrote:
Wed Jun 08, 2022 3:13 pm
Its now fixed for 1.1.61.
thanks for fixing. I finally figure out what cause my scenario desync and report another issue:
viewtopic.php?f=7&t=102629

Post Reply

Return to “Resolved Problems and Bugs”