summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-29 20:13:40 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-29 20:53:57 +0300
commit36c45ae7d8d2577a900ec266b64448d4b488013d (patch)
tree419024ce46e507c2abb0578d15d787093556b246 /src
parent864e023e0faeca5aa662023a54af7e4f9797fafa (diff)
downloadmanaplus-36c45ae7d8d2577a900ec266b64448d4b488013d.tar.gz
manaplus-36c45ae7d8d2577a900ec266b64448d4b488013d.tar.bz2
manaplus-36c45ae7d8d2577a900ec266b64448d4b488013d.tar.xz
manaplus-36c45ae7d8d2577a900ec266b64448d4b488013d.zip
Move cast macroses into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actormanager.h1
-rw-r--r--src/being/actor.h2
-rw-r--r--src/chatlogger.cpp10
-rw-r--r--src/commandline.cpp1
-rw-r--r--src/enums/enums_unittest.cc2
-rw-r--r--src/fs/mkdir.cpp2
-rw-r--r--src/gui/color.h2
-rw-r--r--src/gui/models/beingslistmodel.h1
-rw-r--r--src/gui/models/extendednamesmodel.cpp2
-rw-r--r--src/gui/models/iconsmodel.h1
-rw-r--r--src/gui/models/ignorechoiceslistmodel.h2
-rw-r--r--src/gui/models/itemsmodel.h1
-rw-r--r--src/gui/models/modelistmodel.h1
-rw-r--r--src/gui/models/namesmodel.cpp1
-rw-r--r--src/gui/models/serverslistmodel.h1
-rw-r--r--src/gui/models/shopitems.h2
-rw-r--r--src/gui/models/skillmodel.h2
-rw-r--r--src/gui/models/updatelistmodel.h1
-rw-r--r--src/gui/models/worldlistmodel.h1
-rw-r--r--src/gui/palette.h2
-rw-r--r--src/gui/sdlinput.h2
-rw-r--r--src/gui/theme.h1
-rw-r--r--src/gui/themecolorsidoperators.cpp2
-rw-r--r--src/gui/userpalette.h2
-rw-r--r--src/gui/widgets/serverslistbox.h2
-rw-r--r--src/gui/widgets/skilllistbox.h1
-rw-r--r--src/gui/widgets/skillrectanglelistbox.h1
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h1
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h1
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h1
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h1
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h1
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h1
-rw-r--r--src/gui/widgets/textbox.h2
-rw-r--r--src/gui/widgets/widget2.h2
-rw-r--r--src/guild.h1
-rw-r--r--src/input/inputactionmap.h2
-rw-r--r--src/input/inputactionoperators.cpp2
-rw-r--r--src/input/inputactionsortfunctor.h2
-rw-r--r--src/input/inputmanager.h1
-rw-r--r--src/input/keyboardconfig.h2
-rw-r--r--src/input/touch/touchmanager.h2
-rw-r--r--src/integrity_unittest.cc1
-rw-r--r--src/localconsts.h9
-rw-r--r--src/logger.h2
-rw-r--r--src/net/eathena/bankrecv.cpp2
-rw-r--r--src/net/messageout.h2
-rw-r--r--src/net/packetcounters.cpp2
-rw-r--r--src/net/updatetypeoperators.cpp2
-rw-r--r--src/particle/particle.h2
-rw-r--r--src/particle/textparticle.h2
-rw-r--r--src/party.h1
-rw-r--r--src/render/mockgraphics.cc1
-rw-r--r--src/resources/image/subimage.cpp2
-rw-r--r--src/resources/iteminfo.h1
-rw-r--r--src/resources/map/map.h6
-rw-r--r--src/resources/map/mapheights.h2
-rw-r--r--src/resources/map/objectslayer.cpp2
-rw-r--r--src/resources/wallpaper.cpp1
-rw-r--r--src/utils/base64.cpp2
-rw-r--r--src/utils/buildhex.h2
-rw-r--r--src/utils/cast.h33
-rw-r--r--src/utils/mathutils.h2
-rw-r--r--src/utils/mathutils_unittest.cc1
-rw-r--r--src/utils/sdlpixel.h2
-rw-r--r--src/utils/stringutils.cpp1
-rw-r--r--src/utils/stringutils_unittest.cc1
69 files changed, 142 insertions, 15 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 57eca194d..9441e11fe 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -855,6 +855,7 @@ SET(SRCS
utils/browserboxtools.cpp
utils/browserboxtools.h
utils/buildhex.h
+ utils/cast.h
utils/chatutils.cpp
utils/chatutils.h
utils/checkutils.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c52ba399..6fac4b0ed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -553,6 +553,7 @@ BASE_SRC += events/actionevent.h \
utils/browserboxtools.cpp \
utils/browserboxtools.h \
utils/buildhex.h \
+ utils/cast.h \
utils/checkutils.cpp \
utils/checkutils.h \
utils/copynpaste.cpp \
diff --git a/src/actormanager.h b/src/actormanager.h
index 0c456362f..10ca749fb 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -38,6 +38,7 @@
#include "listeners/configlistener.h"
+#include "utils/cast.h"
#include "utils/stringmap.h"
#include "utils/stringvector.h"
diff --git a/src/being/actor.h b/src/being/actor.h
index 8b3e09260..50a9dca24 100644
--- a/src/being/actor.h
+++ b/src/being/actor.h
@@ -24,6 +24,8 @@
#include "vector.h"
+#include "utils/cast.h"
+
#include <list>
#include "localconsts.h"
diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp
index 3a7792455..d6376f504 100644
--- a/src/chatlogger.cpp
+++ b/src/chatlogger.cpp
@@ -22,6 +22,12 @@
#include "chatlogger.h"
+#include "configuration.h"
+
+#include "fs/mkdir.h"
+
+#include "utils/cast.h"
+
#include <iostream>
#include <dirent.h>
@@ -32,10 +38,6 @@
#include <Carbon/Carbon.h>
#endif // WIN32
-#include "configuration.h"
-
-#include "fs/mkdir.h"
-
#include "debug.h"
ChatLogger *chatLogger = nullptr;
diff --git a/src/commandline.cpp b/src/commandline.cpp
index 506242a2c..71341f288 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -27,6 +27,7 @@
#include "fs/paths.h"
+#include "utils/cast.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/enums/enums_unittest.cc b/src/enums/enums_unittest.cc
index 3ba1e631d..84f2eb642 100644
--- a/src/enums/enums_unittest.cc
+++ b/src/enums/enums_unittest.cc
@@ -22,6 +22,8 @@
#include "enums/being/gender.h"
+#include "utils/cast.h"
+
#include "debug.h"
TEST_CASE("Gender", "Enums")
diff --git a/src/fs/mkdir.cpp b/src/fs/mkdir.cpp
index d45810b7c..341f138da 100644
--- a/src/fs/mkdir.cpp
+++ b/src/fs/mkdir.cpp
@@ -21,6 +21,8 @@
#include "fs/mkdir.h"
+#include "utils/cast.h"
+
#if defined WIN32
#include <limits.h>
#include <windows.h>
diff --git a/src/gui/color.h b/src/gui/color.h
index 4b8e06eb3..c4a1aab01 100644
--- a/src/gui/color.h
+++ b/src/gui/color.h
@@ -64,6 +64,8 @@
#ifndef GUI_COLOR_H
#define GUI_COLOR_H
+#include "utils/cast.h"
+
#include "localconsts.h"
/**
diff --git a/src/gui/models/beingslistmodel.h b/src/gui/models/beingslistmodel.h
index c2b8def74..a50b20d8d 100644
--- a/src/gui/models/beingslistmodel.h
+++ b/src/gui/models/beingslistmodel.h
@@ -24,6 +24,7 @@
#include "gui/models/avatarlistmodel.h"
+#include "utils/cast.h"
#include "utils/dtor.h"
#include <vector>
diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp
index 2c8d7167a..74b52beae 100644
--- a/src/gui/models/extendednamesmodel.cpp
+++ b/src/gui/models/extendednamesmodel.cpp
@@ -20,6 +20,8 @@
#include "gui/models/extendednamesmodel.h"
+#include "utils/cast.h"
+
#include "debug.h"
ExtendedNamesModel::ExtendedNamesModel() :
diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h
index 4028895fb..ce977fb5f 100644
--- a/src/gui/models/iconsmodel.h
+++ b/src/gui/models/iconsmodel.h
@@ -25,6 +25,7 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
#include "utils/foreach.h"
#include "resources/iteminfo.h"
diff --git a/src/gui/models/ignorechoiceslistmodel.h b/src/gui/models/ignorechoiceslistmodel.h
index ef537a5c7..6cd8bbe87 100644
--- a/src/gui/models/ignorechoiceslistmodel.h
+++ b/src/gui/models/ignorechoiceslistmodel.h
@@ -28,6 +28,8 @@
#include "being/playerignorestrategy.h"
#include "being/playerrelations.h"
+#include "utils/cast.h"
+
/**
* Class for choosing one of the various `what to do when ignoring a player' options
*/
diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h
index a49a7cfc5..3b4933ce2 100644
--- a/src/gui/models/itemsmodel.h
+++ b/src/gui/models/itemsmodel.h
@@ -29,6 +29,7 @@
#include "resources/db/itemdb.h"
+#include "utils/cast.h"
#include "utils/foreach.h"
#include <list>
diff --git a/src/gui/models/modelistmodel.h b/src/gui/models/modelistmodel.h
index abeb99f68..ed4d449d7 100644
--- a/src/gui/models/modelistmodel.h
+++ b/src/gui/models/modelistmodel.h
@@ -25,6 +25,7 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
#include "utils/stringvector.h"
#include "localconsts.h"
diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp
index 5a351f471..ee26dbdaa 100644
--- a/src/gui/models/namesmodel.cpp
+++ b/src/gui/models/namesmodel.cpp
@@ -20,6 +20,7 @@
#include "gui/models/namesmodel.h"
+#include "utils/cast.h"
#include "utils/gettext.h"
#include "debug.h"
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
index 206daa02a..8b558d17a 100644
--- a/src/gui/models/serverslistmodel.h
+++ b/src/gui/models/serverslistmodel.h
@@ -31,6 +31,7 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
#include "utils/gettext.h"
/**
diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h
index 3b6d611cb..d162ce524 100644
--- a/src/gui/models/shopitems.h
+++ b/src/gui/models/shopitems.h
@@ -29,6 +29,8 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
+
#include <vector>
#include "localconsts.h"
diff --git a/src/gui/models/skillmodel.h b/src/gui/models/skillmodel.h
index c3331ed30..6c7792508 100644
--- a/src/gui/models/skillmodel.h
+++ b/src/gui/models/skillmodel.h
@@ -25,6 +25,8 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
+
#include "resources/skill/skillinfo.h"
#include "localconsts.h"
diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h
index 74bd44af1..f50072112 100644
--- a/src/gui/models/updatelistmodel.h
+++ b/src/gui/models/updatelistmodel.h
@@ -27,6 +27,7 @@
#include "net/serverinfo.h"
+#include "utils/cast.h"
#include "utils/foreach.h"
#include "localconsts.h"
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
index f22c808bb..9ae5a5e22 100644
--- a/src/gui/models/worldlistmodel.h
+++ b/src/gui/models/worldlistmodel.h
@@ -25,6 +25,7 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
#include "utils/stringutils.h"
#include "net/worldinfo.h"
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 00f295cc4..0905bf22a 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -28,6 +28,8 @@
#include "gui/color.h"
+#include "utils/cast.h"
+
#include <map>
#include <set>
#include <string>
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index 79a30758b..d2b7847df 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -82,6 +82,8 @@
#include "input/keyinput.h"
+#include "utils/cast.h"
+
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_events.h>
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 9ef477452..b617002ad 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -34,6 +34,7 @@
#include "gui/palette.h"
+#include "utils/cast.h"
#include "utils/stringvector.h"
#include "localconsts.h"
diff --git a/src/gui/themecolorsidoperators.cpp b/src/gui/themecolorsidoperators.cpp
index 37dc2e7ab..df3a7e65b 100644
--- a/src/gui/themecolorsidoperators.cpp
+++ b/src/gui/themecolorsidoperators.cpp
@@ -20,6 +20,8 @@
#include "gui/themecolorsidoperators.h"
+#include "utils/cast.h"
+
#include "debug.h"
ThemeColorIdT operator+(const ThemeColorIdT &id, const int& i)
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
index 4f7e0e941..712c1f90a 100644
--- a/src/gui/userpalette.h
+++ b/src/gui/userpalette.h
@@ -32,6 +32,8 @@
#include "gui/models/listmodel.h"
+#include "utils/cast.h"
+
/**
* Class controlling the game's color palette.
*/
diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h
index 20d019f8d..16689d6a9 100644
--- a/src/gui/widgets/serverslistbox.h
+++ b/src/gui/widgets/serverslistbox.h
@@ -27,6 +27,8 @@
#include "gui/models/serverslistmodel.h"
+#include "utils/cast.h"
+
#include "localconsts.h"
class ServersListBox final : public ListBox
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 93c702381..d611b7dce 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -39,6 +39,7 @@
#include "gui/popups/popupmenu.h"
#include "gui/popups/skillpopup.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/skillrectanglelistbox.h b/src/gui/widgets/skillrectanglelistbox.h
index 88698de1c..16fc610a4 100644
--- a/src/gui/widgets/skillrectanglelistbox.h
+++ b/src/gui/widgets/skillrectanglelistbox.h
@@ -36,6 +36,7 @@
#include "gui/popups/popupmenu.h"
#include "gui/popups/skillpopup.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index 017f465c7..d023fa442 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -33,6 +33,7 @@
#include "gui/widgets/tabs/socialfriendsfunctor.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
index 8652a54fe..9a23938ca 100644
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ b/src/gui/widgets/tabs/socialguildtab.h
@@ -26,6 +26,7 @@
#include "being/localplayer.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
index ff8544232..9f8a8ff67 100644
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ b/src/gui/widgets/tabs/socialguildtab2.h
@@ -28,6 +28,7 @@
#include "being/localplayer.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
index 80b5910f3..b86799f6a 100644
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ b/src/gui/widgets/tabs/socialnavigationtab.h
@@ -34,6 +34,7 @@
#include "input/keyboardconfig.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/gettext.h"
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
index d7f22c1f7..1287bfed1 100644
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ b/src/gui/widgets/tabs/socialpartytab.h
@@ -30,6 +30,7 @@
#include "net/partyhandler.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
index 87b0335c1..d8ce21df0 100644
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ b/src/gui/widgets/tabs/socialplayerstab.h
@@ -30,6 +30,7 @@
#include "gui/models/beingslistmodel.h"
+#include "utils/cast.h"
#include "utils/gettext.h"
#include "utils/delete2.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h
index fefd862a0..bcde2e411 100644
--- a/src/gui/widgets/textbox.h
+++ b/src/gui/widgets/textbox.h
@@ -73,6 +73,8 @@
#include "listeners/keylistener.h"
#include "listeners/mouselistener.h"
+#include "utils/cast.h"
+
#include "localconsts.h"
/**
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index ed9110ba4..12f76e897 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -28,6 +28,8 @@
#include "gui/themecolorsidoperators.h"
#include "gui/theme.h"
+#include "utils/cast.h"
+
#include "localconsts.h"
class Widget;
diff --git a/src/guild.h b/src/guild.h
index 2bec6497c..3a58883c9 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -25,6 +25,7 @@
#include "gui/models/avatarlistmodel.h"
+#include "utils/cast.h"
#include "utils/dtor.h"
#include "utils/stringvector.h"
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index a87c0cada..8b8d3bf47 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -41,6 +41,8 @@
#include "input/inputactiondata.h"
#include "input/inputmanager.h"
+#include "utils/cast.h"
+
#include "localconsts.h"
#define defaultAction(name) \
diff --git a/src/input/inputactionoperators.cpp b/src/input/inputactionoperators.cpp
index 911cf2e7b..5d6db0967 100644
--- a/src/input/inputactionoperators.cpp
+++ b/src/input/inputactionoperators.cpp
@@ -20,6 +20,8 @@
#include "input/inputactionoperators.h"
+#include "utils/cast.h"
+
#include "debug.h"
InputActionT operator+(InputActionT action, const int& i)
diff --git a/src/input/inputactionsortfunctor.h b/src/input/inputactionsortfunctor.h
index 1d2583aa9..106f44b0a 100644
--- a/src/input/inputactionsortfunctor.h
+++ b/src/input/inputactionsortfunctor.h
@@ -23,6 +23,8 @@
#include "input/inputactiondata.h"
+#include "utils/cast.h"
+
#include "localconsts.h"
class InputActionSortFunctor final
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
index db61053b0..6deb64858 100644
--- a/src/input/inputmanager.h
+++ b/src/input/inputmanager.h
@@ -25,6 +25,7 @@
#include "events/inputevent.h"
+#include "utils/cast.h"
#include "utils/stringmap.h"
#include <list>
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
index 8691571ae..b5e8dc796 100644
--- a/src/input/keyboardconfig.h
+++ b/src/input/keyboardconfig.h
@@ -25,6 +25,8 @@
#include "localconsts.h"
+#include "utils/cast.h"
+
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_events.h>
diff --git a/src/input/touch/touchmanager.h b/src/input/touch/touchmanager.h
index b5aea56f0..0d5640f50 100644
--- a/src/input/touch/touchmanager.h
+++ b/src/input/touch/touchmanager.h
@@ -27,6 +27,8 @@
#include "gui/rect.h"
+#include "utils/cast.h"
+
#include <vector>
#include "localconsts.h"
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc
index 130716ce6..55c78220f 100644
--- a/src/integrity_unittest.cc
+++ b/src/integrity_unittest.cc
@@ -46,6 +46,7 @@
#include "resources/resourcemanager/resourcemanager.h"
+#include "utils/cast.h"
#include "utils/env.h"
#include "utils/delete2.h"
#include "utils/foreach.h"
diff --git a/src/localconsts.h b/src/localconsts.h
index e6b455cf6..e416924fe 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -23,15 +23,6 @@
#define ENABLEDEBUGLOG 1
-#define CAST_8 static_cast<char>
-#define CAST_S8 static_cast<int8_t>
-#define CAST_U8 static_cast<uint8_t>
-#define CAST_S16 static_cast<int16_t>
-#define CAST_U16 static_cast<uint16_t>
-#define CAST_S32 static_cast<int32_t>
-#define CAST_U32 static_cast<uint32_t>
-#define CAST_SIZE static_cast<size_t>
-
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
diff --git a/src/logger.h b/src/logger.h
index 15b955795..5efa0779f 100644
--- a/src/logger.h
+++ b/src/logger.h
@@ -23,6 +23,8 @@
#ifndef LOGGER_H
#define LOGGER_H
+#include "utils/cast.h"
+
#include "localconsts.h"
PRAGMA48(GCC diagnostic push)
diff --git a/src/net/eathena/bankrecv.cpp b/src/net/eathena/bankrecv.cpp
index 9f566d5a4..12b17727b 100644
--- a/src/net/eathena/bankrecv.cpp
+++ b/src/net/eathena/bankrecv.cpp
@@ -28,6 +28,8 @@
#include "net/messagein.h"
+#include "utils/cast.h"
+
#include "debug.h"
namespace EAthena
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 247cf31b9..1be005220 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -25,6 +25,8 @@
#include "enums/simpletypes/beingid.h"
+#include "utils/cast.h"
+
#include <string>
#include "localconsts.h"
diff --git a/src/net/packetcounters.cpp b/src/net/packetcounters.cpp
index 4170c2cf0..6d0a8bbf6 100644
--- a/src/net/packetcounters.cpp
+++ b/src/net/packetcounters.cpp
@@ -22,6 +22,8 @@
#include "net/packetcounters.h"
+#include "utils/cast.h"
+
#include "debug.h"
extern volatile time_t cur_time;
diff --git a/src/net/updatetypeoperators.cpp b/src/net/updatetypeoperators.cpp
index 8ba8224a0..1ee52455c 100644
--- a/src/net/updatetypeoperators.cpp
+++ b/src/net/updatetypeoperators.cpp
@@ -20,6 +20,8 @@
#include "net/updatetypeoperators.h"
+#include "utils/cast.h"
+
#include "debug.h"
int operator&(const UpdateTypeT &a, const UpdateTypeT &b)
diff --git a/src/particle/particle.h b/src/particle/particle.h
index 7004af0e6..1db2f565b 100644
--- a/src/particle/particle.h
+++ b/src/particle/particle.h
@@ -30,6 +30,8 @@
#include "enums/simpletypes/beingid.h"
+#include "utils/cast.h"
+
#include "particle/particleengine.h"
#include "localconsts.h"
diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h
index e67120688..2e06ae495 100644
--- a/src/particle/textparticle.h
+++ b/src/particle/textparticle.h
@@ -25,6 +25,8 @@
#include "particle/particle.h"
+#include "utils/cast.h"
+
class TextParticle final : public Particle
{
public:
diff --git a/src/party.h b/src/party.h
index 7b46339bf..ca7c11d2e 100644
--- a/src/party.h
+++ b/src/party.h
@@ -24,6 +24,7 @@
#include "gui/models/avatarlistmodel.h"
+#include "utils/cast.h"
#include "utils/dtor.h"
#include "utils/stringvector.h"
diff --git a/src/render/mockgraphics.cc b/src/render/mockgraphics.cc
index d36a6b1f5..f3cadee1d 100644
--- a/src/render/mockgraphics.cc
+++ b/src/render/mockgraphics.cc
@@ -24,6 +24,7 @@
#include "graphicsmanager.h"
+#include "utils/cast.h"
#include "utils/sdlcheckutils.h"
#include "render/vertexes/imagecollection.h"
diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp
index 77d0eb889..735ed27f5 100644
--- a/src/resources/image/subimage.cpp
+++ b/src/resources/image/subimage.cpp
@@ -22,6 +22,8 @@
#include "resources/image/subimage.h"
+#include "utils/cast.h"
+
#ifdef DEBUG_IMAGES
#include "logger.h"
#endif // DEBUG_IMAGES
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 384626856..dd91dc738 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -35,6 +35,7 @@
#include "resources/sprite/spritedisplay.h"
+#include "utils/cast.h"
#include "utils/intmap.h"
// sprite, <itemfrom, itemto>
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index 1d5ccefdc..3ae809058 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -33,12 +33,14 @@
#include "enums/resources/map/maplayerposition.h"
#include "enums/resources/map/maptype.h"
+#include "utils/cast.h"
+
+#include "listeners/configlistener.h"
+
#include "resources/memorycounter.h"
#include "resources/map/properties.h"
-#include "listeners/configlistener.h"
-
#include <vector>
class AmbientLayer;
diff --git a/src/resources/map/mapheights.h b/src/resources/map/mapheights.h
index 43721e817..ef8c4151b 100644
--- a/src/resources/map/mapheights.h
+++ b/src/resources/map/mapheights.h
@@ -23,6 +23,8 @@
#include "resources/memorycounter.h"
+#include "utils/cast.h"
+
#include "localconsts.h"
class MapHeights final : public MemoryCounter
diff --git a/src/resources/map/objectslayer.cpp b/src/resources/map/objectslayer.cpp
index 3224da0e6..05d00c61e 100644
--- a/src/resources/map/objectslayer.cpp
+++ b/src/resources/map/objectslayer.cpp
@@ -20,6 +20,8 @@
#include "resources/map/objectslayer.h"
+#include "utils/cast.h"
+
#include "resources/map/mapobjectlist.h"
#include "debug.h"
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index e474d2315..2cc4c5754 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -29,6 +29,7 @@
#include "resources/wallpaperdata.h"
+#include "utils/cast.h"
#include "utils/foreach.h"
#include <algorithm>
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 9f1c2a1d4..62ba76f21 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -29,6 +29,8 @@
#include "utils/base64.h"
+#include "utils/cast.h"
+
#include "debug.h"
static char base64_table[] =
diff --git a/src/utils/buildhex.h b/src/utils/buildhex.h
index 0a4349bac..777d19784 100644
--- a/src/utils/buildhex.h
+++ b/src/utils/buildhex.h
@@ -21,6 +21,8 @@
#ifndef UTILS_BUILDHEX_H
#define UTILS_BUILDHEX_H
+#include "utils/cast.h"
+
#include "localconsts.h"
PRAGMA48(GCC diagnostic push)
diff --git a/src/utils/cast.h b/src/utils/cast.h
new file mode 100644
index 000000000..9b6289ebc
--- /dev/null
+++ b/src/utils/cast.h
@@ -0,0 +1,33 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef UTILS_CAST_H
+#define UTILS_CAST_H
+
+#define CAST_8 static_cast<char>
+#define CAST_S8 static_cast<int8_t>
+#define CAST_U8 static_cast<uint8_t>
+#define CAST_S16 static_cast<int16_t>
+#define CAST_U16 static_cast<uint16_t>
+#define CAST_S32 static_cast<int32_t>
+#define CAST_U32 static_cast<uint32_t>
+#define CAST_SIZE static_cast<size_t>
+
+#endif // UTILS_CAST_H
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index b82ad3065..045feb10a 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -23,6 +23,8 @@
#ifndef UTILS_MATHUTILS_H
#define UTILS_MATHUTILS_H
+#include "utils/cast.h"
+
#include <string>
#ifndef USE_SDL2
diff --git a/src/utils/mathutils_unittest.cc b/src/utils/mathutils_unittest.cc
index 187accf74..c7a545f87 100644
--- a/src/utils/mathutils_unittest.cc
+++ b/src/utils/mathutils_unittest.cc
@@ -20,6 +20,7 @@
#include "test/unittests.h"
+#include "utils/cast.h"
#include "utils/mathutils.h"
#include "debug.h"
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 920ad4164..54e7e0b41 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -66,6 +66,8 @@
#include "gui/color.h"
+#include "utils/cast.h"
+
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL.h>
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 201ffc0c4..71a82f16f 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -30,6 +30,7 @@
#include "resources/db/itemdb.h"
#endif // DYECMD
+#include "utils/cast.h"
#include "utils/gettext.h"
#include "utils/foreach.h"
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index 354232965..19670db99 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -27,6 +27,7 @@
#include "fs/virtfs/fs.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/dtor.h"