Skip to content

Commit

Permalink
Merge pull request #5142 from myk002/myk_save_version
Browse files Browse the repository at this point in the history
add save version info to dfhack-status.dat
  • Loading branch information
myk002 authored Dec 27, 2024
2 parents 06cb875 + f9936f4 commit e6a9162
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions library/include/modules/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion library/modules/Persistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ distribution.
#include "modules/Persistence.h"
#include "modules/World.h"

#include "df/world.h"

#include <json/json.h>

#include <unordered_map>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions library/modules/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e6a9162

Please sign in to comment.