Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading