From 39e19833f3cdb67b53544f3a8787628e484a50ef Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Wed, 15 Jun 2016 19:00:59 +0300
Subject: Fix other include issues.

---
 src/dyetool/dyemain.cpp                      | 2 +-
 src/gui/sdlinput.cpp                         | 4 ----
 src/net/eathena/petrecv.cpp                  | 6 ------
 src/render/graphics.cpp                      | 8 ++++++--
 src/render/graphics.h                        | 6 +++---
 src/render/opengl/mgltypes.h                 | 6 ++++--
 src/render/rendererslistsdl.h                | 1 +
 src/render/sdl2softwaregraphics.cpp          | 5 -----
 src/render/sdlgraphics.h                     | 1 +
 src/render/vertexes/openglgraphicsvertexes.h | 3 ---
 src/resources/image/image.h                  | 6 +++---
 src/resources/map/map.cpp                    | 2 ++
 src/resources/map/maplayer.cpp               | 4 ----
 src/resources/sdl2softwareimagehelper.h      | 2 --
 src/resources/sdlimagehelper.h               | 1 +
 src/resources/surfaceimagehelper.h           | 2 --
 src/utils/files_unittest.cc                  | 4 ----
 src/utils/mathutils.h                        | 3 +++
 src/utils/sdl2helper.h                       | 1 +
 src/utils/sdlhelper.h                        | 1 +
 src/vector.h                                 | 2 ++
 21 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp
index fb8146566..8a69b79c1 100644
--- a/src/dyetool/dyemain.cpp
+++ b/src/dyetool/dyemain.cpp
@@ -43,9 +43,9 @@
 
 #ifndef USE_SDL2
 #include "resources/sdlimagehelper.h"
+#endif  // USE_SDL2
 
 #include <SDL.h>
-#endif  // USE_SDL2
 
 #include "debug.h"
 
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 9f4ce0c93..7ec7b7027 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -86,10 +86,6 @@
 
 #include "render/graphics.h"
 
-#ifdef USE_SDL2
-#include "gui/gui.h"
-#endif
-
 #include <SDL_timer.h>
 
 #include "debug.h"
diff --git a/src/net/eathena/petrecv.cpp b/src/net/eathena/petrecv.cpp
index 29a19ff86..c89227f72 100644
--- a/src/net/eathena/petrecv.cpp
+++ b/src/net/eathena/petrecv.cpp
@@ -23,7 +23,6 @@
 #include "actormanager.h"
 #include "notifymanager.h"
 
-#include "being/localplayer.h"
 #include "being/petinfo.h"
 #include "being/playerinfo.h"
 
@@ -35,16 +34,11 @@
 
 #include "gui/widgets/createwidget.h"
 
-#include "gui/widgets/tabs/chat/chattab.h"
-
 #include "net/inventoryhandler.h"
 #include "net/messagein.h"
 
 #include "net/eathena/menu.h"
 
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
 #include "debug.h"
 
 namespace EAthena
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index e589058c5..78965afc9 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -84,15 +84,19 @@
 #include "render/nacl/naclgles.h"
 #endif  // __native_client__
 #else  // USE_OPENGL
+#ifndef USE_SDL2
 #include "resources/imagehelper.h"
+#endif  // USE_SDL2
 #endif  // USE_OPENGL
 
 #ifdef USE_OPENGL
 #ifdef __APPLE__
 #include <OpenGL/OpenGL.h>
-#endif
+#endif  // __APPLE__
+#ifndef USE_SDL2
 #include "render/opengl/mgldefines.h"
-#endif
+#endif  // USE_SDL2
+#endif  // USE_OPENGL
 
 #include "debug.h"
 
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 8fb13c804..016f2c4ab 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -75,11 +75,11 @@
 
 #include "resources/mstack.h"
 
-#include <SDL_video.h>
-
 #ifdef USE_SDL2
 #include <SDL_render.h>
-#endif
+#else  // USE_SDL2
+#include <SDL_video.h>
+#endif  // USE_SDL2
 
 #include "localconsts.h"
 
diff --git a/src/render/opengl/mgltypes.h b/src/render/opengl/mgltypes.h
index 50d6c5073..dcd1290d1 100644
--- a/src/render/opengl/mgltypes.h
+++ b/src/render/opengl/mgltypes.h
@@ -50,11 +50,13 @@
 #include "render/opengl/mgldefines.h"
 RENDER_OPENGL_MGLDEFINES_H
 
+#ifndef USE_SDL2
 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
 #include <cstdint>
-#else
+#else  // defined(__GXX_EXPERIMENTAL_CXX0X__)
 #include <stdint.h>
-#endif
+#endif  // defined(__GXX_EXPERIMENTAL_CXX0X__)
+#endif  // USE_SDL2
 
 typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *);
 typedef void (APIENTRY *glBindRenderbuffer_t)(GLenum target,
diff --git a/src/render/rendererslistsdl.h b/src/render/rendererslistsdl.h
index 8bd0c5dcb..1f3297dbe 100644
--- a/src/render/rendererslistsdl.h
+++ b/src/render/rendererslistsdl.h
@@ -23,6 +23,7 @@
 
 #ifdef USE_SDL2
 #include "render/rendererslistsdl2.h"
+RENDER_RENDERERSLISTSDL2_H
 
 #else  // USE_SDL2
 
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 130d34b12..2d0ade4d9 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -24,15 +24,10 @@
 
 #include "render/sdl2softwaregraphics.h"
 
-#include "main.h"
-
-#include "configuration.h"
 #include "graphicsmanager.h"
-#include "logger.h"
 
 #include "render/vertexes/imagecollection.h"
 
-#include "resources/imagehelper.h"
 #include "resources/imagerect.h"
 #include "resources/sdl2softwareimagehelper.h"
 
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index 1dd885628..b335f6e19 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -25,6 +25,7 @@
 
 #ifdef USE_SDL2
 #include "render/sdl2graphics.h"
+RENDER_SDL2GRAPHICS_H
 
 #else
 
diff --git a/src/render/vertexes/openglgraphicsvertexes.h b/src/render/vertexes/openglgraphicsvertexes.h
index 6df146e2c..853161b87 100644
--- a/src/render/vertexes/openglgraphicsvertexes.h
+++ b/src/render/vertexes/openglgraphicsvertexes.h
@@ -32,13 +32,10 @@
 #include <SDL_opengl.h>
 #endif
 
-#endif
-
 #include <vector>
 
 #include "localconsts.h"
 
-#ifdef USE_OPENGL
 class OpenGLGraphicsVertexes final
 {
     public:
diff --git a/src/resources/image/image.h b/src/resources/image/image.h
index 39492c360..ae29a66ae 100644
--- a/src/resources/image/image.h
+++ b/src/resources/image/image.h
@@ -29,8 +29,6 @@
 
 #include "resources/resource.h"
 
-#include <SDL_video.h>
-
 #ifdef USE_OPENGL
 
 #ifdef ANDROID
@@ -45,7 +43,9 @@
 
 #ifdef USE_SDL2
 #include <SDL_render.h>
-#endif
+#else  // USE_SDL2
+#include <SDL_video.h>
+#endif  // USE_SDL2
 
 #include <map>
 
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index e86c0c2a4..e0454ea8c 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -69,7 +69,9 @@
 
 #include <sys/stat.h>
 
+#ifdef ENABLE_PUGIXML
 #include <climits>
+#endif  // ENABLE_LIBXML
 
 #include "debug.h"
 
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index ba8f49455..f71f1de48 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -24,10 +24,6 @@
 
 #include "configuration.h"
 
-#ifndef USE_OPENGL
-#include "render/graphics.h"
-#endif
-
 #include "being/localplayer.h"
 
 #include "enums/resources/map/blockmask.h"
diff --git a/src/resources/sdl2softwareimagehelper.h b/src/resources/sdl2softwareimagehelper.h
index a62937bf7..0160a5660 100644
--- a/src/resources/sdl2softwareimagehelper.h
+++ b/src/resources/sdl2softwareimagehelper.h
@@ -29,8 +29,6 @@
 
 #include "resources/imagehelper.h"
 
-#include <SDL.h>
-
 class Dye;
 class Image;
 
diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h
index 4e1f37a7b..347a8b585 100644
--- a/src/resources/sdlimagehelper.h
+++ b/src/resources/sdlimagehelper.h
@@ -25,6 +25,7 @@
 
 #ifdef USE_SDL2
 #include "resources/sdl2imagehelper.h"
+RESOURCES_SDL2IMAGEHELPER_H
 
 #else
 
diff --git a/src/resources/surfaceimagehelper.h b/src/resources/surfaceimagehelper.h
index 6100b3437..15c8d66d2 100644
--- a/src/resources/surfaceimagehelper.h
+++ b/src/resources/surfaceimagehelper.h
@@ -33,8 +33,6 @@ RESOURCES_SDLIMAGEHELPER_H
 
 #include "resources/imagehelper.h"
 
-#include <SDL.h>
-
 class Dye;
 class Image;
 
diff --git a/src/utils/files_unittest.cc b/src/utils/files_unittest.cc
index db56e03e9..5ccfe0e04 100644
--- a/src/utils/files_unittest.cc
+++ b/src/utils/files_unittest.cc
@@ -27,10 +27,6 @@
 
 #include "resources/resourcemanager/resourcemanager.h"
 
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif  // USE_SDL2
-
 #include "debug.h"
 
 TEST_CASE("Files renameFile")
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 4bc3cf104..c2578e487 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -24,7 +24,10 @@
 #define UTILS_MATHUTILS_H
 
 #include <string>
+
+#ifndef USE_SDL2
 #include <cmath>
+#endif
 
 #include "localconsts.h"
 
diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h
index 7cf471542..da1faeba0 100644
--- a/src/utils/sdl2helper.h
+++ b/src/utils/sdl2helper.h
@@ -27,6 +27,7 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wswitch-default"
 #include <SDL_stdinc.h>
+_SDL_stdinc_h
 #pragma GCC diagnostic pop
 #include <SDL_thread.h>
 
diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h
index 89cd3f789..e75af2be2 100644
--- a/src/utils/sdlhelper.h
+++ b/src/utils/sdlhelper.h
@@ -23,6 +23,7 @@
 
 #ifdef USE_SDL2
 #include "utils/sdl2helper.h"
+UTILS_SDL2HELPER_H
 
 #else
 #include "utils/stringvector.h"
diff --git a/src/vector.h b/src/vector.h
index d24e91e9b..7d72df517 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -23,7 +23,9 @@
 #ifndef VECTOR_H
 #define VECTOR_H
 
+#ifndef USE_SDL2
 #include <cmath>
+#endif  // USE_SDL2
 
 #include <iostream>
 
-- 
cgit v1.2.3-70-g09d2