Page 1 of 1

[0.18.22] Translations requested on the same tick that a game is saved are not fulfilled when that save is re-loaded

Posted: Mon May 04, 2020 1:08 am
by raiguard
Long-winded title, but this is a long-winded bug. It's actually been pestering me for months and months, but I assumed that it was the fault of my translation handler module. No longer do I think that!

The gist of it is, translations that are requested on the same tick that a game is saved are never returned if you reload that save. To reproduce:

1) Download the attached sample mod, and load it up.
2) Start a new game
3) Dismiss the freeplay explanation bubble, wait half a second (ish)
4) Save and reload the game
5) Wait half a second (ish), then pause and check the game's log file, scrolling to the bit where the save was reloaded

What you will find is this:

Code: Select all

14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-111"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-112"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-113"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-114"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-115"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-116"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-117"}
  14.066 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-118"}
  14.067 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-119"}
  14.067 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-120"}
  16.639 Info AppManagerStates.cpp:1844: Saving finished
  18.130 Loading map C:\Files\Development\Factorio\Testbenches\1\saves\FLib\SaveLoadSafe.zip: 1285382 bytes.
  18.188 Loading level.dat: 1978135 bytes.
  18.192 Info Scenario.cpp:187: Map version 0.18.22-1
  18.248 Loading script.dat: 416 bytes.
  18.251 Checksum for script C:/Files/Development/Factorio/Testbenches/1/temp/currently-playing/control.lua: 2466797803
  18.252 Checksum for script __TranslationTest__/control.lua: 2448771134
  18.299 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-121"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-122"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-123"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-124"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-125"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-126"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-127"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-128"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-129"}
  18.300 Script @__TranslationTest__/control.lua:14: REQUESTED: {"translation-130"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-121"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-122"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-123"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-124"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-125"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-126"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-127"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-128"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-129"}
  18.330 Script @__TranslationTest__/control.lua:27: RECEIVED: {"translation-130"}
As you can see, on the same tick that the game is paused, ten translations are requested. When the game is saved and reloaded, those translations are never returned.

If you save, and choose not to reload, the translations will be returned like normal.

Thank you!

Re: [0.18.22] Translations requested on the same tick that a game is saved are not fulfilled when that save is re-loaded

Posted: Mon May 04, 2020 2:53 am
by Rseding91
Thanks for the report. This isn't going to be changed; the same thing can happen in multiplayer if a player gets disconnected before the action gets processed by the server.

The action is always going to be unreliable; but it's the best option that exists.

Re: [0.18.22] Translations requested on the same tick that a game is saved are not fulfilled when that save is re-loaded

Posted: Mon May 04, 2020 4:13 pm
by raiguard
Thanks for the reply, but I disagree with it being a "minor issue" because there's no clean way to deal with it. In singleplayer we have no way of knowing when a game is saved and reloaded so there's no easy way to tell when this might happen.

I can work around it for now, but I do hope this can be dealt with before 1.0. Perhaps a new event for failed translation requests could be made, including the player_index and the localised string it wanted to translate?

Re: [0.18.22] Translations requested on the same tick that a game is saved are not fulfilled when that save is re-loaded

Posted: Mon May 04, 2020 6:57 pm
by Rseding91
Raiguard wrote: Mon May 04, 2020 4:13 pm Thanks for the reply, but I disagree with it being a "minor issue" because there's no clean way to deal with it. In singleplayer we have no way of knowing when a game is saved and reloaded so there's no easy way to tell when this might happen.

I can work around it for now, but I do hope this can be dealt with before 1.0. Perhaps a new event for failed translation requests could be made, including the player_index and the localised string it wanted to translate?
I don't see it as ever changing. The options were: I don't implement the feature at all or I do it like this. I can always remove it if you think it's really that useless as is.

Re: [0.18.22] Translations requested on the same tick that a game is saved are not fulfilled when that save is re-loaded

Posted: Mon May 04, 2020 7:53 pm
by raiguard
I never said it was useless? I apologize if it came across that way.

Re: [0.18.22] Translations requested on the same tick that a game is saved are not fulfilled when that save is re-loaded

Posted: Mon May 04, 2020 11:21 pm
by Rseding91
If I do ever think of a way to make it work outside of "send request, hope it comes back" I'll implement it, but for now this is the best I was able to come up with.