Skip to content

Commit 3cd2450

Browse files
committed
reduce df header inclusion in dfhack header files
1 parent bd6841b commit 3cd2450

65 files changed

Lines changed: 558 additions & 490 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

library/Core.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ distribution.
2424

2525
#include "Internal.h"
2626

27-
#include <string>
28-
#include <vector>
29-
#include <map>
30-
#include <set>
31-
#include <cstdio>
32-
#include <cstring>
33-
#include <iterator>
34-
#include <sstream>
35-
#include <forward_list>
36-
#include <type_traits>
37-
#include <cstdarg>
38-
3927
#include "Error.h"
4028
#include "MemAccess.h"
4129
#include "Core.h"
@@ -48,6 +36,12 @@ distribution.
4836
#include "VersionInfo.h"
4937
#include "PluginManager.h"
5038
#include "ModuleFactory.h"
39+
#include "RemoteServer.h"
40+
#include "RemoteTools.h"
41+
#include "LuaTools.h"
42+
#include "DFHackVersion.h"
43+
#include "md5wrapper.h"
44+
5145
#include "modules/DFSDL.h"
5246
#include "modules/DFSteam.h"
5347
#include "modules/EventManager.h"
@@ -56,24 +50,19 @@ distribution.
5650
#include "modules/Textures.h"
5751
#include "modules/World.h"
5852
#include "modules/Persistence.h"
59-
#include "RemoteServer.h"
60-
#include "RemoteTools.h"
61-
#include "LuaTools.h"
62-
#include "DFHackVersion.h"
6353

64-
using namespace DFHack;
65-
66-
#include "df/plotinfost.h"
54+
#include "df/init.h"
6755
#include "df/gamest.h"
68-
#include "df/world.h"
69-
#include "df/world_data.h"
56+
#include "df/graphic.h"
7057
#include "df/interfacest.h"
58+
#include "df/plotinfost.h"
7159
#include "df/viewscreen_dwarfmodest.h"
7260
#include "df/viewscreen_game_cleanerst.h"
7361
#include "df/viewscreen_loadgamest.h"
7462
#include "df/viewscreen_new_regionst.h"
7563
#include "df/viewscreen_savegamest.h"
76-
#include <df/graphic.h>
64+
#include "df/world.h"
65+
#include "df/world_data.h"
7766

7867
#include <stdio.h>
7968
#include <iomanip>
@@ -82,14 +71,24 @@ using namespace DFHack;
8271
#include <thread>
8372
#include <mutex>
8473
#include <condition_variable>
85-
#include "md5wrapper.h"
86-
74+
#include <string>
75+
#include <vector>
76+
#include <map>
77+
#include <set>
78+
#include <cstdio>
79+
#include <cstring>
80+
#include <iterator>
81+
#include <sstream>
82+
#include <forward_list>
83+
#include <type_traits>
84+
#include <cstdarg>
8785
#include <SDL_events.h>
8886

8987
#ifdef LINUX_BUILD
9088
#include <dlfcn.h>
9189
#endif
9290

91+
using namespace DFHack;
9392
using namespace df::enums;
9493
using df::global::init;
9594
using df::global::world;

library/LuaApi.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ distribution.
2424

2525
#include "Internal.h"
2626

27-
#include <cstring>
28-
#include <string>
29-
#include <vector>
30-
#include <map>
31-
3227
#include "MemAccess.h"
3328
#include "Core.h"
3429
#include "Error.h"
@@ -40,6 +35,9 @@ distribution.
4035
#include "DFHackVersion.h"
4136
#include "PluginManager.h"
4237
#include "md5wrapper.h"
38+
#include "LuaWrapper.h"
39+
#include "LuaTools.h"
40+
#include "MiscUtils.h"
4341

4442
#include "modules/Buildings.h"
4543
#include "modules/Burrows.h"
@@ -61,23 +59,24 @@ distribution.
6159
#include "modules/Units.h"
6260
#include "modules/World.h"
6361

64-
#include "LuaWrapper.h"
65-
#include "LuaTools.h"
66-
67-
#include "MiscUtils.h"
68-
6962
#include "df/activity_entry.h"
7063
#include "df/activity_event.h"
64+
#include "df/announcement_flags.h"
7165
#include "df/announcement_infost.h"
7266
#include "df/building.h"
7367
#include "df/building_cagest.h"
7468
#include "df/building_civzonest.h"
69+
#include "df/building_stockpilest.h"
70+
#include "df/building_tradedepotst.h"
7571
#include "df/burrow.h"
72+
#include "df/caravan_state.h"
73+
#include "df/construction.h"
7674
#include "df/creature_raw.h"
7775
#include "df/dfhack_material_category.h"
7876
#include "df/enabler.h"
7977
#include "df/feature_init.h"
8078
#include "df/flow_info.h"
79+
#include "df/general_ref.h"
8180
#include "df/histfig_entity_link_positionst.h"
8281
#include "df/historical_figure.h"
8382
#include "df/identity.h"
@@ -88,6 +87,7 @@ distribution.
8887
#include "df/job_item.h"
8988
#include "df/job_material_category.h"
9089
#include "df/material.h"
90+
#include "df/map_block.h"
9191
#include "df/nemesis_record.h"
9292
#include "df/plant.h"
9393
#include "df/plant_raw.h"
@@ -96,6 +96,7 @@ distribution.
9696
#include "df/report_zoom_type.h"
9797
#include "df/specific_ref.h"
9898
#include "df/specific_ref_type.h"
99+
#include "df/squad.h"
99100
#include "df/unit.h"
100101
#include "df/unit_misc_trait.h"
101102
#include "df/vermin.h"
@@ -105,6 +106,11 @@ distribution.
105106
#include <lauxlib.h>
106107
#include <lualib.h>
107108

109+
#include <cstring>
110+
#include <string>
111+
#include <vector>
112+
#include <map>
113+
108114
using namespace DFHack;
109115
using namespace DFHack::LuaWrapper;
110116

library/LuaTools.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ distribution.
2424

2525
#include "Internal.h"
2626

27-
#include <csignal>
28-
#include <string>
29-
#include <vector>
30-
#include <map>
31-
3227
#include "MemAccess.h"
3328
#include "Core.h"
3429
#include "VersionInfo.h"
3530
// must be last due to MS stupidity
3631
#include "DataDefs.h"
3732
#include "DataIdentity.h"
3833
#include "DataFuncs.h"
34+
#include "LuaWrapper.h"
35+
#include "LuaTools.h"
36+
#include "MiscUtils.h"
37+
#include "DFHackVersion.h"
38+
#include "PluginManager.h"
3939

4040
#include "modules/World.h"
4141
#include "modules/Gui.h"
@@ -44,30 +44,30 @@ distribution.
4444
#include "modules/Translation.h"
4545
#include "modules/Units.h"
4646

47-
#include "LuaWrapper.h"
48-
#include "LuaTools.h"
49-
50-
#include "MiscUtils.h"
51-
#include "DFHackVersion.h"
52-
#include "PluginManager.h"
53-
5447
#include "df/building.h"
5548
#include "df/enabler.h"
5649
#include "df/entity_position.h"
5750
#include "df/entity_position_assignment.h"
51+
#include "df/extentst.h"
5852
#include "df/historical_entity.h"
53+
#include "df/interface_key.h"
5954
#include "df/item.h"
6055
#include "df/job.h"
6156
#include "df/job_item.h"
6257
#include "df/unit.h"
58+
#include "df/viewscreen.h"
6359
#include "df/world.h"
6460

6561
#include <lua.h>
6662
#include <lauxlib.h>
6763
#include <lualib.h>
68-
6964
#include <lstate.h>
7065

66+
#include <csignal>
67+
#include <string>
68+
#include <vector>
69+
#include <map>
70+
7171
using namespace DFHack;
7272
using namespace DFHack::LuaWrapper;
7373

library/Types.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ distribution.
3030

3131
#include "modules/Filesystem.h"
3232

33+
#include "df/general_ref.h"
34+
#include "df/specific_ref.h"
35+
3336
#ifndef LINUX_BUILD
3437
#include <Windows.h>
3538
#include "wdirent.h"

library/include/DataDefs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,3 +898,12 @@ namespace DFHack {
898898
// A couple of headers that have to be included at once
899899
#include "df/coord2d.h"
900900
#include "df/coord.h"
901+
902+
namespace std {
903+
template <>
904+
struct hash<df::coord> {
905+
std::size_t operator()(const df::coord& c) const {
906+
return c();
907+
}
908+
};
909+
}

library/include/DataIdentity.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ distribution.
3737

3838
#include "DataDefs.h"
3939

40-
#include <df/widget_container.h>
41-
4240
namespace std {
4341
class condition_variable;
4442
class mutex;
4543
};
4644

45+
namespace df {
46+
struct widget_container;
47+
}
48+
4749
/*
4850
* Definitions of DFHack namespace structs used by generated headers.
4951
*/

library/include/LuaTools.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ distribution.
3333
#include <unordered_map>
3434
#include <unordered_set>
3535

36-
#include "df/interfacest.h"
37-
3836
#include "ColorText.h"
3937
#include "DataDefs.h"
4038

39+
#include "df/interface_key.h"
40+
4141
#include <lua.h>
4242
#include <lauxlib.h>
4343

library/include/TileTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ distribution.
2727
#include "Pragma.h"
2828
#include "Export.h"
2929
#include "DataDefs.h"
30+
3031
#include "df/tiletype.h"
3132

3233
namespace DFHack

library/include/Types.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ distribution.
3131
#include "Export.h"
3232

3333
#include "DataDefs.h"
34-
#include "df/general_ref.h"
35-
#include "df/specific_ref.h"
34+
35+
#include "df/general_ref_type.h"
36+
#include "df/specific_ref_type.h"
37+
38+
namespace df {
39+
struct building;
40+
struct general_ref;
41+
struct specific_ref;
42+
}
3643

3744
namespace DFHack
3845
{

library/include/df/custom/coord.methods.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ coord(uint16_t _x, uint16_t _y, uint16_t _z) : x(_x), y(_y), z(_z) {}
33

44
operator coord2d() const { return coord2d(x,y); }
55

6+
std::size_t operator()() const {
7+
size_t r = 17;
8+
const size_t m = 65537;
9+
r = m*(r+x);
10+
r = m*(r+y);
11+
r = m*(r+z);
12+
return r;
13+
}
14+
615
bool isValid() const { return x >= 0; }
716
void clear() { x = y = z = -30000; }
817

0 commit comments

Comments
 (0)