Skip to content
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 = "[",
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 = "[",
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) {}

bool isValid() const { return x >= 0; }
void clear() { x = y = -30000; }
Expand Down
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)
Copy link
Member

Choose a reason for hiding this comment

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

what is requiring -fno-gnu-unique?

Copy link
Member

Choose a reason for hiding this comment

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

probably a STL template; it can be hard to figure out which one because you have to pore over the libc++ implementation and that's very timeconsuming.

-fno-gnu-unique should always be safe for DFHack plugins, as long as they don't crossload another another plug-in module

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing is actually requiring this. Is what a (failed) attempt to make the plugin unload. I will have to check whether it unloads, now that I have removed the GDAL dependency. Keeping this there and the conversation open in the meantime.

dfhack_plugin(fastdwarf fastdwarf.cpp)
dfhack_plugin(filltraffic filltraffic.cpp)
dfhack_plugin(fix-occupancy fix-occupancy.cpp LINK_LIBRARIES lua)
Expand Down
Loading
Loading