Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0e8207
region map export using neither GDAL nor boost
chdoc Mar 30, 2025
d7a04d6
clean up and reinstate export of the remaining biome and region values
chdoc Apr 1, 2025
d899a2a
comments and cleanup
chdoc Apr 3, 2025
7043d2c
convert site export to CSV and remove GDAL dependency
chdoc Apr 3, 2025
3468e6f
use proper site classification and remove gdal include
chdoc Apr 3, 2025
5856c80
move sites classification to map module and additional cleanup
chdoc Apr 4, 2025
b8f92d8
Merge branch 'develop' into export-map-2
chdoc Apr 5, 2025
b53b44f
first version of river export in C++
chdoc May 4, 2025
f495b6d
Merge branch 'develop' into export-map-2
chdoc May 4, 2025
95eab7f
default to exporting all layers
chdoc May 4, 2025
4473f09
Merge branch 'develop' into export-map-2
chdoc Jul 11, 2026
9075ba4
add elevation export
chdoc Jul 14, 2026
721ca8e
Merge branch 'develop' into export-map-2
chdoc Aug 1, 2026
b6a3824
improve code quality
chdoc Aug 1, 2026
2f1bb5f
fix river confluence points
chdoc Aug 2, 2026
7c23828
more cleanup
chdoc Aug 2, 2026
394718a
refactor region output into multiple functions
chdoc Aug 2, 2026
70cb75e
documentation and changelog
chdoc Aug 2, 2026
9397f27
allow grouping of exports by world name and date
chdoc Aug 5, 2026
47d2c1c
Merge branch 'develop' into export-map-2
chdoc Aug 7, 2026
93a23af
parallelize processing of region tiles
chdoc Aug 8, 2026
bbebf84
Move functions to Maps module and update changelog
chdoc Aug 9, 2026
d08da22
fix changelog links
chdoc Aug 9, 2026
7da854b
Rename tool from `export-map` to `export-world-map`
chdoc Aug 9, 2026
b4bf4aa
fix export of Lua folder helpers
chdoc Aug 9, 2026
e1040e3
Merge branch 'develop' into export-map-2
chdoc Aug 19, 2026
868cbbe
implement suggestions from code review
chdoc Aug 22, 2026
cb8641c
use std::span for print_path
chdoc Aug 22, 2026
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
36 changes: 36 additions & 0 deletions library/include/MiscUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,42 @@ inline bool static_add_to_map(CT *pmap, typename CT::key_type key, typename CT::
/*
* MISC
*/
template<
std::ranges::input_range Range,
std::invocable<std::ostream&, std::ranges::range_reference_t<Range>> Callable>
void print_range(
std::ostream &out,
const Range &elements,
Callable&& print_element,
const std::string &prefix = "[",
Comment thread
chdoc marked this conversation as resolved.
Outdated
const std::string &separator = ", ",
const std::string &suffix = "]"
){
out << prefix;
auto it = std::ranges::begin(elements);
auto end = std::ranges::end(elements);

if (it != end) {
print_element(out, *it);
for (++it; it != end; ++it) {
out << separator;
print_element(out, *it);
}
}
out << suffix;
}

template<std::ranges::input_range Range>
void print_range(
std::ostream &out,
const Range& elements,
const std::string &prefix = "[",
Comment thread
chdoc marked this conversation as resolved.
Outdated
const std::string &separator = ", ",
const std::string &suffix = "]"
){
auto print_element = [](std::ostream &out, auto& e) { out << e; };
print_range(out, elements, print_element, prefix, separator, suffix);
}

DFHACK_EXPORT bool split_string(std::vector<std::string> *out,
const std::string &str, const std::string &separator,
Expand Down
2 changes: 1 addition & 1 deletion library/include/df/custom/coord2d.methods.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {}
coord2d(int16_t _x, int16_t _y) : x(_x), y(_y) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been reluctant to make this change myself because I've been uncertain of the consequences - how well tested is this behaviorally?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the fact that it now allows using brace initialization using the correct type for the members, I have not noticed any adverse effects. I haven't played a whole lot on this branch, but I did play a few hours in total and I didn't notice anything off.


bool isValid() const { return x >= 0; }
void clear() { x = y = -30000; }
Expand Down
9 changes: 9 additions & 0 deletions library/include/modules/Maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ distribution.
#include "df/flow_type.h"
#include "df/tile_dig_designation.h"
#include "df/tiletype.h"
#include "df/world_site.h"

namespace df {
struct block_square_event;
Expand Down Expand Up @@ -399,6 +400,14 @@ DFHACK_EXPORT bool removeTileAquifer(int32_t x, int32_t y, int32_t z);
inline bool removeTileAquifer(df::coord pos) { return removeTileAquifer(pos.x, pos.y, pos.z); }
DFHACK_EXPORT int removeAreaAquifer(df::coord pos1, df::coord pos2,
std::function<bool(df::coord, df::map_block *)> filter = [](df::coord pos, df::map_block *block) { return true; });


/**
* A single function does not merit a "Sites" module, hence we collect site functions here in the meantime.
*/

// Get the classification string (e.g. "town", "hillocs", "tower", etc.) for a site
DFHACK_EXPORT const char* getSiteTypeName(df::world_site *site);
}
}
#endif
86 changes: 86 additions & 0 deletions library/modules/Maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,3 +1265,89 @@ int Maps::removeAreaAquifer(df::coord pos1, df::coord pos2, std::function<bool(d

return totalAffectedCount;
}

#include "df/world_site.h"
#include "df/world_site_type.h"
#include "df/site_map_infost.h"

// reverse engineered from DF 50.13 (FUN_140d82ca0, likely sitest::get_site_type_name)
const char* Maps::getSiteTypeName(df::world_site *site) {
using wst = df::enums::world_site_type::world_site_type;
switch (site->type) {
case wst::PlayerFortress:
case wst::MountainHalls:
if (site->min_depth == 0 && (0 < site->max_depth)){
return "fortress";
}
if (site->min_depth > 0) {
return "mountain halls";
}
return "hillocks";

case wst::DarkFortress: {
bool has_market = site->flag.is_set(df::enums::site_flag_type::HAS_MARKET);
return has_market ? "fortress" : "pits";
}

case wst::Cave:
return "cave";

case wst::ForestRetreat:
return "forest retreat";

case wst::Town: {
bool has_market = site->flag.is_set(df::enums::site_flag_type::HAS_MARKET);
return has_market ? "town" : "hamlet";
}

case wst::ImportantLocation:
return "important location";

case wst::LairShrine:
if (site->subtype_info) {
switch (site->subtype_info->lair_type) {
case df::enums::lair_type::LABYRINTH:
return "labyrinth";
case df::enums::lair_type::SHRINE:
return "shrine";
default:
break;
}
}
return "lair";

case wst::Fortress:
if (site->subtype_info) {
switch (site->subtype_info->fortress_type) {
case df::enums::fortress_type::TOWER:
return "tower";
case df::enums::fortress_type::MONASTERY:
return "monastery";
case df::enums::fortress_type::FORT:
return "fort";
default:
return "castle";
}
}
return "fortress";

case wst::Camp:
return "camp";

case wst::Monument:
if (site->subtype_info) {
switch (site->subtype_info->monument_type) {
case df::enums::monument_type::TOMB:
return "tomb";
case df::enums::monument_type::VAULT:
return "vault";
default:
break;
}
}
return "monument";

default:
return "site";
}
}
1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ if(BUILD_SUPPORTED)
#dfhack_plugin(dwarfmonitor dwarfmonitor.cpp LINK_LIBRARIES lua)
#add_subdirectory(embark-assistant)
dfhack_plugin(eventful eventful.cpp LINK_LIBRARIES lua)
dfhack_plugin(export-map export-map.cpp COMPILE_FLAGS_GCC -fno-gnu-unique)
Comment thread
chdoc marked this conversation as resolved.
Outdated
dfhack_plugin(fastdwarf fastdwarf.cpp)
dfhack_plugin(filltraffic filltraffic.cpp)
dfhack_plugin(fix-occupancy fix-occupancy.cpp LINK_LIBRARIES lua)
Expand Down
Loading