From f9936f4ea06f47e1baa7ecd7905562a12ee4676b Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 26 Dec 2024 18:48:44 -0800 Subject: [PATCH] add save version info to dfhack-status.dat --- library/include/modules/World.h | 1 + library/modules/Persistence.cpp | 10 +++++++++- library/modules/World.cpp | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/library/include/modules/World.h b/library/include/modules/World.h index 54824902e8..b03170b5fa 100644 --- a/library/include/modules/World.h +++ b/library/include/modules/World.h @@ -88,6 +88,7 @@ namespace DFHack DFHACK_EXPORT bool isArena(df::game_type t = (df::game_type)-1); DFHACK_EXPORT bool isLegends(df::game_type t = (df::game_type)-1); + DFHACK_EXPORT std::string getWorldName(bool in_english = false); DFHACK_EXPORT df::unit * getAdventurer(); DFHACK_EXPORT int32_t GetCurrentSiteId(); diff --git a/library/modules/Persistence.cpp b/library/modules/Persistence.cpp index 6b5e494a6e..2e6dd19f6c 100644 --- a/library/modules/Persistence.cpp +++ b/library/modules/Persistence.cpp @@ -34,6 +34,8 @@ distribution. #include "modules/Persistence.h" #include "modules/World.h" +#include "df/world.h" + #include #include @@ -205,6 +207,13 @@ void Persistence::Internal::save(color_ostream& out) { if (strlen(Version::dfhack_run_url())) { file << "Build url: " << Version::dfhack_run_url() << std::endl; } + if (df::global::world and df::global::version) { + file << std::endl; + file << "World name: " << World::getWorldName() << " (" << World::getWorldName(true) << ")" << std::endl; + file << "World generated in version: " << df::global::world->original_save_version << std::endl; + file << "World last saved in version: " << df::global::world->save_version << std::endl; + file << "World loaded in version: " << *df::global::version << std::endl; + } } // write entity data @@ -304,7 +313,6 @@ void Persistence::Internal::load(color_ostream& out) { const std::string legacy_fname = getSaveFilePath(world_name, "legacy-data"); if (Filesystem::exists(legacy_fname)) { int synthesized_entity_id = Persistence::WORLD_ENTITY_ID; - using df::global::world; if (World::IsSiteLoaded()) synthesized_entity_id = World::GetCurrentSiteId(); load_file(legacy_fname, synthesized_entity_id); diff --git a/library/modules/World.cpp b/library/modules/World.cpp index 2cd936d6ce..c21d0c9e60 100644 --- a/library/modules/World.cpp +++ b/library/modules/World.cpp @@ -166,6 +166,13 @@ string World::ReadWorldFolder() return world->cur_savegame.save_dir; } +string World::getWorldName(bool in_english) +{ + if (!world || !world->world_data) + return ""; + return Translation::TranslateName(&world->world_data->name, in_english); +} + bool World::isFortressMode(df::game_type t) { if (t == -1 && df::global::gametype)