clementgallet / libTAS

GNU/Linux software to (hopefully) give TAS tools to games
GNU General Public License v3.0
493 stars 58 forks source link

Savestates don't handle file descriptors #139

Closed clementgallet closed 5 years ago

clementgallet commented 5 years ago

Loading a savestate does not recover the positions in file descriptors. This leads to crashes in games that use files continuously, for example games like Deltarune or Hyper Light Drifter that use OGG decompression on the fly (I'm getting ov_read error: -3).

An even worse problem is that loading a savestate won't be able to reopen closed files, because we are not guaranteed to obtain the same file descriptor. I don't have a good solution to this. It is still possible to:

Edit: Well, solution 1 seems realistic after all.

clementgallet commented 5 years ago

I'm quite happy this this solution (f8d2394a0a7aa9d067d1803885d2207594fd48cd). It looks like it solves the problem in the above games. There is still a small problem resulting in lost fds in the following case:

  1. user makes savestate 1
  2. the game opens a file
  3. user makes savestate 2, the file is tracked
  4. user loads savestate 1, the file is still opened, in case the user wants to load savestate 2
  5. the game opens the same file as above, but we are getting a new file descriptor
  6. user makes savestate 2, the new file is tracked, but we lost all references to the old file descriptor