[FIXED][BIG BUG][FLEXI] Renaming ranks can cause data loss.

Started by namida, March 20, 2018, 03:09:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

namida

Steps to reproduce:
1. BACK UP YOUR PACK DATA BEFORE PROCEEDING!!!
2. Load a pack in Flexi.
3. Rename a rank.
4. Save the pack twice. (You can do stuff inbetween the two saves.)

Result: All level files in at least that rank (possibly later ranks too) get deleted and saving fails on the second save. (That rank's levels.nxmi file will be valid, though.)

I suspect this is a result of the Flexi Toolkit trying to copy files from their original location when saving. The bug would then seem to be, on the first save, the toolkit does not update the source file path to correspond to where it just saved the level to. As such, on the second save, the original file is missing - but this occurs after clearing out the target folder - and thus the save fails.

On a side note, this can also occur if eg. you add a level from outside the project folder, then delete the source file. In this case, it will only affect that level onwards (earlier levels in the same rank will be fine).

Old-formats Flexi avoided this issue by loading *all* level files (and images etc) into memory rather than relying on the file from the hard disk. This has its downsides too, in that data loss can occur if the user modified the (at the time) LVL file while Flexi was open, then hit Save in Flexi. Possible solution: Store a copy in memory, as well as the source location, and the modified time of the file at the time it was loaded. When attempting to save, check if source file exists. If it exists and has a newer modified time than the copy in memory, use it; otherwise, use the copy in memory.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

IchoTolot

This could possibly be related to: https://www.lemmingsforums.net/index.php?topic=3761.0

QuoteThere was even an actual error message that I couldn't explain why it was appearing when saving over my pack.
It said there were levels/files currently currently being used by a program, while only the pack toolkit was running. The 2nd save succeeded then without the error. So it seems like the first save attempt is a bit buggy.

Nepster

Thanks for the bug report. I already know where the bug lies: When saving a pack, the file paths of the levels (which are stored internally) are not updated. Will be fixed soon.