Remember loaded custom level and read from it when saving

My previous custom level forwards compatibility would only work if you
saved to the same filename as you read from. But what if you saved to a
new filename? Well, your extra XML is lost.

Not to worry, I've introduced a variable that remembers the filepath of
the currently-loaded level (the existing `filename` attribute is kind of
weird and not really suited for this purpose, so). I tried to make it a
simple `const char*`, but it turns out that's bad when you take the
`c_str()` of an `std::string` that then gets destroyed, so it's best to
use `std::string` in an `std::string` world.

So now when you save a level, it'll attempt to open the original file,
and if that doesn't exist then your extra XML gets lost anyway, but I
shouldn't be expected to keep your XML if you delete the original file.
This commit is contained in:
Misa
2020-11-03 09:55:26 -08:00
committed by Ethan Lee
parent 3f954a169a
commit 5eab074e4d
2 changed files with 15 additions and 4 deletions

View File

@@ -191,6 +191,7 @@ class editorclass{
std::string note;
std::string keybuffer;
std::string filename;
std::string loaded_filepath;
int drawmode;
int tilex, tiley;