Skip to content

Commit bb9c8ba

Browse files
authored
Merge pull request #5789 from ab9rf/header-clean
clean up includes
2 parents 6cb697c + 397d95a commit bb9c8ba

16 files changed

Lines changed: 264 additions & 207 deletions

library/ColorText.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,12 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3535
POSSIBILITY OF SUCH DAMAGE.
3636
*/
3737

38-
39-
#include <stdarg.h>
40-
#include <errno.h>
41-
#include <stdio.h>
42-
#include <iostream>
43-
#include <fstream>
44-
#include <istream>
4538
#include <string>
39+
#include <ostream>
40+
#include <algorithm>
4641

4742
#include "ColorText.h"
48-
#include "MiscUtils.h"
49-
50-
#include <algorithm>
51-
#include <cstdio>
52-
#include <cstdlib>
53-
#include <sstream>
5443

55-
using namespace std;
5644
using namespace DFHack;
5745

5846
bool color_ostream::log_errors_to_stderr = false;
@@ -81,7 +69,7 @@ void color_ostream::end_batch()
8169
flush_proxy();
8270
}
8371

84-
color_ostream::color_ostream() : ostream(new buffer(this)), cur_color(COLOR_RESET)
72+
color_ostream::color_ostream() : std::ostream(new buffer(this)), cur_color(COLOR_RESET)
8573
{
8674
//
8775
}

library/Core.cpp

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,43 @@ distribution.
2626

2727
#include "Internal.h"
2828

29-
#include "Error.h"
30-
#include "MemAccess.h"
29+
#include "ColorText.h"
30+
#include "Commands.h"
31+
#include "Console.h"
32+
#include "CoreDefs.h"
3133
#include "DataDefs.h"
3234
#include "Debug.h"
33-
#include "Console.h"
35+
#include "DFHackVersion.h"
36+
#include "Error.h"
37+
#include "Format.h"
38+
#include "LuaTools.h"
39+
#include "MemAccess.h"
3440
#include "MemoryPatcher.h"
3541
#include "MiscUtils.h"
42+
#include "MiscUtils.h"
3643
#include "Module.h"
37-
#include "VersionInfoFactory.h"
38-
#include "VersionInfo.h"
39-
#include "PluginManager.h"
4044
#include "ModuleFactory.h"
45+
#include "PluginManager.h"
4146
#include "RemoteServer.h"
4247
#include "RemoteTools.h"
43-
#include "LuaTools.h"
44-
#include "DFHackVersion.h"
45-
#include "md5wrapper.h"
46-
#include "Format.h"
47-
48-
#include "Commands.h"
48+
#include "VersionInfo.h"
49+
#include "VersionInfoFactory.h"
4950

5051
#include "modules/DFSDL.h"
5152
#include "modules/DFSteam.h"
5253
#include "modules/EventManager.h"
5354
#include "modules/Filesystem.h"
55+
#include "modules/Graphic.h"
5456
#include "modules/Gui.h"
5557
#include "modules/Hotkey.h"
58+
#include "modules/Persistence.h"
5659
#include "modules/Textures.h"
5760
#include "modules/World.h"
58-
#include "modules/Persistence.h"
5961

60-
#include "df/init.h"
6162
#include "df/gamest.h"
63+
#include "df/global_objects.h"
6264
#include "df/graphic.h"
65+
#include "df/init.h"
6366
#include "df/interfacest.h"
6467
#include "df/plotinfost.h"
6568
#include "df/viewscreen_dwarfmodest.h"
@@ -68,35 +71,52 @@ distribution.
6871
#include "df/viewscreen_loadgamest.h"
6972
#include "df/viewscreen_new_regionst.h"
7073
#include "df/viewscreen_savegamest.h"
71-
#include "df/world.h"
7274
#include "df/world_data.h"
75+
#include "df/world.h"
7376

74-
#include <stdio.h>
75-
#include <iomanip>
76-
#include <stdlib.h>
77+
#include <algorithm>
78+
#include <cassert>
79+
#include <condition_variable>
80+
#include <cstdarg>
81+
#include <cstdint>
82+
#include <cstdio>
83+
#include <cstdlib>
84+
#include <cstring>
85+
#include <filesystem>
86+
#include <forward_list>
7787
#include <fstream>
78-
#include <thread>
88+
#include <iomanip>
89+
#include <iostream>
90+
#include <istream>
91+
#include <map>
92+
#include <memory>
7993
#include <mutex>
80-
#include <condition_variable>
81-
#include <string>
82-
#include <vector>
94+
#include <ostream>
8395
#include <ranges>
84-
#include <span>
85-
#include <map>
8696
#include <set>
87-
#include <cstdio>
88-
#include <cstring>
97+
#include <span>
8998
#include <sstream>
90-
#include <forward_list>
99+
#include <string_view>
100+
#include <string>
101+
#include <system_error>
102+
#include <thread>
91103
#include <type_traits>
92-
#include <cstdarg>
93-
#include <filesystem>
104+
#include <utility>
105+
#include <vector>
106+
107+
#include "md5wrapper.h"
108+
94109
#include <SDL_events.h>
110+
#include <SDL_keycode.h>
111+
#include <SDL_video.h>
95112

113+
#include <lua.h>
96114

97-
#ifdef _WIN32
115+
#ifdef WIN32
98116
#define NOMINMAX
117+
#define WIN32_LEAN_AND_MEAN
99118
#include <Windows.h>
119+
#include <processthreadsapi.h>
100120
#endif
101121

102122
#ifdef LINUX_BUILD
@@ -105,6 +125,7 @@ distribution.
105125

106126
using namespace DFHack;
107127
using namespace df::enums;
128+
108129
using df::global::init;
109130
using df::global::world;
110131
using std::string;

library/DataIdentity.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
#include <stddef.h>
1+
#include "DataIdentity.h"
2+
3+
#include "BitArray.h"
4+
#include "DataDefs.h"
25

36
#include <condition_variable>
7+
#include <cstdint>
8+
#include <filesystem>
49
#include <fstream>
10+
#include <functional>
11+
#include <future>
12+
#include <memory>
513
#include <mutex>
14+
#include <optional>
615
#include <string>
7-
#include <vector>
816
#include <variant>
17+
#include <vector>
918

10-
#include "DataFuncs.h"
11-
#include "DataIdentity.h"
1219

1320
// the space after the uses of "type" in OPAQUE_IDENTITY_TRAITS_NAME is _required_
1421
// without it the macro generates a syntax error when type is a template specification

library/MiscUtils.cpp

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,49 @@ must not be misrepresented as being the original software.
2222
distribution.
2323
*/
2424

25-
#include "Internal.h"
2625
#include "Export.h"
2726
#include "MiscUtils.h"
2827
#include "ColorText.h"
2928

30-
#include "modules/DFSDL.h"
29+
#include <array>
30+
#include <algorithm>
31+
#include <cctype>
32+
#include <cstdarg>
33+
#include <cstdlib>
34+
#include <cmath>
35+
#include <cstdint>
36+
#include <cstdio>
37+
#include <cstring>
38+
#include <exception>
39+
#include <iomanip>
40+
#include <ios>
41+
#include <iostream>
42+
#include <locale>
43+
#include <map>
44+
#include <ostream>
45+
#include <sstream>
46+
#include <string>
47+
#include <utility>
48+
#include <vector>
3149

32-
#ifndef LINUX_BUILD
33-
// We don't want min and max macros
50+
#ifdef WIN32
3451
#define NOMINMAX
35-
#include <Windows.h>
36-
// Suppress warning which occurs in header on some WinSDK versions
37-
// See dfhack/dfhack#5147 for more information
38-
#pragma warning(push)
39-
#pragma warning(disable:4091)
40-
#include <DbgHelp.h>
41-
#pragma warning(pop)
42-
#else
43-
#include <sys/time.h>
44-
#include <ctime>
45-
#include <cxxabi.h>
52+
#define WIN32_LEAN_AND_MEAN
53+
#include <Windows.h>
54+
#include <sysinfoapi.h>
55+
// Suppress warning which occurs in header on some WinSDK versions
56+
// See dfhack/dfhack#5147 for more information
57+
#pragma warning(push)
58+
#pragma warning(disable:4091)
59+
#include <DbgHelp.h>
60+
#pragma warning(pop)
4661
#endif
4762

48-
#include <ctype.h>
49-
#include <stdarg.h>
50-
#include <string.h>
51-
#include <cstdlib>
52-
#include <cmath>
53-
54-
#include <sstream>
55-
#include <map>
56-
#include <array>
57-
#include <unordered_map>
63+
#ifdef LINUX_BUILD
64+
#include <sys/time.h>
65+
#include <ctime>
66+
#include <cxxabi.h>
67+
#endif
5868

5969
NumberFormatType preferred_number_format_type = NumberFormatType::DEFAULT;
6070

@@ -499,8 +509,8 @@ uint64_t GetTimeMs64()
499509
/* Character decoding */
500510

501511
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
502-
#define UTF8_ACCEPT 0
503-
#define UTF8_REJECT 12
512+
constexpr auto UTF8_ACCEPT = 0;
513+
constexpr auto UTF8_REJECT = 12;
504514

505515
static const uint8_t utf8d[] = {
506516
// The first part of the table maps bytes to character classes that

library/PlugLoad.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
#include "Core.h"
21
#include "Debug.h"
3-
#include "Export.h"
42
#include "PluginManager.h"
5-
#include "Hooks.h"
63

74
#include <iostream>
8-
#include <map>
95
#include <string>
10-
#include <vector>
11-
12-
#include <stdio.h>
13-
#include <stdint.h>
146

157
#ifdef WIN32
168
#define NOMINMAX
9+
#define WIN32_LEAN_AND_MEAN
1710
#include <windows.h>
1811
#include <libloaderapi.h>
1912
#define global_search_handle() GetModuleHandle(nullptr)

library/PluginManager.cpp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,46 @@ must not be misrepresented as being the original software.
2222
distribution.
2323
*/
2424

25-
#include "modules/EventManager.h"
26-
#include "modules/Filesystem.h"
27-
#include "modules/Screen.h"
28-
#include "modules/World.h"
29-
#include "Internal.h"
25+
#include "PluginManager.h"
26+
27+
#include "ColorText.h"
3028
#include "Core.h"
29+
#include "CoreDefs.h"
30+
#include "Format.h"
31+
#include "LuaWrapper.h"
32+
#include "LuaTools.h"
3133
#include "MemAccess.h"
32-
#include "PluginManager.h"
34+
#include "MiscUtils.h"
3335
#include "RemoteServer.h"
34-
#include "Console.h"
3536
#include "Types.h"
3637
#include "VersionInfo.h"
3738

38-
#include "DataDefs.h"
39-
#include "MiscUtils.h"
40-
#include "DFHackVersion.h"
41-
42-
#include "LuaWrapper.h"
43-
#include "LuaTools.h"
44-
45-
using namespace DFHack;
39+
#include "modules/EventManager.h"
40+
#include "modules/Filesystem.h"
41+
#include "modules/Screen.h"
42+
#include "modules/World.h"
4643

44+
#include <algorithm>
4745
#include <condition_variable>
46+
#include <cassert>
47+
#include <cstdint>
48+
#include <cstdio>
49+
#include <cstdlib>
50+
#include <cstring>
51+
#include <filesystem>
52+
#include <iostream>
53+
#include <map>
54+
#include <mutex>
4855
#include <string>
4956
#include <vector>
50-
#include <map>
5157

52-
using std::string;
58+
#include "df/viewscreen.h"
5359

54-
#include <assert.h>
60+
#include <lua.h>
61+
#include <lauxlib.h>
62+
63+
using namespace DFHack;
64+
using std::string;
5565

5666
#if defined(_LINUX)
5767
static const string plugin_suffix = ".plug.so";
@@ -871,7 +881,7 @@ void PluginManager::init()
871881
loadAll();
872882

873883
bool any_loaded = false;
874-
for (auto p : all_plugins)
884+
for (auto& p : all_plugins)
875885
{
876886
if (p.second->getState() == Plugin::PS_LOADED)
877887
{

0 commit comments

Comments
 (0)