Panakotta00 / FicsIt-Networks

Control, Monitor, Manage and Automate your Satisfactory.
https://ficsit.app/mod/FicsItNetworks
GNU General Public License v3.0
161 stars 51 forks source link

Overwriting drive contents from save file corrupts binary data #259

Open llamaizing opened 1 year ago

llamaizing commented 1 year ago

Describe the bug When loading a save game, if the local drive contents differ from the contents from the save file, a message box pops up asking if you want to overwrite the drive with the contents of the save (see screenshot). If choosing the overwrite option then files containing binary data may become corrupted (file was not corrupted at the time of the save).

Perhaps there's a coersion to valid utf8 format going on? The file is binary and does not conform to utf8.

The attached .ppm demonstrates the problem. 83 bytes total containing an ASCII header of 56 bytes followed by 27 bytes of binary data representing RGB values for a 9x9 image.

To Reproduce

  1. Build a computer with a drive installed
  2. copy the attached .ppm image file to the drive (decompress .zip file first)
  3. save the game and exit to the main menu
  4. Alter the contents of the drive (e.g. duplicate the image file)
  5. Load the save again, choosing the option to overwrite the drive with contents from save
  6. The image file is now corrupted

Expected behavior The image file should be restored to the way it was at the time of the save. Some bytes are now altered.

Here some test code to read the bytes of the image file:

local file = filesystem.open(IMG_PATH)
local data = file:read(128)
print("total size:", #data)
print(data:byte(1,56)) --header, ASCII
print("## DATA ##")
print(data:byte(57,83)) --binary data
file:close()

Output at time of save:

total size: 83
80 54 10 35 32 67 114 101 97 116 101 100 32 98 121 32 71 73 77 80 32 118 101 114 115 105 111 110 32 50 46 49 48 46 54 32 80 78 77 32 112 108 117 103 45 105 110 10 51 32 51 10 50 53 53 10
## DATA ##
156 118 51 158 120 54 164 126 61 142 107 40 149 112 48 167 129 64 148 111 44 145 107 41 149 108 42

Output after overwriting from save:

total size: 83
80 54 10 35 32 67 114 101 97 116 101 100 32 98 121 32 71 73 77 80 32 118 101 114 115 105 111 110 32 50 46 49 48 46 54 32 80 78 77 32 112 108 117 103 45 105 110 10 51 32 51 10 50 53 53 10
## DATA ##
63 118 51 63 120 54 63 126 61 63 107 40 63 112 48 63 63 64 63 111 44 63 107 41 63 108 42

Notice how the last 3 bytes changed from 149 108 42 to 63 108 42

Screenshots Screenshot showing the overwrite from save dialog: drive_change_warning

Additional context Satisfactory EA for Steam on Windows FIN dev build #_9 from 26 Feb 2023

Binary file that demonstrates the problem: test_img.ppm.zip

Panakotta00 commented 1 year ago

We have a Fix for this issue available, but we can not deploy it until the next major game change that causes FIN to not work, due to backwards compatibility. (We have to know if the Mod Version of the save file is older than the new version, to properly allow a data modle conversion, but there is currently no way of knowing besides the games own verison, but using that, doesnt mean anything if people can reuse the old FIN version, as they might already have saved the game on the new game version but with the old mod version)