TIC-80 icon indicating copy to clipboard operation
TIC-80 copied to clipboard

Exporting a build over a saved cart corrupts the cart and memory

Open SolarLune opened this issue 2 months ago • 2 comments

Hey, just wanted to report this - looks like if you export a native executable over a saved cart (.tic file), it corrupts the cart in-memory, so that you lose your data.

To reproduce this, create a new cart, save it as a filename (say, "test.tic"), then run an export command with the same filename (export linux test.tic). This will create a corrupted build, and the data in-memory is corrupted. I got hit by this when I went to try exporting and pressed tab to autocomplete the filename (which, naturally, included the file extension).

As an aside, once the program's memory is in this state, pressing F5 to get to the music editor will crash TIC-80.

SolarLune avatar Apr 17 '24 10:04 SolarLune

Ah yes, that's the wikipage that is not clear enough. I will improve that, thanks!

The .tic files are in the TIC-80 format, the goal of the export command is to export the file in a different format. So you should do export linux test or export win test.exe but not test.tic. If you rename your file test you should be able to execute it on linux.

Skeptim avatar Apr 17 '24 15:04 Skeptim

Ah yes, that's the wikipage that is not clear enough. I will improve that, thanks!

The .tic files are in the TIC-80 format, the goal of the export command is to export the file in a different format. So you should do export linux test or export win test.exe but not test.tic. If you rename your file test you should be able to execute it on linux.

Better documentation definitely can be very helpful, but the problem is a bit bigger than documentation. The real issue is that if you overwrite a cart using export, it corrupts TIC-80 and your project in memory, making it so that not only did you overwrite the cart on disk, but you can't resave the program. (As an aside, the executable generated is also corrupted.)

If you didn't make a backup, the project's just gone, as far as I can tell.

I presume that this problem is the same regardless of what exact command you use, so something like exporting graphics PNGs over the cart would probably create the same result. An easy fix this on TIC-80's side is just to disallow exporting or saving a resource over a .tic file (so something like if a file path exists, it should internally check to see if it's a TIC-80 project and, if so, disallow saving over it).

However, this also makes me wary of things outside of TIC-80 altering the cart, like renaming the cart or moving it while TIC-80 is open. Ideally, the program should hold the working cart completely in-memory so changes to the cart on disk wouldn't affect the project while you have it open.

EDIT: Here's a link to another person over on itch.io who had the same experience.

SolarLune avatar Apr 17 '24 15:04 SolarLune