The International Simutrans Forum

 

Author Topic: Different save files when saving and reloading while paused  (Read 206 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 180
Different save files when saving and reloading while paused
« on: September 07, 2020, 08:33:51 PM »
To reproduce:
  • (optional) Set savemode = binary in simuconf.tab
  • Save a game while paused
  • Close the game
  • Load the previously saved savegame with the -pause command-line option enabled
  • Save the game to a different save file
  • Compare the two save files; they should be byte-equal (but are not)
Excerpt from running colordiff -C2 <(hexdump -C save/yoshi1.sve) <(hexdump -C save/yoshi2.sve) on two save files generated from the yoshi test map using the above prodedure:
Code: [Select]
***************
*** 37,41 ****
  00000240  0f 00 00 00 0a 00 00 00  08 00 00 00 0f 00 00 00  |................|
  00000250  19 00 00 00 30 00 05 00  10 00 14 00 00 02 31 31  |....0.........11|
! 00000260  30 48 f4 53 73 19 00 00  00 04 00 00 00 31 01 00  |0H.Ss........1..|
  00000270  00 00 04 00 00 00 24 26  10 90 01 03 04 00 82 00  |......$&........|
  00000280  30 20 00 00 00 d0 07 00  00 04 00 00 00 01 00 30  |0 .............0|
--- 37,41 ----
  00000240  0f 00 00 00 0a 00 00 00  08 00 00 00 0f 00 00 00  |................|
  00000250  19 00 00 00 30 00 05 00  10 00 14 00 00 02 31 31  |....0.........11|
! 00000260  30 b5 d8 18 04 19 00 00  00 04 00 00 00 31 01 00  |0............1..|
  00000270  00 00 04 00 00 00 24 26  10 90 01 03 04 00 82 00  |......$&........|
  00000280  30 20 00 00 00 d0 07 00  00 04 00 00 00 01 00 30  |0 .............0|
***************
*** 35316,35325 ****
  0008aa80  04 00 00 00 01 0f 0a 32  00 01 00 00 00 00 00 00  |.......2........|
  0008aa90  00 00 01 00 00 00 01 00  00 00 09 00 63 69 74 79  |............city|
! 0008aaa0  5f 72 6f 61 64 ff 02 40  f0 f8 01 22 09 00 00 24  |_road..@..."...$|
! 0008aab0  ff 02 00 00 00 00 00 9c  01 0d 00 05 51 2e 00 00  |............Q...|
! 0008aac0  0c 00 70 65 64 65 73 74  72 69 61 6e 5f 33 00 00  |..pedestrian_3..|
! 0008aad0  30 40 f0 f8 01 ef 08 00  00 56 ff 02 00 00 00 00  |0@.......V......|
! 0008aae0  00 9c 01 0d 00 05 d9 3b  00 00 0c 00 70 65 64 65  |.......;....pede|
! 0008aaf0  73 74 72 69 61 6e 5f 34  00 00 30 ff ff 01 05 fe  |strian_4..0.....|
  0008ab00  04 00 00 00 01 0f 0b 32  00 01 00 00 00 00 00 00  |.......2........|
  0008ab10  00 00 01 00 00 00 03 00  00 00 09 00 63 69 74 79  |............city|
--- 35316,35325 ----
  0008aa80  04 00 00 00 01 0f 0a 32  00 01 00 00 00 00 00 00  |.......2........|
  0008aa90  00 00 01 00 00 00 01 00  00 00 09 00 63 69 74 79  |............city|
! 0008aaa0  5f 72 6f 61 64 ff 02 40  f0 f8 01 ef 08 00 00 56  |_road..@.......V|
! 0008aab0  ff 02 00 00 00 00 00 9c  01 0d 00 05 d9 3b 00 00  |.............;..|
! 0008aac0  0c 00 70 65 64 65 73 74  72 69 61 6e 5f 34 00 00  |..pedestrian_4..|
! 0008aad0  30 40 f0 f8 01 22 09 00  00 24 ff 02 00 00 00 00  |0@..."...$......|
! 0008aae0  00 9c 01 0d 00 05 51 2e  00 00 0c 00 70 65 64 65  |......Q.....pede|
! 0008aaf0  73 74 72 69 61 6e 5f 33  00 00 30 ff ff 01 05 fe  |strian_3..0.....|
  0008ab00  04 00 00 00 01 0f 0b 32  00 01 00 00 00 00 00 00  |.......2........|
  0008ab10  00 00 01 00 00 00 03 00  00 00 09 00 63 69 74 79  |............city|
***************
*** 35327,35335 ****
  0008ab30  01 0f 0a 32 00 01 00 00  00 00 00 00 00 00 01 00  |...2............|
  0008ab40  00 00 03 00 00 00 09 00  63 69 74 79 5f 72 6f 61  |........city_roa|
! 0008ab50  64 ff 02 40 f0 f8 01 69  03 00 00 ee ff 02 00 00  |d..@...i........|
! 0008ab60  00 00 00 9e 01 0d 00 05  48 19 00 00 05 00 57 6f  |........H.....Wo|
! 0008ab70  6d 61 6e 00 00 31 40 f0  f8 01 d5 06 00 00 8b ff  |man..1@.........|
! 0008ab80  02 00 00 00 00 00 9e 01  0d 00 05 c0 11 00 00 0c  |................|
! 0008ab90  00 70 65 64 65 73 74 72  69 61 6e 5f 32 00 00 31  |.pedestrian_2..1|
  0008aba0  ff ff 01 05 fe 04 00 00  00 01 0f 0e 32 00 01 00  |............2...|
  0008abb0  00 00 00 00 00 00 00 01  00 00 00 04 00 00 00 09  |................|
--- 35327,35335 ----
  0008ab30  01 0f 0a 32 00 01 00 00  00 00 00 00 00 00 01 00  |...2............|
  0008ab40  00 00 03 00 00 00 09 00  63 69 74 79 5f 72 6f 61  |........city_roa|
! 0008ab50  64 ff 02 40 f0 f8 01 d5  06 00 00 8b ff 02 00 00  |d..@............|
! 0008ab60  00 00 00 9e 01 0d 00 05  c0 11 00 00 0c 00 70 65  |..............pe|
! 0008ab70  64 65 73 74 72 69 61 6e  5f 32 00 00 31 40 f0 f8  |destrian_2..1@..|
! 0008ab80  01 69 03 00 00 ee ff 02  00 00 00 00 00 9e 01 0d  |.i..............|
! 0008ab90  00 05 48 19 00 00 05 00  57 6f 6d 61 6e 00 00 31  |..H.....Woman..1|
  0008aba0  ff ff 01 05 fe 04 00 00  00 01 0f 0e 32 00 01 00  |............2...|
  0008abb0  00 00 00 00 00 00 00 01  00 00 00 04 00 00 00 09  |................|
***************

Solving this bug will also probably enable allowing a client to connect to a server without the need for other clients to reload the game.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1391
Re: Different save files when saving and reloading while paused
« Reply #1 on: September 07, 2020, 09:32:00 PM »
Surprised there's not more differences, this is a rather known issue, and why the save forces the save/load on clients in the first place. Loading resets some variables.
If there's only a few, and you can track down what they are, for all savegames, then maybe the client reloading can be removed. But a save/reload cycle should only take a few seconds so...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10143
  • Languages: De,EN,JP
Re: Different save files when saving and reloading while paused
« Reply #2 on: September 08, 2020, 02:22:36 AM »
Older savegames (which happens while new features are introduced and not saved yet) require as well the restoration of the defaults, since the needed value was not supplied.

Useless messages are pruned from the history which cause a difference but is harmless. Server savegames only sent the number and age of trees, not the position to save memory (which can be a lot). This does not affect the gamestate but causes differences.

There may be also some fine internal counter are reset to zero during savegames. One could make of course an automatic check, loading a game, saving it, and then saving it immeadiately again while asserting of deviation from the previous save.

Or you do this manually using <xml> which gives you GB size text files which you throw at diff ...

EDIT: I did so. The main deviation between savegames are a different order of pedestrains, which is not critical (unless more than 254 amass on one tile, which mey lead to desync). If there are animated pedestrians, the animation is also not saved (same for some clouds). Also the finish_rd for the map is called multithreading, so it can change the savegame but not affect the game state. Finally the synv_step is called with (0) after loading even when paused, so soem object may cease to exist during the time for loading.

I do not think it is worth investing time here, especially a zipped game reload is much faster than the server sending out its savegame and the client has to recieve it and reload it anyway.
« Last Edit: September 08, 2020, 03:47:43 AM by prissi »