summaryrefslogtreecommitdiffhomepage
path: root/editor
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-28 22:47:20 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-28 22:47:20 +0200
commit9954b8b4f5fb95470e127a4f24a0c73289dd49a9 (patch)
treecf1586b0ebc57837714fc809d523e847f0e286db /editor
parent280b4c235fe11dd629f882f0fb5054384fcee1d7 (diff)
a
Diffstat (limited to 'editor')
-rw-r--r--editor/save.cpp (renamed from editor/json.cpp)31
1 files changed, 9 insertions, 22 deletions
diff --git a/editor/json.cpp b/editor/save.cpp
index 777f9d22..6b6f5ce2 100644
--- a/editor/json.cpp
+++ b/editor/save.cpp
@@ -5,16 +5,9 @@
namespace floormat {
-#define FM_SAVE_BINARY
-
-#ifdef FM_SAVE_BINARY
-#define quicksave_file save_dir "/" "quicksave.dat"
-#else
-#define quicksave_file save_dir "/" "quicksave.json"
-#endif
-
#define save_dir "../save"
-#define quicksave_tmp quicksave_file ".tmp"
+#define quicksave_file save_dir "/" "quicksave.dat"
+#define quicksave_tmp save_dir "/" "quicksave.tmp"
namespace Path = Corrade::Utility::Path;
using std::filesystem::path;
@@ -38,30 +31,24 @@ void app::do_quicksave()
world.collect(true);
if (Path::exists(quicksave_tmp))
Path::remove(quicksave_tmp);
- fputs("quicksave...", stderr); fflush(stderr);
+ fputs("quicksave... ", stderr); fflush(stderr);
world.serialize(quicksave_tmp);
Path::move(quicksave_tmp, quicksave_file);
- fputs(" done\n", stderr); fflush(stderr);
+ fputs("done\n", stderr); fflush(stderr);
}
void app::do_quickload()
{
- ensure_save_directory();
+ if (!ensure_save_directory())
+ return;
if (!Path::exists(quicksave_file))
{
fm_warn("no quicksave");
return;
}
- auto& world = M->world();
- fputs("quickload...", stderr); fflush(stderr);
-#if 0
-#ifdef FM_SAVE_BINARY
- world = json_helper::from_binary<struct world>(quicksave_file);
-#else
- world = json_helper::from_json<struct world>(quicksave_file);
-#endif
-#endif
- fputs(" done\n", stderr); fflush(stderr);
+ fputs("quickload... ", stderr); fflush(stderr);
+ M->world() = world::deserialize(quicksave_file);
+ fputs("done\n", stderr); fflush(stderr);
}
} // namespace floormat