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/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Export.h"

#include "df/gamest.h"
#include "df/global_objects.h"

#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
Expand Down
38 changes: 1 addition & 37 deletions library/include/DataDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ namespace DFHack {
DFHACK_EXPORT const struct_field_info *find_union_tag(const struct_identity *structure, const struct_field_info *union_field);
}


#define ENUM_ATTR(enum,attr,val) (df::enum_traits<df::enum>::attrs(val).attr)
#define ENUM_ATTR_STR(enum,attr,val) DFHack::ifnull(ENUM_ATTR(enum,attr,val),"?")
#define ENUM_KEY_STR(enum,val) (DFHack::enum_item_key<df::enum>(val))
Expand All @@ -1013,42 +1014,5 @@ namespace DFHack {
*/

// Global object pointers
#include "df/global_objects.h"

#define DF_GLOBAL_VALUE(name,defval) (df::global::name ? *df::global::name : defval)
#define DF_GLOBAL_FIELD(name,fname,defval) (df::global::name ? df::global::name->fname : defval)

// A couple of headers that have to be included at once
#include "df/coord2d.h"
#include "df/coord.h"

namespace std {
template <>
struct hash<df::coord> {
std::size_t operator()(const df::coord& c) const {
return c();
}
};
}

template <>
struct fmt::formatter<df::coord> : fmt::formatter<std::string_view>
{
template <typename FormatContext>
auto format(const df::coord& c, FormatContext& ctx) const
{
return fmt::formatter<std::string_view>::format(
fmt::format("({}, {}, {})", c.x, c.y, c.z), ctx);
}
};

template <>
struct fmt::formatter<df::coord2d> : fmt::formatter<std::string_view>
{
template <typename FormatContext>
auto format(const df::coord2d& c, FormatContext& ctx) const
{
return fmt::formatter<std::string_view>::format(
fmt::format("({}, {})", c.x, c.y), ctx);
}
};
2 changes: 2 additions & 0 deletions library/include/LuaTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ distribution.
#include "ColorText.h"
#include "DataDefs.h"

#include "df/coord.h"
#include "df/coord2d.h"
#include "df/interface_key.h"

#include <lua.h>
Expand Down
90 changes: 69 additions & 21 deletions library/include/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ distribution.
#include <string>

#include "Export.h"
#include "DataDefs.h"

#include "df/coord.h"
#include "df/coord2d.h"
#include "df/general_ref_type.h"
#include "df/global_objects.h"
#include "df/specific_ref_type.h"

namespace df {
Expand All @@ -47,16 +49,16 @@ namespace DFHack
{
int16_t type;
int32_t index;
bool operator<(const t_matglossPair &b) const
bool operator<(const t_matglossPair& b) const
{
if (type != b.type) return (type < b.type);
return (index < b.index);
}
bool operator==(const t_matglossPair &b) const
bool operator==(const t_matglossPair& b) const
{
return (type == b.type) && (index == b.index);
}
bool operator!=(const t_matglossPair &b) const
bool operator!=(const t_matglossPair& b) const
{
return (type != b.type) || (index != b.index);
}
Expand Down Expand Up @@ -95,39 +97,85 @@ namespace DFHack
std::string name;
uint32_t xpNxtLvl;
};
}

typedef std::pair<df::coord2d, df::coord2d> rect2d;
namespace DFHack
{
using rect2d = std::pair<df::coord2d, df::coord2d>;

inline rect2d intersect(rect2d a, rect2d b) {
inline rect2d intersect(rect2d a, rect2d b)
{
df::coord2d g1 = a.first, g2 = a.second;
df::coord2d c1 = b.first, c2 = b.second;
df::coord2d rc1 = df::coord2d(std::max(g1.x, c1.x), std::max(g1.y, c1.y));
df::coord2d rc2 = df::coord2d(std::min(g2.x, c2.x), std::min(g2.y, c2.y));
return rect2d(rc1, rc2);
}

inline rect2d mkrect_xy(int x1, int y1, int x2, int y2) {
inline rect2d mkrect_xy(int x1, int y1, int x2, int y2)
{
return rect2d(df::coord2d(x1, y1), df::coord2d(x2, y2));
}

inline rect2d mkrect_wh(int x, int y, int w, int h) {
return rect2d(df::coord2d(x, y), df::coord2d(x+w-1, y+h-1));
inline rect2d mkrect_wh(int x, int y, int w, int h)
{
return rect2d(df::coord2d(x, y), df::coord2d(x + w - 1, y + h - 1));
}

inline df::coord2d rect_size(const rect2d &rect) {
return rect.second - rect.first + df::coord2d(1,1);
inline df::coord2d rect_size(const rect2d& rect)
{
return rect.second - rect.first + df::coord2d(1, 1);
}

DFHACK_EXPORT int getdir(std::filesystem::path dir, std::vector<std::filesystem::path> &files);
DFHACK_EXPORT bool hasEnding (std::string const &fullString, std::string const &ending);
DFHACK_EXPORT int getdir(std::filesystem::path dir, std::vector<std::filesystem::path>& files);
DFHACK_EXPORT bool hasEnding(std::string const& fullString, std::string const& ending);

DFHACK_EXPORT df::general_ref *findRef(std::vector<df::general_ref*> &vec, df::general_ref_type type);
DFHACK_EXPORT bool removeRef(std::vector<df::general_ref*> &vec, df::general_ref_type type, int id);
DFHACK_EXPORT df::general_ref* findRef(std::vector<df::general_ref*>& vec, df::general_ref_type type);
DFHACK_EXPORT bool removeRef(std::vector<df::general_ref*>& vec, df::general_ref_type type, int id);

DFHACK_EXPORT df::item *findItemRef(std::vector<df::general_ref*> &vec, df::general_ref_type type);
DFHACK_EXPORT df::building *findBuildingRef(std::vector<df::general_ref*> &vec, df::general_ref_type type);
DFHACK_EXPORT df::unit *findUnitRef(std::vector<df::general_ref*> &vec, df::general_ref_type type);
DFHACK_EXPORT df::item* findItemRef(std::vector<df::general_ref*>& vec, df::general_ref_type type);
DFHACK_EXPORT df::building* findBuildingRef(std::vector<df::general_ref*>& vec, df::general_ref_type type);
DFHACK_EXPORT df::unit* findUnitRef(std::vector<df::general_ref*>& vec, df::general_ref_type type);

DFHACK_EXPORT df::specific_ref *findRef(std::vector<df::specific_ref*> &vec, df::specific_ref_type type);
DFHACK_EXPORT bool removeRef(std::vector<df::specific_ref*> &vec, df::specific_ref_type type, void *ptr);
}// namespace DFHack
DFHACK_EXPORT df::specific_ref* findRef(std::vector<df::specific_ref*>& vec, df::specific_ref_type type);
DFHACK_EXPORT bool removeRef(std::vector<df::specific_ref*>& vec, df::specific_ref_type type, void* ptr);

}

// A couple of headers that have to be included at once
#include "df/coord2d.h"
#include "df/coord.h"

namespace std
{
template <>
struct hash<df::coord>
{
std::size_t operator()(const df::coord& c) const
{
return c();
}
};
}

template <>
struct fmt::formatter<df::coord> : fmt::formatter<std::string_view>
{
template <typename FormatContext>
auto format(const df::coord& c, FormatContext& ctx) const
{
return fmt::formatter<std::string_view>::format(
fmt::format("({}, {}, {})", c.x, c.y, c.z), ctx);
}
};

template <>
struct fmt::formatter<df::coord2d> : fmt::formatter<std::string_view>
{
template <typename FormatContext>
auto format(const df::coord2d& c, FormatContext& ctx) const
{
return fmt::formatter<std::string_view>::format(
fmt::format("({}, {})", c.x, c.y), ctx);
}
};
6 changes: 5 additions & 1 deletion library/include/modules/Burrows.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ distribution.
*/

#pragma once

#include <vector>

#include "Export.h"
#include "DataDefs.h"
#include "modules/Maps.h"

#include <vector>
#include "df/coord.h"
#include "df/coord2d.h"

/**
* \defgroup grp_burrows Burrows module and its types
Expand Down
2 changes: 2 additions & 0 deletions library/include/modules/Designations.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "df/coord.h"

namespace df {
struct plant;
}
Expand Down
3 changes: 3 additions & 0 deletions library/include/modules/Maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ distribution.

#include "df/biome_type.h"
#include "df/block_flags.h"
#include "df/coord.h"
#include "df/coord2d.h"
#include "df/feature_type.h"
#include "df/flow_info.h"
#include "df/flow_type.h"
#include "df/matter_state.h"
#include "df/tile_dig_designation.h"
Expand Down
1 change: 1 addition & 0 deletions library/include/modules/Materials.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ distribution.
#include "DataDefs.h"

#include "df/craft_material_class.h"
#include "df/item_type.h"

namespace df
{
Expand Down
7 changes: 6 additions & 1 deletion library/include/modules/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ distribution.
* @ingroup grp_modules
*/

#include "DataDefs.h"
#include "Export.h"

#include "modules/Persistence.h"
#include "DataDefs.h"

#include "df/game_mode.h"
#include "df/game_type.h"
#include "df/unit.h"


namespace df
Expand Down
6 changes: 4 additions & 2 deletions library/modules/Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ SOFTWARE.
*/

#include <algorithm>
#include <string>
#include <filesystem>
#include <chrono>
#include <filesystem>
#include <iostream>
#include <string>

#include "modules/DFSDL.h"
#include "modules/Filesystem.h"

#include "df/global_objects.h"
#include "df/init.h"


using namespace DFHack;

static bool initialized = false;
Expand Down
2 changes: 2 additions & 0 deletions library/modules/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "MiscUtils.h"
#include "modules/Renderer.h"

#include "df/global_objects.h"

using namespace DFHack;
using df::global::enabler;
using df::global::gps;
Expand Down
1 change: 1 addition & 0 deletions library/modules/Textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "VTableInterpose.h"

#include "df/enabler.h"
#include "df/global_objects.h"
#include "df/viewscreen_adopt_regionst.h"
#include "df/viewscreen_loadgamest.h"
#include "df/viewscreen_new_arenast.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/3dveins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "modules/Random.h"
#include "modules/World.h"

#include "df/global_objects.h"
#include "df/inorganic_raw.h"
#include "df/map_block.h"
#include "df/world.h"
Expand Down
2 changes: 2 additions & 0 deletions plugins/aquifer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include "PluginManager.h"
#include "PluginLua.h"
#include "TileTypes.h"
#include "Types.h"

#include "modules/Maps.h"

#include "df/global_objects.h"
#include "df/map_block.h"
#include "df/world.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/buildingplan/buildingplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "df/construction_type.h"
#include "df/burrow.h"
#include "df/global_objects.h"
#include "df/item.h"
#include "df/job_item.h"
#include "df/organic_mat_category.h"
Expand Down
5 changes: 4 additions & 1 deletion plugins/cleanconst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
// and flags the constructions to recreate their components upon disassembly

#include "Console.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"
#include "Types.h"

#include "modules/Maps.h"

#include "DataDefs.h"
#include "df/global_objects.h"
#include "df/item.h"
#include "df/world.h"
#include "df/construction.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/devel/check-structures-sanity/dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cinttypes>
#include <queue>

#include "df/global_objects.h"
#include "df/large_integer.h"

Checker::Checker(color_ostream & out) :
Expand Down
2 changes: 2 additions & 0 deletions plugins/devel/check-structures-sanity/validate.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "check-structures-sanity.h"

#include "df/global_objects.h"

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0501
Expand Down
9 changes: 5 additions & 4 deletions plugins/devel/dumpmats.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Dump all hardcoded materials
#include "Console.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"

#include "DataDefs.h"
#include "df/world.h"
#include "df/material.h"
#include "df/builtin_mats.h"
#include "df/matter_state.h"
#include "df/descriptor_color.h"
#include "df/global_objects.h"
#include "df/item_type.h"
#include "df/material.h"
#include "df/matter_state.h"
#include "df/strain_type.h"
#include "df/world.h"

using std::string;
using std::vector;
Expand Down
Loading
Loading