summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-23 22:01:44 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-23 22:01:44 +0300
commit3c404128c4669a1f4f190e20a89553677717fc50 (patch)
tree2db4e5031089c800c4e00fd6244e578f44a7c910 /src
parent89b267d6d73bbc59f7c313b8a22b97fbb27f99a8 (diff)
downloadplus-3c404128c4669a1f4f190e20a89553677717fc50.tar.gz
plus-3c404128c4669a1f4f190e20a89553677717fc50.tar.bz2
plus-3c404128c4669a1f4f190e20a89553677717fc50.tar.xz
plus-3c404128c4669a1f4f190e20a89553677717fc50.zip
Add missing comments into defines.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp44
-rw-r--r--src/actions/actions.h5
-rw-r--r--src/actions/chat.cpp11
-rw-r--r--src/actions/statusbar.cpp4
-rw-r--r--src/actormanager.cpp6
-rw-r--r--src/actormanager.h9
-rw-r--r--src/being/compoundsprite.cpp24
-rw-r--r--src/being/compoundsprite.h3
-rw-r--r--src/being/localplayer.cpp8
-rw-r--r--src/being/localplayer.h4
-rw-r--r--src/chatlogger.cpp2
-rw-r--r--src/client.cpp145
-rw-r--r--src/client.h9
-rw-r--r--src/commandline.cpp2
-rw-r--r--src/configmanager.cpp36
-rw-r--r--src/configmanager.h3
-rw-r--r--src/configuration.cpp16
-rw-r--r--src/configuration.h6
-rw-r--r--src/const/net/maxpacketversion.h4
-rw-r--r--src/const/net/net.h10
-rw-r--r--src/defaults.cpp32
-rw-r--r--src/dirs.cpp54
-rw-r--r--src/dirs.h9
-rw-r--r--src/dyetool/actions/actions.cpp2
-rw-r--r--src/dyetool/client.cpp58
-rw-r--r--src/dyetool/client.h2
-rw-r--r--src/dyetool/dyemain.cpp5
-rw-r--r--src/enums/input/inputaction.h2
-rw-r--r--src/enums/input/inputtype.h4
-rw-r--r--src/enums/input/keyvalue.h2
-rw-r--r--src/enums/state.h2
-rw-r--r--src/events/keyevent.h8
-rw-r--r--src/eventsmanager.cpp70
-rw-r--r--src/eventsmanager.h5
-rw-r--r--src/game.cpp35
-rw-r--r--src/graphicsmanager.cpp96
-rw-r--r--src/graphicsmanager.h20
-rw-r--r--src/gui/dialogsmanager.cpp18
-rw-r--r--src/gui/fonts/font.cpp30
-rw-r--r--src/gui/fonts/font.h2
-rw-r--r--src/gui/fonts/textchunk.cpp19
-rw-r--r--src/gui/fonts/textchunk.h2
-rw-r--r--src/gui/gui.cpp24
-rw-r--r--src/gui/gui.h7
-rw-r--r--src/gui/models/modelistmodel.cpp6
-rw-r--r--src/gui/models/modelistmodel.h2
-rw-r--r--src/gui/models/typelistmodel.h4
-rw-r--r--src/gui/popupmanager.cpp14
-rw-r--r--src/gui/popups/beingpopup.cpp2
-rw-r--r--src/gui/popups/beingpopup.h2
-rw-r--r--src/gui/popups/popupmenu.cpp12
-rw-r--r--src/gui/sdlinput.cpp53
-rw-r--r--src/gui/setupactiondata.h2
-rw-r--r--src/gui/widgets/browserbox.cpp3
-rw-r--r--src/gui/widgets/inttextfield.cpp5
-rw-r--r--src/gui/widgets/scrollarea.cpp6
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp2
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp31
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.h5
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_other.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_perfomance.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp31
-rw-r--r--src/gui/widgets/tabs/setup_video.h3
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp18
-rw-r--r--src/gui/widgets/textfield.h5
-rw-r--r--src/gui/widgets/window.cpp12
-rw-r--r--src/gui/widgets/window.h2
-rw-r--r--src/gui/widgets/windowcontainer.cpp2
-rw-r--r--src/gui/widgets/windowcontainer.h2
-rw-r--r--src/gui/windowmanager.cpp59
-rw-r--r--src/gui/windowmanager.h2
-rw-r--r--src/gui/windowmanager_unittest.cc6
-rw-r--r--src/gui/windowmenu.cpp12
-rw-r--r--src/gui/windowmenu.h2
-rw-r--r--src/gui/windows/buydialog.cpp2
-rw-r--r--src/gui/windows/chatwindow.cpp8
-rw-r--r--src/gui/windows/chatwindow.h2
-rw-r--r--src/gui/windows/debugwindow.cpp2
-rw-r--r--src/gui/windows/debugwindow.h2
-rw-r--r--src/gui/windows/editserverdialog.cpp6
-rw-r--r--src/gui/windows/itemamountwindow.h2
-rw-r--r--src/gui/windows/killstats.cpp2
-rw-r--r--src/gui/windows/logindialog.cpp6
-rw-r--r--src/gui/windows/ministatuswindow.cpp2
-rw-r--r--src/gui/windows/ministatuswindow.h2
-rw-r--r--src/gui/windows/serverdialog.cpp8
-rw-r--r--src/gui/windows/shopwindow.cpp14
-rw-r--r--src/gui/windows/shopwindow.h5
-rw-r--r--src/gui/windows/shortcutwindow.cpp2
-rw-r--r--src/gui/windows/shortcutwindow.h2
-rw-r--r--src/gui/windows/socialwindow.cpp14
-rw-r--r--src/gui/windows/socialwindow.h2
-rw-r--r--src/gui/windows/textcommandeditor.cpp37
-rw-r--r--src/gui/windows/textcommandeditor.h13
-rw-r--r--src/gui/windows/updaterwindow.cpp6
-rw-r--r--src/gui/windows/whoisonline.cpp19
-rw-r--r--src/gui/windows/whoisonline.h4
-rw-r--r--src/input/inputactionmap.h24
-rw-r--r--src/input/inputmanager.cpp44
-rw-r--r--src/input/joystick.cpp4
-rw-r--r--src/input/key.h2
-rw-r--r--src/input/keyboardconfig.cpp15
-rw-r--r--src/input/keyboardconfig.h4
-rw-r--r--src/input/keyinput.h10
-rw-r--r--src/input/mouseinput.h5
-rw-r--r--src/input/pages/other.cpp2
-rw-r--r--src/input/touch/multitouchmanager.cpp4
-rw-r--r--src/input/touch/multitouchmanager.h4
-rw-r--r--src/integrity_unittest.cc6
-rw-r--r--src/localconsts.h36
-rw-r--r--src/logger.cpp18
-rw-r--r--src/logger.h14
-rw-r--r--src/main.cpp7
-rw-r--r--src/main.h28
-rw-r--r--src/maingui.cpp33
-rw-r--r--src/mumblemanager.cpp23
-rw-r--r--src/mumblemanager.h2
-rw-r--r--src/navigationmanager.cpp4
-rw-r--r--src/navigationmanager.h4
-rw-r--r--src/net/download.cpp28
-rw-r--r--src/net/ea/network.cpp7
-rw-r--r--src/net/eathena/messagein.cpp30
-rw-r--r--src/net/eathena/messageout.cpp14
-rw-r--r--src/net/ipc.cpp3
-rw-r--r--src/net/messagein.cpp2
-rw-r--r--src/net/net.cpp8
-rw-r--r--src/net/sdltcpnet.cpp18
-rw-r--r--src/net/sdltcpnet.h4
-rw-r--r--src/net/serverinfo.h4
-rw-r--r--src/net/tmwa/messagein.cpp27
-rw-r--r--src/net/tmwa/messageout.cpp14
-rw-r--r--src/notifymanager.cpp6
-rw-r--r--src/render/graphics.cpp66
-rw-r--r--src/render/graphics.h27
-rw-r--r--src/render/mobileopengl2graphics.cpp60
-rw-r--r--src/render/mobileopengl2graphics.h6
-rw-r--r--src/render/mobileopenglgraphics.cpp73
-rw-r--r--src/render/mobileopenglgraphics.h9
-rw-r--r--src/render/modernopenglgraphics.cpp56
-rw-r--r--src/render/modernopenglgraphics.h9
-rw-r--r--src/render/normalopenglgraphics.cpp104
-rw-r--r--src/render/normalopenglgraphics.h14
-rw-r--r--src/render/nullopenglgraphics.cpp56
-rw-r--r--src/render/nullopenglgraphics.h11
-rw-r--r--src/render/opengl/mgl.cpp2
-rw-r--r--src/render/opengl/mgldefines.h34
-rw-r--r--src/render/opengl/mglemu.cpp2
-rw-r--r--src/render/opengl/mglfunctions.h4
-rw-r--r--src/render/opengl/mgltypes.h17
-rw-r--r--src/render/opengl/opengldebug.h4
-rw-r--r--src/render/openglx/mglx.cpp2
-rw-r--r--src/render/openglx/mglxinit.cpp2
-rw-r--r--src/render/renderers.cpp10
-rw-r--r--src/render/safeopenglgraphics.cpp5
-rw-r--r--src/render/safeopenglgraphics.h8
-rw-r--r--src/render/sdl2graphics.cpp4
-rw-r--r--src/render/sdl2softwaregraphics.cpp27
-rw-r--r--src/render/sdlgraphics.cpp20
-rw-r--r--src/render/shaders/shaderprogram.cpp2
-rw-r--r--src/render/shaders/shadersmanager.cpp4
-rw-r--r--src/render/surfacegraphics.cpp15
-rw-r--r--src/render/vertexes/imagecollection.cpp4
-rw-r--r--src/render/vertexes/imagecollection.h3
-rw-r--r--src/render/vertexes/imagevertexes.cpp2
-rw-r--r--src/render/vertexes/imagevertexes.h3
-rw-r--r--src/render/vertexes/openglgraphicsvertexes.cpp2
-rw-r--r--src/render/vertexes/openglgraphicsvertexes.h6
-rw-r--r--src/resources/animation/animation.h2
-rw-r--r--src/resources/atlas/atlasmanager.cpp22
-rw-r--r--src/resources/atlas/atlasresource.cpp2
-rw-r--r--src/resources/db/commandsdb.cpp4
-rw-r--r--src/resources/db/itemdb.cpp2
-rw-r--r--src/resources/db/itemdb.h2
-rw-r--r--src/resources/dye/dye.cpp67
-rw-r--r--src/resources/dye/dye_unittest.cc11
-rw-r--r--src/resources/dye/dyepalette.cpp75
-rw-r--r--src/resources/dye/dyepalette.h2
-rw-r--r--src/resources/dye/dyepalette_unittest.cc5
-rw-r--r--src/resources/fboinfo.h4
-rw-r--r--src/resources/image/image.cpp51
-rw-r--r--src/resources/image/image.h18
-rw-r--r--src/resources/image/subimage.cpp29
-rw-r--r--src/resources/image/subimage.h7
-rw-r--r--src/resources/imagehelper.cpp24
-rw-r--r--src/resources/imagehelper.h5
-rw-r--r--src/resources/loaders/musicloader.cpp5
-rw-r--r--src/resources/loaders/walklayerloader.cpp5
-rw-r--r--src/resources/map/map.cpp19
-rw-r--r--src/resources/map/maplayer.cpp2
-rw-r--r--src/resources/map/maplayer.h2
-rw-r--r--src/resources/mapreader.cpp8
-rw-r--r--src/resources/memorymanager.cpp5
-rw-r--r--src/resources/mobileopenglscreenshothelper.cpp7
-rw-r--r--src/resources/notificationinfo.h2
-rw-r--r--src/resources/openglimagehelper.cpp49
-rw-r--r--src/resources/openglimagehelper.h10
-rw-r--r--src/resources/openglscreenshothelper.cpp2
-rw-r--r--src/resources/resource.cpp9
-rw-r--r--src/resources/resource.h8
-rw-r--r--src/resources/resourcemanager/resourcemanager.cpp55
-rw-r--r--src/resources/resourcemanager/resourcemanager.h4
-rw-r--r--src/resources/resourcemanager/resourcemanager_unittest.cc6
-rw-r--r--src/resources/safeopenglimagehelper.cpp39
-rw-r--r--src/resources/safeopenglimagehelper.h8
-rw-r--r--src/resources/screenshothelper.h5
-rw-r--r--src/resources/sdl2imagehelper.cpp2
-rw-r--r--src/resources/sdl2imagehelper.h4
-rw-r--r--src/resources/sdl2softwarescreenshothelper.cpp8
-rw-r--r--src/resources/sdlimagehelper.cpp7
-rw-r--r--src/resources/sdlmusic.cpp2
-rw-r--r--src/resources/sdlscreenshothelper.cpp10
-rw-r--r--src/resources/sprite/animatedsprite.cpp9
-rw-r--r--src/resources/sprite/animatedsprite.h7
-rw-r--r--src/resources/sprite/animatedsprite_unittest.cc6
-rw-r--r--src/resources/wallpaper.cpp4
-rw-r--r--src/soundmanager.cpp10
-rw-r--r--src/soundmanager.h4
-rw-r--r--src/spellmanager.cpp14
-rw-r--r--src/test/testlauncher.cpp7
-rw-r--r--src/test/testlauncher.h6
-rw-r--r--src/test/testmain.cpp2
-rw-r--r--src/test/testmain.h2
-rw-r--r--src/textcommand.cpp6
-rw-r--r--src/textcommand.h7
-rw-r--r--src/utils/chatutils.cpp4
-rw-r--r--src/utils/chatutils_unittest.cc6
-rw-r--r--src/utils/copynpaste.cpp22
-rw-r--r--src/utils/cpu.cpp9
-rw-r--r--src/utils/env.cpp9
-rw-r--r--src/utils/files.cpp14
-rw-r--r--src/utils/files.h2
-rw-r--r--src/utils/fuzzer.cpp2
-rw-r--r--src/utils/gettext.h2
-rw-r--r--src/utils/gettexthelper.cpp7
-rw-r--r--src/utils/gettexthelper.h6
-rw-r--r--src/utils/mathutils.h2
-rw-r--r--src/utils/mkdir.cpp27
-rw-r--r--src/utils/paths.cpp35
-rw-r--r--src/utils/paths.h2
-rw-r--r--src/utils/perfomance.cpp2
-rw-r--r--src/utils/physfsrwops.cpp37
-rw-r--r--src/utils/physfsrwops.h6
-rw-r--r--src/utils/physfstools.cpp7
-rw-r--r--src/utils/process.cpp28
-rw-r--r--src/utils/sdlcheckutils.cpp12
-rw-r--r--src/utils/sdlhelper.cpp10
-rw-r--r--src/utils/sdlpixel.h16
-rw-r--r--src/utils/sdlsharedhelper.cpp5
-rw-r--r--src/utils/specialfolder.cpp2
-rw-r--r--src/utils/specialfolder.h2
-rw-r--r--src/utils/stringutils.cpp9
-rw-r--r--src/utils/stringutils.h6
-rw-r--r--src/utils/timer.cpp5
-rw-r--r--src/utils/translation/podict.cpp2
-rw-r--r--src/utils/translation/podict.h4
-rw-r--r--src/utils/translation/poparser_unittest.cc5
-rw-r--r--src/utils/translation/translationmanager.cpp2
-rw-r--r--src/utils/translation/translationmanager.h2
-rw-r--r--src/utils/xml/libxml.cpp9
-rw-r--r--src/utils/xml/pugixml.cpp3
-rw-r--r--src/utils/xml_unittest.cc5
263 files changed, 1935 insertions, 1565 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index cb829445c..8682a8d48 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -25,7 +25,7 @@
#include "game.h"
#ifdef USE_OPENGL
#include "graphicsmanager.h"
-#endif
+#endif // USE_OPENGL
#include "main.h"
#include "spellmanager.h"
@@ -74,7 +74,7 @@
#if defined USE_OPENGL
#include "render/normalopenglgraphics.h"
-#endif
+#endif // USE_OPENGL
#include "net/adminhandler.h"
#include "net/beinghandler.h"
@@ -109,8 +109,8 @@
#ifdef ANDROID
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
-#endif
-#endif
+#endif // USE_OPENGL
+#endif // ANDROID
#include <sstream>
@@ -608,6 +608,7 @@ impHandler0(itenplz)
return true;
}
#endif // TMWA_SUPPORT
+
return false;
}
@@ -631,7 +632,8 @@ impHandler0(magicAttack)
localPlayer->magicAttack();
return true;
}
-#endif
+#endif // TMWA_SUPPORT
+
return false;
}
@@ -942,13 +944,16 @@ impHandler0(showKeyboard)
SDL_StopTextInput();
else
SDL_StartTextInput();
-#else
+#else // USE_SDL2
+
SDL_ANDROID_ToggleScreenKeyboardTextInput(nullptr);
-#endif
+#endif // USE_SDL2
+
return true;
-#else
+#else // ANDROID
+
return false;
-#endif
+#endif // ANDROID
}
impHandler0(showWindows)
@@ -1296,12 +1301,13 @@ impHandler0(dump)
check_leaks();
return true;
}
-#else
+#else // DEBUG_DUMP_LEAKS1
+
impHandler0(dump)
{
return true;
}
-#endif
+#endif // DEBUG_DUMP_LEAKS1
impHandler0(serverIgnoreAll)
{
@@ -1350,9 +1356,10 @@ impHandler(dumpGraphics)
#if defined USE_OPENGL
str.append(strprintf(",%d", mainGraphics->getOpenGL()));
-#else
+#else // defined USE_OPENGL
+
str.append(",0");
-#endif
+#endif // defined USE_OPENGL
str.append(strprintf(",%f,", static_cast<double>(settings.guiAlpha)))
.append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
@@ -1395,7 +1402,9 @@ impHandler0(dumpOGL)
{
#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
NormalOpenGLGraphics::dumpSettings();
-#endif
+#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
+ // !defined(__native_client__)
+
return true;
}
@@ -1406,12 +1415,13 @@ impHandler(dumpGL)
outStringNormal(event.tab, str, str);
return true;
}
-#else
+#else // USE_OPENGL
+
impHandler0(dumpGL)
{
return true;
}
-#endif
+#endif // USE_OPENGL
impHandler(dumpMods)
{
@@ -1467,7 +1477,7 @@ impHandler0(testSdlFont)
}
return true;
}
-#endif
+#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
impHandler0(createItems)
{
diff --git a/src/actions/actions.h b/src/actions/actions.h
index fd145852d..51c461953 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -83,7 +83,7 @@ namespace Actions
decHandler(error)
#ifndef ENABLE_CILKPLUS
__attribute__ ((noreturn))
-#endif
+#endif // ENABLE_CILKPLUS
;
decHandler(dumpGraphics);
decHandler(dumpEnvironment);
@@ -93,7 +93,8 @@ namespace Actions
decHandler(dumpMods);
#if defined USE_OPENGL && defined DEBUG_SDLFONT
decHandler(testSdlFont);
-#endif
+#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
+
decHandler(createItems);
decHandler(createItem);
decHandler(uploadConfig);
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp
index 0a922daea..150e1fa56 100644
--- a/src/actions/chat.cpp
+++ b/src/actions/chat.cpp
@@ -40,7 +40,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "resources/iteminfo.h"
@@ -96,7 +96,7 @@ static void outString(ChatTab *const tab,
{
guildManager->chat(str);
}
-#endif
+#endif // TMWA_SUPPORT
}
break;
}
@@ -408,9 +408,10 @@ impHandler(guild)
guildHandler->invite(args);
else if (guildManager)
guildManager->invite(args);
-#else
+#else // TMWA_SUPPORT
+
guildHandler->invite(args);
-#endif
+#endif // TMWA_SUPPORT
}
}
else
@@ -523,7 +524,7 @@ impHandler(kickGuild)
{
guildManager->kick(event.args);
}
-#endif
+#endif // TMWA_SUPPORT
}
}
}
diff --git a/src/actions/statusbar.cpp b/src/actions/statusbar.cpp
index 6669f9b34..175beb324 100644
--- a/src/actions/statusbar.cpp
+++ b/src/actions/statusbar.cpp
@@ -42,8 +42,8 @@
#ifdef ANDROID
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#include "debug.h"
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index b995bde47..808ccd7fa 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -205,7 +205,7 @@ ActorManager::ActorManager() :
mSpellHeal1(serverConfig.getValue("spellHeal1", "#lum")),
mSpellHeal2(serverConfig.getValue("spellHeal2", "#inma")),
mSpellItenplz(serverConfig.getValue("spellItenplz", "#itenplz")),
-#endif
+#endif // TMWA_SUPPORT
mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
mCyclePlayers(config.getBoolValue("cyclePlayers")),
@@ -1539,7 +1539,7 @@ void ActorManager::itenplz() const
chatWindow->localChatInput(mSpellItenplz);
}
-#endif
+#endif // TMWA_SUPPORT
bool ActorManager::hasActorSprite(const ActorSprite *const actor) const
{
@@ -1798,7 +1798,7 @@ void ActorManager::parseLevels(std::string levels) const
}
updatePlayerNames();
}
-#endif
+#endif // TMWA_SUPPORT
void ActorManager::optionChanged(const std::string &name)
{
diff --git a/src/actormanager.h b/src/actormanager.h
index 22a4e3e2a..8d4170275 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -233,7 +233,7 @@ class ActorManager final: public ConfigListener
void heal(const Being *const target) const;
void itenplz() const;
-#endif
+#endif // TMWA_SUPPORT
/**
* Returns the whole list of beings.
@@ -286,7 +286,7 @@ class ActorManager final: public ConfigListener
#ifdef TMWA_SUPPORT
void parseLevels(std::string levels) const;
-#endif
+#endif // TMWA_SUPPORT
bool pickUpAll(const int x1,
const int y1,
@@ -389,7 +389,7 @@ class ActorManager final: public ConfigListener
#ifndef UNITTESTS
protected:
-#endif
+#endif // UNITTESTS
bool validateBeing(const Being *const aroundBeing,
Being *const being,
const ActorTypeT &type,
@@ -419,7 +419,8 @@ class ActorManager final: public ConfigListener
std::string mSpellHeal1;
std::string mSpellHeal2;
std::string mSpellItenplz;
-#endif
+#endif // TMWA_SUPPORT
+
bool mTargetDeadPlayers;
bool mTargetOnlyReachable;
bool mCyclePlayers;
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 7f0066fd8..e1349e0ef 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -54,14 +54,14 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
#ifndef USE_SDL2
static const int BUFFER_WIDTH = 100;
static const int BUFFER_HEIGHT = 100;
static const unsigned cache_max_size = 10;
static const unsigned cache_clean_part = 3;
-#endif
+#endif // USE_SDL2
bool CompoundSprite::mEnableDelay = true;
@@ -78,7 +78,7 @@ CompoundSprite::CompoundSprite() :
mLastTime(0),
#ifndef USE_SDL2
mNextRedrawTime(0),
-#endif
+#endif // USE_SDL2
mNeedsRedraw(false),
mEnableAlphaFix(config.getBoolValue("enableAlphaFix")),
mDisableAdvBeingCaching(config.getBoolValue("disableAdvBeingCaching")),
@@ -326,12 +326,12 @@ void CompoundSprite::redraw() const
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
const int amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
const int amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_HWSURFACE,
BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
@@ -371,11 +371,7 @@ void CompoundSprite::redraw() const
SDL_Surface *const surfaceA = MSDL_CreateRGBSurface(SDL_HWSURFACE,
BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(surface, 255);
-#else
SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
-#endif
SDL_BlitSurface(surface, nullptr, surfaceA, nullptr);
delete mImage;
@@ -393,7 +389,7 @@ void CompoundSprite::redraw() const
{
mAlphaImage = nullptr;
}
-#endif
+#endif // USE_SDL2
}
void CompoundSprite::setAlpha(float alpha)
@@ -403,7 +399,7 @@ void CompoundSprite::setAlpha(float alpha)
if (mEnableAlphaFix &&
#ifdef USE_OPENGL
imageHelper->useOpenGL() == RENDER_SOFTWARE &&
-#endif
+#endif // USE_OPENGL
mSprites.size() > 3U)
{
FOR_EACH (SpriteConstIterator, it, mSprites)
@@ -422,7 +418,7 @@ void CompoundSprite::updateImages() const
#ifdef USE_OPENGL
if (imageHelper->useOpenGL() != RENDER_SOFTWARE)
return;
-#endif
+#endif // USE_OPENGL
if (mEnableDelay)
{
@@ -452,7 +448,7 @@ void CompoundSprite::updateImages() const
redraw();
}
}
-#endif
+#endif // USE_SDL2
}
bool CompoundSprite::updateFromCache() const
@@ -520,7 +516,7 @@ bool CompoundSprite::updateFromCache() const
mImage = nullptr;
mAlphaImage = nullptr;
// miss++;
-#endif
+#endif // USE_SDL2
return false;
}
diff --git a/src/being/compoundsprite.h b/src/being/compoundsprite.h
index 71a77e87e..3c4002569 100644
--- a/src/being/compoundsprite.h
+++ b/src/being/compoundsprite.h
@@ -130,7 +130,8 @@ class CompoundSprite notfinal : public Sprite
int mLastTime;
#ifndef USE_SDL2
mutable int mNextRedrawTime;
-#endif
+#endif // USE_SDL2
+
static bool mEnableDelay;
mutable bool mNeedsRedraw;
bool mEnableAlphaFix;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 007a3d88e..a385cf0f7 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -94,7 +94,7 @@
#ifdef USE_MUMBLE
#include "mumblemanager.h"
-#endif
+#endif // USE_MUMBLE
#include <climits>
@@ -246,7 +246,7 @@ void LocalPlayer::logic()
#ifdef USE_MUMBLE
if (mumbleManager)
mumbleManager->setPos(mX, mY, mDirection);
-#endif
+#endif // USE_MUMBLE
// Actions are allowed once per second
if (get_elapsed_time(mLastAction) >= 1000)
@@ -409,7 +409,7 @@ void LocalPlayer::setAction(const BeingActionT &action,
#ifdef USE_MUMBLE
if (mumbleManager)
mumbleManager->setAction(CAST_S32(action));
-#endif
+#endif // USE_MUMBLE
}
void LocalPlayer::setGMLevel(const int level)
@@ -1694,7 +1694,7 @@ void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
}
}
}
-#endif
+#endif // TMWA_SUPPORT
void LocalPlayer::loadHomes()
{
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index d74481298..72c4d7258 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -206,7 +206,7 @@ class LocalPlayer final : public Being,
#ifdef TMWA_SUPPORT
void magicAttack() const;
-#endif
+#endif // TMWA_SUPPORT
void specialMove(const unsigned char direction);
@@ -448,7 +448,7 @@ class LocalPlayer final : public Being,
const int baseMagic,
const int schoolMagic,
const int mana);
-#endif
+#endif // TMWA_SUPPORT
void loadHomes();
diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp
index 4f8b1ed54..e66745fb7 100644
--- a/src/chatlogger.cpp
+++ b/src/chatlogger.cpp
@@ -30,7 +30,7 @@
#include <sys/time.h>
#elif defined __APPLE__
#include <Carbon/Carbon.h>
-#endif
+#endif // WIN32
#include "configuration.h"
#include "utils/mkdir.h"
diff --git a/src/client.cpp b/src/client.cpp
index 64297d599..080d83846 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -96,7 +96,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "particle/particleengine.h"
@@ -141,7 +141,7 @@
#include "utils/mrand.h"
#ifdef ANDROID
#include "utils/paths.h"
-#endif
+#endif // ANDROID
#include "utils/physfstools.h"
#include "utils/sdlcheckutils.h"
#include "utils/timer.h"
@@ -154,34 +154,34 @@
#ifdef USE_OPENGL
#include "test/testlauncher.h"
#include "test/testmain.h"
-#else
+#else // USE_OPENGL
#include "configuration.h"
-#endif
+#endif // USE_OPENGL
#ifdef WIN32
#include <SDL_syswm.h>
#include "utils/specialfolder.h"
#undef ERROR
-#endif
+#endif // WIN32
#ifdef ANDROID
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
#include <fstream>
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#include <sys/stat.h>
#ifdef USE_MUMBLE
#include "mumblemanager.h"
-#endif
+#endif // USE_MUMBLE
#ifdef USE_SDL2
#include <SDL2_framerate.h>
-#else
+#else // USE_SDL2
#include <SDL_framerate.h>
-#endif
+#endif // USE_SDL2
#include "debug.h"
@@ -237,7 +237,7 @@ Client::Client() :
mPerfomanceButton(nullptr),
#ifdef ANDROID
mCloseButton(nullptr),
-#endif
+#endif // ANDROID
mState(State::CHOOSE_SERVER),
mOldState(State::START),
mSkin(nullptr),
@@ -291,7 +291,8 @@ void Client::gameInit()
#ifdef USE_FUZZER
Fuzzer::init();
-#endif
+#endif // USE_FUZZER
+
if (settings.options.test.empty())
ConfigManager::backupConfig("config.xml");
ConfigManager::initConfiguration();
@@ -309,7 +310,7 @@ void Client::gameInit()
#ifndef ANDROID
if (settings.options.test.empty())
ConfigManager::storeSafeParameters();
-#endif
+#endif // ANDROID
ResourceManager::init();
if (!resourceManager->setWriteDir(settings.localDataDir))
@@ -351,20 +352,22 @@ void Client::gameInit()
PacketLimiter::initPacketLimiter();
#ifndef USE_SDL2
SDL_EnableUNICODE(1);
-#endif
+#endif // USE_SDL2
+
WindowManager::applyKeyRepeat();
// disable unused SDL events
#ifndef USE_SDL2
SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
-#endif
+#endif // USE_SDL2
+
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
#ifdef WIN32
Dirs::extractDataDir();
Dirs::mountDataDir();
-#endif
+#endif // WIN32
WindowManager::setIcon();
ConfigManager::checkConfigVersion();
@@ -372,15 +375,17 @@ void Client::gameInit()
Cpu::detect();
#if defined(USE_OPENGL)
#if !defined(ANDROID) && !defined(__APPLE__) && \
-!defined(__native_client__) && !defined(UNITTESTS)
+ !defined(__native_client__) && !defined(UNITTESTS)
if (!settings.options.safeMode &&
settings.options.test.empty() &&
!config.getBoolValue("videodetected"))
{
graphicsManager.detectVideoSettings();
}
-#endif
-#endif
+#endif // !defined(ANDROID) && !defined(__APPLE__) &&
+ // !defined(__native_client__) && !defined(UNITTESTS)
+#endif // defined(USE_OPENGL)
+
updateEnv();
initGraphics();
@@ -389,7 +394,7 @@ void Client::gameInit()
#ifndef WIN32
Dirs::extractDataDir();
Dirs::mountDataDir();
-#endif
+#endif // WIN32
Dirs::updateDataPath();
@@ -405,7 +410,7 @@ void Client::gameInit()
TranslationManager::loadCurrentLang();
#ifdef ENABLE_CUSTOMNLS
TranslationManager::loadGettextLang();
-#endif
+#endif // ENABLE_CUSTOMNLS
WindowManager::initTitle();
@@ -499,13 +504,13 @@ void Client::gameInit()
#ifdef ANDROID
#ifndef USE_SDL2
WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr));
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#ifdef USE_MUMBLE
if (!mumbleManager)
mumbleManager = new MumbleManager();
-#endif
+#endif // USE_MUMBLE
mSkin = theme->load("windowmenu.xml", "");
if (mSkin)
@@ -642,7 +647,7 @@ void Client::gameClear()
#ifdef USE_MUMBLE
delete2(mumbleManager);
-#endif
+#endif // USE_MUMBLE
PlayerInfo::deinit();
@@ -712,7 +717,8 @@ void Client::gameClear()
#ifdef DEBUG_CONFIG
config.enableKeyLogging();
-#endif
+#endif // DEBUG_CONFIG
+
config.removeOldKeys();
config.write();
serverConfig.write();
@@ -725,12 +731,12 @@ void Client::gameClear()
#ifdef USE_PROFILER
Perfomance::clear();
-#endif
+#endif // USE_PROFILER
#ifdef DEBUG_OPENGL_LEAKS
if (logger)
logger->log("textures left: %d", textures_count);
-#endif
+#endif // DEBUG_OPENGL_LEAKS
delete2(chatLogger);
TranslationManager::close();
@@ -749,9 +755,10 @@ int Client::testsExec()
TestLauncher launcher(settings.options.test);
return launcher.exec();
}
-#else
+#else // USE_OPENGL
+
return 0;
-#endif
+#endif // USE_OPENGL
}
#define ADDBUTTON(var, object) var = object; \
@@ -759,7 +766,6 @@ int Client::testsExec()
var->setPosition(x, mButtonPadding); \
top->add(var);
-
void Client::stateConnectGame1()
{
if (gameHandler &&
@@ -828,11 +834,11 @@ void Client::stateConnectServer1()
#ifdef USE_MUMBLE
if (mumbleManager)
mumbleManager->setServer(mCurrentServer.hostname);
-#endif
+#endif // USE_MUMBLE
#ifdef TMWA_SUPPORT
GuildManager::init();
-#endif
+#endif // TMWA_SUPPORT
if (!mConfigAutoSaved)
{
@@ -894,7 +900,8 @@ void Client::stateGame1()
ADDBUTTON(mCloseButton, new Button(desktop,
// TRANSLATORS: close quick button
_("Close"), "close", this))
-#endif
+#endif // ANDROID
+
desktop->setSize(mainGraphics->getWidth(),
mainGraphics->getHeight());
}
@@ -1450,7 +1457,7 @@ int Client::gameExec()
#ifdef USE_MUMBLE
if (mumbleManager)
mumbleManager->setPlayer(localPlayer->getName());
-#endif
+#endif // USE_MUMBLE
}
// Fade out logon-music here too to give the desired effect
@@ -1465,7 +1472,8 @@ int Client::gameExec()
#ifdef ANDROID
delete2(mCloseButton);
-#endif
+#endif // ANDROID
+
delete2(mSetupButton);
delete2(mVideoButton);
delete2(mThemesButton);
@@ -1918,8 +1926,8 @@ void Client::moveButtons(const int width)
#ifdef ANDROID
x -= mCloseButton->getWidth() + mButtonSpacing;
mCloseButton->setPosition(x, mButtonPadding);
-#endif
-#endif
+#endif // ANDROID
+#endif // WIN32
}
}
@@ -1934,7 +1942,7 @@ void Client::logVars()
#ifdef ANDROID
logger->log("APPDIR: %s", getenv("APPDIR"));
logger->log("DATADIR2: %s", getSdStoragePath().c_str());
-#endif
+#endif // ANDROID
}
void Client::slowLogic()
@@ -1966,62 +1974,3 @@ void Client::slowLogic()
}
}
}
-
-#ifdef ANDROID
-#ifdef USE_SDL2
-/*
-void Client::extractAssets()
-{
- if (!getenv("APPDIR"))
- {
- logger->log("error: APPDIR is not set!");
- return;
- }
- const std::string fileName = std::string(getenv(
- "APPDIR")).append("/data.zip");
- logger->log("Extracting asset into: " + fileName);
- uint8_t *buf = new uint8_t[1000000];
-
- FILE *const file = fopen(fileName.c_str(), "w");
- for (int f = 0; f < 100; f ++)
- {
- std::string part = strprintf("manaplus-data.zip%u%u",
- CAST_U32(f / 10),
- CAST_U32(f % 10));
- logger->log("testing asset: " + part);
- SDL_RWops *const rw = SDL_RWFromFile(part.c_str(), "r");
- if (rw)
- {
- const int size = SDL_RWsize(rw);
- int size2 = SDL_RWread(rw, buf, 1, size);
- logger->log("asset size: %d", size2);
- fwrite(buf, 1, size2, file);
- SDL_RWclose(rw);
- Dirs::setProgress();
- }
- else
- {
- break;
- }
- }
- fclose(file);
-
- const std::string fileName2 = std::string(getenv(
- "APPDIR")).append("/locale.zip");
- FILE *const file2 = fopen(fileName2.c_str(), "w");
- SDL_RWops *const rw = SDL_RWFromFile("manaplus-locale.zip", "r");
- if (rw)
- {
- const int size = SDL_RWsize(rw);
- int size2 = SDL_RWread(rw, buf, 1, size);
- fwrite(buf, 1, size2, file2);
- SDL_RWclose(rw);
- setProgress();
- }
- fclose(file2);
-
- delete [] buf;
-}
-*/
-#endif
-#endif
diff --git a/src/client.h b/src/client.h
index f381c5cb6..6b4c3c186 100644
--- a/src/client.h
+++ b/src/client.h
@@ -26,7 +26,7 @@
#ifdef DYECMD
#include "dyetool/client.h"
-#else
+#else // DYECMD
#include "enums/state.h"
@@ -112,9 +112,10 @@ class Client final : public ConfigListener,
#ifdef ANDROID
static void logVars();
-#else
+#else // ANDROID
+
static void logVars() A_CONST;
-#endif
+#endif // ANDROID
void stateConnectGame1();
@@ -139,7 +140,7 @@ class Client final : public ConfigListener,
Button *mPerfomanceButton;
#ifdef ANDROID
Button *mCloseButton;
-#endif
+#endif // ANDROID
StateT mState;
StateT mOldState;
diff --git a/src/commandline.cpp b/src/commandline.cpp
index 110aa60f5..4b8f746d4 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -117,7 +117,7 @@ static void printHelp()
// TRANSLATORS: command line help
_(" -O --no-opengl : Disable OpenGL for this session") <<
std::endl
-#endif
+#endif // USE_OPENGL
;
}
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index 013750e15..9f67ad2c5 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -85,7 +85,7 @@ void ConfigManager::initConfiguration()
{
#ifdef DEBUG_CONFIG
config.setIsMain(true);
-#endif
+#endif // DEBUG_CONFIG
// Fill configuration with defaults
config.setValue("hwaccel", false);
@@ -96,12 +96,15 @@ void ConfigManager::initConfiguration()
config.setValue("opengl", CAST_S32(RENDER_GLES_OPENGL));
#elif (defined WIN32)
config.setValue("opengl", CAST_S32(RENDER_SAFE_OPENGL));
-#else
+#else // (defined __APPLE__)
+
config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-#endif
-#else
+#endif // (defined __APPLE__)
+#else // USE_OPENGL
+
config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-#endif
+#endif // USE_OPENGL
+
config.setValue("screen", false);
config.setValue("sound", true);
config.setValue("guialpha", 0.8F);
@@ -289,9 +292,10 @@ void ConfigManager::storeSafeParameters()
}
#if defined(__APPLE__)
config.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
-#else
+#else // defined(__APPLE__)
+
config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-#endif
+#endif // defined(__APPLE__)
config.write();
@@ -330,7 +334,7 @@ void ConfigManager::storeSafeParameters()
config.setValue("screenheight", height);
}
}
-#endif
+#endif // __native_client__
#define unassignKey(key, value) \
if (config.getStringValue(prefix + key) == value) \
@@ -358,13 +362,13 @@ void ConfigManager::checkConfigVersion()
config.setValue("audioFrequency", 44100);
#ifdef ANDROID
config.setValue("customcursor", false);
-#endif
+#endif // ANDROID
}
if (version < 4)
{
#ifdef ANDROID
config.setValue("showDidYouKnow", false);
-#endif
+#endif // ANDROID
}
if (version < 5)
{
@@ -392,9 +396,11 @@ void ConfigManager::checkConfigVersion()
{
#ifdef USE_SDL2
const std::string prefix = std::string("sdl2");
-#else
+#else // USE_SDL2
+
const std::string prefix = std::string();
-#endif
+#endif // USE_SDL2
+
unassignKey("keyDirectUp", "k108");
unassignKey("keyDirectDown", "k59");
unassignKey("keyDirectLeft", "k107");
@@ -404,9 +410,11 @@ void ConfigManager::checkConfigVersion()
{
#ifdef USE_SDL2
const std::string prefix = std::string("sdl2");
-#else
+#else // USE_SDL2
+
const std::string prefix = std::string();
-#endif
+#endif // USE_SDL2
+
unassignKey("keyAttack", "k120");
}
diff --git a/src/configmanager.h b/src/configmanager.h
index 4bad9d197..b69132fc5 100644
--- a/src/configmanager.h
+++ b/src/configmanager.h
@@ -36,7 +36,8 @@ class ConfigManager final
#ifndef ANDROID
static void storeSafeParameters();
-#endif
+#endif // ANDROID
+
static void backupConfig(const std::string &name);
static void checkConfigVersion();
diff --git a/src/configuration.cpp b/src/configuration.cpp
index ef3c6cf2a..3d6f17ced 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -39,9 +39,9 @@
StringIntMap optionsCount;
#define GETLOG() if (logger) {logger->log("config get: " + key); \
if (mIsMain) optionsCount[key] = 1; }
-#else
+#else // DEBUG_CONFIG
#define GETLOG()
-#endif
+#endif // DEBUG_CONFIG
Configuration config; // XML file configuration reader
Configuration serverConfig; // XML file server configuration reader
@@ -342,9 +342,10 @@ ConfigurationObject::ConfigurationObject() :
mContainerOptions(),
mLogKeys(false),
mIsMain(false)
-#else
+#else // DEBUG_CONFIG
+
mContainerOptions()
-#endif
+#endif // DEBUG_CONFIG
{
}
@@ -366,7 +367,7 @@ Configuration::Configuration() :
#ifdef DEBUG_CONFIG
mLogKeys = false;
mIsMain = false;
-#endif
+#endif // DEBUG_CONFIG
}
void Configuration::cleanDefaults()
@@ -807,7 +808,8 @@ void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer)
if (optionsCount.find(i->first) == optionsCount.end())
logger->log("unused configuration option: " + i->first);
}
-#endif
+#endif // DEBUG_CONFIG
+
XmlTextWriterStartElement(writer, "option");
XmlTextWriterWriteAttribute(writer, "name", i->first.c_str());
XmlTextWriterWriteAttribute(writer, "value", i->second.c_str());
@@ -921,7 +923,7 @@ void Configuration::checkListeners(ConfigListener *const listener,
}
}
}
-#endif
+#endif // ENABLE_CHECKS
void Configuration::removeListeners(ConfigListener *const listener)
{
diff --git a/src/configuration.h b/src/configuration.h
index 96f11d127..829f8201f 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -203,7 +203,7 @@ class ConfigurationObject notfinal
void setIsMain(bool b)
{ mIsMain = b; }
-#endif
+#endif // DEBUG_CONFIG
protected:
ConfigurationObject();
@@ -222,7 +222,7 @@ class ConfigurationObject notfinal
#ifdef DEBUG_CONFIG
bool mLogKeys;
bool mIsMain;
-#endif
+#endif // DEBUG_CONFIG
};
#define valTest(num) mStatsRe##num
@@ -289,7 +289,7 @@ class Configuration final : public ConfigurationObject
void checkListeners(ConfigListener *const listener,
const char *const file,
const unsigned line);
-#endif
+#endif // ENABLE_CHECKS
void setValue(const std::string &key,
const std::string &value) override;
diff --git a/src/const/net/maxpacketversion.h b/src/const/net/maxpacketversion.h
index 1fba13a3f..0fedd3ab5 100644
--- a/src/const/net/maxpacketversion.h
+++ b/src/const/net/maxpacketversion.h
@@ -23,9 +23,9 @@
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <cstdint>
-#else
+#else // defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <stdint.h>
-#endif
+#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
static const uint32_t maxPacketVersion = 20151001;
diff --git a/src/const/net/net.h b/src/const/net/net.h
index afa1f1bbf..d6d129047 100644
--- a/src/const/net/net.h
+++ b/src/const/net/net.h
@@ -23,14 +23,14 @@
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <cstdint>
-#else
+#else // defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <stdint.h>
-#endif
+#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
#ifdef TMWA_SUPPORT
static const uint16_t DEFAULT_PORT = 6901;
-#else
-static const uint16_t DEFAULT_PORT = 6900;
-#endif
+#else // TMWA_SUPPORT
+static const uint16_t DEFAULT_PORT = 6900;
+#endif // TMWA_SUPPORT
#endif // CONST_NET_NET_H
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 312c3a2fe..48febf17f 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -38,7 +38,7 @@
#ifndef USE_SDL2
#include <SDL_keyboard.h>
-#endif
+#endif // USE_SDL2
#include "debug.h"
@@ -131,7 +131,8 @@ DefaultsData* getConfigDefaults()
AddDEF("customcursor", false);
AddDEF("showDidYouKnow", false);
AddDEF("longmouseclick", true);
-#else
+#else // ANDROID
+
AddDEF("screenwidth", defaultScreenWidth);
AddDEF("screenheight", defaultScreenHeight);
AddDEF("showScreenJoystick", false);
@@ -145,7 +146,8 @@ DefaultsData* getConfigDefaults()
AddDEF("customcursor", true);
AddDEF("showDidYouKnow", true);
AddDEF("longmouseclick", false);
-#endif
+#endif // ANDROID
+
AddDEF("showEmotesButton", true);
AddDEF("screen", false);
AddDEF("hwaccel", false);
@@ -283,20 +285,24 @@ DefaultsData* getConfigDefaults()
AddDEF("blur", false);
#if defined(WIN32) || defined(__APPLE__)
AddDEF("centerwindow", true);
-#else
+#else // defined(WIN32) || defined(__APPLE__)
+
AddDEF("centerwindow", false);
-#endif
+#endif // defined(WIN32) || defined(__APPLE__)
+
AddDEF("audioFrequency", 44100);
AddDEF("audioChannels", 2);
#ifdef USE_SDL2
AddDEF("repeateDelay", 500);
AddDEF("repeateInterval", 30);
AddDEF("repeateInterval2", 500);
-#else
+#else // USE_SDL2
+
AddDEF("repeateDelay", SDL_DEFAULT_REPEAT_DELAY);
AddDEF("repeateInterval", SDL_DEFAULT_REPEAT_INTERVAL);
AddDEF("repeateInterval2", SDL_DEFAULT_REPEAT_DELAY);
-#endif
+#endif // USE_SDL2
+
AddDEF("compresstextures", 0);
AddDEF("rectangulartextures", false);
AddDEF("networksleep", 0);
@@ -307,9 +313,11 @@ DefaultsData* getConfigDefaults()
AddDEF("enableCompoundSpriteDelay", true);
#ifdef ANDROID
AddDEF("useAtlases", false);
-#else
+#else // ANDROID
+
AddDEF("useAtlases", true);
-#endif
+#endif // ANDROID
+
AddDEF("useTextureSampler", false);
AddDEF("ministatussaved", 0);
AddDEF("allowscreensaver", false);
@@ -317,9 +325,11 @@ DefaultsData* getConfigDefaults()
AddDEF("protectChatFocus", true);
#if defined(__APPLE__)
AddDEF("enableGamma", false);
-#else
+#else // defined(__APPLE__)
+
AddDEF("enableGamma", true);
-#endif
+#endif // defined(__APPLE__)
+
AddDEF("logInput", false);
AddDEF("highlightWords", "");
AddDEF("globalsFilter", "Sagatha");
diff --git a/src/dirs.cpp b/src/dirs.cpp
index 45b743b79..16a1206a2 100644
--- a/src/dirs.cpp
+++ b/src/dirs.cpp
@@ -31,7 +31,8 @@
#include "utils/base64.h"
#if defined(__native_client__) || (defined(ANDROID) && defined(USE_SDL2))
#include "utils/files.h"
-#endif
+#endif // defined(__native_client__) || (defined(ANDROID) &&
+ // defined(USE_SDL2))
#include "utils/gettext.h"
#include "utils/mkdir.h"
#include "utils/paths.h"
@@ -44,18 +45,18 @@
#include "main.h"
#include "render/graphics.h"
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#ifdef __APPLE__
#include <CoreFoundation/CFBundle.h>
-#endif
+#endif // __APPLE__
#ifdef WIN32
#include <SDL_syswm.h>
#include "utils/specialfolder.h"
#undef ERROR
-#endif
+#endif // WIN32
#include <sys/stat.h>
@@ -65,7 +66,7 @@
#if defined __native_client__
#define _nacl_dir std::string("/persistent/manaplus")
-#endif
+#endif // defined __native_client__
#ifdef ANDROID
#ifdef USE_SDL2
@@ -148,8 +149,8 @@ void extractAssets()
delete [] buf;
}
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
void Dirs::updateDataPath()
{
@@ -184,7 +185,7 @@ void Dirs::extractDataDir()
"/data");
Files::extractZip(zipName, "data", dirName);
Files::extractLocale();
-#endif
+#endif // defined(ANDROID) && defined(USE_SDL2)
}
void Dirs::mountDataDir()
@@ -211,7 +212,8 @@ void Dirs::mountDataDir()
resourceManager->addToSearchPath(path, Append_false);
// possible this need for support run client from dmg images.
// mPackageDir = path;
-#endif
+#endif // defined __APPLE__
+
resourceManager->addToSearchPath(PKG_DATADIR "data", Append_false);
setPackageDir(PKG_DATADIR "data");
resourceManager->addToSearchPath("data", Append_false);
@@ -225,12 +227,12 @@ void Dirs::mountDataDir()
resourceManager->addToSearchPath(appDir + "/data/perserver/default",
Append_false);
}
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#if defined __native_client__
resourceManager->addToSearchPath("/http/data.zip", Append_false);
-#endif
+#endif // defined __native_client__
// Add branding/data to PhysFS search path
if (!settings.options.brandingPath.empty())
@@ -242,9 +244,11 @@ void Dirs::mountDataDir()
const int loc1 = path.find_last_of('/');
const int loc2 = path.find_last_of('\\');
const int loc = CAST_S32(std::max(loc1, loc2));
-#else
+#else // WIN32
+
const int loc = CAST_S32(path.find_last_of('/'));
-#endif
+#endif // WIN32
+
if (loc > 0)
{
resourceManager->addToSearchPath(path.substr(
@@ -344,10 +348,11 @@ void Dirs::initLocalDataDir()
"appShort", "ManaPlus") + "/local";
#elif defined __native_client__
settings.localDataDir = _nacl_dir.append("/local");
-#else
+#else // __APPLE__
+
settings.localDataDir = std::string(PhysFs::getUserDir()) +
".local/share/mana";
-#endif
+#endif // __APPLE__
}
if (mkdir_r(settings.localDataDir.c_str()))
@@ -358,7 +363,7 @@ void Dirs::initLocalDataDir()
}
#ifdef USE_PROFILER
Perfomance::init(settings.localDataDir + "/profiler.log");
-#endif
+#endif // USE_PROFILER
}
void Dirs::initTempDir()
@@ -403,10 +408,12 @@ void Dirs::initConfigDir()
"appShort", "ManaPlus").append("/config");
#elif defined __native_client__
settings.configDir = _nacl_dir.append("/config");
-#else
+#else // __APPLE__
+
settings.configDir = std::string(PhysFs::getUserDir()).append(
"/.config/mana/").append(branding.getValue("appShort", "mana"));
-#endif
+#endif // __APPLE__
+
logger->log("Generating config dir: " + settings.configDir);
}
@@ -478,7 +485,7 @@ void Dirs::initUpdatesDir()
#ifdef WIN32
if (settings.updatesDir.find(":") != std::string::npos)
replaceAll(settings.updatesDir, ":", "_");
-#endif
+#endif // WIN32
const std::string updateDir("/" + settings.updatesDir);
@@ -508,13 +515,14 @@ void Dirs::initUpdatesDir()
errorMessage = _("Error creating updates directory!");
client->setState(State::ERROR);
}
-#else
+#else // defined WIN32
+
logger->log("Error: %s/%s can't be made, but doesn't exist!",
settings.localDataDir.c_str(), settings.updatesDir.c_str());
// TRANSLATORS: update server initialisation error
errorMessage = _("Error creating updates directory!");
client->setState(State::ERROR);
-#endif
+#endif // defined WIN32
}
}
const std::string updateLocal = updateDir + "/local";
diff --git a/src/dirs.h b/src/dirs.h
index 3165d0d21..15435558b 100644
--- a/src/dirs.h
+++ b/src/dirs.h
@@ -34,9 +34,10 @@ class Dirs final
#if defined(ANDROID) && defined(USE_SDL2)
static void extractDataDir();
-#else
+#else // defined(ANDROID) && defined(USE_SDL2)
+
static void extractDataDir() A_CONST;
-#endif
+#endif // defined(ANDROID) && defined(USE_SDL2)
static void mountDataDir();
@@ -57,8 +58,8 @@ class Dirs final
#ifdef ANDROID
#ifdef USE_SDL2
static void setProgress();
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
};
#endif // DIRS_H
diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp
index 6898e27df..98ab8d95d 100644
--- a/src/dyetool/actions/actions.cpp
+++ b/src/dyetool/actions/actions.cpp
@@ -90,7 +90,7 @@ impHandlerVoid(dumpGL)
impHandlerVoid(dumpMods)
#if defined USE_OPENGL && defined DEBUG_SDLFONT
impHandlerVoid(testSdlFont)
-#endif
+#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
impHandlerVoid(createItems)
impHandlerVoid(createItem)
impHandlerVoid(uploadConfig)
diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp
index 74423d3fe..1d089e4ad 100644
--- a/src/dyetool/client.cpp
+++ b/src/dyetool/client.cpp
@@ -61,7 +61,8 @@
#include "utils/mrand.h"
#ifdef ANDROID
#include "utils/paths.h"
-#endif
+#endif // ANDROID
+
#include "utils/physfstools.h"
#include "utils/sdlcheckutils.h"
#include "utils/timer.h"
@@ -76,20 +77,20 @@
#include <SDL_syswm.h>
#include "utils/specialfolder.h"
#undef ERROR
-#endif
+#endif // WIN32
#ifdef ANDROID
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
#include <fstream>
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#ifdef USE_SDL2
#include <SDL2_framerate.h>
-#else
+#else // USE_SDL2
#include <SDL_framerate.h>
-#endif
+#endif // USE_SDL2
#include "debug.h"
@@ -120,7 +121,7 @@ Client::Client() :
mPerfomanceButton(nullptr),
#ifdef ANDROID
mCloseButton(nullptr),
-#endif
+#endif // ANDROID
mState(State::GAME),
mOldState(State::START),
mSkin(nullptr),
@@ -162,7 +163,8 @@ void Client::gameInit()
#ifdef USE_FUZZER
Fuzzer::init();
-#endif
+#endif // USE_FUZZER
+
if (settings.options.test.empty())
ConfigManager::backupConfig("config.xml");
ConfigManager::initConfiguration();
@@ -177,7 +179,7 @@ void Client::gameInit()
#ifndef ANDROID
if (settings.options.test.empty())
ConfigManager::storeSafeParameters();
-#endif
+#endif // ANDROID
ResourceManager::init();
if (!resourceManager->setWriteDir(settings.localDataDir))
@@ -219,20 +221,22 @@ void Client::gameInit()
#ifndef USE_SDL2
SDL_EnableUNICODE(1);
-#endif
+#endif // USE_SDL2
+
WindowManager::applyKeyRepeat();
// disable unused SDL events
#ifndef USE_SDL2
SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
-#endif
+#endif // USE_SDL2
+
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
#ifdef WIN32
Dirs::extractDataDir();
Dirs::mountDataDir();
-#endif
+#endif // WIN32
WindowManager::setIcon();
ConfigManager::checkConfigVersion();
@@ -245,15 +249,17 @@ void Client::gameInit()
{
graphicsManager.detectVideoSettings();
}
-#endif
-#endif
+#endif // !defined(ANDROID) && !defined(__APPLE__) &&
+ // !defined(__native_client__)
+#endif // defined(USE_OPENGL)
+
updateEnv();
initGraphics();
#ifndef WIN32
Dirs::extractDataDir();
Dirs::mountDataDir();
-#endif
+#endif // WIN32
Dirs::updateDataPath();
@@ -269,7 +275,7 @@ void Client::gameInit()
TranslationManager::loadCurrentLang();
#ifdef ENABLE_CUSTOMNLS
TranslationManager::loadGettextLang();
-#endif
+#endif // ENABLE_CUSTOMNLS
WindowManager::initTitle();
@@ -323,8 +329,8 @@ void Client::gameInit()
#ifdef ANDROID
#ifndef USE_SDL2
WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr));
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
mSkin = theme->load("windowmenu.xml", "");
if (mSkin)
@@ -444,7 +450,8 @@ void Client::gameClear()
#ifdef DEBUG_CONFIG
config.enableKeyLogging();
-#endif
+#endif // DEBUG_CONFIG
+
config.removeOldKeys();
config.write();
serverConfig.write();
@@ -457,12 +464,12 @@ void Client::gameClear()
#ifdef USE_PROFILER
Perfomance::clear();
-#endif
+#endif // USE_PROFILER
#ifdef DEBUG_OPENGL_LEAKS
if (logger)
logger->log("textures left: %d", textures_count);
-#endif
+#endif // DEBUG_OPENGL_LEAKS
// delete2(chatLogger);
TranslationManager::close();
@@ -509,7 +516,8 @@ void Client::stateGame()
ADDBUTTON(mCloseButton, new Button(desktop,
// TRANSLATORS: close quick button
_("Close"), "close", this))
-#endif
+#endif // ANDROID
+
desktop->setSize(mainGraphics->getWidth(),
mainGraphics->getHeight());
}
@@ -730,8 +738,8 @@ void Client::moveButtons(const int width)
#ifdef ANDROID
x -= mCloseButton->getWidth() + mButtonSpacing;
mCloseButton->setPosition(x, mButtonPadding);
-#endif
-#endif
+#endif // ANDROID
+#endif // WIN32
}
}
@@ -746,7 +754,7 @@ void Client::logVars()
#ifdef ANDROID
logger->log("APPDIR: %s", getenv("APPDIR"));
logger->log("DATADIR2: %s", getSdStoragePath().c_str());
-#endif
+#endif // ANDROID
}
void Client::slowLogic()
diff --git a/src/dyetool/client.h b/src/dyetool/client.h
index 4c8c2c3bd..bdcdadc09 100644
--- a/src/dyetool/client.h
+++ b/src/dyetool/client.h
@@ -102,7 +102,7 @@ class Client final : public ActionListener
Button *mPerfomanceButton;
#ifdef ANDROID
Button *mCloseButton;
-#endif
+#endif // ANDROID
StateT mState;
StateT mOldState;
diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp
index 8a69b79c1..abe3da289 100644
--- a/src/dyetool/dyemain.cpp
+++ b/src/dyetool/dyemain.cpp
@@ -81,9 +81,10 @@ int main(int argc, char **argv)
#ifdef USE_SDL2
imageHelper = new SurfaceImageHelper;
-#else
+#else // USE_SDL2
+
imageHelper = new SDLImageHelper;
-#endif
+#endif // USE_SDL2
ResourceManager::init();
resourceManager->setWriteDir(".");
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 4f2f12e9c..bbedbec36 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -28,7 +28,7 @@
#ifdef WIN32
#undef ERROR
#undef IGNORE
-#endif
+#endif // WIN32
/**
* All the key functions.
diff --git a/src/enums/input/inputtype.h b/src/enums/input/inputtype.h
index 1e0f6b9ff..2d324df40 100644
--- a/src/enums/input/inputtype.h
+++ b/src/enums/input/inputtype.h
@@ -26,10 +26,10 @@
// hack to avoid conflicts with windows headers.
#ifdef KEYBOARD
#undef KEYBOARD
-#endif
+#endif // KEYBOARD
#ifdef MOUSE
#undef MOUSE
-#endif
+#endif // MOUSE
enumStart(InputType)
{
diff --git a/src/enums/input/keyvalue.h b/src/enums/input/keyvalue.h
index b41bb8fca..12a8410e0 100644
--- a/src/enums/input/keyvalue.h
+++ b/src/enums/input/keyvalue.h
@@ -71,7 +71,7 @@
// that windows define with Guichan.
#if defined (_WIN32) && defined(DELETE)
#undef DELETE
-#endif
+#endif // defined (_WIN32) && defined(DELETE)
namespace KeyValue
{
diff --git a/src/enums/state.h b/src/enums/state.h
index 53b188ea9..f61726a72 100644
--- a/src/enums/state.h
+++ b/src/enums/state.h
@@ -27,7 +27,7 @@
#ifdef WIN32
#undef ERROR
-#endif
+#endif // WIN32
enumStart(State)
{
diff --git a/src/events/keyevent.h b/src/events/keyevent.h
index a131a753e..54ad54759 100644
--- a/src/events/keyevent.h
+++ b/src/events/keyevent.h
@@ -74,7 +74,7 @@
#ifdef USE_SDL2
#include <string>
-#endif
+#endif // USE_SDL2
class Widget;
@@ -100,7 +100,7 @@ class KeyEvent: public InputGuiEvent
mKey(key),
#ifdef USE_SDL2
mText(),
-#endif
+#endif // USE_SDL2
mType(type),
mActionId(actionId)
{ }
@@ -136,7 +136,7 @@ class KeyEvent: public InputGuiEvent
std::string getText() const
{ return mText; }
-#endif
+#endif // USE_SDL2
protected:
/**
@@ -146,7 +146,7 @@ class KeyEvent: public InputGuiEvent
#ifdef USE_SDL2
std::string mText;
-#endif
+#endif // USE_SDL2
/**
* Holds the type of the key event.
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
index c8820487f..cb9427158 100644
--- a/src/eventsmanager.cpp
+++ b/src/eventsmanager.cpp
@@ -24,10 +24,10 @@
#include "client.h"
#ifndef DYECMD
#include "game.h"
-#endif
+#endif // DYECMD
#ifdef USE_MUMBLE
#include "mumblemanager.h"
-#endif
+#endif // USE_MUMBLE
#include "sdlshared.h"
#include "settings.h"
@@ -88,7 +88,7 @@ bool EventsManager::handleCommonEvents(const SDL_Event &event) const
handleSDL2WindowEvent(event);
BLOCK_END("EventsManager::handleCommonEvents")
return true;
-#else
+#else // USE_SDL2
case SDL_VIDEORESIZE:
WindowManager::resizeVideo(event.resize.w,
event.resize.h,
@@ -106,8 +106,8 @@ bool EventsManager::handleCommonEvents(const SDL_Event &event) const
return true;
case SDL_ACCELEROMETER:
break;
-#endif
-#endif
+#endif // ANDROID
+#endif // USE_SDL2
default:
break;
}
@@ -132,7 +132,7 @@ bool EventsManager::handleEvents() const
Game::instance()->handleInput();
}
else
-#endif
+#endif // DYECMD
{
SDL_Event event;
// Handle SDL events
@@ -153,11 +153,8 @@ bool EventsManager::handleEvents() const
}
break;
-#endif
-#else
-#ifndef USE_SDL2
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
default:
break;
}
@@ -169,7 +166,7 @@ bool EventsManager::handleEvents() const
mumbleManager->setPos(localPlayer->getTileX(),
localPlayer->getTileY(), localPlayer->getDirection());
}
-#endif
+#endif // USE_MUMBLE
}
if (client->getState() == State::EXIT)
{
@@ -198,7 +195,8 @@ void EventsManager::handleGameEvents() const
if (handleCommonEvents(event))
break;
} // End while
-#endif
+#endif // DYECMD
+
BLOCK_END("EventsManager::handleGameEvents")
}
@@ -346,7 +344,8 @@ void EventsManager::logEvent(const SDL_Event &event)
case SDL_APP_DIDENTERBACKGROUND:
logger->log("SDL_APP_DIDENTERBACKGROUND");
break;
-#else
+#else // USE_SDL2
+
case SDL_MOUSEMOTION:
logger->log("event: SDL_MOUSEMOTION: %u,%d,%d",
event.motion.state, event.motion.x, event.motion.y);
@@ -369,7 +368,8 @@ void EventsManager::logEvent(const SDL_Event &event)
logger->log("event: SDL_ACTIVEEVENT: %d %d",
event.active.state, event.active.gain);
break;
-#endif
+#endif // USE_SDL2
+
case SDL_MOUSEBUTTONDOWN:
logger->log("event: SDL_MOUSEBUTTONDOWN: %d,%d,%d,%d",
event.button.button, event.button.state,
@@ -417,8 +417,9 @@ void EventsManager::logEvent(const SDL_Event &event)
case SDL_ACCELEROMETER:
logger->log("event: SDL_ACCELEROMETER");
break;
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
+
default:
logger->log("event: other: %u", event.type);
break;
@@ -430,7 +431,8 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
{
#ifndef DYECMD
int fpsLimit = 0;
-#endif
+#endif // DYECMD
+
const int eventType = event.window.event;
const bool inGame = (client->getState() == State::GAME);
switch (eventType)
@@ -463,7 +465,8 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
localPlayer->setHalfAway(true);
}
}
-#endif
+#endif // DYECMD
+
setPriority(false);
break;
case SDL_WINDOWEVENT_RESTORED:
@@ -479,7 +482,8 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
localPlayer->setHalfAway(false);
}
}
-#endif
+#endif // DYECMD
+
setPriority(true);
break;
default:
@@ -501,15 +505,17 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
}
Game::instance()->updateFrameRate(fpsLimit);
}
-#endif
+#endif // DYECMD
}
-#else
+#else // USE_SDL2
+
void EventsManager::handleActive(const SDL_Event &event)
{
#ifndef DYECMD
int fpsLimit = 0;
const bool inGame = (client->getState() == State::GAME);
-#endif
+#endif // DYECMD
+
if (event.active.state & SDL_APPACTIVE)
{
if (event.active.gain)
@@ -522,14 +528,15 @@ void EventsManager::handleActive(const SDL_Event &event)
fpsLimit = config.getIntValue("fpslimit");
localPlayer->setHalfAway(false);
}
-#endif
+#endif // DYECMD
+
setPriority(true);
}
else
{ // window minimization
#ifdef ANDROID
client->setState(State::EXIT);
-#else
+#else // ANDROID
WindowManager::setIsMinimized(true);
#ifndef DYECMD
if (inGame && localPlayer && !settings.awayMode)
@@ -537,19 +544,20 @@ void EventsManager::handleActive(const SDL_Event &event)
fpsLimit = config.getIntValue("altfpslimit");
localPlayer->setHalfAway(true);
}
-#endif
+#endif // DYECMD
+
setPriority(false);
-#endif
+#endif // ANDROID
}
#ifndef DYECMD
if (inGame && localPlayer)
localPlayer->updateStatus();
-#endif
+#endif // DYECMD
}
#ifndef DYECMD
if (inGame && localPlayer)
localPlayer->updateName();
-#endif
+#endif // DYECMD
if (event.active.state & SDL_APPINPUTFOCUS)
settings.inputFocused = event.active.gain;
@@ -558,6 +566,6 @@ void EventsManager::handleActive(const SDL_Event &event)
#ifndef DYECMD
if (inGame)
Game::instance()->updateFrameRate(fpsLimit);
-#endif
+#endif // DYECMD
}
-#endif
+#endif // USE_SDL2
diff --git a/src/eventsmanager.h b/src/eventsmanager.h
index ecc49d95b..5bf8b16b8 100644
--- a/src/eventsmanager.h
+++ b/src/eventsmanager.h
@@ -48,9 +48,10 @@ class EventsManager final : public ConfigListener
#ifdef USE_SDL2
static void handleSDL2WindowEvent(const SDL_Event &event);
-#else
+#else // USE_SDL2
+
static void handleActive(const SDL_Event &event);
-#endif
+#endif // USE_SDL2
void optionChanged(const std::string &name) override final;
diff --git a/src/game.cpp b/src/game.cpp
index d9ad1cb47..56e86ba6d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -134,16 +134,16 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#ifdef USE_MUMBLE
#include "mumblemanager.h"
-#endif
+#endif // USE_MUMBLE
#ifdef WIN32
#include <sys/time.h>
#undef ERROR
-#endif
+#endif // WIN32
#include "debug.h"
@@ -162,7 +162,8 @@ static void initEngines()
effectManager = new EffectManager;
#ifdef TMWA_SUPPORT
GuildManager::init();
-#endif
+#endif // TMWA_SUPPORT
+
crazyMoves = new CrazyMoves;
particleEngine = new ParticleEngine;
@@ -320,7 +321,7 @@ static void destroyGuiWindows()
#ifdef TMWA_SUPPORT
if (guildManager)
guildManager->clear();
-#endif
+#endif // TMWA_SUPPORT
delete2(windowMenu);
delete2(localChatTab) // Need to do this first, so it can remove itself
@@ -332,7 +333,8 @@ static void destroyGuiWindows()
#ifdef TMWA_SUPPORT
if (guildManager && GuildManager::getEnableGuildBot())
guildManager->reload();
-#endif
+#endif // TMWA_SUPPORT
+
logger->log("start deleting");
delete2(emoteWindow);
delete2(chatWindow)
@@ -413,7 +415,7 @@ Game::Game() :
#ifdef USE_OPENGL
MapReader::loadEmptyAtlas();
-#endif
+#endif // USE_OPENGL
initEngines();
@@ -433,7 +435,7 @@ Game::Game() :
#ifdef TMWA_SUPPORT
if (guildManager && GuildManager::getEnableGuildBot())
guildManager->requestGuildInfo();
-#endif
+#endif // TMWA_SUPPORT
settings.disableLoggingInGame = config.getBoolValue(
"disableLoggingInGame");
@@ -443,7 +445,7 @@ Game::~Game()
{
#ifdef USE_OPENGL
MapReader::unloadEmptyAtlas();
-#endif
+#endif // USE_OPENGL
settings.disableLoggingInGame = false;
touchManager.setInGame(false);
@@ -465,10 +467,11 @@ Game::~Game()
delete2(mCurrentMap)
#ifdef TMWA_SUPPORT
delete2(guildManager)
-#endif
+#endif // TMWA_SUPPORT
#ifdef USE_MUMBLE
delete2(mumbleManager)
-#endif
+#endif // USE_MUMBLE
+
delete2(crazyMoves);
Being::clearCache();
@@ -576,7 +579,8 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot)
cutFirst(nacScreenshotlDir, "/persistent");
naclPostMessage("copy-from-persistent", nacScreenshotlDir);
logger->log("nacl screenshot path: " + nacScreenshotlDir);
-#endif
+#endif // __native_client__
+
if (success)
{
if (localChatTab)
@@ -658,11 +662,10 @@ void Game::slowLogic()
#ifdef TMWA_SUPPORT
if (shopWindow)
cilk_spawn shopWindow->updateTimes();
-#endif
-#ifdef TMWA_SUPPORT
if (guildManager)
guildManager->slowLogic();
-#endif
+#endif // TMWA_SUPPORT
+
if (skillDialog)
cilk_spawn skillDialog->slowLogic();
@@ -1104,7 +1107,7 @@ void Game::changeMap(const std::string &mapPath)
#ifdef USE_MUMBLE
if (mumbleManager)
mumbleManager->setMap(mapPath);
-#endif
+#endif // USE_MUMBLE
if (localPlayer)
localPlayer->recreateItemParticles();
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 28a7bd9fa..2ccac6463 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -45,7 +45,6 @@
#include "settings.h"
#ifdef USE_OPENGL
-
#include "render/mobileopengl2graphics.h"
#include "render/mobileopenglgraphics.h"
#include "render/modernopenglgraphics.h"
@@ -55,7 +54,8 @@
#include "render/opengl/mgl.h"
#include "render/opengl/mglcheck.h"
#include "render/opengl/mglemu.h"
-#endif
+#endif // USE_OPENGL
+
#include "render/sdlgraphics.h"
#ifdef USE_OPENGL
@@ -77,7 +77,7 @@
#include "resources/sdl2softwareimagehelper.h"
#include "resources/sdl2softwarescreenshothelper.h"
#include "resources/surfaceimagehelper.h"
-#endif
+#endif // USE_SDL2
#include "utils/delete2.h"
#include "utils/sdlhelper.h"
@@ -97,11 +97,11 @@
#ifdef USE_OPENGL
#ifndef GL_MAX_RENDERBUFFER_SIZE
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#endif
+#endif // GL_MAX_RENDERBUFFER_SIZE
#define useCompression(name) \
OpenGLImageHelper::setInternalTextureType(name); \
logger->log("using " #name " texture compression");
-#endif
+#endif // USE_OPENGL
GraphicsManager graphicsManager;
@@ -123,7 +123,7 @@ const std::string densityNames[] =
#ifdef USE_OPENGL
GLenum GraphicsManager::mLastError(GL_NO_ERROR);
-#endif
+#endif // USE_OPENGL
GraphicsManager::GraphicsManager() :
mExtensions(),
@@ -151,7 +151,7 @@ GraphicsManager::GraphicsManager() :
mSupportDebug(0),
mSupportModernOpengl(false),
mGles(false),
-#endif
+#endif // USE_OPENGL
mUseAtlases(false)
{
}
@@ -161,7 +161,7 @@ GraphicsManager::~GraphicsManager()
#ifdef USE_OPENGL
if (isGLNotNull(mglGenSamplers) && mTextureSampler)
mglDeleteSamplers(1, &mTextureSampler);
-#endif
+#endif // USE_OPENGL
}
#ifdef USE_OPENGL
@@ -180,7 +180,8 @@ int GraphicsManager::detectGraphics()
int compressTextures = 0;
#if !defined(ANDROID) && !defined(__native_client__)
mainGraphics = new NormalOpenGLGraphics;
-#endif
+#endif // !defined(ANDROID) && !defined(__native_client__)
+
SDL_Window *const window = createWindow(100, 100, 0,
SDL_ANYFORMAT | SDL_OPENGL);
mainGraphics->setWindow(window, 100, 100);
@@ -411,18 +412,19 @@ void GraphicsManager::createRenderers()
default:
#ifndef USE_SDL2
case RENDER_SDL2_DEFAULT:
-#endif
-#ifdef USE_SDL2
- imageHelper = new SDL2SoftwareImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new SDL2SoftwareGraphics;
- screenshortHelper = new Sdl2SoftwareScreenshotHelper;
-#else
imageHelper = new SDLImageHelper;
surfaceImageHelper = imageHelper;
mainGraphics = new SDLGraphics;
screenshortHelper = new SdlScreenshotHelper;
-#endif
+#else // USE_SDL2
+
+ imageHelper = new SDL2SoftwareImageHelper;
+ surfaceImageHelper = new SurfaceImageHelper;
+ mainGraphics = new SDL2SoftwareGraphics;
+ screenshortHelper = new Sdl2SoftwareScreenshotHelper;
+
+#endif // USE_SDL2
+
break;
#ifdef USE_SDL2
case RENDER_SDL2_DEFAULT:
@@ -432,7 +434,7 @@ void GraphicsManager::createRenderers()
mainGraphics->setRendererFlags(SDL_RENDERER_ACCELERATED);
screenshortHelper = new SdlScreenshotHelper;
break;
-#endif
+#endif // USE_SDL2
};
#endif // USE_OPENGL
}
@@ -471,15 +473,18 @@ void GraphicsManager::setVideoMode()
#elif defined __native_client__
#ifdef USE_SDL2
// not implimented
-#else
+#else // USE_SDL2
+
const SDL_VideoInfo* info = SDL_GetVideoInfo();
int width = info->current_w;
int height = info->current_h;
-#endif
-#else
+#endif // USE_SDL2
+#else // defined __native_client__
+
int width = config.getIntValue("screenwidth");
int height = config.getIntValue("screenheight");
-#endif
+#endif // defined __native_client__
+
const int scale = config.getIntValue("scale");
// Try to set the desired video mode
@@ -524,12 +529,12 @@ void GraphicsManager::initGraphics()
config.getBoolValue("alphaCache") && !openGLMode);
ImageHelper::setEnableAlpha((config.getFloatValue("guialpha") != 1.0F ||
openGLMode) && config.getBoolValue("enableGuiOpacity"));
-#else
+#else // USE_OPENGL
SurfaceImageHelper::SDLSetEnableAlphaCache(
config.getBoolValue("alphaCache"));
ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0F &&
config.getBoolValue("enableGuiOpacity"));
-#endif
+#endif // USE_OPENGL
createRenderers();
detectPixelSize();
setVideoMode();
@@ -592,7 +597,7 @@ void GraphicsManager::initGraphics()
settings.textureSize = sizes[pos];
logger->log("Detected max texture size: %u", settings.textureSize);
#endif // !defined(ANDROID) && !defined(__APPLE__)
-#endif
+#endif // USE_OPENGL
}
#ifdef USE_SDL2
@@ -612,13 +617,14 @@ SDL_Renderer *GraphicsManager::createRenderer(SDL_Window *const window,
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
return renderer;
}
-#else
+#else // USE_SDL2
+
SDL_Window *GraphicsManager::createWindow(const int w, const int h,
const int bpp, const int flags)
{
return SDL_SetVideoMode(w, h, bpp, flags);
}
-#endif
+#endif // USE_SDL2
#ifdef USE_OPENGL
void GraphicsManager::updateExtensions()
@@ -727,7 +733,7 @@ void GraphicsManager::updatePlanformExtensions()
}
logger->log("width=%d", DisplayWidth(display, screenNum));
}
-#endif
+#endif // WIN32
}
}
@@ -827,7 +833,8 @@ void GraphicsManager::updateTextureFormat()
OpenGLImageHelper::setInternalTextureType(GL_RGBA);
#ifndef ANDROID
SafeOpenGLImageHelper::setInternalTextureType(GL_RGBA);
-#endif
+#endif // ANDROID
+
logger->log1("using RGBA texture format");
}
else
@@ -835,7 +842,8 @@ void GraphicsManager::updateTextureFormat()
OpenGLImageHelper::setInternalTextureType(4);
#ifndef ANDROID
SafeOpenGLImageHelper::setInternalTextureType(4);
-#endif
+#endif // ANDROID
+
logger->log1("using 4 texture format");
}
}
@@ -880,7 +888,7 @@ void GraphicsManager::setGLVersion()
mMajor = 1;
mMinor = 0;
}
-#endif
+#endif // ANDROID
}
void GraphicsManager::logVersion() const
@@ -985,7 +993,8 @@ void GraphicsManager::initOpenGLFunctions()
{
#ifdef __native_client__
emulateFunction(glTextureSubImage2DEXT);
-#else
+#else // __native_client__
+
const bool is10 = checkGLVersion(1, 0);
const bool is11 = checkGLVersion(1, 1);
const bool is12 = checkGLVersion(1, 2);
@@ -1361,8 +1370,8 @@ void GraphicsManager::initOpenGLFunctions()
#ifdef WIN32
assignFunctionARB(wglGetExtensionsString);
-#endif
-#endif
+#endif // WIN32
+#endif // __native_client__
}
void GraphicsManager::updateLimits()
@@ -1370,7 +1379,8 @@ void GraphicsManager::updateLimits()
GLint value = 0;
#ifdef __native_client__
mMaxVertices = 500;
-#else
+#else // __native_client__
+
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &value);
logger->log("GL_MAX_ELEMENTS_VERTICES: %d", value);
@@ -1387,7 +1397,7 @@ void GraphicsManager::updateLimits()
"Overriding to 500");
mMaxVertices = 500;
}
-#endif
+#endif // __native_client__
value = 0;
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
@@ -1433,7 +1443,7 @@ void GraphicsManager::createTextureSampler()
OpenGLImageHelper::setUseTextureSampler(mUseTextureSampler);
#ifndef ANDROID
SafeOpenGLImageHelper::setUseTextureSampler(false);
-#endif
+#endif // ANDROID
}
GLenum GraphicsManager::getLastError()
@@ -1617,7 +1627,7 @@ void GraphicsManager::updateDebugLog() const
mglDebugMessageCallback(&debugCallback, this);
}
}
-#endif
+#endif // USE_OPENGL
void GraphicsManager::detectPixelSize()
{
@@ -1649,7 +1659,7 @@ void GraphicsManager::detectPixelSize()
mWidthMM = DisplayWidthMM(display, screenNum);
mHeightMM = DisplayHeightMM(display, screenNum);
}
-#endif
+#endif // WIN32
}
#if defined ANDROID
#ifdef USE_SDL2
@@ -1671,11 +1681,13 @@ void GraphicsManager::detectPixelSize()
mMaxHeight = atoi(getenv("DISPLAY_RESOLUTION_HEIGHT"));
mWidthMM = atoi(getenv("DISPLAY_WIDTH_MM"));
mHeightMM = atoi(getenv("DISPLAY_HEIGHT_MM"));
-#else
+#else // USE_SDL2
+
SDL_ANDROID_GetMetrics(&mMaxWidth, &mMaxHeight,
&mWidthMM, &mHeightMM, &mDensity);
-#endif
-#endif
+#endif // USE_SDL2
+#endif // defined ANDROID
+
logger->log("screen size in pixels: %ux%u", mMaxWidth, mMaxHeight);
logger->log("screen size in millimeters: %ux%u", mWidthMM, mHeightMM);
logger->log("actual screen density: " + getDensityString());
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 1e7675135..003d32d6c 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -25,17 +25,17 @@
#ifdef ANDROID
#include <GLES/gl.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
// hack to hide warnings
#undef GL_GLEXT_VERSION
#undef GL_GLEXT_PROTOTYPES
-#endif
+#endif // ANDROID
-#endif
+#endif // USE_OPENGL
#include "sdlshared.h"
@@ -50,7 +50,7 @@ class TestMain;
struct FBOInfo;
#ifdef USE_SDL2
struct SDL_Renderer;
-#endif
+#endif // USE_SDL2
struct SDL_Window;
class GraphicsManager final
@@ -76,7 +76,7 @@ class GraphicsManager final
#ifdef USE_SDL2
SDL_Renderer *createRenderer(SDL_Window *const window,
const int flags);
-#endif
+#endif // USE_SDL2
bool getAllVideoModes(StringVect &modeList);
@@ -163,7 +163,7 @@ class GraphicsManager final
static void resetCachedError()
{ mLastError = GL_NO_ERROR; }
-#endif
+#endif // USE_OPENGL
private:
std::set<std::string> mExtensions;
@@ -179,7 +179,8 @@ class GraphicsManager final
std::string mGlShaderVersionString;
#ifdef USE_OPENGL
static GLenum mLastError;
-#endif
+#endif // USE_OPENGL
+
int mMinor;
int mMajor;
@@ -216,7 +217,8 @@ class GraphicsManager final
bool mSupportModernOpengl;
bool mGles;
-#endif
+#endif // USE_OPENGL
+
bool mUseAtlases;
};
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index ec4da8119..9cfc69342 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -39,7 +39,7 @@
#include "gui/windows/updaterwindow.h"
#include "listeners/playerpostdeathlistener.h"
-#endif
+#endif // DYECMD
#include "listeners/weightlistener.h"
@@ -53,7 +53,7 @@
#ifdef WIN32
#undef ERROR
-#endif
+#endif // WIN32
OkDialog *deathNotice = nullptr;
DialogsManager *dialogsManager = nullptr;
@@ -66,7 +66,7 @@ namespace
PlayerPostDeathListener postDeathListener;
WeightListener weightListener;
} // namespace
-#endif
+#endif // DYECMD
DialogsManager::DialogsManager() :
AttributeListener(),
@@ -84,7 +84,8 @@ void DialogsManager::closeDialogs()
SellDialog::closeAll();
if (inventoryHandler)
inventoryHandler->destroyStorage();
-#endif
+#endif // DYECMD
+
if (deathNotice)
{
deathNotice->scheduleDelete();
@@ -100,7 +101,7 @@ void DialogsManager::createUpdaterWindow()
settings.oldUpdates,
false,
UpdateType::Normal);
-#endif
+#endif // DYECMD
}
Window *DialogsManager::openErrorDialog(const std::string &header,
@@ -153,7 +154,7 @@ void DialogsManager::playerDeath()
260);
deathNotice->addActionListener(&postDeathListener);
}
-#endif
+#endif // DYECMD
}
#ifndef DYECMD
@@ -211,10 +212,11 @@ void DialogsManager::attributeChanged(const AttributesT id,
}
}
}
-#else
+#else // DYECMD
+
void DialogsManager::attributeChanged(const AttributesT id A_UNUSED,
const int oldVal A_UNUSED,
const int newVal A_UNUSED)
{
}
-#endif
+#endif // DYECMD
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp
index 7bc0c5357..93356fefd 100644
--- a/src/gui/fonts/font.cpp
+++ b/src/gui/fonts/font.cpp
@@ -247,12 +247,14 @@ void Font::drawString(Graphics *const graphics,
{
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter ++;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
cache->removeBack();
}
#ifdef DEBUG_FONT_COUNTERS
mCreateCounter ++;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
TextChunk *chunk2 = new TextChunk(text, col, col2, this);
chunk2->generate(mFont, alpha);
@@ -321,36 +323,40 @@ void Font::doClean()
const size_t size = CAST_SIZE(cache->size);
#ifdef DEBUG_FONT_COUNTERS
logger->log("ptr: %u, size: %ld", f, size);
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
if (size > CACHE_SIZE_SMALL3)
{
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter += 100;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
cache->removeBack(100);
#ifdef DEBUG_FONT_COUNTERS
logger->log("delete3");
-#endif
+#endif // DEBUG_FONT_COUNTERS
}
else if (size > CACHE_SIZE_SMALL2)
{
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter += 20;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
cache->removeBack(20);
#ifdef DEBUG_FONT_COUNTERS
logger->log("delete2");
-#endif
+#endif // DEBUG_FONT_COUNTERS
}
else if (size > CACHE_SIZE_SMALL1)
{
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter ++;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
cache->removeBack();
#ifdef DEBUG_FONT_COUNTERS
logger->log("delete1");
-#endif
+#endif // DEBUG_FONT_COUNTERS
}
}
}
@@ -405,12 +411,14 @@ void Font::generate(TextChunk &chunk)
{
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter ++;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
cache->removeBack();
}
#ifdef DEBUG_FONT_COUNTERS
mCreateCounter ++;
-#endif
+#endif // DEBUG_FONT_COUNTERS
+
const float alpha = static_cast<float>(chunk.color.a) / 255.0F;
chunk.generate(mFont, alpha);
// logger->log("generate image: " + chunk.text);
diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h
index d8e16936f..302980b93 100644
--- a/src/gui/fonts/font.h
+++ b/src/gui/fonts/font.h
@@ -150,6 +150,6 @@ class Font final
#ifdef UNITTESTS
extern int textChunkCnt;
-#endif
+#endif // UNITTESTS
#endif // GUI_FONTS_FONT_H
diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp
index 06e649bf4..3025305fd 100644
--- a/src/gui/fonts/textchunk.cpp
+++ b/src/gui/fonts/textchunk.cpp
@@ -46,7 +46,7 @@ char *restrict strBuf = nullptr;
#ifdef UNITTESTS
int textChunkCnt = 0;
-#endif
+#endif // UNITTESTS
TextChunk::TextChunk() :
img(nullptr),
@@ -59,7 +59,7 @@ TextChunk::TextChunk() :
{
#ifdef UNITTESTS
textChunkCnt ++;
-#endif
+#endif // UNITTESTS
}
TextChunk::TextChunk(const std::string &restrict text0,
@@ -76,7 +76,7 @@ TextChunk::TextChunk(const std::string &restrict text0,
{
#ifdef UNITTESTS
textChunkCnt ++;
-#endif
+#endif // UNITTESTS
}
TextChunk::~TextChunk()
@@ -84,7 +84,7 @@ TextChunk::~TextChunk()
delete2(img);
#ifdef UNITTESTS
textChunkCnt --;
-#endif
+#endif // UNITTESTS
}
bool TextChunk::operator==(const TextChunk &restrict chunk) const
@@ -103,9 +103,10 @@ void TextChunk::generate(TTF_Font *restrict const font,
sdlCol.g = CAST_U8(color.g);
#ifdef USE_SDL2
sdlCol.a = 255;
-#else
+#else // USE_SDL2
+
sdlCol.unused = 0;
-#endif
+#endif // USE_SDL2
getSafeUtf8String(text, strBuf);
@@ -140,9 +141,11 @@ void TextChunk::generate(TTF_Font *restrict const font,
sdlCol2.g = CAST_U8(color2.g);
#ifdef USE_SDL2
sdlCol2.a = 255;
-#else
+#else // USE_SDL2
+
sdlCol2.unused = 0;
-#endif
+#endif // USE_SDL2
+
SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended(
font, strBuf, sdlCol2);
if (!surface2)
diff --git a/src/gui/fonts/textchunk.h b/src/gui/fonts/textchunk.h
index e2151bac2..8cb1df9f2 100644
--- a/src/gui/fonts/textchunk.h
+++ b/src/gui/fonts/textchunk.h
@@ -67,6 +67,6 @@ class TextChunk final
#ifdef UNITTESTS
extern int textChunkCnt;
-#endif
+#endif // UNITTESTS
#endif // GUI_FONTS_TEXTCHUNK_H
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 17c3558ae..c4c6a1794 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -78,9 +78,9 @@
#ifndef DYECMD
#include "dragdrop.h"
-#else
+#else // DYECMD
#include "resources/image/image.h"
-#endif
+#endif // DYECMD
#include "settings.h"
#include "listeners/focuslistener.h"
@@ -135,7 +135,7 @@ Gui::Gui() :
#ifdef ANDROID
mLastMouseRealX(0),
mLastMouseRealY(0),
-#endif
+#endif // ANDROID
mFocusListeners(),
mForegroundColor(theme->getColor(ThemeColorId::TEXT, 255)),
mForegroundColor2(theme->getColor(ThemeColorId::TEXT_OUTLINE, 255)),
@@ -408,7 +408,7 @@ bool Gui::handleKeyInput()
#ifdef USE_SDL2
if (!keyInput.getText().empty())
eventToGlobalKeyListeners.setText(keyInput.getText());
-#endif
+#endif // USE_SDL2
distributeKeyEventToGlobalKeyListeners(
eventToGlobalKeyListeners);
@@ -434,7 +434,7 @@ bool Gui::handleKeyInput()
#ifdef USE_SDL2
if (!keyInput.getText().empty())
event.setText(keyInput.getText());
-#endif
+#endif // USE_SDL2
if (!mFocusHandler->getFocused()->isFocusable())
mFocusHandler->focusNone();
@@ -511,7 +511,8 @@ void Gui::draw()
const int posY = mouseY - (image->mBounds.h / 2);
mGraphics->drawImage(image, posX, posY);
}
-#endif
+#endif // DYECMD
+
Image *const mouseCursor = mMouseCursors->get(
CAST_SIZE(mCursorType));
if (mouseCursor)
@@ -927,7 +928,8 @@ void Gui::distributeMouseEvent(Widget *const source,
#ifndef DYECMD
if (type == MouseEventType::RELEASED)
dragDrop.clear();
-#endif
+#endif // DYECMD
+
if (!widget || event.isConsumed())
break;
@@ -1005,8 +1007,9 @@ void Gui::handleMouseInput()
#ifndef USE_SDL2
SDL_WarpMouse(mLastMouseX, mLastMouseY,
mLastMouseRealX, mLastMouseRealY);
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
+
mMouseInactivityTimer = 0;
continue;
}
@@ -1018,7 +1021,8 @@ void Gui::handleMouseInput()
#ifdef ANDROID
mLastMouseRealX = mouseInput.getRealX();
mLastMouseRealY = mouseInput.getRealY();
-#endif
+#endif // ANDROID
+
switch (mouseInput.getType())
{
case MouseEventType::PRESSED:
diff --git a/src/gui/gui.h b/src/gui/gui.h
index bbeced8d2..258262b3f 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -95,9 +95,9 @@ class Window;
#ifdef USE_SDL2
#define MouseStateType uint32_t
-#else
+#else // USE_SDL2
#define MouseStateType uint8_t
-#endif
+#endif // USE_SDL2
/**
* \defgroup GUI Core GUI related classes (widgets)
@@ -523,7 +523,8 @@ class Gui final
#ifdef ANDROID
uint16_t mLastMouseRealX;
uint16_t mLastMouseRealY;
-#endif
+#endif // ANDROID
+
typedef std::list<FocusListener*> FocusListenerList;
typedef FocusListenerList::iterator FocusListenerIterator;
FocusListenerList mFocusListeners;
diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp
index 75959cf12..5c63cf15e 100644
--- a/src/gui/models/modelistmodel.cpp
+++ b/src/gui/models/modelistmodel.cpp
@@ -51,7 +51,7 @@ static bool modeSorter(const std::string &mode1, const std::string &mode2)
return false;
}
-#endif
+#endif // ANDROID
ModeListModel::ModeListModel() :
mVideoModes()
@@ -69,7 +69,7 @@ ModeListModel::ModeListModel() :
std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter);
mVideoModes.push_back("custom");
-#endif
+#endif // ANDROID
}
#ifndef ANDROID
@@ -85,7 +85,7 @@ void ModeListModel::addCustomMode(const std::string &mode)
}
mVideoModes.push_back(mode);
}
-#endif
+#endif // ANDROID
int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
{
diff --git a/src/gui/models/modelistmodel.h b/src/gui/models/modelistmodel.h
index 9e5339a3d..4bdd29417 100644
--- a/src/gui/models/modelistmodel.h
+++ b/src/gui/models/modelistmodel.h
@@ -61,7 +61,7 @@ class ModeListModel final : public ListModel
private:
#ifndef ANDROID
void addCustomMode(const std::string &mode);
-#endif
+#endif // ANDROID
StringVect mVideoModes;
};
diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h
index 6d96568c7..11f32ddeb 100644
--- a/src/gui/models/typelistmodel.h
+++ b/src/gui/models/typelistmodel.h
@@ -39,9 +39,9 @@ class TypeListModel final : public ListModel
int getNumberOfElements() override final A_WARN_UNUSED
#if defined(TMWA_SUPPORT)
{ return 3; }
-#else
+#else // defined(TMWA_SUPPORT)
{ return 2; }
-#endif
+#endif // defined(TMWA_SUPPORT)
/**
* Used to get an element from the list
diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp
index ff9122fb1..0cab27cd8 100644
--- a/src/gui/popupmanager.cpp
+++ b/src/gui/popupmanager.cpp
@@ -45,7 +45,7 @@ void PopupManager::closePopupMenu()
#ifndef DYECMD
if (popupMenu)
popupMenu->handleLink("cancel", nullptr);
-#endif
+#endif // DYECMD
}
void PopupManager::hideBeingPopup()
@@ -53,7 +53,7 @@ void PopupManager::hideBeingPopup()
#ifndef DYECMD
if (beingPopup)
beingPopup->setVisible(Visible_false);
-#endif
+#endif // DYECMD
}
void PopupManager::hideTextPopup()
@@ -67,7 +67,7 @@ void PopupManager::hidePopupMenu()
#ifndef DYECMD
if (popupMenu)
popupMenu->setVisible(Visible_false);
-#endif
+#endif // DYECMD
}
bool PopupManager::isPopupMenuVisible()
@@ -76,7 +76,7 @@ bool PopupManager::isPopupMenuVisible()
return popupMenu ? popupMenu->isPopupVisible() : false;
#else
return false;
-#endif
+#endif // DYECMD
}
void PopupManager::clearPopup()
@@ -84,7 +84,7 @@ void PopupManager::clearPopup()
#ifndef DYECMD
if (popupMenu)
popupMenu->clear();
-#endif
+#endif // DYECMD
}
bool PopupManager::isTextPopupVisible()
@@ -96,7 +96,7 @@ bool PopupManager::isBeingPopupVisible()
{
#ifndef DYECMD
return beingPopup ? beingPopup->isPopupVisible() : false;
-#else
+#else // DYECMD
return false;
-#endif
+#endif // DYECMD
}
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
index 44432c4d5..a206f0c48 100644
--- a/src/gui/popups/beingpopup.cpp
+++ b/src/gui/popups/beingpopup.cpp
@@ -319,4 +319,4 @@ void BeingPopup::logic()
logicChildren();
BLOCK_END("BeingPopup::logic")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/popups/beingpopup.h b/src/gui/popups/beingpopup.h
index 691b07f51..136a11d66 100644
--- a/src/gui/popups/beingpopup.h
+++ b/src/gui/popups/beingpopup.h
@@ -54,7 +54,7 @@ class BeingPopup final : public Popup
#ifdef USE_PROFILER
void logic();
-#endif
+#endif // USE_PROFILER
private:
void addLabels(const int fontHeight);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 7532a9099..fae3c7251 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -76,7 +76,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "resources/chatobject.h"
#include "resources/iteminfo.h"
@@ -237,7 +237,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
#ifdef TMWA_SUPPORT
if (guild2->getServerGuild()
|| (guildManager && guildManager->havePower()))
-#endif
+#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/guild 'NAME'",
// TRANSLATORS: popup menu item
@@ -595,7 +595,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
#ifdef TMWA_SUPPORT
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
-#endif
+#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/kickguild 'NAME'",
// TRANSLATORS: popup menu item
@@ -615,7 +615,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
#ifdef TMWA_SUPPORT
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
-#endif
+#endif // TMWA_SUPPORT
{
// TRANSLATORS: popup menu item
// TRANSLATORS: invite player to guild
@@ -954,7 +954,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
#ifdef TMWA_SUPPORT
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
-#endif
+#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/kickguild 'NAME'",
// TRANSLATORS: popup menu item
@@ -975,7 +975,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
#ifdef TMWA_SUPPORT
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
-#endif
+#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/guild 'NAME'",
// TRANSLATORS: popup menu item
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 7ec7b7027..3ca69c820 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -165,7 +165,8 @@ void SDLInput::pushInput(const SDL_Event &event)
mouseInput.setY(gui->getLastMouseY());
#ifdef ANDROID
mouseInput.setReal(0, 0);
-#endif
+#endif // ANDROID
+
mouseInput.setButton(MouseButton::WHEEL);
if (y > 0)
mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
@@ -177,14 +178,14 @@ void SDLInput::pushInput(const SDL_Event &event)
break;
}
-#endif
+#endif // USE_SDL2
#ifdef ANDROID
#ifndef USE_SDL2
case SDL_ACCELEROMETER:
break;
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
case SDL_MOUSEBUTTONDOWN:
{
@@ -197,11 +198,13 @@ void SDLInput::pushInput(const SDL_Event &event)
#ifdef ANDROID
#ifdef USE_SDL2
mouseInput.setReal(x, y);
-#else
+#else // USE_SDL2
+
mouseInput.setReal(event.button.realx / scale,
event.button.realy / scale);
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
+
mouseInput.setButton(convertMouseButton(event.button.button));
#ifndef USE_SDL2
@@ -210,7 +213,7 @@ void SDLInput::pushInput(const SDL_Event &event)
else if (event.button.button == SDL_BUTTON_WHEELUP)
mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
else
-#endif
+#endif // USE_SDL2
mouseInput.setType(MouseEventType::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
@@ -227,11 +230,13 @@ void SDLInput::pushInput(const SDL_Event &event)
#ifdef ANDROID
#ifdef USE_SDL2
mouseInput.setReal(x, y);
-#else
+#else // USE_SDL2
+
mouseInput.setReal(event.button.realx / scale,
event.button.realy / scale);
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
+
mouseInput.setButton(convertMouseButton(event.button.button));
mouseInput.setType(MouseEventType::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
@@ -248,11 +253,13 @@ void SDLInput::pushInput(const SDL_Event &event)
#ifdef ANDROID
#ifdef USE_SDL2
mouseInput.setReal(x, y);
-#else
+#else // USE_SDL2
+
mouseInput.setReal(event.motion.realx / scale,
event.motion.realy / scale);
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
+
mouseInput.setButton(MouseButton::EMPTY);
mouseInput.setType(MouseEventType::MOVED);
mouseInput.setTimeStamp(SDL_GetTicks());
@@ -282,7 +289,8 @@ void SDLInput::pushInput(const SDL_Event &event)
if ((event.active.state & SDL_APPMOUSEFOCUS) && event.active.gain)
mMouseInWindow = true;
break;
-#endif
+#endif // USE_SDL2
+
default:
break;
} // end switch
@@ -311,7 +319,8 @@ MouseButtonT SDLInput::convertMouseButton(const int button)
case SDL_BUTTON_WHEELUP:
case SDL_BUTTON_WHEELDOWN:
return MouseButton::EMPTY;
-#endif
+#endif // USE_SDL2
+
default:
// We have an unknown mouse type which is ignored.
logger->log("unknown button type: %d", button);
@@ -324,9 +333,10 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event)
const SDL_keysym keysym = event.key.keysym;
#ifdef USE_SDL2
int value = keysym.scancode;
-#else
+#else // USE_SDL2
+
int value = keysym.unicode;
-#endif
+#endif // USE_SDL2
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -366,7 +376,7 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event)
// is only valid on key down events in SDL.
#ifndef USE_SDL2
if (event.type == SDL_KEYUP || keysym.unicode == ' ')
-#endif
+#endif // USE_SDL2
{
value = KeyValue::SPACE;
}
@@ -374,7 +384,7 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event)
case SDLK_ESCAPE:
#ifdef USE_SDL2
case SDLK_AC_BACK:
-#endif
+#endif // USE_SDL2
value = KeyValue::ESCAPE;
break;
case SDLK_DELETE:
@@ -465,7 +475,8 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event)
case SDLK_RSUPER:
value = KeyValue::RIGHT_SUPER;
break;
-#endif
+#endif // USE_SDL2
+
case SDLK_MODE:
value = KeyValue::ALT_GR;
break;
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h
index 3753e00ee..ecf29470f 100644
--- a/src/gui/setupactiondata.h
+++ b/src/gui/setupactiondata.h
@@ -42,7 +42,7 @@ struct SetupActionData final
{ }
A_DELETE_COPY(SetupActionData)
-#endif
+#endif // ADVGCC
std::string name;
const InputActionT actionId;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 7aeeda6a8..a229cb10f 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -268,7 +268,8 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
if (id)
bLink.caption = ItemDB::get(id).getName();
}
-#endif
+#endif // DYECMD
+
if (translator)
bLink.caption = translator->getStr(bLink.caption);
}
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
index e28aae7e2..5ac5ec38f 100644
--- a/src/gui/widgets/inttextfield.cpp
+++ b/src/gui/widgets/inttextfield.cpp
@@ -81,10 +81,11 @@ void IntTextField::keyPressed(KeyEvent &event)
if (chr < '0' || chr > '9')
return;
}
-#else
+#else // USE_SDL2
+
if (!event.getKey().isNumber())
return;
-#endif
+#endif // USE_SDL2
TextField::keyPressed(event);
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index db44a8a93..6ec9d73d7 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -841,10 +841,12 @@ void ScrollArea::mouseReleased(MouseEvent& event)
#ifdef ANDROID
int dx = mClickX - event.getX();
int dy = mClickY - event.getY();
-#else
+#else // ANDROID
+
int dx = event.getX() - mClickX;
int dy = event.getY() - mClickY;
-#endif
+#endif // ANDROID
+
if ((dx < 20 && dx > 0) || (dx > -20 && dx < 0))
dx = 0;
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index fad52cfb4..fccd428f4 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -52,7 +52,7 @@
#ifdef WIN32
#include <sys/time.h>
-#endif
+#endif // WIN32
#include <sstream>
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index 2757d591c..4ee856ef4 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -36,7 +36,7 @@
#ifdef USE_OPENGL
#include "resources/imagehelper.h"
-#endif
+#endif // USE_OPENGL
#include "resources/map/map.h"
@@ -75,12 +75,12 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
mDrawCallsLabel(new Label(this, strprintf("%s %s",
// TRANSLATORS: debug window label
_("Draw calls:"), "?"))),
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
mBindsLabel(new Label(this, strprintf("%s %s",
// TRANSLATORS: debug window label
_("Texture binds:"), "?"))),
-#endif
+#endif // DEBUG_BIND_TEXTURE
// TRANSLATORS: debug window label, frames per second
mFPSLabel(new Label(this, strprintf(_("%d FPS"), 0))),
// TRANSLATORS: debug window label, logic per second
@@ -125,10 +125,11 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
mFPSText = _("%d FPS (SDL2 default)");
break;
};
-#else
+#else // USE_OPENGL
+
// TRANSLATORS: debug window label
mFPSText = _("%d FPS (Software)");
-#endif
+#endif // USE_OPENGL
place(0, 0, mFPSLabel, 2);
place(0, 1, mLPSLabel, 2);
@@ -144,22 +145,24 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
#if defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) \
|| defined(DEBUG_BIND_TEXTURE)
int n = 10;
-#endif
+#endif // defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS)
+ // || defined(DEBUG_BIND_TEXTURE)
#ifdef DEBUG_OPENGL_LEAKS
mTexturesLabel = new Label(this, strprintf("%s %s",
// TRANSLATORS: debug window label
_("Textures count:"), "?"));
place(0, n, mTexturesLabel, 2);
n ++;
-#endif
+#endif // DEBUG_OPENGL_LEAKS
#ifdef DEBUG_DRAW_CALLS
place(0, n, mDrawCallsLabel, 2);
n ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
place(0, n, mBindsLabel, 2);
-#endif
-#endif
+#endif // DEBUG_BIND_TEXTURE
+#endif // USE_OPENGL
+
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
setDimension(Rect(0, 0, 600, 300));
@@ -221,7 +224,7 @@ void MapDebugTab::logic()
mTexturesLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Textures count:"), textures_count));
-#endif
+#endif // DEBUG_OPENGL_LEAKS
#ifdef DEBUG_DRAW_CALLS
if (mainGraphics)
{
@@ -229,7 +232,7 @@ void MapDebugTab::logic()
// TRANSLATORS: debug window label
_("Draw calls:"), mainGraphics->getDrawCalls()));
}
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
if (mainGraphics)
{
@@ -237,8 +240,8 @@ void MapDebugTab::logic()
// TRANSLATORS: debug window label
_("Texture binds:"), mainGraphics->getBinds()));
}
-#endif
-#endif
+#endif // DEBUG_BIND_TEXTURE
+#endif // USE_OPENGL
}
}
else
diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h
index 044a2884c..a526d71f3 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.h
+++ b/src/gui/widgets/tabs/debugwindowtabs.h
@@ -71,10 +71,11 @@ class MapDebugTab final : public DebugTab
time_t mUpdateTime;
#ifdef DEBUG_DRAW_CALLS
Label *mDrawCallsLabel A_NONNULLPOINTER;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
Label *mBindsLabel A_NONNULLPOINTER;
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
Label *mFPSLabel A_NONNULLPOINTER;
Label *mLPSLabel A_NONNULLPOINTER;
std::string mFPSText;
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
index af23ad2fe..f4b9534df 100644
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ b/src/gui/widgets/tabs/setup_audio.cpp
@@ -158,7 +158,7 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Enable mumble voice chat"), "",
"enableMumble", this, "enableMumbleEvent");
-#endif
+#endif // USE_MUMBLE
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Download music"), "",
diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp
index 186e76fc2..4008a42af 100644
--- a/src/gui/widgets/tabs/setup_other.cpp
+++ b/src/gui/widgets/tabs/setup_other.cpp
@@ -415,7 +415,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
"", "usefbo", this, "usefboEvent");
-#endif
+#endif // ANDROID
#ifndef WIN32
// TRANSLATORS: settings option
@@ -423,7 +423,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
"screenshotDirectory3", this, "screenshotDirectory3Event",
MainConfig_true,
UseBase64_true);
-#endif
+#endif // WIN32
// TRANSLATORS: settings option
new SetupItemIntTextField(_("Network delay between sub servers"),
diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp
index 25f25a4c7..a55d264f0 100644
--- a/src/gui/widgets/tabs/setup_perfomance.cpp
+++ b/src/gui/widgets/tabs/setup_perfomance.cpp
@@ -78,7 +78,7 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Enable map reduce (Software)"), "",
"enableMapReduce", this, "enableMapReduceEvent");
-#endif
+#endif // USE_SDL2
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Enable compound sprite delay (Software)"), "",
@@ -127,7 +127,7 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Disable beings caching (Software)"), "",
"disableBeingCaching", this, "disableBeingCachingEvent");
-#endif
+#endif // USE_SDL2
// TRANSLATORS: settings group
new SetupItemLabel(_("Different options (enable or disable can "
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 3797884a3..85927cd0e 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -48,11 +48,11 @@
#if defined(ANDROID) || defined(__APPLE__) || !defined(USE_OPENGL)
#include "configuration.h"
-#endif
+#endif // defined(ANDROID) || defined(__APPLE__) || !defined(USE_OPENGL)
#if defined(ANDROID) || defined(__APPLE__)
#include "utils/stringutils.h"
-#endif
+#endif // defined(ANDROID) || defined(__APPLE__)
#include "gui/models/modelistmodel.h"
#include "gui/models/opengllistmodel.h"
@@ -86,7 +86,8 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
// TRANSLATORS: video settings button
mDetectButton(new Button(this, _("Detect best mode"), "detect", this)),
-#endif
+#endif // !defined(ANDROID) && !defined(__APPLE__) &&
+ // !defined(__native_client__)
mDialog(nullptr),
mCustomCursorEnabled(config.getBoolValue("customcursor")),
mEnableResize(config.getBoolValue("enableresize")),
@@ -95,11 +96,11 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
#ifdef ANDROID
// TRANSLATORS: video settings checkbox
_("Show cursor"),
-#else
+#else // ANDROID
// TRANSLATORS: video settings checkbox
_("Custom cursor"),
-#endif
- mCustomCursorEnabled)),
+#endif // ANDROID
+ mCustomCursorEnabled)),
// TRANSLATORS: video settings checkbox
mEnableResizeCheckBox(new CheckBox(this, _("Enable resize"),
mEnableResize)),
@@ -179,13 +180,15 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
place(0, 8, mDetectButton);
-#else
+#else // !defined(ANDROID) && !defined(__APPLE__) &&
+ // !defined(__native_client__)
mNoFrameCheckBox->setEnabled(false);
mEnableResizeCheckBox->setEnabled(false);
#ifndef __native_client__
mFsCheckBox->setEnabled(false);
#endif // __native_client__
-#endif
+#endif // !defined(ANDROID) && !defined(__APPLE__) &&
+ // !defined(__native_client__)
int width = 600;
@@ -220,7 +223,7 @@ void Setup_Video::apply()
// checks for opengl usage
if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE)
{
-#endif
+#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
if (!WindowManager::setFullScreen(fullscreen))
{
fullscreen = !fullscreen;
@@ -261,7 +264,8 @@ void Setup_Video::apply()
nullptr,
260);
}
-#endif
+#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
+
config.setValue("screen", fullscreen);
}
@@ -425,10 +429,11 @@ void Setup_Video::action(const ActionEvent &event)
260);
}
}
-#else
+#else // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
+
mainGraphics->setWindowSize(width, height);
WindowManager::doResizeVideo(width, height, false);
-#endif
+#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
}
config.setValue("oldscreen", config.getBoolValue("screen"));
@@ -501,5 +506,5 @@ void Setup_Video::action(const ActionEvent &event)
delete test;
}
}
-#endif
+#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
}
diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h
index e1a94557e..5cc519315 100644
--- a/src/gui/widgets/tabs/setup_video.h
+++ b/src/gui/widgets/tabs/setup_video.h
@@ -70,7 +70,8 @@ class Setup_Video final : public SetupTab,
Label *mAltFpsLabel;
#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
Button *mDetectButton;
-#endif
+#endif // !defined(ANDROID) && !defined(__APPLE__) &&
+ // !defined(__native_client__)
TextDialog *mDialog;
bool mCustomCursorEnabled;
bool mEnableResize;
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
index 6cb00ad17..a8b783af2 100644
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ b/src/gui/widgets/tabs/setup_visual.cpp
@@ -133,7 +133,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Grab mouse and keyboard input"),
"", "grabinput", this, "grabinputEvent");
-#endif
+#endif // ANDROID
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Blurring textures (OpenGL)"),
@@ -211,7 +211,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Center game window"),
"", "centerwindow", this, "centerwindowEvent");
-#endif
+#endif // defined(WIN32) || defined(__APPLE__)
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Allow screensaver to run"),
@@ -244,5 +244,5 @@ void Setup_Visual::apply()
WindowManager::applyGrabMode();
#ifndef WIN32
WindowManager::applyScale();
-#endif
+#endif // WIN32
}
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index b80e21eeb..13fddb119 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -312,7 +312,8 @@ void TextField::keyPressed(KeyEvent &event)
return;
}
bool consumed(false);
-#else
+#else // USE_SDL2
+
if (val >= 32)
{
if (mNumeric)
@@ -375,7 +376,7 @@ void TextField::keyPressed(KeyEvent &event)
mLastEventPaste = 0;
bool consumed(false);
-#endif
+#endif // USE_SDL2
const InputActionT action = event.getActionId();
if (!inputManager.isActionActive(InputAction::GUI_CTRL))
@@ -562,13 +563,15 @@ void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
{
#ifdef USE_SDL2
handlePaste();
-#else
+#else // USE_SDL2
+
// hack to prevent paste key sticking
if (mLastEventPaste && mLastEventPaste > cur_time)
break;
handlePaste();
mLastEventPaste = cur_time + 2;
-#endif
+#endif // USE_SDL2
+
consumed = true;
break;
}
@@ -762,14 +765,15 @@ void TextField::mousePressed(MouseEvent &event)
#ifdef ANDROID
if (!WindowManager::isKeyboardVisible())
inputManager.executeAction(InputAction::SHOW_KEYBOARD);
-#endif
+#endif // ANDROID
+
event.consume();
if (event.getButton() == MouseButton::RIGHT)
{
#ifndef DYECMD
if (popupMenu)
popupMenu->showTextFieldPopup(this);
-#endif
+#endif // DYECMD
}
else if (event.getButton() == MouseButton::LEFT)
{
@@ -784,7 +788,7 @@ void TextField::focusGained(const Event &event A_UNUSED)
#ifdef ANDROID
if (!WindowManager::isKeyboardVisible())
inputManager.executeAction(InputAction::SHOW_KEYBOARD);
-#endif
+#endif // ANDROID
}
void TextField::focusLost(const Event &event A_UNUSED)
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index e5173b3f1..359d54971 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -181,9 +181,10 @@ class TextField notfinal : public Widget,
#ifdef ANDROID
void focusGained(const Event &event) override final;
-#else
+#else // ANDROID
+
void focusGained(const Event &event) override final A_CONST;
-#endif
+#endif // ANDROID
void focusLost(const Event &event) override A_CONST;
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 55dfe166a..f0ae81f17 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -69,9 +69,9 @@
#include "configuration.h"
#ifndef DYECMD
#include "dragdrop.h"
-#else
+#else // DYECMD
#include "resources/image/image.h"
-#endif
+#endif // DYECMD
#include "soundmanager.h"
#include "const/sound.h"
@@ -247,7 +247,7 @@ Window::~Window()
#ifndef DYECMD
if (setupWindow)
setupWindow->unregisterWindowForReset(this);
-#endif
+#endif // DYECMD
client->windowRemoved(this);
@@ -869,7 +869,7 @@ void Window::mousePressed(MouseEvent &event)
popupMenu->showWindowPopup(this);
}
}
-#endif
+#endif // DYECMD
}
void Window::close()
@@ -908,7 +908,7 @@ void Window::updateResizeHandler(MouseEvent &event)
#ifndef DYECMD
if (!dragDrop.isEmpty())
return;
-#endif
+#endif // DYECMD
mResizeHandles = getResizeHandles(event);
@@ -1481,4 +1481,4 @@ void Window::logic()
logicChildren();
BLOCK_END("Window::logic")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 7aca70bd9..bc77264a2 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -578,7 +578,7 @@ class Window notfinal : public BasicContainer2,
#ifdef USE_PROFILER
virtual void logic();
-#endif
+#endif // USE_PROFILER
protected:
bool canMove() const A_WARN_UNUSED;
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index b3f01d0fe..3a2f35dba 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -101,4 +101,4 @@ void WindowContainer::draw(Graphics *const graphics)
Container::draw(graphics);
BLOCK_END("WindowContainer::draw")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
index cc9b3c814..feb9d719c 100644
--- a/src/gui/widgets/windowcontainer.h
+++ b/src/gui/widgets/windowcontainer.h
@@ -56,7 +56,7 @@ class WindowContainer notfinal : public Container
#ifdef USE_PROFILER
void draw(Graphics *const graphics) override A_NONNULL(2);
-#endif
+#endif // UNITTESTS
private:
/**
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index 8da30d648..8b439e6de 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -67,20 +67,20 @@
#ifdef ANDROID
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#ifdef USE_SDL2
#include <SDL2_framerate.h>
-#else
+#else // USE_SDL2
#include <SDL_framerate.h>
-#endif
+#endif // USE_SDL2
#include <SDL_image.h>
#ifdef WIN32
#include <SDL_syswm.h>
-#endif
+#endif // WIN32
#include "debug.h"
@@ -91,7 +91,8 @@ namespace
SDL_Surface *mIcon(nullptr);
#ifndef USE_SDL2
int mKeyboardHeight(0);
-#endif
+#endif // USE_SDL2
+
bool mIsMinimized(false);
bool mNewMessageFlag(false);
} // namespace
@@ -118,7 +119,8 @@ void WindowManager::createWindows()
CREATEWIDGETV0(itemPopup, ItemPopup);
CREATEWIDGETV0(spellPopup, SpellPopup);
CREATEWIDGETV0(skillPopup, SkillPopup);
-#endif
+#endif // DYECMD
+
CREATEWIDGETV0(textPopup, TextPopup);
}
@@ -137,7 +139,8 @@ void WindowManager::deleteWindows()
delete2(userPalette);
delete2(spellManager)
delete2(spellShortcut)
-#endif
+#endif // DYECMD
+
delete2(textPopup);
}
@@ -161,7 +164,7 @@ void WindowManager::initTitle()
settings.windowCaption.c_str());
#ifndef WIN32
setIcon();
-#endif
+#endif // WIN32
}
void WindowManager::updateTitle()
@@ -221,9 +224,10 @@ void WindowManager::doResizeVideo(const int actualWidth,
#ifdef __native_client__
naclPostMessage("resize-window",
strprintf("%d,%d", actualWidth, actualHeight));
-#else
+#else // __native_client__
+
resizeVideo(actualWidth, actualHeight, always);
-#endif
+#endif // __native_client__
}
void WindowManager::resizeVideo(int actualWidth,
@@ -262,7 +266,7 @@ void WindowManager::resizeVideo(int actualWidth,
Game *const game = Game::instance();
if (game)
game->videoResized(width, height);
-#endif
+#endif // DYECMD
if (gui)
gui->draw();
@@ -278,11 +282,12 @@ bool WindowManager::setFullScreen(const bool fs)
naclPostMessage("set-fullscreen",
fs ? "on" : "off");
return true;
-#else
+#else // __native_client__
+
if (!mainGraphics)
return false;
return mainGraphics->setFullscreen(fs);
-#endif
+#endif // __native_client__
}
void WindowManager::applyGrabMode()
@@ -312,7 +317,7 @@ void WindowManager::applyKeyRepeat()
#ifndef USE_SDL2
SDL_EnableKeyRepeat(config.getIntValue("repeateDelay"),
config.getIntValue("repeateInterval"));
-#endif
+#endif // USE_SDL2
}
void WindowManager::applyScale()
@@ -353,9 +358,11 @@ void WindowManager::setIcon()
std::string iconFile = branding.getValue("appIcon", "icons/manaplus");
#ifdef WIN32
iconFile.append(".ico");
-#else
+#else // WIN32
+
iconFile.append(".png");
-#endif
+#endif // WIN32
+
iconFile = Files::getPath(iconFile);
logger->log("Loading icon from file: %s", iconFile.c_str());
@@ -376,27 +383,31 @@ void WindowManager::setIcon()
}
if (icon)
SetClassLong(pInfo.window, GCL_HICON, reinterpret_cast<LONG>(icon));
-#else
+#else // WIN32
+
mIcon = MIMG_Load(iconFile.c_str());
if (mIcon)
{
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(mIcon, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
+
SDL::SetWindowIcon(mainGraphics->getWindow(), mIcon);
}
-#endif
+#endif // WIN32
}
bool WindowManager::isKeyboardVisible()
{
#ifdef USE_SDL2
return SDL_IsTextInputActive();
-#else
+#else // USE_SDL2
+
return mKeyboardHeight > 1;
-#endif
+#endif // USE_SDL2
}
bool WindowManager::getIsMinimized()
@@ -409,7 +420,7 @@ void WindowManager::updateScreenKeyboard(const int height)
{
mKeyboardHeight = height;
}
-#endif
+#endif // USE_SDL2
void WindowManager::deleteIcon()
{
diff --git a/src/gui/windowmanager.h b/src/gui/windowmanager.h
index 74fe1c2f1..8ddddfcd4 100644
--- a/src/gui/windowmanager.h
+++ b/src/gui/windowmanager.h
@@ -63,7 +63,7 @@ namespace WindowManager
#ifndef USE_SDL2
void updateScreenKeyboard(const int height);
-#endif
+#endif // USE_SDL2
void reloadWallpaper();
diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc
index b098b865e..2305b0424 100644
--- a/src/gui/windowmanager_unittest.cc
+++ b/src/gui/windowmanager_unittest.cc
@@ -145,9 +145,11 @@ TEST_CASE("Windows tests", "windowmanager")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
+
ActorSprite::load();
userPalette = new UserPalette;
theme = new Theme;
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 789e8fce2..20577b6ff 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -89,9 +89,10 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
_("Chat"), x, h, InputAction::WINDOW_CHAT,
#ifdef ANDROID
Visible_true);
-#else
+#else // ANDROID
Visible_false);
-#endif
+#endif // ANDROID
+
// TRANSLATORS: short button name for status window.
addButton(N_("STA"),
// TRANSLATORS: long button name for status window.
@@ -175,9 +176,10 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
_("Debug"), x, h, InputAction::WINDOW_DEBUG,
#ifdef ANDROID
Visible_true);
-#else
+#else // ANDROID
Visible_false);
-#endif
+#endif // ANDROID
+
// TRANSLATORS: short button name for windows list menu.
addButton(N_("WIN"),
// TRANSLATORS: long button name for windows list menu.
@@ -471,4 +473,4 @@ void WindowMenu::logicChildren()
BasicContainer::logicChildren();
BLOCK_END("WindowMenu::logicChildren")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index cf9d701f7..cc70bd55d 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -84,7 +84,7 @@ class WindowMenu final : public Container,
#ifdef USE_PROFILER
void logicChildren();
-#endif
+#endif // USE_PROFILER
protected:
void drawChildren(Graphics *const graphics) override final
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index ec321a15f..8da750d34 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -267,7 +267,7 @@ void BuyDialog::init()
if (mAdvanced && (
#ifdef TMWA_SUPPORT
mNpcId == fromInt(Nick, BeingId) ||
-#endif
+#endif // TMWA_SUPPORT
mNpcId == fromInt(Cash, BeingId)))
{
mAdvanced = false;
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 1b33eab2f..d7392acc6 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -140,13 +140,15 @@ ChatWindow::ChatWindow() :
setDefaultSize(w, 90, ImagePosition::UPPER_LEFT, -110, -35);
else
setDefaultSize(w, 123, ImagePosition::UPPER_LEFT, -110, -35);
-#else
+#else // ANDROID
+
if (mainGraphics->getWidth() < 600)
w = mainGraphics->getWidth() - 10;
if (w < 100)
w = 100;
setDefaultSize(w, 123, ImagePosition::LOWER_LEFT);
-#endif
+#endif // ANDROID
+
setMinWidth(150);
setMinHeight(90);
@@ -2080,7 +2082,7 @@ void ChatWindow::logicChildren()
BasicContainer::logicChildren();
BLOCK_END("ChatWindow::logicChildren")
}
-#endif
+#endif // USE_PROFILER
void ChatWindow::addGlobalMessage(const std::string &line)
{
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 78d87eb6d..26ef6d0bb 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -310,7 +310,7 @@ class ChatWindow final : public Window,
#ifdef USE_PROFILER
void logicChildren();
-#endif
+#endif // USE_PROFILER
protected:
friend class ChannelTab;
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 2c9a5c3f6..2a13511f1 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -170,4 +170,4 @@ void DebugWindow::logicChildren()
BasicContainer::logicChildren();
BLOCK_END("DebugWindow::logicChildren")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h
index 12bb97f13..af4d0732e 100644
--- a/src/gui/windows/debugwindow.h
+++ b/src/gui/windows/debugwindow.h
@@ -64,7 +64,7 @@ class DebugWindow final : public Window
#ifdef USE_PROFILER
void logicChildren();
-#endif
+#endif // USE_PROFILER
private:
TabbedArea *mTabs A_NONNULLPOINTER;
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index 8f65bb8f5..2291c9028 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -242,14 +242,16 @@ void EditServerDialog::action(const ActionEvent &event)
case 2:
mServer.type = ServerType::EVOL2;
break;
-#else
+#else // TMWA_SUPPORT
+
case 0:
mServer.type = ServerType::EATHENA;
break;
case 1:
mServer.type = ServerType::EVOL2;
break;
-#endif
+#endif // TMWA_SUPPORT
+
default:
mServer.type = ServerType::UNKNOWN;
break;
diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h
index a89bb83f5..a728e824c 100644
--- a/src/gui/windows/itemamountwindow.h
+++ b/src/gui/windows/itemamountwindow.h
@@ -87,7 +87,7 @@ class ItemAmountWindow final : public Window,
#ifndef UNITTESTS
private:
-#endif
+#endif // UNITTESTS
static void finish(Item *const item,
const int amount,
const int price,
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index 68b57b077..13c1dbbc4 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -38,7 +38,7 @@
#ifdef WIN32
#include <sys/time.h>
-#endif
+#endif // WIN32
#include "debug.h"
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 9ef745cc3..4d58bf968 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -180,9 +180,11 @@ void LoginDialog::postInit()
setContentSize(310, h);
#ifdef ANDROID
setDefaultSize(310, h, ImagePosition::UPPER_CENTER, 0, 0);
-#else
+#else // ANDROID
+
setDefaultSize(310, h, ImagePosition::CENTER, 0, 0);
-#endif
+#endif // ANDROID
+
center();
loadWindowState();
reflowLayout();
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 0f3ea0a4d..4dc59e1cd 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -571,4 +571,4 @@ void MiniStatusWindow::logicChildren()
BasicContainer::logicChildren();
BLOCK_END("MiniStatusWindow::logicChildren")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
index 82fa059c7..400aeb126 100644
--- a/src/gui/windows/ministatuswindow.h
+++ b/src/gui/windows/ministatuswindow.h
@@ -102,7 +102,7 @@ class MiniStatusWindow final : public Window,
#ifdef USE_PROFILER
void logicChildren();
-#endif
+#endif // USE_PROFILER
private:
bool isInBar(ProgressBar *bar, int x, int y) const;
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 68de46288..3f6c18ff8 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -51,7 +51,7 @@
#ifdef WIN32
#undef ERROR
-#endif
+#endif // WIN32
static const int MAX_SERVERLIST = 15;
@@ -62,9 +62,11 @@ static std::string serverTypeToString(const ServerTypeT type)
case ServerType::TMWATHENA:
#ifdef TMWA_SUPPORT
return "TmwAthena";
-#else
+#else // TMWA_SUPPORT
+
return "";
-#endif
+#endif // TMWA_SUPPORT
+
case ServerType::EATHENA:
return "eAthena";
case ServerType::EVOL2:
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 1b9d0a94a..5121d531b 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -30,7 +30,7 @@
#include "gui/windows/tradewindow.h"
#include "const/gui/chat.h"
-#endif
+#endif // TMWA_SUPPORT
#include "gui/windows/editdialog.h"
@@ -54,7 +54,7 @@
#ifdef TMWA_SUPPORT
#include "actormanager.h"
#include "soundmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "configuration.h"
#include "settings.h"
@@ -64,20 +64,20 @@
#ifdef TMWA_SUPPORT
#include "being/playerrelations.h"
#include "net/chathandler.h"
-#endif
+#endif // TMWA_SUPPORT
#include "net/buyingstorehandler.h"
#include "net/vendinghandler.h"
#include "net/serverfeatures.h"
#ifdef TMWA_SUPPORT
#include "net/tradehandler.h"
-#endif
+#endif // TMWA_SUPPORT
#include "utils/delete2.h"
#include "utils/gettext.h"
#ifdef TMWA_SUPPORT
#include "resources/iteminfo.h"
-#endif
+#endif // TMWA_SUPPORT
#include "resources/inventory/inventory.h"
@@ -271,7 +271,7 @@ void ShopWindow::action(const ActionEvent &event)
announce(mSellShopItems, SELL);
}
}
-#endif
+#endif // TMWA_SUPPORT
else if (eventId == "delete")
{
if (isBuySelected)
@@ -1071,7 +1071,7 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem,
}
return false;
}
-#endif
+#endif // TMWA_SUPPORT
int ShopWindow::sumAmount(const Item *const shopItem)
{
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index 50d924a1f..502e5c526 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -140,8 +140,8 @@ class ShopWindow final : public Window,
bool findShopItem(const ShopItem *const shopItem,
const int mode) const A_WARN_UNUSED;
+#endif // TMWA_SUPPORT
-#endif
static int sumAmount(const Item *const shopItem) A_WARN_UNUSED;
bool isShopEmpty() const A_WARN_UNUSED;
@@ -159,7 +159,8 @@ class ShopWindow final : public Window,
private:
#ifdef TMWA_SUPPORT
void startTrade();
-#endif
+#endif // TMWA_SUPPORT
+
void updateSelection();
void updateShopName();
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 9d4b34b6d..5184b3e1d 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -264,4 +264,4 @@ void ShortcutWindow::logicChildren()
BasicContainer::logicChildren();
BLOCK_END("ShortcutWindow::logicChildren")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h
index 2e0d8ee83..69d97749f 100644
--- a/src/gui/windows/shortcutwindow.h
+++ b/src/gui/windows/shortcutwindow.h
@@ -78,7 +78,7 @@ class ShortcutWindow final : public Window
#ifdef USE_PROFILER
void logicChildren();
-#endif
+#endif // USE_PROFILER
private:
ShortcutWindow();
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 498ffc827..5b465161a 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -41,7 +41,7 @@
#include "gui/widgets/tabs/socialguildtab2.h"
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "debug.h"
@@ -313,9 +313,10 @@ void SocialWindow::action(const ActionEvent &event)
guildHandler->inviteResponse(mGuildInvited, true);
else
guildManager->inviteResponse(true);
-#else
+#else // TMWA_SUPPORT
+
guildHandler->inviteResponse(mGuildInvited, true);
-#endif
+#endif // TMWA_SUPPORT
}
else if (eventId == "no")
{
@@ -332,9 +333,10 @@ void SocialWindow::action(const ActionEvent &event)
guildHandler->inviteResponse(mGuildInvited, false);
else
guildManager->inviteResponse(false);
-#else
+#else // TMWA_SUPPORT
+
guildHandler->inviteResponse(mGuildInvited, false);
-#endif
+#endif // TMWA_SUPPORT
}
mGuildInvited = 0;
@@ -657,4 +659,4 @@ void SocialWindow::logicChildren()
BasicContainer::logicChildren();
BLOCK_END("SocialWindow::logicChildren")
}
-#endif
+#endif // USE_PROFILER
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h
index ad60c9ca8..6c23fd292 100644
--- a/src/gui/windows/socialwindow.h
+++ b/src/gui/windows/socialwindow.h
@@ -131,7 +131,7 @@ class SocialWindow final : public Window,
#ifdef USE_PROFILER
void logicChildren();
-#endif
+#endif // USE_PROFILER
protected:
friend class SocialTab;
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index 40405f3e8..f22009013 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -45,7 +45,7 @@
#ifdef TMWA_SUPPORT
const unsigned int MAGIC_START_ID = 340;
-#endif
+#endif // TMWA_SUPPORT
TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor name
@@ -54,14 +54,14 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
#ifdef TMWA_SUPPORT
mIsMagicCommand(command ?
(command->getCommandType() == TextCommandType::Magic) : false),
-#endif
+#endif // TMWA_SUPPORT
mCommand(command),
#ifdef TMWA_SUPPORT
// TRANSLATORS: command editor button
mIsMagic(new RadioButton(this, _("magic"), "magic", mIsMagicCommand)),
// TRANSLATORS: command editor button
mIsOther(new RadioButton(this, _("other"), "magic", !mIsMagicCommand)),
-#endif
+#endif // TMWA_SUPPORT
// TRANSLATORS: command editor label
mSymbolLabel(new Label(this, _("Symbol:"))),
mSymbolTextField(new TextField(this)),
@@ -93,7 +93,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor label
mSchoolLvlLabel(new Label(this, _("School level:"))),
mSchoolLvlField(new IntTextField(this, 0)),
-#endif
+#endif // TMWA_SUPPORT
// TRANSLATORS: command editor button
mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
// TRANSLATORS: command editor button
@@ -129,7 +129,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
mSchoolLvlField->setRange(0, 5);
mSchoolLvlField->setWidth(20);
-#endif
+#endif // TMWA_SUPPORT
mTypeDropDown->setActionEventId("type");
mTypeDropDown->addActionListener(this);
@@ -150,19 +150,13 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
showControls(Visible_true);
else
showControls(Visible_false);
-#endif
- mSymbolTextField->setText(command->getSymbol());
- mCommandTextField->setText(command->getCommand());
- mCommentTextField->setText(command->getComment());
- mTypeDropDown->setSelected(CAST_S32(command->getTargetType()));
-#ifdef TMWA_SUPPORT
mManaField->setValue(command->getMana());
mMagicLvlField->setValue(command->getBaseLvl());
mSchoolDropDown->setSelected(CAST_S32(command->getSchool())
- MAGIC_START_ID);
mSchoolLvlField->setValue(command->getSchoolLvl());
-#endif
+#endif // TMWA_SUPPORT
}
ContainerPlacer placer;
@@ -198,7 +192,8 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
placer(0, 10, mSaveButton, 2).setPadding(3);
placer(2, 10, mCancelButton, 2).setPadding(3);
placer(4, 10, mDeleteButton, 2).setPadding(3);
-#else
+#else // TMWA_SUPPORT
+
placer(0, 0, mSymbolLabel, 2).setPadding(3);
placer(2, 0, mSymbolTextField, 3).setPadding(3);
placer(0, 1, mCommandLabel, 2).setPadding(3);
@@ -216,7 +211,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
placer(0, 5, mSaveButton, 2).setPadding(3);
placer(2, 5, mCancelButton, 2).setPadding(3);
placer(4, 5, mDeleteButton, 2).setPadding(3);
-#endif
+#endif // TMWA_SUPPORT
setWidth(w);
setHeight(h);
@@ -239,7 +234,7 @@ TextCommandEditor::~TextCommandEditor()
delete2(mTargetTypeModel);
#ifdef TMWA_SUPPORT
delete2(mMagicSchoolModel);
-#endif
+#endif // TMWA_SUPPORT
}
void TextCommandEditor::action(const ActionEvent &event)
@@ -270,7 +265,7 @@ void TextCommandEditor::action(const ActionEvent &event)
mIsMagicCommand = false;
showControls(Visible_false);
}
-#endif
+#endif // TMWA_SUPPORT
}
#ifdef TMWA_SUPPORT
@@ -285,7 +280,7 @@ void TextCommandEditor::showControls(const Visible show)
mSchoolLvlLabel->setVisible(show);
mSchoolLvlField->setVisible(show);
}
-#endif
+#endif // TMWA_SUPPORT
void TextCommandEditor::scheduleDelete()
{
@@ -302,7 +297,7 @@ void TextCommandEditor::save()
mCommand->setCommandType(TextCommandType::Magic);
else
mCommand->setCommandType(TextCommandType::Text);
-#endif
+#endif // TMWA_SUPPORT
mCommand->setSymbol(mSymbolTextField->getText());
mCommand->setCommand(mCommandTextField->getText());
@@ -317,7 +312,8 @@ void TextCommandEditor::save()
mCommand->setSchool(static_cast<MagicSchoolT>(
mSchoolDropDown->getSelected() + MAGIC_START_ID));
mCommand->setSchoolLvl(mSchoolLvlField->getValue());
-#endif
+#endif // TMWA_SUPPORT
+
if (spellManager)
spellManager->save();
}
@@ -337,7 +333,8 @@ void TextCommandEditor::deleteCommand()
mCommand->setBaseLvl(0);
mCommand->setSchool(MagicSchool::SkillMagic);
mCommand->setSchoolLvl(0);
-#endif
+#endif // TMWA_SUPPORT
+
if (spellManager)
spellManager->save();
}
diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h
index 07562320a..e651352c9 100644
--- a/src/gui/windows/textcommandeditor.h
+++ b/src/gui/windows/textcommandeditor.h
@@ -34,7 +34,8 @@ class IntTextField;
class Label;
#ifdef TMWA_SUPPORT
class MagicSchoolModel;
-#endif
+#endif // TMWA_SUPPORT
+
class RadioButton;
class TargetTypeModel;
class TextCommand;
@@ -65,7 +66,7 @@ class TextCommandEditor final : public Window,
private:
#ifdef TMWA_SUPPORT
void showControls(const Visible show);
-#endif
+#endif // TMWA_SUPPORT
void save();
@@ -73,12 +74,13 @@ class TextCommandEditor final : public Window,
#ifdef TMWA_SUPPORT
bool mIsMagicCommand;
-#endif
+#endif // TMWA_SUPPORT
TextCommand* mCommand;
#ifdef TMWA_SUPPORT
RadioButton* mIsMagic A_NONNULLPOINTER;
-#endif
+#endif // TMWA_SUPPORT
+
RadioButton* mIsOther A_NONNULLPOINTER;
Label* mSymbolLabel A_NONNULLPOINTER;
TextField* mSymbolTextField A_NONNULLPOINTER;
@@ -102,7 +104,8 @@ class TextCommandEditor final : public Window,
DropDown* mSchoolDropDown A_NONNULLPOINTER;
Label* mSchoolLvlLabel A_NONNULLPOINTER;
IntTextField* mSchoolLvlField A_NONNULLPOINTER;
-#endif
+#endif // TMWA_SUPPORT
+
Button* mCancelButton A_NONNULLPOINTER;
Button* mSaveButton A_NONNULLPOINTER;
Button* mDeleteButton A_NONNULLPOINTER;
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index b2adf2be3..fed308094 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -464,10 +464,12 @@ void UpdaterWindow::loadPatch()
#elif defined(WIN32)
const std::string url = "windowsDownloadUrl";
const std::string text = "windowsDownloadUrl";
-#else
+#else // defined(ANDROID)
+
const std::string url = "otherDownloadUrl";
const std::string text = "otherDownloadUrl";
-#endif
+#endif // defined(ANDROID)
+
mBrowserBox->addRow(std::string(" ##1[@@").append(
branding.getStringValue(url)).append("|").append(
branding.getStringValue(text)).append("@@]"), true);
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index a138c3994..d07cb9f7d 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -29,7 +29,7 @@
#include "party.h"
#ifdef TMWA_SUPPORT
#include "settings.h"
-#endif
+#endif // TMWA_SUPPORT
#include "gui/onlineplayer.h"
#include "gui/popupmanager.h"
@@ -51,7 +51,7 @@
#ifdef TMWA_SUPPORT
#include "net/download.h"
-#endif
+#endif // TMWA_SUPPORT
#include "net/packetlimiter.h"
#include "net/playerhandler.h"
#include "net/serverfeatures.h"
@@ -61,17 +61,17 @@
#ifndef TMWA_SUPPORT
#include <curl/curl.h>
-#endif
+#endif // TMWA_SUPPORT
#include "debug.h"
#ifdef free
#undef free
-#endif
+#endif // free
#ifdef malloc
#undef malloc
-#endif
+#endif // malloc
WhoIsOnline *whoIsOnline = nullptr;
@@ -603,7 +603,7 @@ int WhoIsOnline::downloadThread(void *ptr)
wio->mDownloadStatus = UPDATE_ERROR;
return 0;
}
-#endif
+#endif // TMWA_SUPPORT
void WhoIsOnline::download()
{
@@ -625,7 +625,7 @@ void WhoIsOnline::download()
if (mThread == nullptr)
mDownloadStatus = UPDATE_ERROR;
}
-#endif
+#endif // TMWA_SUPPORT
}
void WhoIsOnline::logic()
@@ -698,7 +698,8 @@ void WhoIsOnline::slowLogic()
default:
break;
}
-#endif
+#endif // TMWA_SUPPORT
+
BLOCK_END("WhoIsOnline::slowLogic")
}
@@ -725,7 +726,7 @@ void WhoIsOnline::action(const ActionEvent &event)
}
}
else
-#endif
+#endif // TMWA_SUPPORT
{
if (PacketLimiter::limitPackets(PacketType::PACKET_ONLINELIST))
{
diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h
index 5233a17ad..b125bc655 100644
--- a/src/gui/windows/whoisonline.h
+++ b/src/gui/windows/whoisonline.h
@@ -63,7 +63,7 @@ class WhoIsOnline final : public Window,
* Loads and display online list from the memory buffer.
*/
void loadWebList();
-#endif
+#endif // TMWA_SUPPORT
void loadList(const std::vector<OnlinePlayer*> &list);
@@ -118,7 +118,7 @@ class WhoIsOnline final : public Window,
size_t size,
size_t nmemb,
FILE *restrict stream);
-#endif
+#endif // TMWA_SUPPORT
const std::string prepareNick(const std::string &restrict nick,
const int level,
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 85595d43b..44cc82845 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -316,9 +316,9 @@ static const InputActionData inputActionData
addKey(SDLK_ESCAPE),
#if defined(USE_SDL2) && defined(ANDROID)
addKey(SDLK_AC_BACK),
-#else
+#else // defined(USE_SDL2) && defined(ANDROID)
emptyKey,
-#endif
+#endif // defined(USE_SDL2) && defined(ANDROID)
Input::GRP_DEFAULT,
&Actions::quit,
InputAction::NO_VALUE, 50,
@@ -2311,9 +2311,9 @@ static const InputActionData inputActionData
{"keyIgnoreInput1",
#ifdef USE_SDL2
emptyKey,
-#else
+#else // USE_SDL2
addKey(SDLK_LSUPER),
-#endif
+#endif // USE_SDL2
emptyKey,
Input::GRP_DEFAULT,
&Actions::ignoreInput,
@@ -2325,9 +2325,9 @@ static const InputActionData inputActionData
{"keyIgnoreInput2",
#ifdef USE_SDL2
emptyKey,
-#else
+#else // USE_SDL2
addKey(SDLK_RSUPER),
-#endif
+#endif // USE_SDL2
emptyKey,
Input::GRP_DEFAULT,
&Actions::ignoreInput,
@@ -2637,9 +2637,9 @@ static const InputActionData inputActionData
addKey(SDLK_ESCAPE),
#if defined(USE_SDL2) && defined(ANDROID)
addKey(SDLK_AC_BACK),
-#else
+#else // defined(USE_SDL2) && defined(ANDROID)
emptyKey,
-#endif
+#endif // defined(USE_SDL2) && defined(ANDROID)
Input::GRP_GUICHAN,
nullptr,
InputAction::NO_VALUE, 50,
@@ -3503,16 +3503,16 @@ static const InputActionData inputActionData
Input::GRP_DEFAULT,
#if defined USE_OPENGL && defined DEBUG_SDLFONT
&Actions::testSdlFont,
-#else
+#else // defined USE_OPENGL && defined DEBUG_SDLFONT
nullptr,
-#endif
+#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
InputAction::NO_VALUE, 50,
InputCondition::INGAME,
#if defined USE_OPENGL && defined DEBUG_SDLFONT
"testsdlfont",
-#else
+#else // defined USE_OPENGL && defined DEBUG_SDLFONT
"",
-#endif
+#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
UseArgs_false,
Protected_true},
{"keyEnableHightlight",
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index d07522146..a916776c0 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -33,7 +33,7 @@
#include "input/keyboardconfig.h"
#ifdef USE_SDL2
#include "input/touch/multitouchmanager.h"
-#endif
+#endif // USE_SDL2
#include "input/touch/touchmanager.h"
@@ -129,9 +129,11 @@ void InputManager::retrieve() restrict2
#ifdef USE_SDL2
const std::string cf = std::string("sdl2")
+ inputActionData[i].configField;
-#else
+#else // USE_SDL2
+
const std::string cf = inputActionData[i].configField;
-#endif
+#endif // USE_SDL2
+
InputFunction &restrict kf = mKey[i];
if (!cf.empty())
{
@@ -191,9 +193,11 @@ void InputManager::store() const restrict2
#ifdef USE_SDL2
const std::string cf = std::string("sdl2")
+ inputActionData[i].configField;
-#else
+#else // USE_SDL2
+
const std::string cf = inputActionData[i].configField;
-#endif
+#endif // USE_SDL2
+
if (!cf.empty())
{
std::string keyStr;
@@ -268,10 +272,12 @@ void InputManager::resetKey(const InputActionT i) restrict2
val0.value = -1;
if (val1.value == SDL_SCANCODE_UNKNOWN)
val1.value = -1;
-#else
+#else // USE_SDL2
+
val0.value = kd.defaultValue1;
val1.value = kd.defaultValue2;
-#endif
+#endif // USE_SDL2
+
updateKeyString(key, CAST_SIZE(i));
}
@@ -343,7 +349,7 @@ void InputManager::callbackNewKey() restrict2
{
#ifndef DYECMD
mSetupInput->newKeyCallback(mNewKeyIndex);
-#endif
+#endif // DYECMD
}
bool InputManager::isActionActive(const InputActionT index) const restrict2
@@ -570,13 +576,14 @@ bool InputManager::handleAssignKey(const SDL_Event &restrict event,
}
return false;
}
-#else
+#else // DYECMD
+
bool InputManager::handleAssignKey(const SDL_Event &restrict event A_UNUSED,
const InputTypeT type A_UNUSED) restrict2
{
return false;
}
-#endif
+#endif // DYECMD
bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
{
@@ -605,7 +612,8 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
BLOCK_END("InputManager::handleEvent")
return true;
}
-#endif
+#endif // DYECMD
+
break;
}
case SDL_KEYUP:
@@ -639,14 +647,15 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
case SDL_FINGERUP:
multiTouchManager.handleFingerUp(event);
break;
-#else
+#else // USE_SDL2
#ifdef ANDROID
case SDL_ACCELEROMETER:
{
break;
}
-#endif
-#endif
+#endif // ANDROID
+#endif // USE_SDL2
+
default:
break;
}
@@ -689,8 +698,9 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
{
break;
}
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
+
default:
break;
}
@@ -779,7 +789,7 @@ void InputManager::updateConditionMask() restrict2
mMask |= InputCondition::NOFOLLOW;
mMask |= InputCondition::NOBLOCK;
}
-#endif
+#endif // DYECMD
if (!settings.awayMode)
mMask |= InputCondition::NOAWAY;
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
index eb816c239..5c91edd43 100644
--- a/src/input/joystick.cpp
+++ b/src/input/joystick.cpp
@@ -198,7 +198,7 @@ void Joystick::logic()
logger->log("axis 3 pos: %d", SDL_JoystickGetAxis(mJoystick, 3));
if (SDL_JoystickGetAxis(mJoystick, 4))
logger->log("axis 4 pos: %d", SDL_JoystickGetAxis(mJoystick, 4));
-#endif
+#endif // DEBUG_JOYSTICK
if (!mDirection && mHaveHats)
{
@@ -224,7 +224,7 @@ void Joystick::logic()
#ifdef DEBUG_JOYSTICK
if (mActiveButtons[i])
logger->log("button: %d", i);
-#endif
+#endif // DEBUG_JOYSTICK
}
}
else
diff --git a/src/input/key.h b/src/input/key.h
index c0cc37b00..42440721f 100644
--- a/src/input/key.h
+++ b/src/input/key.h
@@ -71,7 +71,7 @@
// that windows define with Guichan.
#if defined (_WIN32) && defined(DELETE)
#undef DELETE
-#endif
+#endif // defined (_WIN32) && defined(DELETE)
/**
* Represents a key or a character.
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp
index 888b86724..ecd563656 100644
--- a/src/input/keyboardconfig.cpp
+++ b/src/input/keyboardconfig.cpp
@@ -63,13 +63,14 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event)
{
#ifdef USE_SDL2
return event.key.keysym.scancode;
-#else
+#else // USE_SDL2
+
if (event.key.keysym.sym)
return CAST_S32(event.key.keysym.sym);
else if (event.key.keysym.scancode > 1)
return -event.key.keysym.scancode;
return 0;
-#endif
+#endif // USE_SDL2
}
InputActionT KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp)
@@ -92,9 +93,10 @@ std::string KeyboardConfig::getKeyName(const int key)
#ifdef USE_SDL2
return SDL_GetKeyName(SDL_GetKeyFromScancode(
static_cast<SDL_Scancode>(key)));
-#else
+#else // USE_SDL2
+
return SDL_GetKeyName(static_cast<SDLKey>(key));
-#endif
+#endif // USE_SDL2
}
// TRANSLATORS: long key name, should be short
@@ -151,9 +153,10 @@ SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event)
{
#ifdef USE_SDL2
return event.key.keysym.scancode;
-#else
+#else // USE_SDL2
+
return event.key.keysym.sym;
-#endif
+#endif // USE_SDL2
}
KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event)
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
index 6d7830ee7..3b9610141 100644
--- a/src/input/keyboardconfig.h
+++ b/src/input/keyboardconfig.h
@@ -26,12 +26,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
_SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#include <SDL_keyboard.h>
#include "sdlshared.h"
diff --git a/src/input/keyinput.h b/src/input/keyinput.h
index d582303a0..cd5235575 100644
--- a/src/input/keyinput.h
+++ b/src/input/keyinput.h
@@ -84,7 +84,7 @@ class KeyInput final
mType(KeyEventType::PRESSED),
#ifdef USE_SDL2
mText(),
-#endif
+#endif // USE_SDL2
mActionId(InputAction::UNDEFINED_VALUE)
{ }
@@ -93,7 +93,7 @@ class KeyInput final
mType(k.mType),
#ifdef USE_SDL2
mText(k.mText),
-#endif
+#endif // USE_SDL2
mActionId(k.mActionId)
{
}
@@ -104,7 +104,7 @@ class KeyInput final
mType = k.mType;
#ifdef USE_SDL2
mText = k.mText;
-#endif
+#endif // USE_SDL2
mActionId = k.mActionId;
return *this;
}
@@ -152,7 +152,7 @@ class KeyInput final
{
return mText;
}
-#endif
+#endif // USE_SDL2
protected:
/**
@@ -167,7 +167,7 @@ class KeyInput final
#ifdef USE_SDL2
std::string mText;
-#endif
+#endif // USE_SDL2
InputActionT mActionId;
};
diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h
index e4efa93c9..a8a948cf3 100644
--- a/src/input/mouseinput.h
+++ b/src/input/mouseinput.h
@@ -173,13 +173,14 @@ class MouseInput final
int getTouchY() const A_WARN_UNUSED
{ return mRealY; }
-#else
+#else // ANDROID
+
int getTouchX() const A_WARN_UNUSED
{ return mX; }
int getTouchY() const A_WARN_UNUSED
{ return mY; }
-#endif
+#endif // ANDROID
protected:
/**
diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp
index 3a0ab3154..997bec32a 100644
--- a/src/input/pages/other.cpp
+++ b/src/input/pages/other.cpp
@@ -390,7 +390,7 @@ SetupActionData setupActionDataOther[] =
InputAction::TEST_SDL_FONT,
"",
},
-#endif
+#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
{
// TRANSLATORS: input action name
N_("Upload main config"),
diff --git a/src/input/touch/multitouchmanager.cpp b/src/input/touch/multitouchmanager.cpp
index b608b0085..b268df0e5 100644
--- a/src/input/touch/multitouchmanager.cpp
+++ b/src/input/touch/multitouchmanager.cpp
@@ -24,7 +24,7 @@
#include "render/graphics.h"
#include "gui/sdlinput.h"
-#endif
+#endif // USE_SDL2
#include "debug.h"
MultiTouchManager multiTouchManager;
@@ -85,4 +85,4 @@ void MultiTouchManager::checkDevice(const long touchId,
}
}
}
-#endif
+#endif // USE_SDL2
diff --git a/src/input/touch/multitouchmanager.h b/src/input/touch/multitouchmanager.h
index 25b56d3d8..a9323991c 100644
--- a/src/input/touch/multitouchmanager.h
+++ b/src/input/touch/multitouchmanager.h
@@ -27,7 +27,7 @@
#ifdef USE_SDL2
union SDL_Event;
-#endif
+#endif // USE_SDL2
struct MultiTouchEvent final
{
@@ -59,7 +59,7 @@ class MultiTouchManager final
void checkDevice(const long touchId,
const long fingerId);
-#endif
+#endif // USE_SDL2
private:
MultiTouchDevicesMap mEvents;
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc
index 0c61a15a4..5958445b2 100644
--- a/src/integrity_unittest.cc
+++ b/src/integrity_unittest.cc
@@ -80,9 +80,11 @@ TEST_CASE("integrity tests", "integrity")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
+
ActorSprite::load();
SECTION("integrity test 1")
diff --git a/src/localconsts.h b/src/localconsts.h
index c21070ba2..08f2efe40 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -122,11 +122,11 @@
#define A_CONST __attribute__ ((const))
#define A_PURE __attribute__ ((pure))
#define A_INLINE __attribute__ ((always_inline))
-#else
+#else // ENABLE_CILKPLUS
#define A_CONST
#define A_PURE
#define A_INLINE
-#endif
+#endif // ENABLE_CILKPLUS
#ifdef __INTEL_COMPILER
#define RETURNS_NONNULL
@@ -140,11 +140,11 @@
#ifndef ENABLE_CILKPLUS
#define A_NONNULL(...) __attribute__((nonnull (__VA_ARGS__)))
-#else
+#else // ENABLE_CILKPLUS
#define A_NONNULL(...)
-#endif
+#endif // ENABLE_CILKPLUS
-#else
+#else // __GNUC__
#define A_UNUSED
#define A_WARN_UNUSED
#define gnu_printf printf
@@ -153,14 +153,14 @@
#define restrict2
#define RETURNS_NONNULL
#define A_NONNULL(...)
-#endif
+#endif // __GNUC__
#ifdef __clang__
#define gnu_printf printf
-#endif
+#endif // __clang__
#ifdef ENABLE_CILKPLUS
#include <cilk/cilk.h>
-#endif
+#endif // ENABLE_CILKPLUS
#ifdef ADVGCC
#define const2 const
@@ -242,9 +242,9 @@
#ifdef ENABLE_CHECKPLUGIN
#define A_NONNULLPOINTER __attribute__((nonnullpointer))
-#else
+#else // ENABLE_CHECKPLUGIN
#define A_NONNULLPOINTER
-#endif
+#endif // ENABLE_CHECKPLUGIN
#ifdef ENABLE_CHECKS
@@ -261,24 +261,24 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_version.h>
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#if SDL_VERSION_ATLEAST(2, 0, 0)
#ifndef USE_SDL2
#warning using SDL2 headers but configure set to use SDL1.2
#warning please add configure flag --with-sdl2
#define USE_SDL2
-#endif
-#else
+#endif // USE_SDL2
+#else // SDL_VERSION_ATLEAST(2, 0, 0)
#ifdef USE_SDL2
#error using SDL1.2 headers but configure set to use SDL2
#error please remove configure flag --with-sdl2
-#endif
-#endif
+#endif // USE_SDL2
+#endif // SDL_VERSION_ATLEAST(2, 0, 0)
// #define DEBUG_CONFIG 1
// #define DEBUG_BIND_TEXTURE 1
@@ -316,9 +316,9 @@
#ifdef DYECMD
#undef USE_FUZZER
-#endif
+#endif // DYECMD
#include "utils/perfomance.h"
UTILS_PERFOMANCE_H // guard for protect previous include
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif // HAVE_CONFIG_H
diff --git a/src/logger.cpp b/src/logger.cpp
index b0474c243..49f83efcc 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -34,7 +34,7 @@
#include <windows.h>
#elif defined __APPLE__
#include <Carbon/Carbon.h>
-#endif
+#endif // WIN32
#include <sys/time.h>
@@ -99,7 +99,7 @@ Logger::Logger() :
{
#if defined __native_client__ && defined(NACL_LOG)
std::cout.setf(std::ios_base::unitbuf);
-#endif
+#endif // defined __native_client__ && defined(NACL_LOG)
}
Logger::~Logger()
@@ -206,7 +206,7 @@ void Logger::dlog2(const std::string &str,
}
}
}
-#endif
+#endif // ENABLEDEBUGLOG
void Logger::log1(const char *const buf)
{
@@ -385,9 +385,11 @@ void Logger::safeError(const std::string &error_text)
error_text).append("\"");
if (system(msg.c_str()) == -1)
std::cerr << "Error: " << error_text << std::endl;
-#else
+#else // WIN32
+
std::cerr << "Error: " << error_text << std::endl;
-#endif
+#endif // WIN32
+
exit(1);
}
@@ -413,9 +415,11 @@ void Logger::error(const std::string &error_text)
"Please see log file for more information.\"");
if (system(msg.c_str()) == -1)
std::cerr << "Error: " << error_text << std::endl;
-#else
+#else // WIN32
+
std::cerr << "Error: " << error_text << std::endl;
-#endif
+#endif // WIN32
+
exit(1);
}
diff --git a/src/logger.h b/src/logger.h
index 8a7bbbd8c..bfbfe2f68 100644
--- a/src/logger.h
+++ b/src/logger.h
@@ -26,12 +26,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
_SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#include <SDL_mutex.h>
#include <fstream>
@@ -50,12 +50,12 @@ _SDL_stdinc_h
if (logger) \
logger->dlog(str)
#define IGNOREDEBUGLOG mIgnore = Net::isIgnorePacket(mId)
-#else
+#else // ENABLEDEBUGLOG
#define DEBUGLOG(str) {}
#define DEBUGLOG2(str, comment) {}
#define DEBUGLOGSTR(str)
#define IGNOREDEBUGLOG {}
-#endif
+#endif // ENABLEDEBUGLOG
#define UNIMPLIMENTEDPACKET \
logger->unimplimented(msg.getId())
@@ -178,7 +178,7 @@ class Logger final
void dlog2(const std::string &str,
const int pos,
const char* const comment);
-#endif
+#endif // ENABLEDEBUGLOG
void setDebugLog(const bool n)
{ mDebugLog = n; }
@@ -193,7 +193,7 @@ class Logger final
void error(const std::string &error_text)
#ifndef ENABLE_CILKPLUS
__attribute__ ((noreturn))
-#endif
+#endif // ENABLE_CILKPLUS
;
/**
@@ -203,7 +203,7 @@ class Logger final
void safeError(const std::string &error_text)
#ifndef ENABLE_CILKPLUS
__attribute__ ((noreturn))
-#endif
+#endif // ENABLE_CILKPLUS
;
void unimplimented(const int id);
diff --git a/src/main.cpp b/src/main.cpp
index 805ad7df4..ae87c7a0e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,15 +25,16 @@
#ifdef UNITTESTS
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
-#endif
+#endif // UNITTESTS
#include "debug.h"
#if !defined(UNITTESTS) && !defined(ANDROID)
#if defined __native_client__
extern "C"
-#endif
+#endif // defined __native_client__
+
int main(int argc, char *argv[])
{
return mainGui(argc, argv);
}
-#endif
+#endif // !defined(UNITTESTS) && !defined(ANDROID)
diff --git a/src/main.h b/src/main.h
index b3500fd98..d30dcf238 100644
--- a/src/main.h
+++ b/src/main.h
@@ -52,12 +52,12 @@
#include "../config.h"
#elif defined WIN32
#include "winver.h"
-#else
+#else // HAVE_CONFIG_H
#ifdef PACKAGE_VERSION
#undef PACKAGE_VERSION
-#endif
+#endif // PACKAGE_VERSION
#define PACKAGE_VERSION SMALL_VERSION;
-#endif
+#endif // HAVE_CONFIG_H
#if defined __APPLE__
#define PACKAGE_OS "Mac OS X"
@@ -128,9 +128,9 @@
#define PACKAGE_OS "Windows"
#elif defined __native_client__
#define PACKAGE_OS "nacl"
-#else
+#else // OTHER
#define PACKAGE_OS "Other"
-#endif
+#endif // defined __APPLE__
// define DEBUG_LEAKS 1
// define DEBUG_CONFIG 1
@@ -141,16 +141,16 @@
#ifdef USE_SDL2
#define SDL_NAME "SDL2"
-#else
+#else // USE_SDL2
#define SDL_NAME "SDL1.2"
-#endif
-#if defined(ENABLE_PUGIXML)
+#endif // USE_SDL2
+#if defined(ENABLE_PUGIXML)
#define XML_NAME "pugixml"
#elif defined(ENABLE_LIBXML)
#define XML_NAME "libxml2"
-#else
+#else // defined(ENABLE_PUGIXML)
#define XML_NAME "unknown"
-#endif
+#endif // defined(ENABLE_PUGIXML)
#define PACKAGE_EXTENDED_VERSION "ManaPlus (" PACKAGE_OS \
"; %s; " SDL_NAME ", " XML_NAME "; 4144 v" SMALL_VERSION ")"
@@ -162,15 +162,15 @@
#ifdef ANDROID
#ifdef PKG_DATADIR
#undef PKG_DATADIR
-#endif
+#endif // PKG_DATADIR
#ifdef LOCALEDIR
#undef LOCALEDIR
-#endif
+#endif // LOCALEDIR
#define LOCALEDIR "locale"
-#endif
+#endif // ANDROID
#ifndef PKG_DATADIR
#define PKG_DATADIR ""
-#endif
+#endif // PKG_DATADIR
#endif // MAIN_H
diff --git a/src/maingui.cpp b/src/maingui.cpp
index 528ccf3a9..f3602feb7 100644
--- a/src/maingui.cpp
+++ b/src/maingui.cpp
@@ -30,7 +30,7 @@
#ifdef ANDROID
#include "utils/mkdir.h"
#include "utils/paths.h"
-#endif
+#endif // ANDROID
#include "utils/physfscheckutils.h"
#include "utils/physfsrwops.h"
#include "utils/process.h"
@@ -38,7 +38,7 @@
#ifdef __MINGW32__
#include <windows.h>
-#endif
+#endif // __MINGW32__
#include <iostream>
@@ -47,7 +47,7 @@
#ifndef SDL_VERSIONNUM
#error missing <SDL_version.h>
-#endif
+#endif // SDL_VERSIONNUM
#define SDL_IMAGE_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, \
@@ -70,15 +70,16 @@ char *selfName = nullptr;
#ifndef UNITTESTS
#ifdef ANDROID
int main(int argc, char *argv[])
-#else
+#else // ANDROID
+
int mainGui(int argc, char *argv[])
-#endif
+#endif // ANDROID
{
#if defined(__MINGW32__)
// load mingw crash handler. Won't fail if dll is not present.
// may load libray from current dir, it may not same as program dir
LoadLibrary("exchndl.dll");
-#endif
+#endif // defined(__MINGW32__)
selfName = argv[0];
@@ -88,20 +89,21 @@ int mainGui(int argc, char *argv[])
#ifdef ANDROID
mkdir_r(getSdStoragePath().c_str());
-#endif
+#endif // ANDROID
PhysFs::init(argv[0]);
XML::initXML();
#if SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
IMG_Init(IMG_INIT_PNG);
-#endif
+#endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
#if SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
Mix_Init(MIX_INIT_OGG);
-#endif
+#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
#ifdef WIN32
SetCurrentDirectory(PhysFs::getBaseDir());
-#endif
+#endif // WIN32
+
setPriority(true);
client = new Client;
int ret = 0;
@@ -119,17 +121,18 @@ int mainGui(int argc, char *argv[])
#if SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
Mix_Quit();
-#endif
+#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
#if SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
IMG_Quit();
-#endif
+#endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
#ifdef DUMP_LEAKED_RESOURCES
reportRWops();
-#endif
+#endif // DUMP_LEAKED_RESOURCES
#ifdef DEBUG_PHYSFS
reportPhysfsLeaks();
-#endif
+#endif // DEBUG_PHYSFS
+
return ret;
}
-#endif
+#endif // UNITTESTS
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
index c55f3dd26..2e6241b50 100644
--- a/src/mumblemanager.cpp
+++ b/src/mumblemanager.cpp
@@ -18,7 +18,7 @@
#ifdef __OpenBSD__
#include <sys/param.h>
-#endif
+#endif // __OpenBSD__
#include <wchar.h>
#include <cctype>
@@ -30,13 +30,13 @@
#ifndef WIN32
#include <sys/mman.h>
-#endif
+#endif // WIN32
#include "debug.h"
#ifdef USE_MUMBLE
MumbleManager *mumbleManager = nullptr;
-#endif
+#endif // USE_MUMBLE
MumbleManager::MumbleManager() :
mLinkedMem(nullptr),
@@ -53,9 +53,11 @@ MumbleManager::~MumbleManager()
#ifdef WIN32
UnmapViewOfFile(mLinkedMem);
#elif defined BSD4_4
-#else
+#else // WIN32
+
munmap(mLinkedMem, sizeof(struct LinkedMem));
-#endif
+#endif // WIN32
+
mLinkedMem = nullptr;
}
}
@@ -88,7 +90,8 @@ void MumbleManager::init()
{
#if defined BSD4_4
return;
-#endif
+#endif // defined BSD4_4
+
if (mLinkedMem || !config.getBoolValue("enableMumble"))
return;
@@ -113,7 +116,8 @@ void MumbleManager::init()
return;
}
#elif defined BSD4_4
-#else
+#else // WIN32
+
char memName[256];
snprintf(memName, sizeof(memName), "/MumbleLink.%u", getuid());
@@ -137,7 +141,8 @@ void MumbleManager::init()
return;
}
-#endif
+#endif // WIN32
+
wcsncpy(mLinkedMemCache.name, L"ManaPlus", 256);
wcsncpy(mLinkedMemCache.description, L"ManaPlus Plugin", 2048);
mLinkedMemCache.uiVersion = 2;
@@ -292,4 +297,4 @@ void MumbleManager::setServer(const std::string &serverName)
memcpy(mLinkedMem, &mLinkedMemCache, sizeof(mLinkedMemCache));
}
-#endif
+#endif // USE_MUMBLE
diff --git a/src/mumblemanager.h b/src/mumblemanager.h
index 883063774..ec45d011e 100644
--- a/src/mumblemanager.h
+++ b/src/mumblemanager.h
@@ -15,7 +15,7 @@
#include <string>
#if defined (__FreeBSD__) || (defined __DragonFly__)
#include <sys/stat.h>
-#endif
+#endif // defined (__FreeBSD__) || (defined __DragonFly__)
#include "localconsts.h"
diff --git a/src/navigationmanager.cpp b/src/navigationmanager.cpp
index 9d7ec7083..612061afc 100644
--- a/src/navigationmanager.cpp
+++ b/src/navigationmanager.cpp
@@ -47,7 +47,7 @@ namespace
int y;
};
} // namespace
-#endif
+#endif // DYECMD
NavigationManager::NavigationManager()
{
@@ -172,4 +172,4 @@ bool NavigationManager::findWalkableTile(int &x1, int &y1,
}
return false;
}
-#endif
+#endif // DYECMD
diff --git a/src/navigationmanager.h b/src/navigationmanager.h
index cf5e31e5d..bea22a9f3 100644
--- a/src/navigationmanager.h
+++ b/src/navigationmanager.h
@@ -39,7 +39,7 @@ class NavigationManager final
#ifndef DYECMD
static Resource *loadWalkLayer(const Map *const map);
-#endif
+#endif // DYECMD
private:
#ifndef DYECMD
@@ -55,7 +55,7 @@ class NavigationManager final
const int num,
const MetaTile *const tiles,
int *const data) A_NONNULL(6, 7);
-#endif
+#endif // DYECMD
};
#endif // NAVIGATIONMANAGER_H
diff --git a/src/net/download.cpp b/src/net/download.cpp
index b92385076..3844cc01f 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -38,7 +38,7 @@
#if defined __native_client__
#include "utils/files.h"
-#endif
+#endif // defined __native_client__
#include <sstream>
@@ -530,7 +530,8 @@ void Download::addProxy(CURL *const curl)
case 3: // HTTP 1.0
#if CURLVERSION_ATLEAST(7, 19, 4)
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP_1_0);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 19, 4)
+
break;
case 4: // SOCKS4
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
@@ -538,20 +539,24 @@ void Download::addProxy(CURL *const curl)
case 5: // SOCKS4A
#if CURLVERSION_ATLEAST(7, 18, 0)
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
-#else
+#else // CURLVERSION_ATLEAST(7, 18, 0)
+
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 18, 0)
+
break;
case 6: // SOCKS5
#if CURLVERSION_ATLEAST(7, 18, 0)
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 18, 0)
+
break;
case 7: // SOCKS5 hostname
#if CURLVERSION_ATLEAST(7, 18, 0)
curl_easy_setopt(curl, CURLOPT_PROXYTYPE,
CURLPROXY_SOCKS5_HOSTNAME);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 18, 0)
+
break;
}
}
@@ -563,13 +568,13 @@ void Download::secureCurl(CURL *const curl)
CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
CURLPROTO_HTTP | CURLPROTO_HTTPS);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 19, 4)
#if CURLVERSION_ATLEAST(7, 21, 0)
curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 0);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 21, 0)
#if CURLVERSION_ATLEAST(7, 15, 1)
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3);
-#endif
+#endif // CURLVERSION_ATLEAST(7, 15, 1)
}
#if CURLVERSION_ATLEAST(7, 21, 7)
@@ -577,11 +582,12 @@ void Download::addHeaders(CURL *const curl)
{
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
}
-#else
+#else // CURLVERSION_ATLEAST(7, 21, 7)
+
void Download::addHeaders(CURL *const curl A_UNUSED)
{
}
-#endif
+#endif // CURLVERSION_ATLEAST(7, 21, 7)
void Download::prepareForm(curl_httppost **form, const std::string &fileName)
{
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index 15a45fde0..571fa2ebb 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -37,7 +37,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
extern unsigned int mLastHost;
@@ -353,10 +353,11 @@ uint16_t Network::readWord(const int pos) const
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return SDL_Swap16(*reinterpret_cast<uint16_t*>(
mInBuffer + CAST_SIZE(pos)));
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
return (*reinterpret_cast<uint16_t*>(
mInBuffer + CAST_SIZE(pos)));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
void Network::fixSendBuffer()
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
index 3f5149ef9..b32db3060 100644
--- a/src/net/eathena/messagein.cpp
+++ b/src/net/eathena/messagein.cpp
@@ -35,7 +35,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
namespace EAthena
{
@@ -60,7 +60,8 @@ void MessageIn::postInit(const char *const str,
const std::string verStr = toString(mVersion);
DEBUGLOG2("Version", 0, verStr.c_str());
}
-#endif
+#endif // ENABLEDEBUGLOG
+
readInt16(str);
}
@@ -73,9 +74,10 @@ uint16_t MessageIn::readId() const
int16_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
value = SDL_Swap16(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
return value;
}
@@ -89,9 +91,10 @@ int16_t MessageIn::readInt16(const char *const str)
int16_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
value = SDL_Swap16(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readInt16: " + toStringPrint(CAST_U32(
CAST_U16(value))),
@@ -110,9 +113,10 @@ uint16_t MessageIn::readUInt16(const char *const str)
uint16_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t));
value = SDL_Swap16(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32(
CAST_U16(value))),
@@ -131,9 +135,10 @@ int32_t MessageIn::readInt32(const char *const str)
int32_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t));
value = SDL_Swap32(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)),
mPos, str);
@@ -156,9 +161,10 @@ int64_t MessageIn::readInt64(const char *const str)
int64_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t));
value = SDL_Swap64(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readInt64: " + toStringPrint(CAST_U32(value)),
mPos, str);
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 83fc381c5..6cbcba027 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -32,7 +32,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
namespace EAthena
{
@@ -57,9 +57,11 @@ void MessageOut::writeInt16(const int16_t value, const char *const str)
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int16_t swap = SDL_Swap16(value);
memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t));
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32(
CAST_U16(value))),
mPos, str);
@@ -75,9 +77,11 @@ void MessageOut::writeInt32(const int32_t value, const char *const str)
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int32_t swap = SDL_Swap32(value);
memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t));
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
mPos += 4;
PacketCounters::incOutBytes(4);
}
diff --git a/src/net/ipc.cpp b/src/net/ipc.cpp
index 088bd3b81..cc1ad7ad1 100644
--- a/src/net/ipc.cpp
+++ b/src/net/ipc.cpp
@@ -197,7 +197,8 @@ void IPC::flush()
chatWindow->chatInput(*it);
}
}
-#endif
+#endif // DYECMD
+
mDelayedCommands.clear();
SDL_mutexV(mMutex);
}
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 8c2e32a75..60b4f9793 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -322,7 +322,7 @@ unsigned char *MessageIn::readBytes(int length, const char *const dstr)
if (dstr)
logger->dlog(dstr);
logger->dlog("ReadBytes: " + str);
-#endif
+#endif // ENABLEDEBUGLOG
PacketCounters::incInBytes(length);
return buf;
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 9b6be857a..007b4a83c 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -28,7 +28,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/generalhandler.h"
-#endif
+#endif // TMWA_SUPPORT
#include "net/eathena/generalhandler.h"
@@ -133,9 +133,11 @@ void connectToServer(const ServerInfo &server)
default:
#ifdef TMWA_SUPPORT
new TmwAthena::GeneralHandler;
-#else
+#else // TMWA_SUPPORT
+
new EAthena::GeneralHandler;
-#endif
+#endif // TMWA_SUPPORT
+
break;
}
diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp
index bea2d0e11..3337cd260 100644
--- a/src/net/sdltcpnet.cpp
+++ b/src/net/sdltcpnet.cpp
@@ -28,7 +28,7 @@
#include <netinet/in.h>
#include <netdb.h>
#include <linux/tcp.h>
-#else
+#else // defined(M_TCPOK) && !defined(ANDROID)
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
@@ -37,9 +37,9 @@
#define TCP_THIN_LINEAR_TIMEOUTS 16
// Fast retrans. after 1 dupack
#define TCP_THIN_DUPACK 17
-#endif
+#endif // defined(M_TCPOK) && !defined(ANDROID)
-#endif
+#endif // defined __linux__ || defined __linux
PRAGMACLANG6(GCC diagnostic push)
PRAGMACLANG6(GCC diagnostic ignored "-Wold-style-cast")
@@ -60,7 +60,9 @@ struct TCPsocketHack final
IPaddress localAddress;
int sflag;
};
-#endif
+#endif // !defined(__native_client__)
+ // && (defined(TCP_THIN_LINEAR_TIMEOUTS)
+ // || defined(TCP_THIN_DUPACK))
void TcpNet::init()
{
@@ -118,18 +120,20 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip)
{
logger->log_r("error on set TCP_THIN_LINEAR_TIMEOUTS");
}
-#endif
+#endif // TCP_THIN_LINEAR_TIMEOUTS
#ifdef TCP_THIN_DUPACK
if (setsockopt(hack->channel, IPPROTO_TCP,
TCP_THIN_DUPACK, &val, sizeof(val)))
{
logger->log_r("error on set TCP_THIN_DUPACK");
}
-#endif
+#endif // TCP_THIN_DUPACK
}
}
}
-#endif
+#endif // !defined(__native_client__)
+ // && (defined(TCP_THIN_LINEAR_TIMEOUTS)
+ // || defined(TCP_THIN_DUPACK))
return sock;
}
diff --git a/src/net/sdltcpnet.h b/src/net/sdltcpnet.h
index 37b78e146..a43220371 100644
--- a/src/net/sdltcpnet.h
+++ b/src/net/sdltcpnet.h
@@ -24,12 +24,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
_SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#include <SDL_net.h>
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 1e87f88f8..033bf4ad6 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -67,9 +67,9 @@ class ServerInfo final
updateHosts(),
#ifdef TMWA_SUPPORT
port(6901),
-#else
+#else // TMWA_SUPPORT
port(6900),
-#endif
+#endif // TMWA_SUPPORT
version(),
packetVersion(),
save(false),
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
index ffea1ee4e..219466187 100644
--- a/src/net/tmwa/messagein.cpp
+++ b/src/net/tmwa/messagein.cpp
@@ -35,7 +35,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
namespace TmwAthena
{
@@ -64,9 +64,10 @@ uint16_t MessageIn::readId() const
int16_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
value = SDL_Swap16(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
return value;
}
@@ -80,9 +81,10 @@ int16_t MessageIn::readInt16(const char *const str)
int16_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
value = SDL_Swap16(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readInt16: " + toStringPrint(CAST_U32(
CAST_U16(value))),
@@ -101,9 +103,10 @@ uint16_t MessageIn::readUInt16(const char *const str)
uint16_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t));
value = SDL_Swap16(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32(
CAST_U16(value))),
@@ -122,9 +125,10 @@ int32_t MessageIn::readInt32(const char *const str)
int32_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t));
value = SDL_Swap32(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)),
mPos, str);
@@ -147,9 +151,10 @@ int64_t MessageIn::readInt64(const char *const str)
int64_t swap;
memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t));
value = SDL_Swap64(swap);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
DEBUGLOG2("readInt64: " + toStringPrint(CAST_U32(value)),
mPos, str);
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 237d4f185..e0e7ffdb2 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -32,7 +32,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
namespace TmwAthena
{
@@ -60,9 +60,11 @@ void MessageOut::writeInt16(const int16_t value, const char *const str)
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int16_t swap = SDL_Swap16(value);
memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t));
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
mPos += 2;
PacketCounters::incOutBytes(2);
}
@@ -75,9 +77,11 @@ void MessageOut::writeInt32(const int32_t value, const char *const str)
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int32_t swap = SDL_Swap32(value);
memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t));
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t));
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
mPos += 4;
PacketCounters::incOutBytes(4);
}
diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp
index 1cbd755ff..fcd432ec0 100644
--- a/src/notifymanager.cpp
+++ b/src/notifymanager.cpp
@@ -29,7 +29,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "resources/notifications.h"
@@ -51,9 +51,9 @@ namespace NotifyManager
return guildHandler->getTab();
else if (guildManager)
return guildManager->getTab();
-#else
+#else // TMWA_SUPPORT
return guildHandler->getTab();
-#endif
+#endif // TMWA_SUPPORT
}
return nullptr;
}
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 59524d300..931ac41f7 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -68,11 +68,11 @@
#ifdef USE_OPENGL
#include "configuration.h"
#include "graphicsmanager.h"
-#endif
+#endif // USE_OPENGL
#if defined(USE_OPENGL) && defined(USE_X11)
#include "render/openglx/mglxinit.h"
-#endif
+#endif // defined(USE_OPENGL) && defined(USE_X11)
#ifdef USE_OPENGL
#include "resources/openglimagehelper.h"
@@ -102,8 +102,8 @@ RENDER_OPENGL_MGLDEFINES_H
#ifdef USE_OPENGL
#ifndef GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
#define GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
-#endif
-#endif
+#endif // GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
+#endif // USE_OPENGL
Graphics *mainGraphics A_NONNULLPOINTER = nullptr;
@@ -116,10 +116,10 @@ Graphics::Graphics() :
mWindow(nullptr),
#ifdef USE_SDL2
mRenderer(nullptr),
-#endif
+#endif // USE_SDL2
#ifdef USE_OPENGL
mGLContext(nullptr),
-#endif
+#endif // USE_OPENGL
mBpp(0),
mAlpha(false),
mFullscreen(false),
@@ -158,8 +158,8 @@ Graphics::~Graphics()
SDL_GL_DeleteContext(mGLContext);
mGLContext = nullptr;
}
-#endif
-#endif
+#endif // USE_OPENGL
+#endif // USE_SDL2
}
void Graphics::setSync(const bool sync) restrict2
@@ -233,7 +233,8 @@ int Graphics::getOpenGLFlags() const restrict2
int displayFlags = SDL_WINDOW_OPENGL;
if (mFullscreen)
displayFlags |= SDL_WINDOW_FULLSCREEN;
-#else
+#else // USE_SDL2
+
int displayFlags = SDL_ANYFORMAT | SDL_OPENGL;
#endif // USE_SDL2
@@ -248,14 +249,15 @@ int Graphics::getOpenGLFlags() const restrict2
#if !defined(_WIN32)
if (mEnableResize)
displayFlags |= SDL_RESIZABLE;
-#endif
+#endif // !defined(_WIN32)
}
if (mNoFrame)
displayFlags |= SDL_NOFRAME;
return displayFlags;
-#else
+#else // USE_OPENGL
+
return 0;
#endif // USE_OPENGL
}
@@ -276,10 +278,10 @@ bool Graphics::setOpenGLMode() restrict2
#if defined(USE_X11)
Glx::initFunctions();
-#endif
+#endif // defined(USE_X11)
#ifdef __native_client__
NaclGles::initGles();
-#endif
+#endif // __native_client__
#ifdef USE_SDL2
int w1 = 0;
@@ -303,7 +305,7 @@ bool Graphics::setOpenGLMode() restrict2
const GLint VBL = 1;
CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL);
}
-#endif
+#endif // __APPLE__
graphicsManager.setGLVersion();
graphicsManager.logVersion();
@@ -344,7 +346,7 @@ bool Graphics::setOpenGLMode() restrict2
#ifndef ANDROID
SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_RECTANGLE_ARB;
SafeOpenGLImageHelper::mTextureSize = texSize;
-#endif
+#endif // ANDROID
}
else
{
@@ -354,7 +356,8 @@ bool Graphics::setOpenGLMode() restrict2
#ifndef ANDROID
SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_2D;
SafeOpenGLImageHelper::mTextureSize = texSize;
-#endif
+#endif // ANDROID
+
logger->log("OpenGL texture size: %d pixels",
OpenGLImageHelper::mTextureSize);
}
@@ -369,14 +372,15 @@ int Graphics::getSoftwareFlags() const restrict2
{
#ifdef USE_SDL2
int displayFlags = SDL_WINDOW_SHOWN;
-#else
+#else // USE_SDL2
+
int displayFlags = SDL_ANYFORMAT;
if (mHWAccel)
displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
else
displayFlags |= SDL_SWSURFACE;
-#endif
+#endif // USE_SDL2
if (mFullscreen)
displayFlags |= SDL_FULLSCREEN;
@@ -393,9 +397,9 @@ void Graphics::createGLContext(const bool custom A_UNUSED) restrict2
{
#ifdef USE_SDL2
mGLContext = SDL_GL_CreateContext(mWindow);
-#endif
+#endif // USE_SDL2
}
-#endif
+#endif // USE_OPENGL
void Graphics::updateMemoryInfo() restrict2
{
@@ -409,7 +413,7 @@ void Graphics::updateMemoryInfo() restrict2
&mStartFreeMem);
logger->log("free video memory: %d", mStartFreeMem);
}
-#endif
+#endif // USE_OPENGL
}
int Graphics::getMemoryUsage() const restrict2
@@ -425,7 +429,7 @@ int Graphics::getMemoryUsage() const restrict2
&val);
return mStartFreeMem - val;
}
-#endif
+#endif // USE_OPENGL
return 0;
}
@@ -445,7 +449,7 @@ void Graphics::dumpRendererInfo(const char *restrict const str,
if (info.flags & SDL_RENDERER_TARGETTEXTURE)
logger->log(" texture target");
}
-#endif
+#endif // USE_SDL2
bool Graphics::videoInfo() restrict2
{
@@ -467,7 +471,8 @@ bool Graphics::videoInfo() restrict2
dumpRendererInfo("renderer name: %s", info);
}
}
-#else
+#else // USE_SDL2
+
char videoDriverName[65];
if (SDL_VideoDriverName(videoDriverName, 64))
logger->log("Using video driver: %s", videoDriverName);
@@ -500,7 +505,7 @@ bool Graphics::videoInfo() restrict2
((vi->blit_sw_A) ? "yes" : "no"));
logger->log("Accelerated color fills: %s",
((vi->blit_fill) ? "yes" : "no"));
-#endif
+#endif // USE_SDL2
return true;
}
@@ -614,12 +619,12 @@ void Graphics::setWindowSize(const int width,
{
SDL_SetWindowSize(mWindow, width, height);
}
-#else
+#else // USE_SDL2
void Graphics::setWindowSize(const int width A_UNUSED,
const int height A_UNUSED) restrict2
{
}
-#endif
+#endif // USE_SDL2
void Graphics::pushClipArea(const Rect &restrict area) restrict2
{
@@ -713,10 +718,11 @@ void Graphics::setOpenGLFlags() restrict2
#ifndef ANDROID
#ifndef __MINGW32__
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST);
-#endif
-#endif
+#endif // __MINGW32__
+#endif // ANDROID
+
glHint(GL_TEXTURE_COMPRESSION_HINT_ARB, GL_FASTEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 997ed2196..b2e38367d 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -86,10 +86,10 @@
#ifdef USE_SDL2
#define RectPos int32_t
#define RectSize int32_t
-#else
+#else // USE_SDL2
#define RectPos int16_t
#define RectSize uint16_t
-#endif
+#endif // USE_SDL2
class Image;
class ImageCollection;
@@ -106,7 +106,8 @@ class Graphics notfinal
public:
#ifdef USE_OPENGL
friend class OpenGLScreenshotHelper;
-#endif
+#endif // USE_SDL2
+
friend class SdlScreenshotHelper;
A_DELETE_COPY(Graphics)
@@ -250,9 +251,9 @@ class Graphics notfinal
void setWindowSize(const int width,
#ifdef USE_SDL2
const int height) restrict2;
-#else
+#else // USE_SDL2
const int height) restrict2 A_CONST;
-#endif
+#endif // USE_SDL2
/**
* Returns the width of the screen.
@@ -321,18 +322,18 @@ class Graphics notfinal
#ifdef DEBUG_DRAW_CALLS
virtual unsigned int getDrawCalls() const restrict2
{ return 0; }
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
virtual unsigned int getBinds() const restrict2
{ return 0; }
-#endif
+#endif // DEBUG_BIND_TEXTURE
#ifdef USE_SDL2
void dumpRendererInfo(const char *restrict const str,
const SDL_RendererInfo &restrict info) restrict2;
virtual void setRendererFlags(const uint32_t flags A_UNUSED) restrict2
{ }
-#endif
+#endif // USE_SDL2
/**
* Blits an image onto the screen.
@@ -405,10 +406,11 @@ class Graphics notfinal
#ifdef USE_OPENGL
#ifdef USE_SDL2
virtual void createGLContext(const bool custom) restrict2;
-#else
+#else // USE_SDL2
+
virtual void createGLContext(const bool custom) restrict2 A_CONST;
-#endif
-#endif
+#endif // USE_SDL2
+#endif // USE_OPENGL
/**
* Draws a single point/pixel.
@@ -503,7 +505,8 @@ class Graphics notfinal
#ifdef USE_OPENGL
void setOpenGLFlags() restrict2;
-#endif
+#endif // USE_OPENGL
+
/**
* Holds the clip area stack.
*/
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
index 576bc67ab..574e16a40 100644
--- a/src/render/mobileopengl2graphics.cpp
+++ b/src/render/mobileopengl2graphics.cpp
@@ -29,7 +29,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "render/shaders/shaderprogram.h"
#include "render/shaders/shadersmanager.h"
@@ -85,7 +85,7 @@ int MobileOpenGL2Graphics::mTextureHeight = 1;
#ifdef DEBUG_DRAW_CALLS
unsigned int MobileOpenGL2Graphics::mDrawCalls = 0U;
unsigned int MobileOpenGL2Graphics::mLastDrawCalls = 0U;
-#endif
+#endif // DEBUG_DRAW_CALLS
MobileOpenGL2Graphics::MobileOpenGL2Graphics() :
mFloatArray(nullptr),
@@ -103,7 +103,7 @@ MobileOpenGL2Graphics::MobileOpenGL2Graphics() :
mDrawTypeUniform(0U),
#ifndef __native_client__
mVao(0U),
-#endif
+#endif // __native_client__
mVbo(0U),
mVboBinded(0U),
mAttributesBinded(0U),
@@ -112,7 +112,7 @@ MobileOpenGL2Graphics::MobileOpenGL2Graphics() :
#ifdef DEBUG_BIND_TEXTURE
mOldTexture(),
mOldTextureId(0),
-#endif
+#endif // DEBUG_BIND_TEXTURE
mFbo()
{
mOpenGL = RENDER_GLES2_OPENGL;
@@ -133,7 +133,7 @@ void MobileOpenGL2Graphics::deleteGLObjects() restrict2
#ifndef __native_client__
if (mVao)
mglDeleteVertexArrays(1, &mVao);
-#endif
+#endif // __native_client__
}
void MobileOpenGL2Graphics::initArrays(const int vertCount) restrict2
@@ -158,7 +158,7 @@ void MobileOpenGL2Graphics::postInit() restrict2
#ifndef __native_client__
mglGenVertexArrays(1, &mVao);
mglBindVertexArray(mVao);
-#endif
+#endif // __native_client__
mglGenBuffers(1, &mVbo);
// logger->log("gen vbo buffer: %u", mVbo);
bindArrayBuffer(mVbo);
@@ -287,7 +287,7 @@ void MobileOpenGL2Graphics::drawQuad(const int srcX,
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -318,7 +318,7 @@ void MobileOpenGL2Graphics::drawRescaledQuad(const int srcX, const int srcY,
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -337,7 +337,7 @@ void MobileOpenGL2Graphics::drawImageInline(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
setTexturingAndBlending(true);
bindArrayBufferAndAttributes(mVbo);
@@ -375,7 +375,7 @@ void MobileOpenGL2Graphics::testDraw() restrict2
// vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
}
@@ -422,7 +422,7 @@ void MobileOpenGL2Graphics::drawRescaledImage(const Image *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
setTexturingAndBlending(true);
bindArrayBufferAndAttributes(mVbo);
@@ -472,7 +472,7 @@ void MobileOpenGL2Graphics::drawPatternInline(const Image *
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
setTexturingAndBlending(true);
@@ -536,7 +536,7 @@ void MobileOpenGL2Graphics::drawRescaledPattern(const Image *
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
setTexturingAndBlending(true);
@@ -601,7 +601,7 @@ inline void MobileOpenGL2Graphics::drawVertexes(const
bindArrayBufferAndAttributes(*ivbo);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLES, 0, *ivp / 4);
}
}
@@ -718,7 +718,7 @@ void MobileOpenGL2Graphics::drawTileCollection(const ImageCollection
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
drawVertexes(vert->ogl);
}
@@ -819,7 +819,7 @@ void MobileOpenGL2Graphics::drawTileVertexes(const ImageVertexes *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
setTexturingAndBlending(true);
bindArrayBufferAndAttributes(mVbo);
@@ -858,16 +858,16 @@ void MobileOpenGL2Graphics::updateScreen() restrict2
#ifdef DEBUG_DRAW_CALLS
mLastDrawCalls = mDrawCalls;
mDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef USE_SDL2
SDL_GL_SwapWindow(mWindow);
-#else
+#else // USE_SDL2
SDL_GL_SwapBuffers();
-#endif
+#endif // USE_SDL2
#ifdef DEBUG_OPENGL
if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
-#endif
+#endif // DEBUG_OPENGL
BLOCK_END("Graphics::updateScreen")
}
@@ -877,7 +877,7 @@ void MobileOpenGL2Graphics::beginDraw() restrict2
#ifndef __native_client__
mglDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
mglHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, GL_FASTEST);
-#endif
+#endif // __native_client__
pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
@@ -925,7 +925,7 @@ void MobileOpenGL2Graphics::drawPoint(int x, int y) restrict2
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_POINTS, 0, 1);
}
@@ -944,7 +944,7 @@ void MobileOpenGL2Graphics::drawLine(int x1, int y1,
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_LINES, 0, 2);
}
@@ -969,7 +969,7 @@ void MobileOpenGL2Graphics::drawRectangle(const Rect &restrict rect) restrict2
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_LINE_LOOP, 0, 4);
}
@@ -994,7 +994,7 @@ void MobileOpenGL2Graphics::fillRectangle(const Rect &restrict rect) restrict2
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -1291,7 +1291,7 @@ void MobileOpenGL2Graphics::drawTriangleArray(const int size) restrict2
mFloatArray, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLES, 0, size / 4);
}
@@ -1303,7 +1303,7 @@ void MobileOpenGL2Graphics::drawTriangleArray(const GLfloat *restrict const
array, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLES, 0, size / 4);
}
@@ -1313,7 +1313,7 @@ void MobileOpenGL2Graphics::drawLineArrays(const int size) restrict2
mFloatArray, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_LINES, 0, size / 4);
}
@@ -1334,11 +1334,11 @@ void MobileOpenGL2Graphics::debugBindTexture(const Image *restrict const image)
mOldTexture = texture;
}
}
-#else
+#else // DEBUG_BIND_TEXTURE
void MobileOpenGL2Graphics::debugBindTexture(const Image *restrict const
image A_UNUSED) restrict2
{
}
-#endif
+#endif // DEBUG_BIND_TEXTURE
#endif // USE_OPENGL
diff --git a/src/render/mobileopengl2graphics.h b/src/render/mobileopengl2graphics.h
index 2efa367c4..217e86609 100644
--- a/src/render/mobileopengl2graphics.h
+++ b/src/render/mobileopengl2graphics.h
@@ -142,7 +142,8 @@ class MobileOpenGL2Graphics final : public Graphics
GLuint mDrawTypeUniform;
#ifndef __native_client__
GLuint mVao;
-#endif
+#endif // __native_client__
+
GLuint mVbo;
GLuint mVboBinded;
GLuint mAttributesBinded;
@@ -151,7 +152,8 @@ class MobileOpenGL2Graphics final : public Graphics
#ifdef DEBUG_BIND_TEXTURE
std::string mOldTexture;
unsigned mOldTextureId;
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
FBOInfo mFbo;
};
#endif // defined(USE_OPENGL) && !defined(ANDROID)
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 83d57e33b..77e89c447 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -27,7 +27,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "render/vertexes/imagecollection.h"
@@ -70,7 +70,7 @@ GLuint MobileOpenGLGraphics::mTextureBinded = 0;
#ifdef DEBUG_DRAW_CALLS
unsigned int MobileOpenGLGraphics::mDrawCalls = 0;
unsigned int MobileOpenGLGraphics::mLastDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
MobileOpenGLGraphics::MobileOpenGLGraphics() :
mFloatTexArray(nullptr),
@@ -89,7 +89,7 @@ MobileOpenGLGraphics::MobileOpenGLGraphics() :
#ifdef DEBUG_BIND_TEXTURE
mOldTexture(),
mOldTextureId(0),
-#endif
+#endif // DEBUG_BIND_TEXTURE
mFbo()
{
mOpenGL = RENDER_GLES_OPENGL;
@@ -205,7 +205,7 @@ static inline void drawQuad(const Image *restrict const image,
#ifdef DEBUG_DRAW_CALLS
MobileOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
}
@@ -258,7 +258,7 @@ static inline void drawRescaledQuad(const Image *restrict const image,
#ifdef DEBUG_DRAW_CALLS
MobileOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
}
@@ -279,7 +279,7 @@ void MobileOpenGLGraphics::drawImageInline(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -415,7 +415,7 @@ void MobileOpenGLGraphics::completeCache() restrict2
setColorAlpha(mAlphaCached);
#ifdef DEBUG_BIND_TEXTURE
// debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, mImageCached);
setTexturingAndBlending(true);
@@ -445,7 +445,7 @@ void MobileOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -487,7 +487,7 @@ void MobileOpenGLGraphics::drawPatternInline(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -552,7 +552,7 @@ void MobileOpenGLGraphics::drawRescaledPattern(const Image *
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -745,7 +745,7 @@ void MobileOpenGLGraphics::drawTileCollection(const ImageCollection *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
drawVertexes(vert->ogl);
@@ -848,7 +848,7 @@ void MobileOpenGLGraphics::drawTileVertexes(const ImageVertexes *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
drawVertexes(vert->ogl);
@@ -888,16 +888,18 @@ void MobileOpenGLGraphics::updateScreen() restrict2
#ifdef DEBUG_DRAW_CALLS
mLastDrawCalls = mDrawCalls;
mDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef USE_SDL2
SDL_GL_SwapWindow(mWindow);
-#else
+#else // USE_SDL2
+
SDL_GL_SwapBuffers();
-#endif
+#endif // USE_SDL2
#ifdef DEBUG_OPENGL
if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
-#endif
+#endif // DEBUG_OPENGL
+
BLOCK_END("Graphics::updateScreen")
}
@@ -913,11 +915,12 @@ void MobileOpenGLGraphics::beginDraw() restrict2
glOrthof(0.0, static_cast<float>(mRect.w),
static_cast<float>(mRect.h),
0.0, -1.0, 1.0);
-#else
+#else // ANDROID
+
glOrtho(0.0, static_cast<double>(mRect.w),
static_cast<double>(mRect.h),
0.0, -1.0, 1.0);
-#endif
+#endif // ANDROID
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -937,7 +940,7 @@ void MobileOpenGLGraphics::beginDraw() restrict2
mglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
mglHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
mglHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
-#endif
+#endif // ANDROID
pushClipArea(Rect(0, 0, mRect.w, mRect.h));
}
@@ -1006,20 +1009,21 @@ void MobileOpenGLGraphics::popClipArea() restrict2
#ifdef ANDROID
void MobileOpenGLGraphics::drawPoint(int x A_UNUSED, int y A_UNUSED) restrict2
-#else
+#else // ANDROID
void MobileOpenGLGraphics::drawPoint(int x, int y) restrict2
-#endif
+#endif // ANDROID
{
setTexturingAndBlending(false);
restoreColor();
#ifdef ANDROID
// TODO need fix
-#else
+#else // ANDROID
+
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
-#endif
+#endif // ANDROID
}
void MobileOpenGLGraphics::drawLine(int x1, int y1,
@@ -1113,7 +1117,8 @@ void MobileOpenGLGraphics::drawRectangle(const Rect &restrict rect,
glVertexPointer(2, GL_SHORT, 0, &vert);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
else
@@ -1129,7 +1134,8 @@ void MobileOpenGLGraphics::drawRectangle(const Rect &restrict rect,
glVertexPointer(2, GL_SHORT, 0, &vert);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
mglDrawArrays(GL_LINE_LOOP, 0, 4);
}
BLOCK_END("Graphics::drawRectangle")
@@ -1205,7 +1211,8 @@ inline void MobileOpenGLGraphics::drawTriangleArrayfs(const int size) restrict2
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
mglDrawArrays(GL_TRIANGLES, 0, size / 2);
}
@@ -1217,7 +1224,8 @@ inline void MobileOpenGLGraphics::drawTriangleArrayfsCached(const int size)
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
mglDrawArrays(GL_TRIANGLES, 0, size / 2);
}
@@ -1232,7 +1240,8 @@ inline void MobileOpenGLGraphics::drawTriangleArrayfs(const GLshort *restrict
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
mglDrawArrays(GL_TRIANGLES, 0, size / 2);
}
@@ -1242,7 +1251,8 @@ inline void MobileOpenGLGraphics::drawLineArrays(const int size) restrict2
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
mglDrawArrays(GL_LINES, 0, size / 2);
}
@@ -1330,11 +1340,12 @@ void MobileOpenGLGraphics::debugBindTexture(const Image *restrict const image)
mOldTexture = texture;
}
}
-#else
+#else // DEBUG_BIND_TEXTURE
+
void MobileOpenGLGraphics::debugBindTexture(const Image *restrict const
image A_UNUSED) restrict2
{
}
-#endif
+#endif // DEBUG_BIND_TEXTURE
#endif // defined(USE_OPENGL) && !defined(__native_client__)
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index a428b138a..f472abe58 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -35,17 +35,17 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#elif !defined(__native_client__)
#include <GL/glext.h>
#endif // defined(__APPLE__)
-#endif
+#endif // ANDROID
class OpenGLGraphicsVertexes;
@@ -103,7 +103,8 @@ class MobileOpenGLGraphics final : public Graphics
#ifdef DEBUG_BIND_TEXTURE
std::string mOldTexture;
unsigned mOldTextureId;
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
FBOInfo mFbo;
};
#endif // defined(USE_OPENGL) && !defined(__native_client__)
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 1629dbea5..10f5d209a 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -29,7 +29,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "render/shaders/shaderprogram.h"
#include "render/shaders/shadersmanager.h"
@@ -82,7 +82,7 @@ GLuint ModernOpenGLGraphics::mTextureBinded = 0;
#ifdef DEBUG_DRAW_CALLS
unsigned int ModernOpenGLGraphics::mDrawCalls = 0;
unsigned int ModernOpenGLGraphics::mLastDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
ModernOpenGLGraphics::ModernOpenGLGraphics() :
mIntArray(nullptr),
@@ -109,7 +109,7 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() :
#ifdef DEBUG_BIND_TEXTURE
mOldTexture(),
mOldTextureId(0),
-#endif
+#endif // DEBUG_BIND_TEXTURE
mFbo()
{
mOpenGL = RENDER_MODERN_OPENGL;
@@ -285,7 +285,7 @@ void ModernOpenGLGraphics::drawQuad(const int srcX,
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -313,7 +313,7 @@ void ModernOpenGLGraphics::drawRescaledQuad(const int srcX, const int srcY,
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -332,7 +332,7 @@ void ModernOpenGLGraphics::drawImageInline(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(GL_TEXTURE_2D, image->mGLImage);
setTexturingAndBlending(true);
bindArrayBufferAndAttributes(mVbo);
@@ -370,7 +370,7 @@ void ModernOpenGLGraphics::testDraw() restrict2
// elements, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
}
@@ -415,7 +415,7 @@ void ModernOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
bindArrayBufferAndAttributes(mVbo);
@@ -459,7 +459,8 @@ void ModernOpenGLGraphics::drawPatternInline(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -521,7 +522,8 @@ void ModernOpenGLGraphics::drawRescaledPattern(const Image *
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -589,7 +591,7 @@ inline void ModernOpenGLGraphics::drawVertexes(const
bindArrayBufferAndAttributes(*ivbo);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
// logger->log("draw from array: %u", *ivbo);
mglDrawArrays(GL_TRIANGLES, 0, *ivp / 4);
}
@@ -708,7 +710,8 @@ void ModernOpenGLGraphics::drawTileCollection(const ImageCollection
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
drawVertexes(vert->ogl);
}
@@ -803,7 +806,8 @@ void ModernOpenGLGraphics::drawTileVertexes(const ImageVertexes *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
bindArrayBufferAndAttributes(mVbo);
@@ -842,16 +846,16 @@ void ModernOpenGLGraphics::updateScreen() restrict2
#ifdef DEBUG_DRAW_CALLS
mLastDrawCalls = mDrawCalls;
mDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef USE_SDL2
SDL_GL_SwapWindow(mWindow);
-#else
+#else // USE_SDL2
SDL_GL_SwapBuffers();
-#endif
+#endif // USE_SDL2
#ifdef DEBUG_OPENGL
if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
-#endif
+#endif // DEBUG_OPENGL
BLOCK_END("Graphics::updateScreen")
}
@@ -908,7 +912,7 @@ void ModernOpenGLGraphics::drawPoint(int x, int y) restrict2
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_POINTS, 0, 1);
}
@@ -928,7 +932,7 @@ void ModernOpenGLGraphics::drawLine(int x1, int y1,
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_LINES, 0, 2);
}
@@ -954,7 +958,7 @@ void ModernOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_LINE_LOOP, 0, 4);
}
@@ -980,7 +984,7 @@ void ModernOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
vertices, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -1298,7 +1302,7 @@ void ModernOpenGLGraphics::drawTriangleArray(const int size) restrict2
mIntArray, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLES, 0, size / 4);
}
@@ -1310,7 +1314,7 @@ void ModernOpenGLGraphics::drawTriangleArray(const GLint *restrict const array,
array, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_TRIANGLES, 0, size / 4);
}
@@ -1321,7 +1325,7 @@ void ModernOpenGLGraphics::drawLineArrays(const int size)
mIntArray, GL_STREAM_DRAW);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
mglDrawArrays(GL_LINES, 0, size / 4);
}
@@ -1342,12 +1346,12 @@ void ModernOpenGLGraphics::debugBindTexture(const Image *restrict const image)
mOldTexture = texture;
}
}
-#else
+#else // DEBUG_BIND_TEXTURE
void ModernOpenGLGraphics::debugBindTexture(const Image *restrict const
image A_UNUSED) restrict2
{
}
-#endif
+#endif // DEBUG_BIND_TEXTURE
#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
// !defined(__native_client__)
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index 53d6966c2..f81e152ad 100644
--- a/src/render/modernopenglgraphics.h
+++ b/src/render/modernopenglgraphics.h
@@ -35,17 +35,17 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#elif !defined(__native_client__)
#include <GL/glext.h>
#endif // defined(__APPLE__)
-#endif
+#endif // ANDROID
class OpenGLGraphicsVertexes;
class ShaderProgram;
@@ -146,7 +146,8 @@ class ModernOpenGLGraphics final : public Graphics
#ifdef DEBUG_BIND_TEXTURE
std::string mOldTexture;
unsigned mOldTextureId;
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
FBOInfo mFbo;
};
#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 3a2bfde49..7ca56e624 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -85,11 +85,11 @@ GLuint NormalOpenGLGraphics::mTextureBinded = 0;
#ifdef DEBUG_DRAW_CALLS
unsigned int NormalOpenGLGraphics::mDrawCalls = 0;
unsigned int NormalOpenGLGraphics::mLastDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
unsigned int NormalOpenGLGraphics::mBinds = 0;
unsigned int NormalOpenGLGraphics::mLastBinds = 0;
-#endif
+#endif // DEBUG_BIND_TEXTURE
NormalOpenGLGraphics::NormalOpenGLGraphics() :
mFloatTexArray(nullptr),
@@ -110,7 +110,7 @@ NormalOpenGLGraphics::NormalOpenGLGraphics() :
#ifdef DEBUG_BIND_TEXTURE
mOldTexture(),
mOldTextureId(0),
-#endif
+#endif // DEBUG_BIND_TEXTURE
mFbo()
{
mOpenGL = RENDER_NORMAL_OPENGL;
@@ -250,7 +250,8 @@ static inline void drawQuad(const Image *restrict const image,
bindPointerIntFloat(&vert[0], &tex[0]);
#ifdef DEBUG_DRAW_CALLS
NormalOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, 4);
}
else
@@ -273,7 +274,8 @@ static inline void drawQuad(const Image *restrict const image,
bindPointerInt(&vert[0], &tex[0]);
#ifdef DEBUG_DRAW_CALLS
NormalOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, 4);
}
}
@@ -322,7 +324,8 @@ static inline void drawRescaledQuad(const Image *restrict const image,
bindPointerIntFloat(&vert[0], &tex[0]);
#ifdef DEBUG_DRAW_CALLS
NormalOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, 4);
}
else
@@ -345,7 +348,8 @@ static inline void drawRescaledQuad(const Image *restrict const image,
bindPointerInt(&vert[0], &tex[0]);
#ifdef DEBUG_DRAW_CALLS
NormalOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, 4);
}
}
@@ -366,7 +370,8 @@ void NormalOpenGLGraphics::drawImageInline(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -404,7 +409,8 @@ void NormalOpenGLGraphics::testDraw() restrict2
bindPointerIntFloat(&vert[0], &tex[0]);
#ifdef DEBUG_DRAW_CALLS
NormalOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, 4);
}
else
@@ -428,7 +434,8 @@ void NormalOpenGLGraphics::testDraw() restrict2
bindPointerInt(&vert[0], &tex[0]);
#ifdef DEBUG_DRAW_CALLS
NormalOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, 4);
}
}
@@ -600,7 +607,8 @@ void NormalOpenGLGraphics::completeCache() restrict2
setColorAlpha(mAlphaCached);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, mImageCached);
setTexturingAndBlending(true);
@@ -634,7 +642,8 @@ void NormalOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -676,7 +685,8 @@ void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -769,7 +779,8 @@ void NormalOpenGLGraphics::drawRescaledPattern(const Image *
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -1060,7 +1071,8 @@ void NormalOpenGLGraphics::drawTileCollection(const ImageCollection
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
drawVertexes(vert->ogl);
@@ -1182,7 +1194,8 @@ void NormalOpenGLGraphics::drawTileVertexes(const ImageVertexes *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
drawVertexes(vert->ogl);
@@ -1221,20 +1234,21 @@ void NormalOpenGLGraphics::updateScreen() restrict2
#ifdef DEBUG_DRAW_CALLS
mLastDrawCalls = mDrawCalls;
mDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
#ifdef DEBUG_BIND_TEXTURE
mLastBinds = mBinds;
mBinds = 0;
-#endif
+#endif // DEBUG_BIND_TEXTURE
#ifdef USE_SDL2
SDL_GL_SwapWindow(mWindow);
-#else
+#else // USE_SDL2
SDL_GL_SwapBuffers();
-#endif
+#endif // USE_SDL2
#ifdef DEBUG_OPENGL
if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
-#endif
+#endif // DEBUG_OPENGL
+
// may be need clear?
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
BLOCK_END("Graphics::updateScreen")
@@ -1255,11 +1269,12 @@ void NormalOpenGLGraphics::beginDraw() restrict2
glOrthof(0.0, static_cast<float>(w),
static_cast<float>(h),
0.0, -1.0, 1.0);
-#else
+#else // ANDROID
+
glOrtho(0.0, static_cast<double>(w),
static_cast<double>(h),
0.0, -1.0, 1.0);
-#endif
+#endif // ANDROID
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -1281,7 +1296,7 @@ void NormalOpenGLGraphics::beginDraw() restrict2
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
-#endif
+#endif // ANDROID
pushClipArea(Rect(0, 0, w, h));
}
@@ -1355,11 +1370,12 @@ void NormalOpenGLGraphics::drawPoint(int x, int y) restrict2
#ifdef ANDROID
// TODO need fix
-#else
+#else // ANDROID
+
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
-#endif
+#endif // ANDROID
}
void NormalOpenGLGraphics::drawLine(int x1, int y1,
@@ -1450,8 +1466,9 @@ void NormalOpenGLGraphics::drawRectangle(const Rect &restrict rect,
glVertexPointer(2, GL_FLOAT, 0, &vert);
vertPtr = nullptr;
#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif
+ mDrawCalls ++;
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(filled ? GL_QUADS : GL_LINE_LOOP, 0, 4);
BLOCK_END("Graphics::drawRectangle")
}
@@ -1516,7 +1533,7 @@ void NormalOpenGLGraphics::bindTexture(const GLenum target,
glBindTexture(target, texture);
#ifdef DEBUG_BIND_TEXTURE
mBinds ++;
-#endif
+#endif // DEBUG_BIND_TEXTURE
}
}
@@ -1525,7 +1542,8 @@ inline void NormalOpenGLGraphics::drawQuadArrayfi(const int size) restrict2
bindPointerIntFloat(&mIntVertArray[0], &mFloatTexArray[0]);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1535,7 +1553,8 @@ inline void NormalOpenGLGraphics::drawQuadArrayfiCached(const int size)
bindPointerIntFloat(&mIntVertArrayCached[0], &mFloatTexArrayCached[0]);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1550,7 +1569,8 @@ inline void NormalOpenGLGraphics::drawQuadArrayfi(const GLint *restrict const
glTexCoordPointer(2, GL_FLOAT, 0, floatTexArray);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1559,7 +1579,8 @@ inline void NormalOpenGLGraphics::drawQuadArrayii(const int size) restrict2
bindPointerInt(&mIntVertArray[0], &mIntTexArray[0]);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1569,7 +1590,8 @@ inline void NormalOpenGLGraphics::drawQuadArrayiiCached(const int size)
bindPointerInt(&mIntVertArrayCached[0], &mIntTexArrayCached[0]);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1584,7 +1606,8 @@ inline void NormalOpenGLGraphics::drawQuadArrayii(const GLint *restrict const
glTexCoordPointer(2, GL_INT, 0, intTexArray);
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1594,7 +1617,8 @@ inline void NormalOpenGLGraphics::drawLineArrayi(const int size) restrict2
vertPtr = nullptr;
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_LINES, 0, size / 2);
}
@@ -1604,7 +1628,8 @@ inline void NormalOpenGLGraphics::drawLineArrayf(const int size) restrict2
vertPtr = nullptr;
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
glDrawArrays(GL_LINES, 0, size / 2);
}
@@ -1690,12 +1715,13 @@ void NormalOpenGLGraphics::debugBindTexture(const Image *restrict const image)
mOldTexture = texture;
}
}
-#else
+#else // DEBUG_BIND_TEXTURE
+
void NormalOpenGLGraphics::debugBindTexture(const Image *restrict const
image A_UNUSED) restrict2
{
}
-#endif
+#endif // DEBUG_BIND_TEXTURE
#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
// !defined(__native_client__)
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
index 187ca7d2d..170542abb 100644
--- a/src/render/normalopenglgraphics.h
+++ b/src/render/normalopenglgraphics.h
@@ -35,17 +35,17 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#elif !defined(__native_client__)
#include <GL/glext.h>
#endif // defined(__APPLE__)
-#endif
+#endif // ANDROID
class OpenGLGraphicsVertexes;
@@ -96,7 +96,7 @@ class NormalOpenGLGraphics final : public Graphics
#ifdef DEBUG_BIND_TEXTURE
unsigned int getBinds() const restrict2 noexcept2
{ return mLastBinds; }
-#endif
+#endif // DEBUG_BIND_TEXTURE
private:
GLfloat *mFloatTexArray A_NONNULLPOINTER;
@@ -120,9 +120,11 @@ class NormalOpenGLGraphics final : public Graphics
unsigned int mOldTextureId;
static unsigned int mBinds;
static unsigned int mLastBinds;
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
FBOInfo mFbo;
};
-#endif
+#endif // defined USE_OPENGL && !defined ANDROID &&
+ // !defined(__native_client__)
#endif // RENDER_NORMALOPENGLGRAPHICS_H
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index ad37f70f7..a39ce8518 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -26,7 +26,7 @@
#ifdef DEBUG_BIND_TEXTURE
#include "logger.h"
-#endif
+#endif // DEBUG_BIND_TEXTURE
#include "render/vertexes/imagecollection.h"
@@ -41,7 +41,7 @@ GLuint NullOpenGLGraphics::mTextureBinded = 0;
#ifdef DEBUG_DRAW_CALLS
unsigned int NullOpenGLGraphics::mDrawCalls = 0;
unsigned int NullOpenGLGraphics::mLastDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
NullOpenGLGraphics::NullOpenGLGraphics() :
mFloatTexArray(nullptr),
@@ -56,7 +56,7 @@ NullOpenGLGraphics::NullOpenGLGraphics() :
#ifdef DEBUG_BIND_TEXTURE
mOldTexture(),
mOldTextureId(0),
-#endif
+#endif // DEBUG_BIND_TEXTURE
mFbo()
{
mOpenGL = RENDER_NULL;
@@ -122,13 +122,13 @@ static inline void drawQuad(const Image *restrict const image A_UNUSED,
{
#ifdef DEBUG_DRAW_CALLS
NullOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
else
{
#ifdef DEBUG_DRAW_CALLS
NullOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
}
@@ -146,13 +146,13 @@ static inline void drawRescaledQuad(const Image *restrict const image A_UNUSED,
{
#ifdef DEBUG_DRAW_CALLS
NullOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
else
{
#ifdef DEBUG_DRAW_CALLS
NullOpenGLGraphics::mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
}
@@ -178,7 +178,8 @@ void NullOpenGLGraphics::drawImageInline(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -228,7 +229,8 @@ void NullOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -268,7 +270,8 @@ void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -401,7 +404,8 @@ void NullOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
@@ -748,7 +752,8 @@ void NullOpenGLGraphics::drawTileCollection(const ImageCollection
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
drawVertexes(vert->ogl);
@@ -909,7 +914,8 @@ void NullOpenGLGraphics::drawTileVertexes(const ImageVertexes *
setColorAlpha(image->mAlpha);
#ifdef DEBUG_BIND_TEXTURE
debugBindTexture(image);
-#endif
+#endif // DEBUG_BIND_TEXTURE
+
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
setTexturingAndBlending(true);
drawVertexes(vert->ogl);
@@ -946,7 +952,8 @@ void NullOpenGLGraphics::updateScreen() restrict2
#ifdef DEBUG_DRAW_CALLS
mLastDrawCalls = mDrawCalls;
mDrawCalls = 0;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
BLOCK_END("Graphics::updateScreen")
}
@@ -1049,7 +1056,8 @@ void NullOpenGLGraphics::drawRectangle(const Rect &restrict rect A_UNUSED,
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
+
BLOCK_END("Graphics::drawRectangle")
}
@@ -1116,7 +1124,7 @@ inline void NullOpenGLGraphics::drawQuadArrayfi(const int size A_UNUSED)
{
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
inline void NullOpenGLGraphics::drawQuadArrayfi(const GLint *restrict const
@@ -1128,7 +1136,7 @@ inline void NullOpenGLGraphics::drawQuadArrayfi(const GLint *restrict const
{
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
inline void NullOpenGLGraphics::drawQuadArrayii(const int size A_UNUSED)
@@ -1136,7 +1144,7 @@ inline void NullOpenGLGraphics::drawQuadArrayii(const int size A_UNUSED)
{
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
inline void NullOpenGLGraphics::drawQuadArrayii(const GLint *restrict const
@@ -1148,7 +1156,7 @@ inline void NullOpenGLGraphics::drawQuadArrayii(const GLint *restrict const
{
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
inline void NullOpenGLGraphics::drawLineArrayi(const int size A_UNUSED)
@@ -1156,7 +1164,7 @@ inline void NullOpenGLGraphics::drawLineArrayi(const int size A_UNUSED)
{
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
inline void NullOpenGLGraphics::drawLineArrayf(const int size A_UNUSED)
@@ -1164,7 +1172,7 @@ inline void NullOpenGLGraphics::drawLineArrayf(const int size A_UNUSED)
{
#ifdef DEBUG_DRAW_CALLS
mDrawCalls ++;
-#endif
+#endif // DEBUG_DRAW_CALLS
}
void NullOpenGLGraphics::dumpSettings()
@@ -1227,11 +1235,11 @@ void NullOpenGLGraphics::debugBindTexture(const Image *restrict const image)
mOldTexture = texture;
}
}
-#else
+#else // DEBUG_BIND_TEXTURE
+
void NullOpenGLGraphics::debugBindTexture(const Image *restrict const
image A_UNUSED) restrict2
{
}
-#endif
-
+#endif // DEBUG_BIND_TEXTURE
#endif // USE_OPENGL
diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h
index 920ee8fcc..62a157cd3 100644
--- a/src/render/nullopenglgraphics.h
+++ b/src/render/nullopenglgraphics.h
@@ -35,17 +35,17 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#elif !defined(__native_client__)
#include <GL/glext.h>
#endif // defined(__APPLE__)
-#endif
+#endif // ANDROID
class OpenGLGraphicsVertexes;
@@ -101,9 +101,8 @@ class NullOpenGLGraphics final : public Graphics
#ifdef DEBUG_BIND_TEXTURE
std::string mOldTexture;
unsigned mOldTextureId;
-#endif
+#endif // DEBUG_BIND_TEXTURE
FBOInfo mFbo;
};
-#endif
-
+#endif // defined USE_OPENGL
#endif // RENDER_NULLOPENGLGRAPHICS_H
diff --git a/src/render/opengl/mgl.cpp b/src/render/opengl/mgl.cpp
index cdcd5808b..11c4ca462 100644
--- a/src/render/opengl/mgl.cpp
+++ b/src/render/opengl/mgl.cpp
@@ -31,4 +31,4 @@
MGL_DEFINE
-#endif
+#endif // USE_OPENGL
diff --git a/src/render/opengl/mgldefines.h b/src/render/opengl/mgldefines.h
index 05d4bafcc..84b12da26 100644
--- a/src/render/opengl/mgldefines.h
+++ b/src/render/opengl/mgldefines.h
@@ -29,17 +29,17 @@
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
-#endif
+#endif // GL_NUM_EXTENSIONS
#ifndef GL_COMPRESSED_RGBA_ARB
#define GL_COMPRESSED_RGBA_ARB 0x84EE
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
-#endif
+#endif // GL_COMPRESSED_RGBA_ARB
#ifndef GL_MAX_ELEMENTS_VERTICES
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#endif
+#endif // GL_MAX_ELEMENTS_VERTICES
#ifndef GL_DEBUG_OUTPUT
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
@@ -61,14 +61,14 @@
#define GL_DEBUG_SEVERITY_HIGH 0x9146
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
#define GL_DEBUG_SEVERITY_LOW 0x9148
-#endif
+#endif // GL_DEBUG_OUTPUT
#ifndef GL_DEBUG_TYPE_PUSH_GROUP
#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
-#endif
+#endif // GL_DEBUG_TYPE_PUSH_GROUP
#ifndef GL_DEBUG_TYPE_POP_GROUP
#define GL_DEBUG_TYPE_POP_GROUP 0x826a
-#endif
+#endif // GL_DEBUG_TYPE_POP_GROUP
#ifndef GL_EXT_debug_label
#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
@@ -77,18 +77,18 @@
#define GL_BUFFER_OBJECT_EXT 0x9151
#define GL_QUERY_OBJECT_EXT 0x9153
#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
-#endif
+#endif // GL_EXT_debug_label
#ifndef GL_ARRAY_BUFFER
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#endif
+#endif // GL_ARRAY_BUFFER
#ifndef GL_STREAM_DRAW
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
-#endif
+#endif // GL_STREAM_DRAW
#ifndef GL_COMPILE_STATUS
#define GL_FRAGMENT_SHADER 0x8B30
@@ -97,39 +97,39 @@
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_INFO_LOG_LENGTH 0x8B84
-#endif
+#endif // GL_COMPILE_STATUS
#ifndef GL_DEPTH_CLAMP
#define GL_DEPTH_CLAMP 0x864F
#define GL_RASTERIZER_DISCARD 0x8C89
#define GL_SAMPLE_MASK 0x8E51
-#endif
+#endif // GL_DEPTH_CLAMP
#ifndef GL_POLYGON_SMOOTH
#define GL_POLYGON_SMOOTH 0x0B41
-#endif
+#endif // GL_POLYGON_SMOOTH
#ifndef GL_DEPTH_BOUNDS_TEST_EXT
#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
-#endif
+#endif // GL_DEPTH_BOUNDS_TEST_EXT
#ifndef GL_TEXTURE_COMPRESSION_HINT_ARB
#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
-#endif
+#endif // GL_TEXTURE_COMPRESSION_HINT_ARB
#ifndef GLX_CONTEXT_PROFILE_MASK_ARB
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
-#endif
+#endif // GLX_CONTEXT_PROFILE_MASK_ARB
#ifndef GLX_CONTEXT_MAJOR_VERSION_ARB
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
#define GLX_CONTEXT_FLAGS_ARB 0x2094
-#endif
+#endif // GLX_CONTEXT_MAJOR_VERSION_ARB
#ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
-#endif
+#endif // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
#endif // USE_OPENGL
diff --git a/src/render/opengl/mglemu.cpp b/src/render/opengl/mglemu.cpp
index 297dae3e1..669f7952f 100644
--- a/src/render/opengl/mglemu.cpp
+++ b/src/render/opengl/mglemu.cpp
@@ -44,4 +44,4 @@ void APIENTRY emuglActiveTexture(GLenum texture A_UNUSED)
{
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/render/opengl/mglfunctions.h b/src/render/opengl/mglfunctions.h
index de445c06b..a8009f899 100644
--- a/src/render/opengl/mglfunctions.h
+++ b/src/render/opengl/mglfunctions.h
@@ -35,10 +35,10 @@ LOGGER_H
#define getFunction(name) nullptr
#elif defined __native_client__
#define getFunction(name) glGetProcAddressREGAL(name)
-#else
+#else // WIN32
#define getFunction(name) glXGetProcAddress(\
reinterpret_cast<const GLubyte*>(name))
-#endif
+#endif // WIN32
#define assignFunction(func) \
{ \
diff --git a/src/render/opengl/mgltypes.h b/src/render/opengl/mgltypes.h
index dcd1290d1..828b862ce 100644
--- a/src/render/opengl/mgltypes.h
+++ b/src/render/opengl/mgltypes.h
@@ -27,14 +27,14 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#define APIENTRY GL_APIENTRY
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
#ifdef __native_client__
#include <GL/Regal.h>
-#else
+#else // __native_client__
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#else // defined(__APPLE__)
@@ -44,8 +44,8 @@
#error missing include <GL/glext.h>
#endif // __glext_h_
#endif // defined(__APPLE__)
-#endif
-#endif
+#endif // __native_client__
+#endif // ANDROID
#include "render/opengl/mgldefines.h"
RENDER_OPENGL_MGLDEFINES_H
@@ -142,7 +142,8 @@ typedef void (APIENTRY *glGetProgramInfoLog_t) (GLuint program,
typedef void (APIENTRY *glBindAttribLocation_t) (GLuint program,
GLuint index, const GLchar *name);
typedef void (APIENTRY *glActiveTexture_t) (GLenum texture);
-#endif
+#endif // __native_client__
+
typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program,
const GLchar *name);
typedef void (APIENTRY *glUniform3f_t) (GLint location,
@@ -215,9 +216,9 @@ typedef void (APIENTRY *glDebugMessageCallback_t) (GLDEBUGPROC_t callback,
#ifdef WIN32
typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc);
-#else
+#else // WIN32
#define CALLBACK
-#endif
+#endif // WIN32
#endif // USE_OPENGL
#endif // RENDER_OPENGL_MGLTYPES_H
diff --git a/src/render/opengl/opengldebug.h b/src/render/opengl/opengldebug.h
index 8d2f19e18..ebd449795 100644
--- a/src/render/opengl/opengldebug.h
+++ b/src/render/opengl/opengldebug.h
@@ -30,9 +30,9 @@ RENDER_OPENGL_MGL_H
mglPushGroupMarker(sizeof(text), text);
#define GLDEBUG_END() if (mglPopGroupMarker) \
mglPopGroupMarker();
-#else
+#else // defined(DEBUG_OPENGL) && defined(USE_OPENGL)
#define GLDEBUG_START(text)
#define GLDEBUG_END()
-#endif
+#endif // defined(DEBUG_OPENGL) && defined(USE_OPENGL)
#endif // RENDER_OPENGL_OPENGLDEBUG_H
diff --git a/src/render/openglx/mglx.cpp b/src/render/openglx/mglx.cpp
index 4fdc85838..73b00082b 100644
--- a/src/render/openglx/mglx.cpp
+++ b/src/render/openglx/mglx.cpp
@@ -31,4 +31,4 @@
MGLX_DEFINE
-#endif
+#endif // defined(USE_OPENGL) && defined(USE_X11)
diff --git a/src/render/openglx/mglxinit.cpp b/src/render/openglx/mglxinit.cpp
index 78a20ebf0..ffe2c5f2f 100644
--- a/src/render/openglx/mglxinit.cpp
+++ b/src/render/openglx/mglxinit.cpp
@@ -39,4 +39,4 @@ void Glx::initFunctions()
assignFunction(glXSwapBuffers);
}
-#endif
+#endif // defined(USE_OPENGL) && defined(USE_X11)
diff --git a/src/render/renderers.cpp b/src/render/renderers.cpp
index a11c438d1..ac5cc71d9 100644
--- a/src/render/renderers.cpp
+++ b/src/render/renderers.cpp
@@ -29,12 +29,14 @@ static RenderType getDefault() noexcept2
#ifdef USE_OPENGL
#ifdef ANDROID
return RENDER_GLES_OPENGL;
-#else
+#else // ANDROID
+
return RENDER_NORMAL_OPENGL;
-#endif
-#else
+#endif // ANDROID
+#else // USE_OPENGL
+
return RENDER_SOFTWARE;
-#endif
+#endif // USE_OPENGL
}
RenderType intToRenderType(const int mode) noexcept2
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 50364590d..6ddb33ebc 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -493,11 +493,12 @@ void SafeOpenGLGraphics::updateScreen() restrict2
SDL_GL_SwapWindow(mWindow);
#else
SDL_GL_SwapBuffers();
-#endif
+#endif // USE_SDL2
#ifdef DEBUG_OPENGL
if (isGLNotNull(mglFrameTerminator))
mglFrameTerminator();
-#endif
+#endif // DEBUG_OPENGL
+
BLOCK_END("Graphics::updateScreen")
}
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index 1805730fa..e311333a2 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -32,17 +32,17 @@
#ifdef ANDROID
#include <GLES/gl.h>
#include <GLES/glext.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#elif !defined(__native_client__)
#include <GL/glext.h>
#endif // defined(__APPLE__)
-#endif
+#endif // ANDROID
class SafeOpenGLGraphics final : public Graphics
{
@@ -72,6 +72,6 @@ class SafeOpenGLGraphics final : public Graphics
bool mColorAlpha;
FBOInfo mFbo;
};
-#endif
+#endif // defined USE_OPENGL && !defined ANDROID
#endif // RENDER_SAFEOPENGLGRAPHICS_H
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index ce6250c7b..701b96001 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -99,12 +99,12 @@ static int FakeSDL_RenderCopy(SDL_Renderer *restrict const renderer,
return ret;
}
-#else
+#else // DEBUG_SDL_SURFACES
#define MSDL_RenderCopy(render, texture, src, dst) \
SDL_RenderCopy(render, texture, src, dst)
-#endif
+#endif // DEBUG_SDL_SURFACES
#define setRenderDrawColor(mColor) \
SDL_SetRenderDrawColor(mRenderer, \
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 2d0ade4d9..d60d70cc8 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -41,13 +41,13 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
static unsigned int *cR = nullptr;
static unsigned int *cG = nullptr;
static unsigned int *cB = nullptr;
-#endif
+#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
#define defRectFromArea(rect, area) \
const SDL_Rect rect = \
@@ -995,11 +995,12 @@ void SDL2SoftwareGraphics::fillRectangle(const Rect &restrict rectangle)
p[2] = CAST_U8((p[2] * ca + cb) >> 8);
p[1] = CAST_U8((p[1] * ca + cg) >> 8);
p[0] = CAST_U8((p[0] * ca + cr) >> 8);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
p[0] = CAST_U8((p[0] * ca + cb) >> 8);
p[1] = CAST_U8((p[1] * ca + cg) >> 8);
p[2] = CAST_U8((p[2] * ca + cr) >> 8);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
}
break;
@@ -1029,7 +1030,8 @@ void SDL2SoftwareGraphics::fillRectangle(const Rect &restrict rectangle)
| (g & 0xff00) | (r & 0xff0000));
}
}
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (!cR)
{
cR = new unsigned int[0x100];
@@ -1089,7 +1091,8 @@ void SDL2SoftwareGraphics::fillRectangle(const Rect &restrict rectangle)
| cR[(dst & rMask) / rShift];
}
}
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
}
default:
@@ -1241,7 +1244,8 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2) restrict2
p[2] = b2;
p += 3;
}
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
for (; x1 <= x2; ++x1)
{
p[0] = b2;
@@ -1249,7 +1253,8 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2) restrict2
p[2] = b0;
p += 3;
}
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
}
@@ -1371,7 +1376,8 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) restrict2
p[2] = b2;
p += pitch;
}
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
for (; y1 <= y2; ++y1)
{
p[0] = b2;
@@ -1379,7 +1385,8 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) restrict2
p[2] = b0;
p += pitch;
}
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
}
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index 9cd734f30..c0e9b58a3 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -40,13 +40,13 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
static unsigned int *cR = nullptr;
static unsigned int *cG = nullptr;
static unsigned int *cB = nullptr;
-#endif
+#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
SDLGraphics::SDLGraphics() :
Graphics(),
@@ -970,11 +970,11 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
p[2] = CAST_U8((p[2] * ca + cb) >> 8);
p[1] = CAST_U8((p[1] * ca + cg) >> 8);
p[0] = CAST_U8((p[0] * ca + cr) >> 8);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
p[0] = CAST_U8((p[0] * ca + cb) >> 8);
p[1] = CAST_U8((p[1] * ca + cg) >> 8);
p[2] = CAST_U8((p[2] * ca + cr) >> 8);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
}
break;
@@ -1004,7 +1004,7 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
| (g & 0xff00) | (r & 0xff0000));
}
}
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (!cR)
{
cR = new unsigned int[0x100];
@@ -1064,7 +1064,7 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
| cR[(dst & rMask) / rShift];
}
}
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
break;
}
default:
@@ -1235,7 +1235,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2) restrict2
p[2] = b2;
p += 3;
}
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
for (; x1 <= x2; ++x1)
{
p[0] = b2;
@@ -1243,7 +1243,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2) restrict2
p[2] = b0;
p += 3;
}
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
break;
}
@@ -1365,7 +1365,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) restrict2
p[2] = b2;
p += pitch;
}
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
for (; y1 <= y2; ++y1)
{
p[0] = b2;
@@ -1373,7 +1373,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) restrict2
p[2] = b0;
p += pitch;
}
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
break;
}
diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp
index e334b4a7e..f62f3bbc0 100644
--- a/src/render/shaders/shaderprogram.cpp
+++ b/src/render/shaders/shaderprogram.cpp
@@ -25,7 +25,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "render/shaders/shader.h"
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
index cf7dd81d9..96f4c3738 100644
--- a/src/render/shaders/shadersmanager.cpp
+++ b/src/render/shaders/shadersmanager.cpp
@@ -28,7 +28,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "render/shaders/shader.h"
#include "render/shaders/shaderprogram.h"
@@ -141,4 +141,4 @@ ShaderProgram *ShadersManager::getGles2Program()
false);
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp
index f499e2c14..7c3bfaa57 100644
--- a/src/render/surfacegraphics.cpp
+++ b/src/render/surfacegraphics.cpp
@@ -63,7 +63,8 @@ void SurfaceGraphics::drawImage(const Image *restrict const image,
#ifdef USE_SDL2
SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#else
+#else // USE_SDL2
+
if (mBlitMode == BlitMode::BLIT_NORMAL)
{
SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
@@ -73,7 +74,7 @@ void SurfaceGraphics::drawImage(const Image *restrict const image,
SurfaceImageHelper::combineSurface(image->mSDLSurface,
&srcRect, mTarget, &dstRect);
}
-#endif
+#endif // USE_SDL2
}
void SurfaceGraphics::copyImage(const Image *restrict const image,
@@ -97,9 +98,10 @@ void SurfaceGraphics::copyImage(const Image *restrict const image,
#ifdef USE_SDL2
// probably need change some flags
SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#else
+#else // USE_SDL2
+
SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#endif
+#endif // USE_SDL2
}
void SurfaceGraphics::drawImageCached(const Image *restrict const image,
@@ -123,7 +125,8 @@ void SurfaceGraphics::drawImageCached(const Image *restrict const image,
#ifdef USE_SDL2
SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#else
+#else // USE_SDL2
+
if (mBlitMode == BlitMode::BLIT_NORMAL)
{
SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
@@ -133,7 +136,7 @@ void SurfaceGraphics::drawImageCached(const Image *restrict const image,
SurfaceImageHelper::combineSurface(image->mSDLSurface, &srcRect,
mTarget, &dstRect);
}
-#endif
+#endif // USE_SDL2
}
void SurfaceGraphics::completeCache() restrict2
diff --git a/src/render/vertexes/imagecollection.cpp b/src/render/vertexes/imagecollection.cpp
index 47c45b18c..6e8e74877 100644
--- a/src/render/vertexes/imagecollection.cpp
+++ b/src/render/vertexes/imagecollection.cpp
@@ -27,7 +27,7 @@
ImageCollection::ImageCollection() :
#ifdef USE_OPENGL
currentGLImage(0),
-#endif
+#endif // USE_OPENGL
currentImage(nullptr),
currentVert(nullptr),
draws()
@@ -43,7 +43,7 @@ void ImageCollection::clear() restrict2
{
#ifdef USE_OPENGL
currentGLImage = 0;
-#endif
+#endif // USE_OPENGL
currentImage = nullptr;
currentVert = nullptr;
diff --git a/src/render/vertexes/imagecollection.h b/src/render/vertexes/imagecollection.h
index 922fb6bd5..211a2959e 100644
--- a/src/render/vertexes/imagecollection.h
+++ b/src/render/vertexes/imagecollection.h
@@ -40,7 +40,8 @@ class ImageCollection final
#ifdef USE_OPENGL
GLuint currentGLImage;
-#endif
+#endif // USE_OPENGL
+
const Image *restrict currentImage;
ImageVertexes *restrict currentVert;
diff --git a/src/render/vertexes/imagevertexes.cpp b/src/render/vertexes/imagevertexes.cpp
index 675078faf..6a43baa34 100644
--- a/src/render/vertexes/imagevertexes.cpp
+++ b/src/render/vertexes/imagevertexes.cpp
@@ -28,7 +28,7 @@ ImageVertexes::ImageVertexes() :
image(nullptr),
#ifdef USE_OPENGL
ogl(),
-#endif
+#endif // USE_OPENGL
sdl()
{
sdl.reserve(30);
diff --git a/src/render/vertexes/imagevertexes.h b/src/render/vertexes/imagevertexes.h
index 16d50f158..74c1baa30 100644
--- a/src/render/vertexes/imagevertexes.h
+++ b/src/render/vertexes/imagevertexes.h
@@ -47,7 +47,8 @@ class ImageVertexes final
const Image *restrict image;
#ifdef USE_OPENGL
OpenGLGraphicsVertexes ogl;
-#endif
+#endif // USE_OPENGL
+
DoubleRects sdl;
};
diff --git a/src/render/vertexes/openglgraphicsvertexes.cpp b/src/render/vertexes/openglgraphicsvertexes.cpp
index ee442355f..b60efbc4f 100644
--- a/src/render/vertexes/openglgraphicsvertexes.cpp
+++ b/src/render/vertexes/openglgraphicsvertexes.cpp
@@ -222,4 +222,4 @@ GLint *OpenGLGraphicsVertexes::continueIntTexArray() restrict2
}
return mIntTexArray;
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/render/vertexes/openglgraphicsvertexes.h b/src/render/vertexes/openglgraphicsvertexes.h
index 853161b87..ea2ff86d2 100644
--- a/src/render/vertexes/openglgraphicsvertexes.h
+++ b/src/render/vertexes/openglgraphicsvertexes.h
@@ -25,12 +25,12 @@
#ifdef ANDROID
#include <GLES/gl.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
-#endif
+#endif // ANDROID
#include <vector>
diff --git a/src/resources/animation/animation.h b/src/resources/animation/animation.h
index 7a0ade3fa..b396bae49 100644
--- a/src/resources/animation/animation.h
+++ b/src/resources/animation/animation.h
@@ -84,7 +84,7 @@ class Animation final : public MemoryCounter
#ifdef UNITTESTS
Frames &getFrames() noexcept2
{ return mFrames; }
-#endif
+#endif // UNITTESTS
int calcMemoryLocal() const override final;
diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp
index 746e9b8f3..b097bcfc4 100644
--- a/src/resources/atlas/atlasmanager.cpp
+++ b/src/resources/atlas/atlasmanager.cpp
@@ -26,7 +26,7 @@
#ifdef DEBUG_IMAGES
#include "logger.h"
-#endif
+#endif // DEBUG_IMAGES
#include "utils/mathutils.h"
#include "utils/physfscheckutils.h"
@@ -50,7 +50,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
AtlasManager::AtlasManager()
{
@@ -70,7 +70,7 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name,
int sz = settings.textureSize;
if (maxSize > sz)
maxSize = sz;
-#endif
+#endif // !defined(ANDROID) && !defined(__APPLE__)
// sorting images on atlases.
simpleSort(name, atlases, images, maxSize);
@@ -163,7 +163,8 @@ void AtlasManager::loadImages(const StringVect &files,
#ifdef DEBUG_IMAGES
logger->log("set name %p, %s", static_cast<void*>(image),
image->mIdPath.c_str());
-#endif
+#endif // DEBUG_IMAGES
+
images.push_back(image);
}
}
@@ -278,12 +279,13 @@ void AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
const unsigned int gmask = 0x00ff0000;
const unsigned int bmask = 0x0000ff00;
const unsigned int amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int rmask = 0x000000ff;
const unsigned int gmask = 0x0000ff00;
const unsigned int bmask = 0x00ff0000;
const unsigned int amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
// do not create atlas based on only one image
if (atlas->items.size() == 1)
@@ -356,7 +358,8 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
#ifdef DEBUG_IMAGES
logger->log("set name %p, %s", static_cast<void*>(image),
image->mIdPath.c_str());
-#endif
+#endif // DEBUG_IMAGES
+
image->incRef();
FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items)
@@ -374,7 +377,8 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
#ifdef DEBUG_IMAGES
logger->log("set name %p, %s", static_cast<void*>(image2),
image2->mIdPath.c_str());
-#endif
+#endif // DEBUG_IMAGES
+
image2->incRef();
}
}
@@ -439,4 +443,4 @@ void AtlasManager::moveToDeleted(AtlasResource *const resource)
}
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/resources/atlas/atlasresource.cpp b/src/resources/atlas/atlasresource.cpp
index 915d33f33..a9033764d 100644
--- a/src/resources/atlas/atlasresource.cpp
+++ b/src/resources/atlas/atlasresource.cpp
@@ -88,4 +88,4 @@ int AtlasResource::calcMemoryChilds(const int level) const
return sz;
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/resources/db/commandsdb.cpp b/src/resources/db/commandsdb.cpp
index 74096c25a..dafb6edb8 100644
--- a/src/resources/db/commandsdb.cpp
+++ b/src/resources/db/commandsdb.cpp
@@ -117,7 +117,7 @@ void CommandsDB::loadXmlFile(const std::string &fileName,
commandNode, "level2", 0, 0, 1000);
const int mana = XML::getIntProperty(
commandNode, "mana", 0, 0, 100000);
-#endif
+#endif // TMWA_SUPPORT
TextCommand *cmd = nullptr;
#ifdef TMWA_SUPPORT
@@ -135,7 +135,7 @@ void CommandsDB::loadXmlFile(const std::string &fileName,
mana);
}
else
-#endif
+#endif // TMWA_SUPPORT
{
cmd = new TextCommand(id,
name,
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index c862e6796..724724bac 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -1070,4 +1070,4 @@ ItemDB::ItemInfos &ItemDB::getItemInfosTest()
{
return mItemInfos;
}
-#endif
+#endif // UNITTESTS
diff --git a/src/resources/db/itemdb.h b/src/resources/db/itemdb.h
index 3a992b90c..8a2547b48 100644
--- a/src/resources/db/itemdb.h
+++ b/src/resources/db/itemdb.h
@@ -69,7 +69,7 @@ namespace ItemDB
ItemDB::NamedItemInfos &getNamedItemInfosTest();
ItemDB::ItemInfos &getItemInfosTest();
-#endif
+#endif // UNITTESTS
int getTagId(const std::string &tagName) A_WARN_UNUSED;
} // namespace ItemDB
diff --git a/src/resources/dye/dye.cpp b/src/resources/dye/dye.cpp
index 3aa42d7e7..e37b2e943 100644
--- a/src/resources/dye/dye.cpp
+++ b/src/resources/dye/dye.cpp
@@ -36,7 +36,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
Dye::Dye(const std::string &restrict description)
{
@@ -164,9 +164,11 @@ void Dye::normalDye(uint32_t *restrict pixels,
const uint32_t p = pixels[ptr];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 0xff000000;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (alpha)
{
unsigned int color[3];
@@ -174,11 +176,13 @@ void Dye::normalDye(uint32_t *restrict pixels,
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
if (cmax == 0)
@@ -205,10 +209,11 @@ void Dye::normalDye(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
pixels[ptr] = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
pixels[ptr] = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
endlabel:{}
}
@@ -222,9 +227,11 @@ endlabel:{}
const uint32_t p = *pixels;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 0xff000000;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (!alpha)
continue;
unsigned int color[3];
@@ -232,11 +239,12 @@ endlabel:{}
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
@@ -263,10 +271,11 @@ endlabel:{}
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*pixels = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
*pixels = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
#endif // ENABLE_CILKPLUS
}
@@ -283,9 +292,11 @@ void Dye::normalOGLDye(uint32_t *restrict pixels,
const uint32_t p = pixels[ptr];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 255;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (alpha)
{
unsigned int color[3];
@@ -293,11 +304,12 @@ void Dye::normalOGLDye(uint32_t *restrict pixels,
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
@@ -324,10 +336,11 @@ void Dye::normalOGLDye(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
pixels[ptr] = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
pixels[ptr] = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
endlabel:{}
}
@@ -341,9 +354,11 @@ endlabel:{}
const uint32_t p = *pixels;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 255;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (!alpha)
continue;
unsigned int color[3];
@@ -351,11 +366,12 @@ endlabel:{}
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
@@ -382,10 +398,11 @@ endlabel:{}
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*pixels = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
*pixels = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
#endif // ENABLE_CILKPLUS
}
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
index 06abc09c7..09645039d 100644
--- a/src/resources/dye/dye_unittest.cc
+++ b/src/resources/dye/dye_unittest.cc
@@ -323,17 +323,16 @@ TEST_CASE("Dye real dye")
#ifdef USE_SDL2
imageHelper = new SurfaceImageHelper;
-#else
- imageHelper = new SDLImageHelper;
-#endif
-#ifdef USE_SDL2
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
+ imageHelper = new SDLImageHelper;
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
ActorSprite::load();
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp
index 9b2a2a8a8..9ea08331d 100644
--- a/src/resources/dye/dyepalette.cpp
+++ b/src/resources/dye/dyepalette.cpp
@@ -26,7 +26,7 @@
#ifndef DYECMD
#include "resources/db/palettedb.h"
-#endif
+#endif // DYECMD
#include "utils/stringutils.h"
@@ -40,7 +40,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
DyePalette::DyePalette(const std::string &restrict description,
const uint8_t blockSize) :
@@ -94,7 +94,8 @@ DyePalette::DyePalette(const std::string &restrict description,
}
return;
}
-#endif
+#endif // DYECMD
+
logger->log("Error, invalid embedded palette: %s", description.c_str());
}
@@ -242,10 +243,12 @@ void DyePalette::replaceSColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = pixels[ptr] & 0xff000000;
const unsigned int data = pixels[ptr] & 0x00ffffff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = *p & 0xff;
const unsigned int data = pixels[ptr] & 0xffffff00;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
// logger->log("c:%04d %08x", c, *pixels);
// logger->log("data: %08x", data);
if (!alpha)
@@ -264,10 +267,11 @@ void DyePalette::replaceSColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int coldata = (col.value[2] << 16U)
| (col.value[1] << 8U) | (col.value[0]);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int coldata = (col.value[2] << 8U)
| (col.value[1] << 16U) | (col.value[0] << 24U);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
// logger->log("coldata: %08x", coldata);
if (data == coldata)
{
@@ -291,10 +295,12 @@ void DyePalette::replaceSColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = *pixels & 0xff000000;
const unsigned int data = (*pixels) & 0x00ffffff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = *p & 0xff;
const unsigned int data = (*pixels) & 0xffffff00;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
// logger->log("c:%04d %08x", c, *pixels);
// logger->log("data: %08x", data);
if (!alpha)
@@ -313,10 +319,12 @@ void DyePalette::replaceSColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int coldata = (col.value[2] << 16U)
| (col.value[1] << 8U) | (col.value[0]);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int coldata = (col.value[2] << 8U)
| (col.value[1] << 16U) | (col.value[0] << 24U);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
// logger->log("coldata: %08x", coldata);
if (data == coldata)
{
@@ -361,12 +369,13 @@ void DyePalette::replaceAColor(uint32_t *restrict pixels,
| (col.value[2] << 16U)
| (col.value[1] << 8U)
| (col.value[0]);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int coldata = (col.value[3])
| (col.value[2] << 8U)
| (col.value[1] << 16U) |
(col.value[0] << 24U);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (data == coldata)
{
@@ -402,12 +411,12 @@ void DyePalette::replaceAColor(uint32_t *restrict pixels,
| (col.value[2] << 16U)
| (col.value[1] << 8U)
| (col.value[0]);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int coldata = (col.value[3])
| (col.value[2] << 8U)
| (col.value[1] << 16U) |
(col.value[0] << 24U);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (data == coldata)
{
@@ -441,10 +450,12 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = *p & 0xff;
const unsigned int data = (pixels[ptr]) & 0xffffff00;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = pixels[ptr] & 0xff000000;
const unsigned int data = (pixels[ptr]) & 0x00ffffff;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (alpha)
{
std::vector<DyeColor>::const_iterator it = mColors.begin();
@@ -457,10 +468,12 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int coldata = (col.value[0] << 24)
| (col.value[1] << 16) | (col.value[2] << 8);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int coldata = (col.value[0])
| (col.value[1] << 8) | (col.value[2] << 16);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (data == coldata)
{
p[0] = col2.value[0];
@@ -484,10 +497,12 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = *p & 0xff;
const unsigned int data = (*pixels) & 0xffffff00;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = *pixels & 0xff000000;
const unsigned int data = (*pixels) & 0x00ffffff;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (!alpha)
continue;
@@ -501,10 +516,12 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int coldata = (col.value[0] << 24)
| (col.value[1] << 16) | (col.value[2] << 8);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int coldata = (col.value[0])
| (col.value[1] << 8) | (col.value[2] << 16);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (data == coldata)
{
p[0] = col2.value[0];
@@ -547,12 +564,14 @@ void DyePalette::replaceAOGLColor(uint32_t *restrict pixels,
| (col.value[1] << 16U)
| (col.value[2] << 8U)
| col.value[3];
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int coldata = (col.value[0])
| (col.value[1] << 8U)
| (col.value[2] << 16U)
| (col.value[3] << 24U);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (data == coldata)
{
p[0] = col2.value[0];
@@ -587,12 +606,14 @@ void DyePalette::replaceAOGLColor(uint32_t *restrict pixels,
| (col.value[1] << 16U)
| (col.value[2] << 8U)
| col.value[3];
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int coldata = (col.value[0])
| (col.value[1] << 8U)
| (col.value[2] << 16U)
| (col.value[3] << 24U);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (data == coldata)
{
p[0] = col2.value[0];
diff --git a/src/resources/dye/dyepalette.h b/src/resources/dye/dyepalette.h
index 9796f40c5..f7258b4ec 100644
--- a/src/resources/dye/dyepalette.h
+++ b/src/resources/dye/dyepalette.h
@@ -92,7 +92,7 @@ class DyePalette final
#ifndef UNITTESTS
private:
-#endif
+#endif // UNITTESTS
std::vector<DyeColor> mColors;
};
diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc
index 9d9f5fda6..d42e98b2e 100644
--- a/src/resources/dye/dyepalette_unittest.cc
+++ b/src/resources/dye/dyepalette_unittest.cc
@@ -64,9 +64,10 @@ TEST_CASE("DyePalette tests")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
ActorSprite::load();
paths.setDefaultValues(getPathsDefaults());
diff --git a/src/resources/fboinfo.h b/src/resources/fboinfo.h
index 95d800bda..81d753856 100644
--- a/src/resources/fboinfo.h
+++ b/src/resources/fboinfo.h
@@ -26,14 +26,14 @@
#ifdef ANDROID
#include <GLES/gl.h>
#include <GLES/glext.h>
-#else
+#else // ANDROID
#include <SDL_opengl.h>
#if defined(__APPLE__)
#include <OpenGL/glext.h>
#elif !defined(__native_client__)
#include <GL/glext.h>
#endif // defined(__APPLE__)
-#endif
+#endif // ANDROID
#include "localconsts.h"
diff --git a/src/resources/image/image.cpp b/src/resources/image/image.cpp
index bb3fe6ce6..379a1c074 100644
--- a/src/resources/image/image.cpp
+++ b/src/resources/image/image.cpp
@@ -53,7 +53,7 @@ Image::Image(SDL_Texture *restrict const image,
mGLImage(0),
mTexWidth(0),
mTexHeight(0),
-#endif
+#endif // USE_OPENGL
mBounds(),
mAlpha(1.0F),
mSDLSurface(nullptr),
@@ -68,7 +68,7 @@ Image::Image(SDL_Texture *restrict const image,
{
#ifdef DEBUG_IMAGES
logger->log("created image: %p", this);
-#endif
+#endif // DEBUG_IMAGES
mBounds.x = 0;
mBounds.y = 0;
@@ -86,7 +86,7 @@ Image::Image(SDL_Texture *restrict const image,
mBounds.h = 0;
}
}
-#endif
+#endif // USE_SDL2
Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
uint8_t *restrict const alphaChannel) :
@@ -95,13 +95,13 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
mGLImage(0),
mTexWidth(0),
mTexHeight(0),
-#endif
+#endif // USE_OPENGL
mBounds(),
mAlpha(1.0F),
mSDLSurface(image),
#ifdef USE_SDL2
mTexture(nullptr),
-#endif
+#endif // USE_SDL2
mAlphaChannel(alphaChannel),
mAlphaCache(),
mLoaded(false),
@@ -112,7 +112,7 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
{
#ifdef DEBUG_IMAGES
logger->log("created image: %p", static_cast<void*>(this));
-#endif
+#endif // DEBUG_IMAGES
mBounds.x = 0;
mBounds.y = 0;
@@ -143,7 +143,7 @@ Image::Image(const GLuint glimage, const int width, const int height,
mSDLSurface(nullptr),
#ifdef USE_SDL2
mTexture(nullptr),
-#endif
+#endif // USE_SDL2
mAlphaChannel(nullptr),
mAlphaCache(),
mLoaded(false),
@@ -154,7 +154,7 @@ Image::Image(const GLuint glimage, const int width, const int height,
{
#ifdef DEBUG_IMAGES
logger->log("created image: %p", static_cast<void*>(this));
-#endif
+#endif // DEBUG_IMAGES
mBounds.x = 0;
mBounds.y = 0;
@@ -166,14 +166,15 @@ Image::Image(const GLuint glimage, const int width, const int height,
mLoaded = true;
}
}
-#endif
+#endif // USE_OPENGL
Image::~Image()
{
#ifdef DEBUG_IMAGES
logger->log("delete image: %p", static_cast<void*>(this));
logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str());
-#endif
+#endif // DEBUG_IMAGES
+
unload();
}
@@ -210,7 +211,7 @@ void Image::unload()
SDL_DestroyTexture(mTexture);
mTexture = nullptr;
}
-#endif
+#endif // USE_SDL2
#ifdef USE_OPENGL
if (mGLImage)
@@ -220,9 +221,9 @@ void Image::unload()
#ifdef DEBUG_OPENGL_LEAKS
if (textures_count > 0)
textures_count --;
-#endif
+#endif // DEBUG_OPENGL_LEAKS
}
-#endif
+#endif // USE_OPENGL
}
bool Image::hasAlphaChannel() const
@@ -233,7 +234,7 @@ bool Image::hasAlphaChannel() const
#ifdef USE_OPENGL
if (OpenGLImageHelper::mUseOpenGL != RENDER_SOFTWARE)
return true;
-#endif
+#endif // USE_OPENGL
return false;
}
@@ -272,7 +273,8 @@ void Image::setAlpha(const float alpha)
{
logger->log("alpha: " + toString(i->first));
}
-#endif
+#endif // DEBUG_ALPHA_CACHE
+
SDLCleanCache();
}
surface = mSDLSurface;
@@ -309,11 +311,12 @@ void Image::setAlpha(const float alpha)
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(mSDLSurface,
CAST_U8(255 * mAlpha));
-#else
+#else // USE_SDL2
+
// Set the alpha value this image is drawn at
SDL_SetAlpha(mSDLSurface, SDL_SRCALPHA,
CAST_U8(255 * mAlpha));
-#endif
+#endif // USE_SDL2
}
else
{
@@ -391,7 +394,7 @@ void Image::setAlpha(const float alpha)
SDL_SetTextureAlphaMod(mTexture,
CAST_U8(255 * mAlpha));
}
-#endif
+#endif // USE_SDL2
else
{
mAlpha = alpha;
@@ -446,19 +449,21 @@ Image *Image::getSubImage(const int x, const int y,
width, height,
mTexWidth, mTexHeight);
}
-#endif
+#endif // USE_OPENGL
#ifdef USE_SDL2
#ifndef USE_OPENGL
const RenderType mode = ImageHelper::mUseOpenGL;
-#endif
+#endif // USE_OPENGL
+
if (mode == RENDER_SOFTWARE)
return new SubImage(this, mSDLSurface, x, y, width, height);
else
return new SubImage(this, mTexture, x, y, width, height);
-#else
+#else // USE_SDL2
+
return new SubImage(this, mSDLSurface, x, y, width, height);
-#endif
+#endif // USE_SDL2
}
void Image::SDLTerminateAlphaCache()
@@ -488,4 +493,4 @@ void Image::decRef()
OpenGLImageHelper::invalidate(mGLImage);
Resource::decRef();
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/resources/image/image.h b/src/resources/image/image.h
index ae29a66ae..bb78f685c 100644
--- a/src/resources/image/image.h
+++ b/src/resources/image/image.h
@@ -33,13 +33,13 @@
#ifdef ANDROID
#include <GLES/gl.h>
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
-#endif
-#endif
+#endif // ANDROID
+#endif // USE_OPENGL
#ifdef USE_SDL2
#include <SDL_render.h>
@@ -64,7 +64,7 @@ class Image notfinal : public Resource
friend class SDL2SoftwareGraphics;
friend class SDL2SoftwareImageHelper;
friend class SurfaceImageHelper;
-#endif
+#endif // USE_SDL2
friend class TestLauncher;
#ifdef USE_OPENGL
friend class AtlasManager;
@@ -171,7 +171,7 @@ class Image notfinal : public Resource
GLuint mGLImage;
int mTexWidth;
int mTexHeight;
-#endif
+#endif // USE_OPENGL
bool isHasAlphaChannel() const A_WARN_UNUSED
{ return mHasAlphaChannel; }
@@ -212,14 +212,14 @@ class Image notfinal : public Resource
#ifdef USE_SDL2
Image(SDL_Texture *restrict const image,
const int width, const int height);
-#endif
+#endif // USE_SDL2
SDL_Surface *getByAlpha(const float alpha) A_WARN_UNUSED;
SDL_Surface *mSDLSurface;
#ifdef USE_SDL2
SDL_Texture *mTexture;
-#endif
+#endif // USE_SDL2
/** Alpha Channel pointer used for 32bit based SDL surfaces */
uint8_t *mAlphaChannel;
@@ -241,7 +241,7 @@ class Image notfinal : public Resource
*/
Image(const GLuint glimage, const int width, const int height,
const int texWidth, const int texHeight);
-#endif
+#endif // USE_OPENGL
};
#endif // RESOURCES_IMAGE_H
diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp
index 615474334..a26604d75 100644
--- a/src/resources/image/subimage.cpp
+++ b/src/resources/image/subimage.cpp
@@ -24,7 +24,7 @@
#ifdef DEBUG_IMAGES
#include "logger.h"
-#endif
+#endif // DEBUG_IMAGES
#include "debug.h"
@@ -47,10 +47,10 @@ SubImage::SubImage(Image *const parent,
mSource = parent->getIdPath();
#ifdef DEBUG_IMAGES
logger->log("set name2 %p, %s", this, mSource.c_str());
-#endif
+#endif // DEBUG_IMAGES
#ifdef DEBUG_BIND_TEXTURE
mIdPath = parent->getIdPath();
-#endif
+#endif // DEBUG_BIND_TEXTURE
}
else
{
@@ -80,7 +80,7 @@ SubImage::SubImage(Image *const parent,
}
mUseAlphaCache = false;
}
-#endif
+#endif // USE_SDL2
SubImage::SubImage(Image *const parent,
SDL_Surface *const image,
@@ -101,10 +101,10 @@ SubImage::SubImage(Image *const parent,
#ifdef DEBUG_IMAGES
logger->log("set name2 %p, %s", static_cast<void*>(this),
mSource.c_str());
-#endif
+#endif // DEBUG_IMAGES
#ifdef DEBUG_BIND_TEXTURE
mIdPath = parent->getIdPath();
-#endif
+#endif // DEBUG_BIND_TEXTURE
}
else
{
@@ -163,10 +163,10 @@ SubImage::SubImage(Image *const parent,
#ifdef DEBUG_IMAGES
logger->log("set name2 %p, %s", static_cast<void*>(this),
mSource.c_str());
-#endif
+#endif // DEBUG_IMAGES
#ifdef DEBUG_BIND_TEXTURE
mIdPath = parent->getIdPath();
-#endif
+#endif // DEBUG_BIND_TEXTURE
}
else
{
@@ -177,14 +177,14 @@ SubImage::SubImage(Image *const parent,
}
mIsAlphaVisible = mHasAlphaChannel;
}
-#endif
+#endif // USE_OPENGL
SubImage::~SubImage()
{
#ifdef DEBUG_IMAGES
logger->log("delete subimage: %p", static_cast<void*>(this));
logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str());
-#endif
+#endif // DEBUG_IMAGES
// Avoid destruction of the image
mSDLSurface = nullptr;
// Avoid possible destruction of its alpha channel
@@ -192,16 +192,17 @@ SubImage::~SubImage()
#ifdef USE_SDL2
// Avoid destruction of texture
mTexture = nullptr;
-#endif
+#endif // USE_SDL2
#ifdef USE_OPENGL
mGLImage = 0;
-#endif
+#endif // USE_OPENGL
if (mParent)
{
#ifdef DEBUG_IMAGES
logger->log("decref from subminage: %p, parent: %p",
static_cast<void*>(this), static_cast<void*>(mParent));
-#endif
+#endif // DEBUG_IMAGES
+
mParent->decRef();
mParent = nullptr;
}
@@ -221,7 +222,7 @@ void SubImage::decRef()
{
Resource::decRef();
}
-#endif
+#endif // USE_OPENGL
int SubImage::calcMemoryLocal() const
{
diff --git a/src/resources/image/subimage.h b/src/resources/image/subimage.h
index 1687081de..14decc14d 100644
--- a/src/resources/image/subimage.h
+++ b/src/resources/image/subimage.h
@@ -39,14 +39,15 @@ class SubImage final : public Image
#ifdef USE_SDL2
SubImage(Image *const parent, SDL_Texture *const image,
const int x, const int y, const int width, const int height);
-#endif
+#endif // USE_SDL2
+
SubImage(Image *const parent, SDL_Surface *const image,
const int x, const int y, const int width, const int height);
#ifdef USE_OPENGL
SubImage(Image *const parent, const GLuint image,
const int x, const int y, const int width, const int height,
const int texWidth, const int textHeight);
-#endif
+#endif // USE_OPENGL
A_DELETE_COPY(SubImage)
@@ -72,7 +73,7 @@ class SubImage final : public Image
#ifdef USE_OPENGL
void decRef() override final;
-#endif
+#endif // USE_OPENGL
SDL_Rect mInternalBounds;
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index 737e43aaa..78afafcd7 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -35,7 +35,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
ImageHelper *imageHelper = nullptr;
ImageHelper *surfaceImageHelper = nullptr;
@@ -79,12 +79,13 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
rgba.Gmask = 0x0000FF00;
rgba.Bmask = 0x00FF0000;
rgba.Amask = 0xFF000000;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rgba.Rmask = 0xFF000000;
rgba.Gmask = 0x00FF0000;
rgba.Bmask = 0x0000FF00;
rgba.Amask = 0x000000FF;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
SDL_Surface *const surf = MSDL_ConvertSurface(
tmpImage, &rgba, SDL_SWSURFACE);
@@ -135,7 +136,8 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
#ifndef USE_SDL2
RGBAFormat.colorkey = 0;
RGBAFormat.alpha = 0;
-#endif
+#endif // USE_SDL2
+
RGBAFormat.BitsPerPixel = 32;
RGBAFormat.BytesPerPixel = 4;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -151,7 +153,8 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
RGBAFormat.Amask = 0x000000FF;
RGBAFormat.Ashift = 24;
RGBAFormat.Aloss = 0;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
RGBAFormat.Rmask = 0x000000FF;
RGBAFormat.Rshift = 24;
RGBAFormat.Rloss = 0;
@@ -164,7 +167,8 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
RGBAFormat.Amask = 0xFF000000;
RGBAFormat.Ashift = 0;
RGBAFormat.Aloss = 0;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
return MSDL_ConvertSurface(tmpImage, &RGBAFormat, SDL_SWSURFACE);
}
@@ -178,7 +182,8 @@ void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image)
logger->log("Bytes per pixel: %d", format->BytesPerPixel);
#ifndef USE_SDL2
logger->log("Alpha: %d", format->alpha);
-#endif
+#endif // USE_SDL2
+
logger->log("Loss: %02x, %02x, %02x, %02x",
CAST_U32(format->Rloss),
CAST_U32(format->Gloss),
@@ -226,12 +231,13 @@ SDL_Surface *ImageHelper::create32BitSurface(int width,
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
const int amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
const int amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
return MSDL_CreateRGBSurface(SDL_SWSURFACE,
width, height, 32, rmask, gmask, bmask, amask);
diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h
index f869c0f93..2f4276305 100644
--- a/src/resources/imagehelper.h
+++ b/src/resources/imagehelper.h
@@ -64,7 +64,8 @@ class ImageHelper notfinal
virtual Image *createTextSurface(SDL_Surface *const tmpImage,
const int width, const int height,
float alpha) A_WARN_UNUSED = 0;
-#else
+#else // __GNUC__
+
virtual Image *loadSurface(SDL_Surface *const) A_WARN_UNUSED
{ return nullptr; }
@@ -72,7 +73,7 @@ class ImageHelper notfinal
const int width, const int height,
const float alpha) const A_WARN_UNUSED
{ return nullptr; }
-#endif
+#endif // __GNUC__
virtual SDL_Surface *create32BitSurface(int width,
int height)
diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp
index d994be547..44a91dc06 100644
--- a/src/resources/loaders/musicloader.cpp
+++ b/src/resources/loaders/musicloader.cpp
@@ -55,13 +55,14 @@ namespace
{
return new SDLMusic(music, nullptr, rl->path);
}
-#else
+#else // USE_SDL2
+
// Mix_LoadMUSType_RW was added without version changed in SDL1.2 :(
if (Mix_Music *const music = Mix_LoadMUS_RW(rw))
{
return new SDLMusic(music, rw, rl->path);
}
-#endif
+#endif // USE_SDL2
else
{
logger->log("Error, failed to load music: %s", Mix_GetError());
diff --git a/src/resources/loaders/walklayerloader.cpp b/src/resources/loaders/walklayerloader.cpp
index 73f451ad8..8556b7b4d 100644
--- a/src/resources/loaders/walklayerloader.cpp
+++ b/src/resources/loaders/walklayerloader.cpp
@@ -59,10 +59,11 @@ WalkLayer *Loader::getWalkLayer(const std::string &name,
return static_cast<WalkLayer*>(resourceManager->get("map_" + name,
WalkLayerLoader::load, &rl));
}
-#else
+#else // DYECMD
+
WalkLayer *Loader::getWalkLayer(const std::string &name A_UNUSED,
Map *const map A_UNUSED)
{
return nullptr;
}
-#endif
+#endif // DYECMD
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 2b6dd070b..2d6631aa5 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -58,7 +58,7 @@
#ifdef USE_OPENGL
#include "render/renderers.h"
-#endif
+#endif // USE_OPENGL
#include "utils/delete2.h"
#include "utils/dtor.h"
@@ -117,9 +117,9 @@ Map::Map(const std::string &name,
mOpacity(config.getFloatValue("guialpha")),
#ifdef USE_OPENGL
mOpenGL(intToRenderType(config.getIntValue("opengl"))),
-#else
+#else // USE_OPENGL
mOpenGL(RENDER_SOFTWARE),
-#endif
+#endif // USE_OPENGL
mPvp(0),
mTilesetsIndexed(false),
mIndexedTilesets(nullptr),
@@ -149,9 +149,9 @@ Map::Map(const std::string &name,
mOpenGL == RENDER_GLES_OPENGL ||
mOpenGL == RENDER_GLES2_OPENGL ||
mOpenGL == RENDER_MODERN_OPENGL),
-#else
+#else // USE_OPENGL
mCachedDraw(false),
-#endif
+#endif // USE_OPENGL
mCustom(false),
mDrawOnlyFringe(false)
{
@@ -388,7 +388,7 @@ void Map::draw(Graphics *restrict const graphics,
updateFlag = 1;
}
}
-#endif
+#endif // USE_OPENGL
if (mDrawOnlyFringe)
{
@@ -444,7 +444,7 @@ void Map::draw(Graphics *restrict const graphics,
(*it)->drawOGL(graphics);
}
else
-#endif
+#endif // USE_OPENGL
{
FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
{
@@ -1442,7 +1442,8 @@ void Map::reduce() restrict2
{
#ifdef USE_SDL2
return;
-#else
+#else // USE_SDL2
+
if (!mFringeLayer ||
mOpenGL != RENDER_SOFTWARE ||
!config.getBoolValue("enableMapReduce"))
@@ -1590,7 +1591,7 @@ void Map::reduce() restrict2
}
}
logger->log("tiles reduced: %d", cnt);
-#endif
+#endif // USE_SDL2
}
void Map::addHeights(const MapHeights *restrict const heights) restrict2
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index f71f1de48..57a32ea8f 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -375,7 +375,7 @@ void MapLayer::drawOGL(Graphics *const graphics) const restrict2
BLOCK_END("MapLayer::drawOGL")
// logger->log("draws: %d", k);
}
-#endif
+#endif // USE_OPENGL
void MapLayer::drawFringe(Graphics *const graphics,
int startX,
diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h
index 6db6d344e..8ba017398 100644
--- a/src/resources/map/maplayer.h
+++ b/src/resources/map/maplayer.h
@@ -123,7 +123,7 @@ class MapLayer final: public MemoryCounter, public ConfigListener
int endY,
const int scrollX,
const int scrollY) restrict2 A_NONNULL(2);
-#endif
+#endif // USE_OPENGL
void updateSDL(const Graphics *restrict const graphics,
int startX,
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 5c6282135..c4134e106 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -25,7 +25,7 @@
#include "configuration.h"
#ifdef USE_OPENGL
#include "graphicsmanager.h"
-#endif
+#endif // USE_OPENGL
#include "main.h"
#include "const/resources/map/map.h"
@@ -45,7 +45,7 @@
#include "resources/db/mapdb.h"
#include "resources/loaders/atlasloader.h"
#include "resources/loaders/emptyatlasloader.h"
-#endif
+#endif // USE_OPENGL
#include "resources/map/tileanimation.h"
@@ -372,7 +372,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
}
}
BLOCK_END("MapReader::readMap load atlas")
-#endif
+#endif // USE_OPENGL
for_each_xml_child_node(childNode, node)
{
@@ -1101,7 +1101,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
reportAlways("Error: image '%s' not present in atlas",
source.c_str());
}
-#endif
+#endif // USE_OPENGL
}
else
{
diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp
index 33d6f442e..5694d3858 100644
--- a/src/resources/memorymanager.cpp
+++ b/src/resources/memorymanager.cpp
@@ -83,7 +83,8 @@ void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED)
#ifdef DYECMD
if (resourceManager)
resourceManager->calcMemory(0);
-#else
+#else // DYECMD
+
int sz = 0;
if (resourceManager)
sz += resourceManager->calcMemory(0);
@@ -93,5 +94,5 @@ void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED)
tab->chatLog(strprintf(_("Calculated memory usage: %d"), sz),
ChatMsgType::BY_SERVER);
}
-#endif
+#endif // DYECMD
}
diff --git a/src/resources/mobileopenglscreenshothelper.cpp b/src/resources/mobileopenglscreenshothelper.cpp
index 57f024031..5a11cc3cd 100644
--- a/src/resources/mobileopenglscreenshothelper.cpp
+++ b/src/resources/mobileopenglscreenshothelper.cpp
@@ -32,7 +32,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "debug.h"
@@ -89,10 +89,11 @@ SDL_Surface *MobileOpenGLScreenshotHelper::getScreenshot()
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
SDL_SetSurfaceBlendMode(tmpImage, SDL_BLENDMODE_NONE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
if (SDL_MUSTLOCK(screenshot))
SDL_LockSurface(screenshot);
diff --git a/src/resources/notificationinfo.h b/src/resources/notificationinfo.h
index bdf44bffc..87376a21d 100644
--- a/src/resources/notificationinfo.h
+++ b/src/resources/notificationinfo.h
@@ -37,7 +37,7 @@ struct NotificationInfo final
{ }
A_DELETE_COPY(NotificationInfo)
-#endif
+#endif // ADVGCC
const char *sound;
const char *text;
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index ef0ef063e..7925e7faa 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -31,7 +31,7 @@
#include "render/modernopenglgraphics.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "render/normalopenglgraphics.h"
#include "render/safeopenglgraphics.h"
@@ -52,7 +52,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
int OpenGLImageHelper::mTextureType = 0;
int OpenGLImageHelper::mInternalTextureType = GL_RGBA8;
@@ -163,10 +163,11 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
// Determine 32-bit masks based on byte order
uint32_t rmask, gmask, bmask, amask;
@@ -175,12 +176,13 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (tmpImage->format->BitsPerPixel != 32
|| realWidth != width || realHeight != height
@@ -191,7 +193,8 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
SDL_Surface *oldImage = tmpImage;
#ifdef USE_SDL2
SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif
+#endif // USE_SDL2
+
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
@@ -213,10 +216,11 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
// Determine 32-bit masks based on byte order
uint32_t rmask, gmask, bmask, amask;
@@ -225,12 +229,13 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (tmpImage->format->BitsPerPixel != 32
|| rmask != tmpImage->format->Rmask
@@ -240,7 +245,8 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
SDL_Surface *oldImage = tmpImage;
#ifdef USE_SDL2
SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif
+#endif // USE_SDL2
+
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
32, rmask, gmask, bmask, amask);
@@ -278,7 +284,8 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
case RENDER_GLES2_OPENGL:
MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
break;
-#else
+#else // ANDROID
+
case RENDER_NORMAL_OPENGL:
NormalOpenGLGraphics::bindTexture(mTextureType, texture);
break;
@@ -294,7 +301,8 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
case RENDER_GLES2_OPENGL:
MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
break;
-#endif
+#endif // ANDROID
+
case RENDER_SOFTWARE:
case RENDER_SDL2_DEFAULT:
case RENDER_NULL:
@@ -356,7 +364,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
}
#if !defined(ANDROID) && !defined(__native_client__)
mglTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
-#endif
+#endif // !defined(ANDROID) && !defined(__native_client__)
mglTexImage2D(mTextureType, 0, mInternalTextureType,
tmpImage->w, tmpImage->h,
@@ -371,7 +379,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
}
*/
-#endif
+#endif // DEBUG_OPENGL
/*
GLint compressed;
@@ -385,7 +393,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
#ifdef DEBUG_OPENGL_LEAKS
textures_count ++;
-#endif
+#endif // DEBUG_OPENGL_LEAKS
if (SDL_MUSTLOCK(tmpImage))
SDL_UnlockSurface(tmpImage);
@@ -428,12 +436,13 @@ SDL_Surface *OpenGLImageHelper::create32BitSurface(int width,
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
const int amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
const int amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
width = powerOfTwo(width);
height = powerOfTwo(height);
@@ -503,4 +512,4 @@ void OpenGLImageHelper::copySurfaceToImage(const Image *const image,
MSDL_FreeSurface(surface);
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
index 99929bb02..5f6e0b8aa 100644
--- a/src/resources/openglimagehelper.h
+++ b/src/resources/openglimagehelper.h
@@ -30,19 +30,19 @@
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
-#endif
+#endif // GL_TEXTURE_RECTANGLE_ARB
#include "resources/imagehelper.h"
#ifdef ANDROID
#include <GLES/gl.h>
#define GL_RGBA8 GL_RGBA8_OES
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
-#endif
+#endif // ANDROID
class Dye;
class Image;
@@ -155,5 +155,5 @@ class OpenGLImageHelper final : public ImageHelper
static bool mUseTextureSampler;
};
-#endif
+#endif // USE_OPENGL
#endif // RESOURCES_OPENGLIMAGEHELPER_H
diff --git a/src/resources/openglscreenshothelper.cpp b/src/resources/openglscreenshothelper.cpp
index d9ba241a3..ef940bc83 100644
--- a/src/resources/openglscreenshothelper.cpp
+++ b/src/resources/openglscreenshothelper.cpp
@@ -31,7 +31,7 @@
#include "render/opengl/mgl.h"
#ifdef __native_client__
#include "render/opengl/naclglfunctions.h"
-#endif
+#endif // __native_client__
#include "debug.h"
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index d0845e3ce..61a7cc0c2 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -38,16 +38,17 @@ void Resource::incRef()
logger->log("before incRef for: %p", static_cast<void*>(this));
mRefCount++;
logger->log("after incRef: %p, %u", static_cast<void*>(this), mRefCount);
-#else
+#else // DEBUG_IMAGES
+
mRefCount++;
-#endif
+#endif // DEBUG_IMAGES
}
void Resource::decRef()
{
#ifdef DEBUG_IMAGES
logger->log("before decRef for: %p", static_cast<void*>(this));
-#endif
+#endif // DEBUG_IMAGES
// Reference may not already have reached zero
if (mRefCount == 0)
@@ -60,7 +61,7 @@ void Resource::decRef()
#ifdef DEBUG_IMAGES
logger->log("after decRef: %p, %u", static_cast<void*>(this), mRefCount);
-#endif
+#endif // DEBUG_IMAGES
if (mRefCount == 0 && !mNotCount)
{
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 71e22b812..009fff4a7 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -48,9 +48,9 @@ class Resource notfinal : public MemoryCounter
#ifdef DEBUG_DUMP_LEAKS
mNotCount(false),
mDumped(false)
-#else
+#else // DEBUG_DUMP_LEAKS
mNotCount(false)
-#endif
+#endif // DEBUG_DUMP_LEAKS
{
}
@@ -108,7 +108,7 @@ class Resource notfinal : public MemoryCounter
void setDumped(const bool n)
{ mDumped = n; }
-#endif
+#endif // DEBUG_DUMP_LEAKS
protected:
/**
@@ -126,7 +126,7 @@ class Resource notfinal : public MemoryCounter
bool mNotCount;
#ifdef DEBUG_DUMP_LEAKS
bool mDumped;
-#endif
+#endif // DEBUG_DUMP_LEAKS
};
#endif // RESOURCES_RESOURCE_H
diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp
index 765790aac..8f7de4e69 100644
--- a/src/resources/resourcemanager/resourcemanager.cpp
+++ b/src/resources/resourcemanager/resourcemanager.cpp
@@ -40,7 +40,7 @@
#ifndef USE_OPENGL
#include <SDL_image.h>
-#endif
+#endif // USE_OPENGL
#include <sstream>
#include <sys/time.h>
@@ -71,7 +71,8 @@ ResourceManager::~ResourceManager()
#ifdef DEBUG_LEAKS
#ifdef UNITTESTS
bool status(false);
-#endif
+#endif // UNITTESTS
+
while (iter != mResources.end())
{
if (iter->second)
@@ -83,7 +84,7 @@ ResourceManager::~ResourceManager()
toString(iter->second->getRefCount())).append(")"));
#ifdef UNITTESTS
status = true;
-#endif
+#endif // UNITTESTS
}
}
++iter;
@@ -92,10 +93,10 @@ ResourceManager::~ResourceManager()
#ifdef UNITTESTS
if (status)
reportAlways("Found leaked resources.");
-#endif
+#endif // UNITTESTS
iter = mResources.begin();
-#endif
+#endif // DEBUG_LEAKS
while (iter != mResources.end())
{
@@ -105,7 +106,8 @@ ResourceManager::~ResourceManager()
++iter;
continue;
}
-#endif
+#endif // DEBUG_LEAKS
+
if (dynamic_cast<SpriteDef*>(iter->second))
{
cleanUp(iter->second);
@@ -129,7 +131,8 @@ ResourceManager::~ResourceManager()
++iter;
continue;
}
-#endif
+#endif // DEBUG_LEAKS
+
if (dynamic_cast<ImageSet*>(iter->second))
{
cleanUp(iter->second);
@@ -153,7 +156,8 @@ ResourceManager::~ResourceManager()
++iter;
continue;
}
-#endif
+#endif // DEBUG_LEAKS
+
if (iter->second)
{
cleanUp(iter->second);
@@ -193,7 +197,7 @@ void ResourceManager::cleanUp(Resource *const res)
delete res;
#ifdef DEBUG_LEAKS
cleanOrphans(true);
-#endif
+#endif // DEBUG_LEAKS
}
void ResourceManager::cleanProtected()
@@ -286,9 +290,10 @@ void ResourceManager::logResource(const Resource *const res)
src.append(" ").append(toString(count));
logger->log("resource(%s) %s", res->mIdPath.c_str(), src.c_str());
}
-#else
+#else // USE_OPENGL
+
logger->log("resource(%s)", res->mIdPath.c_str());
-#endif
+#endif // USE_OPENGL
}
void ResourceManager::clearDeleted(const bool full)
@@ -420,7 +425,8 @@ bool ResourceManager::addResource(const std::string &idPath,
#ifdef DEBUG_IMAGES
logger->log("set name %p, %s", static_cast<void*>(resource),
resource->mIdPath.c_str());
-#endif
+#endif // DEBUG_IMAGES
+
mResources[idPath] = resource;
return true;
}
@@ -494,14 +500,16 @@ Resource *ResourceManager::get(const std::string &idPath,
#ifdef DEBUG_IMAGES
logger->log("set name %p, %s", static_cast<void*>(resource),
resource->mIdPath.c_str());
-#endif
+#endif // DEBUG_IMAGES
+
mResources[idPath] = resource;
}
else
{
reportAlways("Error loading image: %s", idPath.c_str());
}
-#else
+#else // DISABLE_RESOURCE_CACHING
+
Resource *resource = fun(data, idPath);
if (resource)
@@ -511,13 +519,13 @@ Resource *ResourceManager::get(const std::string &idPath,
#ifdef DEBUG_IMAGES
logger->log("set name %p, %s", static_cast<void*>(resource),
resource->mIdPath.c_str());
-#endif
+#endif // DEBUG_IMAGES
}
else
{
reportAlways("Error loading image: " + idPath);
}
-#endif
+#endif // DISABLE_RESOURCE_CACHING
// Returns nullptr if the object could not be created.
return resource;
@@ -565,9 +573,10 @@ void ResourceManager::release(Resource *const res)
mOrphanedResources.insert(*resIter);
mResources.erase(resIter);
-#else
+#else // DISABLE_RESOURCE_CACHING
+
delete res;
-#endif
+#endif // DISABLE_RESOURCE_CACHING
}
void ResourceManager::moveToDeleted(Resource *const res)
@@ -648,7 +657,8 @@ void ResourceManager::deleteInstance()
#ifdef UNITTESTS
bool status(false);
-#endif
+#endif // UNITTESTS
+
while (iter != resourceManager->mResources.end())
{
const Resource *const res = iter->second;
@@ -661,7 +671,7 @@ void ResourceManager::deleteInstance()
res->getRefCount())).append(")"));
#ifdef UNITTESTS
status = true;
-#endif
+#endif // UNITTESTS
}
}
++iter;
@@ -669,9 +679,10 @@ void ResourceManager::deleteInstance()
#ifdef UNITTESTS
if (status)
reportAlways("Found leaked resources.");
-#endif
+#endif // UNITTESTS
}
-#endif
+#endif // DUMP_LEAKED_RESOURCES
+
delete2(resourceManager);
}
diff --git a/src/resources/resourcemanager/resourcemanager.h b/src/resources/resourcemanager/resourcemanager.h
index 6d2f12b37..f63677d85 100644
--- a/src/resources/resourcemanager/resourcemanager.h
+++ b/src/resources/resourcemanager/resourcemanager.h
@@ -160,7 +160,7 @@ class ResourceManager final : public MemoryCounter
Resources* getOrphanedResources() A_WARN_UNUSED
{ return &mOrphanedResources; }
-#endif
+#endif // DEBUG_DUMP_LEAKS
bool cleanOrphans(const bool always = false);
@@ -183,7 +183,7 @@ class ResourceManager final : public MemoryCounter
#ifndef UNITTESTS
private:
-#endif
+#endif // UNITTESTS
/**
* Deletes the resource after logging a cleanup message.
*/
diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc
index ec5e3b0d9..10f61c200 100644
--- a/src/resources/resourcemanager/resourcemanager_unittest.cc
+++ b/src/resources/resourcemanager/resourcemanager_unittest.cc
@@ -103,9 +103,11 @@ TEST_CASE("resourcemanager", "resourcemanager")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
+
ActorSprite::load();
resourceManager = new ResourceManager;
testResouceCounter = 0;
diff --git a/src/resources/safeopenglimagehelper.cpp b/src/resources/safeopenglimagehelper.cpp
index f43351d7c..b1daf05e9 100644
--- a/src/resources/safeopenglimagehelper.cpp
+++ b/src/resources/safeopenglimagehelper.cpp
@@ -48,7 +48,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
int SafeOpenGLImageHelper::mTextureType = 0;
int SafeOpenGLImageHelper::mInternalTextureType = GL_RGBA8;
@@ -163,10 +163,11 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
// Determine 32-bit masks based on byte order
uint32_t rmask, gmask, bmask, amask;
@@ -175,12 +176,13 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (tmpImage->format->BitsPerPixel != 32
|| realWidth != width || realHeight != height
@@ -191,7 +193,8 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
SDL_Surface *oldImage = tmpImage;
#ifdef USE_SDL2
SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif
+#endif // USE_SDL2
+
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
@@ -214,10 +217,11 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
// Determine 32-bit masks based on byte order
uint32_t rmask, gmask, bmask, amask;
@@ -226,12 +230,13 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (tmpImage->format->BitsPerPixel != 32
|| rmask != tmpImage->format->Rmask
@@ -241,7 +246,8 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
SDL_Surface *oldImage = tmpImage;
#ifdef USE_SDL2
SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif
+#endif // USE_SDL2
+
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
32, rmask, gmask, bmask, amask);
@@ -353,7 +359,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
}
#ifndef ANDROID
glTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
-#endif
+#endif // ANDROID
glTexImage2D(mTextureType, 0, mInternalTextureType,
tmpImage->w, tmpImage->h,
@@ -368,7 +374,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
}
*/
-#endif
+#endif // DEBUG_OPENGL
/*
GLint compressed;
@@ -382,7 +388,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
#ifdef DEBUG_OPENGL_LEAKS
textures_count ++;
-#endif
+#endif // DEBUG_OPENGL_LEAKS
if (SDL_MUSTLOCK(tmpImage))
SDL_UnlockSurface(tmpImage);
@@ -425,12 +431,13 @@ SDL_Surface *SafeOpenGLImageHelper::create32BitSurface(int width,
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
const int amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
const int amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
width = powerOfTwo(width);
height = powerOfTwo(height);
diff --git a/src/resources/safeopenglimagehelper.h b/src/resources/safeopenglimagehelper.h
index 691924cfe..90a168bad 100644
--- a/src/resources/safeopenglimagehelper.h
+++ b/src/resources/safeopenglimagehelper.h
@@ -30,19 +30,19 @@
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
-#endif
+#endif // GL_TEXTURE_RECTANGLE_ARB
#include "resources/imagehelper.h"
#ifdef ANDROID
#include <GLES/gl.h>
#define GL_RGBA8 GL_RGBA8_OES
-#else
+#else // ANDROID
#ifndef USE_SDL2
#define GL_GLEXT_PROTOTYPES 1
-#endif
+#endif // USE_SDL2
#include <SDL_opengl.h>
-#endif
+#endif // ANDROID
class Dye;
class Image;
diff --git a/src/resources/screenshothelper.h b/src/resources/screenshothelper.h
index bccce863e..01dabed6c 100644
--- a/src/resources/screenshothelper.h
+++ b/src/resources/screenshothelper.h
@@ -26,11 +26,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
+
_SDL_stdinc_h
#include <SDL_video.h>
diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp
index e647bed8f..bed611708 100644
--- a/src/resources/sdl2imagehelper.cpp
+++ b/src/resources/sdl2imagehelper.cpp
@@ -32,9 +32,7 @@
#include "debug.h"
bool SDLImageHelper::mEnableAlphaCache = false;
-#ifdef USE_SDL2
SDL_Renderer *SDLImageHelper::mRenderer = nullptr;
-#endif
Image *SDLImageHelper::loadSurface(SDL_Surface *const tmpImage)
{
diff --git a/src/resources/sdl2imagehelper.h b/src/resources/sdl2imagehelper.h
index dd88887f3..59cec36ea 100644
--- a/src/resources/sdl2imagehelper.h
+++ b/src/resources/sdl2imagehelper.h
@@ -81,19 +81,15 @@ class SDLImageHelper final : public ImageHelper
SDL_Surface *restrict const dst,
SDL_Rect *restrict const dstrect);
-#ifdef USE_SDL2
static void setRenderer(SDL_Renderer *const renderer)
{ mRenderer = renderer; }
-#endif
protected:
/** SDL_Surface to SDL_Surface Image loader */
Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
static bool mEnableAlphaCache;
-#ifdef USE_SDL2
static SDL_Renderer *mRenderer;
-#endif
};
#endif // USE_SDL2
diff --git a/src/resources/sdl2softwarescreenshothelper.cpp b/src/resources/sdl2softwarescreenshothelper.cpp
index e36745b82..af9982fa1 100644
--- a/src/resources/sdl2softwarescreenshothelper.cpp
+++ b/src/resources/sdl2softwarescreenshothelper.cpp
@@ -34,7 +34,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
Sdl2SoftwareScreenshotHelper::Sdl2SoftwareScreenshotHelper() :
ScreenshotHelper()
@@ -58,11 +58,13 @@ SDL_Surface *Sdl2SoftwareScreenshotHelper::getScreenshot()
const int rmask = 0xff000000;
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int amask = 0x00000000;
SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index 004c05171..de2c0a62a 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -39,7 +39,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
bool SDLImageHelper::mEnableAlphaCache = false;
@@ -65,12 +65,13 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
rgba.Gmask = 0x0000FF00;
rgba.Bmask = 0x00FF0000;
rgba.Amask = 0xFF000000;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rgba.Rmask = 0xFF000000;
rgba.Gmask = 0x00FF0000;
rgba.Bmask = 0x0000FF00;
rgba.Amask = 0x000000FF;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
SDL_Surface *const surf = MSDL_ConvertSurface(
tmpImage, &rgba, SDL_SWSURFACE);
diff --git a/src/resources/sdlmusic.cpp b/src/resources/sdlmusic.cpp
index ba09fcc17..70801d5e2 100644
--- a/src/resources/sdlmusic.cpp
+++ b/src/resources/sdlmusic.cpp
@@ -43,7 +43,7 @@ SDLMusic::~SDLMusic()
SDL_RWclose(mRw);
mRw = nullptr;
}
-#endif
+#endif // USE_SDL2
}
bool SDLMusic::play(const int loops, const int fadeIn)
diff --git a/src/resources/sdlscreenshothelper.cpp b/src/resources/sdlscreenshothelper.cpp
index a7375d919..5062be44d 100644
--- a/src/resources/sdlscreenshothelper.cpp
+++ b/src/resources/sdlscreenshothelper.cpp
@@ -32,7 +32,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
SdlScreenshotHelper::SdlScreenshotHelper() :
ScreenshotHelper()
@@ -56,11 +56,13 @@ SDL_Surface *SdlScreenshotHelper::getScreenshot()
const int rmask = 0xff000000;
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int amask = 0x00000000;
SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
@@ -71,7 +73,7 @@ SDL_Surface *SdlScreenshotHelper::getScreenshot()
#ifndef USE_SDL2
if (screenshot)
SDL_BlitSurface(mainGraphics->mWindow, nullptr, screenshot, nullptr);
-#endif
+#endif // USE_SDL2
return screenshot;
}
diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp
index 738f8c31b..60a2d7f9d 100644
--- a/src/resources/sprite/animatedsprite.cpp
+++ b/src/resources/sprite/animatedsprite.cpp
@@ -77,7 +77,8 @@ AnimatedSprite *AnimatedSprite::load(const std::string &restrict filename,
AnimatedSprite *restrict const as = new AnimatedSprite(s);
#ifdef DEBUG_ANIMATIONS
as->setSpriteName(filename);
-#endif
+#endif // DEBUG_ANIMATIONS
+
as->play(SpriteAction::STAND);
s->decRef();
return as;
@@ -100,7 +101,8 @@ AnimatedSprite *AnimatedSprite::delayedLoad(const std::string &restrict
AnimatedSprite *restrict const as = new AnimatedSprite(nullptr);
#ifdef DEBUG_ANIMATIONS
as->setSpriteName(filename);
-#endif
+#endif // DEBUG_ANIMATIONS
+
as->play(SpriteAction::STAND);
as->setDelayLoad(filename, variant);
return as;
@@ -114,7 +116,8 @@ AnimatedSprite *AnimatedSprite::clone(const AnimatedSprite *restrict const
AnimatedSprite *restrict const sprite = new AnimatedSprite(anim->mSprite);
#ifdef DEBUG_ANIMATIONS
sprite->setSpriteName(anim->getSpriteName());
-#endif
+#endif // DEBUG_ANIMATIONS
+
sprite->play(SpriteAction::STAND);
return sprite;
}
diff --git a/src/resources/sprite/animatedsprite.h b/src/resources/sprite/animatedsprite.h
index 702896be3..7f8332e46 100644
--- a/src/resources/sprite/animatedsprite.h
+++ b/src/resources/sprite/animatedsprite.h
@@ -135,7 +135,7 @@ class AnimatedSprite final : public Sprite
unsigned int getFrameTime() const restrict2
{ return mFrameTime; }
-#endif
+#endif // UNITTESTS
#ifdef DEBUG_ANIMATIONS
void setSpriteName(const std::string &restrict name)
@@ -143,7 +143,7 @@ class AnimatedSprite final : public Sprite
std::string getSpriteName() const A_WARN_UNUSED
{ return mSpriteName; }
-#endif
+#endif // DEBUG_ANIMATIONS
private:
bool updateCurrentAnimation(const unsigned int dt) restrict2;
@@ -153,7 +153,8 @@ class AnimatedSprite final : public Sprite
#ifdef DEBUG_ANIMATIONS
std::string mSpriteName;
-#endif
+#endif // DEBUG_ANIMATIONS
+
SpriteDirection::Type mDirection; /**< The sprite direction. */
int mLastTime; /**< The last time update was called. */
diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc
index 9111434b2..d62c79fc8 100644
--- a/src/resources/sprite/animatedsprite_unittest.cc
+++ b/src/resources/sprite/animatedsprite_unittest.cc
@@ -67,9 +67,11 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
+
ActorSprite::load();
SECTION("basic test 1")
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 944574468..93d6699b5 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -32,11 +32,11 @@
#ifdef WIN32
#include <sys/time.h>
-#endif
+#endif // WIN32
#ifdef __clang__
#include <time.h>
-#endif
+#endif // __clang__
#include "debug.h"
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
index 8ee6f2a26..f3a48059c 100644
--- a/src/soundmanager.cpp
+++ b/src/soundmanager.cpp
@@ -26,7 +26,7 @@
#ifndef DYECMD
#include "being/localplayer.h"
-#endif
+#endif // DYECMD
#include "resources/sdlmusic.h"
#include "resources/soundeffect.h"
@@ -255,10 +255,10 @@ void SoundManager::info()
#ifdef USE_SDL2
const char *driver = SDL_GetCurrentAudioDriver();
-#else
+#else // USE_SDL2
char driver[40] = "Unknown";
SDL_AudioDriverName(driver, 40);
-#endif
+#endif // USE_SDL2
Mix_QuerySpec(&rate, &audioFormat, &channels);
switch (audioFormat)
@@ -443,7 +443,7 @@ void SoundManager::playSfx(const std::string &path A_UNUSED,
const int y A_UNUSED) const
{
}
-#else
+#else // DYECMD
void SoundManager::playSfx(const std::string &path,
const int x, const int y) const
{
@@ -479,7 +479,7 @@ void SoundManager::playSfx(const std::string &path,
sample->decRef();
}
}
-#endif
+#endif // DYECMD
void SoundManager::playGuiSound(const std::string &name)
{
diff --git a/src/soundmanager.h b/src/soundmanager.h
index 474b38b41..f6dc2622f 100644
--- a/src/soundmanager.h
+++ b/src/soundmanager.h
@@ -26,12 +26,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
_SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#include <SDL_mixer.h>
#include "enums/simpletypes/skiperror.h"
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 35ccbf651..3000bc0fb 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -147,7 +147,7 @@ void SpellManager::invoke(const int spellId) const
&& PlayerInfo::getAttribute(Attributes::PLAYER_MP)
>= CAST_S32(spell->getMana()))
)
-#endif
+#endif // TMWA_SUPPORT
{
const Being *const target = localPlayer->getTarget();
if (spell->getTargetType() == CommandTarget::NoTarget)
@@ -159,11 +159,12 @@ void SpellManager::invoke(const int spellId) const
spell->getCommandType() == TextCommandType::Text)) &&
(spell->getTargetType() == CommandTarget::AllowTarget ||
spell->getTargetType() == CommandTarget::NeedTarget))
-#else
+#else // TMWA_SUPPORT
+
if (target &&
(spell->getTargetType() == CommandTarget::AllowTarget ||
spell->getTargetType() == CommandTarget::NeedTarget))
-#endif
+#endif // TMWA_SUPPORT
{
invokeSpell(spell, target);
}
@@ -302,7 +303,7 @@ void SpellManager::load()
static_cast<MagicSchoolT>(school), schoolLvl, mana));
}
else
-#endif
+#endif // TMWA_SUPPORT
{
addSpell(new TextCommand(i, symbol, cmd, comment,
static_cast<CommandTargetT>(targetType), icon));
@@ -340,7 +341,8 @@ void SpellManager::save() const
CAST_U32(spell->getSchool()),
spell->getSchoolLvl(),
CAST_U32(spell->getMana())));
-#else
+#else // TMWA_SUPPORT
+
serverConfig.setValue("commandShortcutFlags" + toString(i),
strprintf("%u %u %u %u %u %u", 1U,
CAST_U32(spell->getTargetType()),
@@ -348,7 +350,7 @@ void SpellManager::save() const
0U,
0U,
0U));
-#endif
+#endif // TMWA_SUPPORT
}
else
{
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index ba9cfc267..7c01402a8 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -54,7 +54,7 @@
#ifdef WIN32
#include <windows.h>
#define sleep(seconds) Sleep((seconds) * 1000)
-#endif
+#endif // WIN32
#include <sys/time.h>
@@ -501,7 +501,8 @@ int TestLauncher::testDyeSpeed()
((static_cast<long int>(time1.tv_sec) * 1000000000L
+ static_cast<long int>(time1.tv_nsec)) / 1);
printf("time: %ld\n", diff);
-#endif
+#endif // defined __linux__ || defined __linux
+
return 0;
}
@@ -689,4 +690,4 @@ int TestLauncher::calcFps(const timeval &start,
return CAST_S32(static_cast<long>(calls) * 10000 / mtime);
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h
index 109b661da..4bfba9abd 100644
--- a/src/test/testlauncher.h
+++ b/src/test/testlauncher.h
@@ -27,11 +27,11 @@
#ifdef WIN32
#include <sys/time.h>
-#endif
+#endif // WIN32
#ifdef __native_client__
#include <sys/time.h>
-#endif
+#endif // __native_client__
#include "localconsts.h"
@@ -84,5 +84,5 @@ class TestLauncher final
std::ofstream file;
};
-#endif
+#endif // USE_OPENGL
#endif // TEST_TESTLAUNCHER_H
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index a242b89bd..e5270d020 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -426,4 +426,4 @@ int TestMain::invokeSafeOpenGLRenderTest(const std::string &test)
log->log("%s: %d", test.c_str(), ret);
return ret;
}
-#endif
+#endif // USE_OPENGL
diff --git a/src/test/testmain.h b/src/test/testmain.h
index 9cc81702d..f54f60829 100644
--- a/src/test/testmain.h
+++ b/src/test/testmain.h
@@ -89,5 +89,5 @@ class TestMain final
Configuration mConfig;
};
-#endif
+#endif // USE_OPENGL
#endif // TEST_TESTMAIN_H
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 96b727788..c991a5d94 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -62,7 +62,7 @@ TextCommand::TextCommand(const int id,
{
loadImage();
}
-#endif
+#endif // TMWA_SUPPORT
TextCommand::TextCommand(const int id,
const std::string &symbol,
@@ -82,7 +82,7 @@ TextCommand::TextCommand(const int id,
mBaseLvl(0),
mSchoolLvl(0),
mCommandType(TextCommandType::Text),
-#endif
+#endif // TMWA_SUPPORT
mImage(nullptr)
{
loadImage();
@@ -101,7 +101,7 @@ TextCommand::TextCommand(const int id) :
mBaseLvl(0),
mSchoolLvl(0),
mCommandType(TextCommandType::Text),
-#endif
+#endif // TMWA_SUPPORT
mImage(nullptr)
{
loadImage();
diff --git a/src/textcommand.h b/src/textcommand.h
index 496c6d8ff..230c926a0 100644
--- a/src/textcommand.h
+++ b/src/textcommand.h
@@ -53,7 +53,7 @@ class TextCommand final
const MagicSchoolT school = MagicSchool::SkillMagic,
const unsigned int schoolLvl = 0U,
const unsigned int mana = 0U);
-#endif
+#endif // TMWA_SUPPORT
/**
* Constructor.
@@ -128,7 +128,7 @@ class TextCommand final
void setCommandType(const TextCommandTypeT commandType)
{ mCommandType = commandType; }
-#endif
+#endif // TMWA_SUPPORT
void setCommand(const std::string &command)
{ mCommand = command; }
@@ -170,7 +170,8 @@ class TextCommand final
unsigned mBaseLvl;
unsigned mSchoolLvl;
TextCommandTypeT mCommandType;
-#endif
+#endif // TMWA_SUPPORT
+
Image *mImage;
};
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
index eab50ee1c..323778372 100644
--- a/src/utils/chatutils.cpp
+++ b/src/utils/chatutils.cpp
@@ -36,7 +36,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "utils/stringutils.h"
@@ -78,7 +78,7 @@ void outStringNormal(ChatTab *const tab,
{
guildManager->chat(str);
}
-#endif
+#endif // TMWA_SUPPORT
}
break;
}
diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc
index d4da5e453..92698b88e 100644
--- a/src/utils/chatutils_unittest.cc
+++ b/src/utils/chatutils_unittest.cc
@@ -61,9 +61,11 @@ TEST_CASE("chatutils replaceVars")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
+
ActorSprite::load();
localPlayer = new LocalPlayer(static_cast<BeingId>(1),
BeingTypeId_zero);
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 464e7ee80..8eba45f30 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -28,10 +28,10 @@
*/
#ifdef _MSC_VER
-# include "msvc/config.h"
+#include "msvc/config.h"
#elif defined(HAVE_CONFIG_H)
-# include "config.h"
-#endif
+#include "config.h"
+#endif // _MSC_VER
#include "utils/copynpaste.h"
@@ -45,7 +45,7 @@
#if defined(__APPLE__)
#ifdef Status
#undef Status
-#endif
+#endif // Status
#include <Carbon/Carbon.h>
#elif defined USE_X11
#include "render/graphics.h"
@@ -58,7 +58,7 @@
#include "utils/naclmessages.h"
#elif defined WIN32
#include <SDL_syswm.h>
-#endif
+#endif // defined(__APPLE__)
#endif // USE_SDL2
@@ -81,7 +81,7 @@ bool sendBuffer(const std::string &restrict text)
return !SDL_SetClipboardText(text.c_str());
}
-#else
+#else // USE_SDL2
#ifdef WIN32
bool retrieveBuffer(std::string& text, size_t& pos)
@@ -450,9 +450,10 @@ static bool runxsel(const std::string &text, const char *p1, const char *p2)
const char *const xselPath =
#if defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
"/usr/local/bin/xsel";
-#else
+#else // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
"/usr/bin/xsel";
-#endif
+#endif // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
+
if (p2)
{
execl(xselPath, "xsel", p1, p2,
@@ -496,7 +497,8 @@ bool sendBuffer(const std::string &restrict text)
naclPostMessage("clipboard-copy", text);
return true;
}
-#else
+#else // WIN32
+
bool retrieveBuffer(std::string&, size_t&)
{
return false;
@@ -506,5 +508,5 @@ bool sendBuffer(const std::string &restrict text A_UNUSED)
{
return false;
}
-#endif
+#endif // WIN32
#endif // USE_SDL2
diff --git a/src/utils/cpu.cpp b/src/utils/cpu.cpp
index 672cc115f..12cc8ceab 100644
--- a/src/utils/cpu.cpp
+++ b/src/utils/cpu.cpp
@@ -27,7 +27,8 @@
// nothing
#elif defined(__linux__) || defined(__linux)
#include "utils/stringutils.h"
-#endif
+#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
+ // && (GCC_VERSION >= 40800) && !defined(ANDROID)
#include "debug.h"
@@ -91,9 +92,11 @@ void Cpu::detect()
}
fclose(file);
logger->log("cpu features was not detected");
-#else
+#else // OTHER
+
logger->log("cpu features not supported");
-#endif
+#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
+ // && (GCC_VERSION >= 40800) && !defined(ANDROID)
}
void Cpu::printFlags()
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
index ea53cb2ef..4085f8b50 100644
--- a/src/utils/env.cpp
+++ b/src/utils/env.cpp
@@ -35,7 +35,7 @@ void updateEnv()
setEnv("SDL_VIDEO_CENTERED", "1");
else
setEnv("SDL_VIDEO_CENTERED", "0");
-#endif
+#endif // defined(WIN32) || defined(__APPLE__)
if (config.getBoolValue("allowscreensaver"))
setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
@@ -60,7 +60,7 @@ void updateEnv()
default:
break;
}
-#endif
+#endif // WIN32
}
void setEnv(const char *const name, const char *const value)
@@ -70,9 +70,10 @@ void setEnv(const char *const name, const char *const value)
#ifdef WIN32
if (putenv(const_cast<char*>((std::string(name)
+ "=" + value).c_str())))
-#else
+#else // WIN32
+
if (setenv(name, value, 1))
-#endif
+#endif // WIN32
{
logger->log("setenv failed: %s=%s", name, value);
}
diff --git a/src/utils/files.cpp b/src/utils/files.cpp
index 6f7ae3147..1aa0e245c 100644
--- a/src/utils/files.cpp
+++ b/src/utils/files.cpp
@@ -26,7 +26,7 @@
#include "resources/resourcemanager/resourcemanager.h"
#include "utils/mkdir.h"
-#endif
+#endif // defined(ANDROID) || defined(__native_client__)
#include "utils/mkdir.h"
#include "utils/paths.h"
@@ -77,7 +77,8 @@ namespace
{
#ifdef ANDROID
int mFilesCount = 0;
-#endif
+#endif // ANDROID
+
Files::CopyFileCallbackPtr mCallbackPtr = nullptr;
} // namespace
@@ -101,7 +102,7 @@ void Files::copyPhysFsFile(const std::string &restrict inFile,
mCallbackPtr(mFilesCount);
mFilesCount ++;
}
-#endif
+#endif // ANDROID
}
void Files::copyPhysFsDir(const std::string &restrict inDir,
@@ -169,9 +170,10 @@ int Files::renameFile(const std::string &restrict srcName,
return 0;
return -1;
-#else
+#else // defined __native_client__
+
return ::rename(srcName.c_str(), dstName.c_str());
-#endif
+#endif // defined __native_client__
}
int Files::copyFile(const std::string &restrict srcName,
@@ -265,7 +267,7 @@ std::string Files::getPath(const std::string &file)
std::string dataZip = "/http/data.zip/";
if (path.substr(0, dataZip.length()) == dataZip)
path = path.replace(0, dataZip.length(), "/http/data/");
-#endif
+#endif // defined __native_client__
}
else
{
diff --git a/src/utils/files.h b/src/utils/files.h
index 8123a5949..b14030b9f 100644
--- a/src/utils/files.h
+++ b/src/utils/files.h
@@ -29,7 +29,7 @@ namespace Files
{
#ifdef ANDROID
void extractLocale();
-#endif
+#endif // ANDROID
#if defined(ANDROID) || defined(__native_client__)
typedef void (*CopyFileCallbackPtr) (int cnt);
diff --git a/src/utils/fuzzer.cpp b/src/utils/fuzzer.cpp
index c9dbad952..8efc88808 100644
--- a/src/utils/fuzzer.cpp
+++ b/src/utils/fuzzer.cpp
@@ -57,4 +57,4 @@ bool Fuzzer::conditionTerminate(const char *const name)
return false;
}
-#endif
+#endif // USE_FUZZER
diff --git a/src/utils/gettext.h b/src/utils/gettext.h
index d4b8938b5..5abdde531 100644
--- a/src/utils/gettext.h
+++ b/src/utils/gettext.h
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif // HAVE_CONFIG_H
#ifdef ENABLE_NLS
diff --git a/src/utils/gettexthelper.cpp b/src/utils/gettexthelper.cpp
index 3ee1bb0b3..650258e42 100644
--- a/src/utils/gettexthelper.cpp
+++ b/src/utils/gettexthelper.cpp
@@ -22,7 +22,7 @@
#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
#include "configuration.h"
-#endif
+#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
#ifdef ENABLE_NLS
#include "client.h"
@@ -148,8 +148,9 @@ void GettextHelper::bindTextDomain(const char *const path)
else
logger->log("bindtextdomain failed");
}
-#else
+#else // ENABLE_NLS
+
void GettextHelper::bindTextDomain(const char *const path A_UNUSED)
{
}
-#endif
+#endif // ENABLE_NLS
diff --git a/src/utils/gettexthelper.h b/src/utils/gettexthelper.h
index 5480371ab..6f298b839 100644
--- a/src/utils/gettexthelper.h
+++ b/src/utils/gettexthelper.h
@@ -23,7 +23,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif // HAVE_CONFIG_H
#include "localconsts.h"
@@ -35,9 +35,9 @@ class GettextHelper final
private:
#ifdef ENABLE_NLS
static void bindTextDomain(const char *const path);
-#else
+#else // ENABLE_NLS
static void bindTextDomain(const char *const path A_UNUSED);
-#endif
+#endif // ENABLE_NLS
};
#endif // UTILS_GETTEXTHELPER_H
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index c2578e487..892d24d96 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -27,7 +27,7 @@
#ifndef USE_SDL2
#include <cmath>
-#endif
+#endif // USE_SDL2
#include "localconsts.h"
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 25a8ba521..000bfeed4 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -24,16 +24,10 @@
#if defined WIN32
#include <limits.h>
#include <windows.h>
-#endif
+#endif // defined WIN32
#include <sys/stat.h>
-#ifdef M_MKDIR_TEST_
-// compile with -D_MKDIR_TEST_ to get a standalone binary
-#include <cstdio>
-#include <cstdlib>
-#endif
-
#include "debug.h"
#if defined WIN32
@@ -101,15 +95,12 @@ int mkdir_r(const char *const pathname)
return -1;
}
-#ifdef M_MKDIR_TEST_
- printf("%s\n", tmp);
-#endif
*p = '/';
}
}
return 0;
}
-#else
+#else // WIN32
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
@@ -164,22 +155,10 @@ int mkdir_r(const char *const pathname)
return -1;
}
-#ifdef M_MKDIR_TEST_
- printf("%s\n", tmp);
-#endif
*p = '/';
}
}
delete []tmp;
return 0;
}
-#endif
-
-#ifdef M_MKDIR_TEST_
-int main(int argc, char** argv)
-{
- if (argc < 2)
- exit(1);
- mkdir_r(argv[1]);
-}
-#endif
+#endif // WIN32
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index e5d098a42..44e132c05 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -19,10 +19,10 @@
*/
#ifdef _MSC_VER
-# include "msvc/config.h"
+#include "msvc/config.h"
#elif defined(HAVE_CONFIG_H)
-# include "config.h"
-#endif
+#include "config.h"
+#endif // _MSC_VER
#include "utils/paths.h"
@@ -33,12 +33,12 @@
#include "utils/files.h"
#include "resources/resourcemanager/resourcemanager.h"
-#endif
+#endif // USE_X11
#ifdef __native_client__
#include <limits.h>
#define realpath(N, R) strcpy(R, N)
-#endif
+#endif // __native_client__
#ifdef WIN32
#include "utils/specialfolder.h"
@@ -47,13 +47,13 @@
#include <limits>
#elif defined __native_client__
#include <limits.h>
-#endif
+#endif // WIN32
#ifdef ANDROID
#ifdef USE_SDL2
#include <SDL_system.h>
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#include "debug.h"
@@ -69,9 +69,12 @@ std::string getRealPath(const std::string &str)
if (!realPath)
return "";
realpath(str.c_str(), realPath);
-#else
+#else // defined(__OpenBSD__) || defined(__ANDROID__) ||
+ // defined(__native_client__)
+
char *realPath = realpath(str.c_str(), nullptr);
-#endif
+#endif // defined(__OpenBSD__) || defined(__ANDROID__) ||
+ // defined(__native_client__)
if (!realPath)
return "";
@@ -148,13 +151,14 @@ std::string getSelfName()
}
}
-#else
+#else // WIN32
+
std::string getSelfName()
{
return "";
}
-#endif
+#endif // WIN32
std::string getPicturesDir()
{
@@ -195,9 +199,10 @@ std::string getPicturesDir()
}
return std::string(PhysFs::getUserDir()).append("Desktop");
-#else
+#else // WIN32
+
return std::string(PhysFs::getUserDir()).append("Desktop");
-#endif
+#endif // WIN32
}
#ifdef ANDROID
@@ -205,7 +210,7 @@ std::string getSdStoragePath()
{
return getenv("DATADIR2");
}
-#endif
+#endif // ANDROID
std::string getPackageDir()
{
diff --git a/src/utils/paths.h b/src/utils/paths.h
index 6d1cf150d..423cffffc 100644
--- a/src/utils/paths.h
+++ b/src/utils/paths.h
@@ -41,7 +41,7 @@ std::string getPicturesDir() A_WARN_UNUSED;
#ifdef ANDROID
std::string getSdStoragePath() A_WARN_UNUSED;
-#endif
+#endif // ANDROID
std::string getPackageDir() A_WARN_UNUSED;
diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp
index 42ab6aaaf..df0258fee 100644
--- a/src/utils/perfomance.cpp
+++ b/src/utils/perfomance.cpp
@@ -97,4 +97,4 @@ namespace Perfomance
}
} // namespace Perfomance
-#endif
+#endif // USE_PROFILER
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp
index e5e7e8e98..f3ebb25b3 100644
--- a/src/utils/physfsrwops.cpp
+++ b/src/utils/physfsrwops.cpp
@@ -34,14 +34,14 @@
#ifdef USE_SDL2
#define PHYSFSINT int64_t
#define PHYSFSSIZE size_t
-#else
+#else // USE_SDL2
#define PHYSFSINT int32_t
#define PHYSFSSIZE int
-#endif
+#endif // USE_SDL2
#ifdef DUMP_LEAKED_RESOURCES
static int openedRWops = 0;
-#endif
+#endif // DUMP_LEAKED_RESOURCES
static PHYSFSINT physfsrwops_seek(SDL_RWops *const rw, const PHYSFSINT offset,
const int whence)
@@ -172,10 +172,11 @@ static int physfsrwops_close(SDL_RWops *const rw)
if (openedRWops <= 0)
logger->log("closing already closed RWops");
openedRWops --;
-#endif
+#endif // DUMP_LEAKED_RESOURCES
#ifdef DEBUG_PHYSFS
FakePhysFSClose(rw);
-#endif
+#endif // DEBUG_PHYSFS
+
return 0;
} /* physfsrwops_close */
@@ -186,7 +187,7 @@ static PHYSFSINT physfsrwops_size(SDL_RWops *const rw)
rw->hidden.unknown.data1);
return PHYSFS_fileLength(handle);
} /* physfsrwops_size */
-#endif
+#endif // USE_SDL2
static SDL_RWops *create_rwops(PHYSFS_file *const handle)
{
@@ -203,7 +204,8 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
{
#ifdef USE_SDL2
retval->size = &physfsrwops_size;
-#endif
+#endif // USE_SDL2
+
retval->seek = &physfsrwops_seek;
retval->read = &physfsrwops_read;
retval->write = &physfsrwops_write;
@@ -212,7 +214,7 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
} /* if */
#ifdef DUMP_LEAKED_RESOURCES
openedRWops ++;
-#endif
+#endif // DUMP_LEAKED_RESOURCES
} /* else */
return retval;
@@ -238,7 +240,7 @@ static bool checkFilePath(const char *const fname)
return false;
return true;
}
-#endif
+#endif // __APPLE__
SDL_RWops *PHYSFSRWOPS_openRead(const char *const fname)
{
@@ -246,18 +248,19 @@ SDL_RWops *PHYSFSRWOPS_openRead(const char *const fname)
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
-#endif
+#endif // __APPLE__
#ifdef USE_FUZZER
if (Fuzzer::conditionTerminate(fname))
return nullptr;
-#endif
+#endif // USE_FUZZER
#ifdef USE_PROFILER
SDL_RWops *const ret = create_rwops(PhysFs::openRead(fname));
BLOCK_END("PHYSFSRWOPS_openRead")
return ret;
-#else
+#else // USE_PROFILER
+
return create_rwops(PhysFs::openRead(fname));
-#endif
+#endif // USE_PROFILER
} /* PHYSFSRWOPS_openRead */
SDL_RWops *PHYSFSRWOPS_openWrite(const char *const fname)
@@ -265,7 +268,8 @@ SDL_RWops *PHYSFSRWOPS_openWrite(const char *const fname)
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
-#endif
+#endif // __APPLE__
+
return create_rwops(PhysFs::openWrite(fname));
} /* PHYSFSRWOPS_openWrite */
@@ -274,7 +278,8 @@ SDL_RWops *PHYSFSRWOPS_openAppend(const char *const fname)
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
-#endif
+#endif // __APPLE__
+
return create_rwops(PhysFs::openAppend(fname));
} /* PHYSFSRWOPS_openAppend */
@@ -284,6 +289,6 @@ void reportRWops()
if (openedRWops)
logger->log("leaking RWops: %d", openedRWops);
}
-#endif
+#endif // DUMP_LEAKED_RESOURCES
/* end of physfsrwops.c ... */
diff --git a/src/utils/physfsrwops.h b/src/utils/physfsrwops.h
index 1a03b7a2f..f69a05da8 100644
--- a/src/utils/physfsrwops.h
+++ b/src/utils/physfsrwops.h
@@ -28,12 +28,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
_SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#include <SDL_rwops.h>
#include "utils/physfstools.h"
@@ -90,6 +90,6 @@ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *const handle) A_WARN_UNUSED;
#ifdef DUMP_LEAKED_RESOURCES
void reportRWops();
-#endif
+#endif // DUMP_LEAKED_RESOURCES
#endif // UTILS_PHYSFSRWOPS_H
diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp
index 1e2ef1e2e..78fc227eb 100644
--- a/src/utils/physfstools.cpp
+++ b/src/utils/physfstools.cpp
@@ -27,7 +27,7 @@
#ifdef ANDROID
#include "utils/paths.h"
-#endif
+#endif // ANDROID
#include "debug.h"
@@ -43,11 +43,12 @@ namespace PhysFs
void init(const char *const name A_UNUSED)
{
if (!PHYSFS_init((getRealPath(".").append("/fakebinary")).c_str()))
-#else
+#else // defined(__native_client__)
+
void init(const char *const name)
{
if (!PHYSFS_init(name))
-#endif
+#endif // defined(__native_client__)
{
std::cout << "Error while initializing PhysFS: "
<< PHYSFS_getLastError() << std::endl;
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index 72deaad5b..cd3d8558c 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -27,14 +27,14 @@
#ifdef USE_SDL2
#ifdef ANDROID
#include <SDL_system.h>
-#endif
-#endif
+#endif // ANDROID
+#endif // USE_SDL2
#include "debug.h"
#ifndef __native_client__
const int timeOut = 10;
-#endif
+#endif // __native_client__
#ifdef WIN32
@@ -220,7 +220,7 @@ bool execFile(const std::string &pathName, const std::string &name,
return true;
}
-#else
+#else // OTHER
int execFileWait(const std::string &pathName A_UNUSED,
const std::string &name A_UNUSED,
@@ -239,7 +239,7 @@ bool execFile(const std::string &pathName A_UNUSED,
return false;
}
-#endif
+#endif // WIN32
#ifdef WIN32
bool openBrowser(std::string url)
@@ -252,14 +252,17 @@ bool openBrowser(std::string url)
#include "utils/stringutils.h"
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
-#endif
+#endif // USE_SDL2
+
bool openBrowser(std::string url)
{
#ifdef USE_SDL2
SDL_OpenBrowser(replaceAll(url, " ", "").c_str());
-#else
+#else // USE_SDL2
+
SDL_ANDROID_OpenBrowser(replaceAll(url, " ", "").c_str());
-#endif
+#endif // USE_SDL2
+
return true;
}
#elif defined __APPLE__
@@ -287,13 +290,13 @@ bool openBrowser(std::string url)
naclPostMessage("open-browser", url);
return true;
}
-#else
+#else // OTHER
bool openBrowser(std::string url)
{
return false;
}
-#endif
+#endif // WIN32
#ifdef WIN32
void setPriority(const bool big)
@@ -304,8 +307,9 @@ void setPriority(const bool big)
else
SetPriorityClass(hCurrentProcess, BELOW_NORMAL_PRIORITY_CLASS);
}
-#else
+#else // WIN32
+
void setPriority(const bool big A_UNUSED)
{
}
-#endif
+#endif // WIN32
diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp
index 8c2f77dbd..b35d151fd 100644
--- a/src/utils/sdlcheckutils.cpp
+++ b/src/utils/sdlcheckutils.cpp
@@ -46,7 +46,8 @@ static SDL_Surface *addSurface(const char *restrict const name,
#ifdef DEBUG_SURFACE_ALLOCATION
logger->log("add surface: %s %s:%u %p", name,
file, line, static_cast<void*>(surface));
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
std::map<void*, SDLMemoryObject*>::iterator
it = mSurfaces.find(surface);
if (it != mSurfaces.end())
@@ -58,7 +59,8 @@ static SDL_Surface *addSurface(const char *restrict const name,
logger->log("adding existing surface: %p, count:%d\n"
"was add %s\nwas deleted %s", surface, obj->mCnt,
obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
obj->mCnt ++;
}
}
@@ -76,7 +78,8 @@ static void deleteSurface(const char *restrict const name A_UNUSED,
{
#ifdef DEBUG_SURFACE_ALLOCATION
logger->log("delete surface: %s %s:%u %p", name, file, line, surface);
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
std::map<void*, SDLMemoryObject*>::iterator
it = mSurfaces.find(surface);
if (it == mSurfaces.end())
@@ -94,7 +97,8 @@ static void deleteSurface(const char *restrict const name A_UNUSED,
logger->log("debug deleting surface: %p, count:%d\n"
"was add %s\nwas deleted %s", surface, cnt,
obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
if (cnt < 1)
{ // surface was here but was deleted
logger->log("deleting already deleted surface: %p at %s:%d\n"
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
index 2e0b51e54..501f27034 100644
--- a/src/utils/sdlhelper.cpp
+++ b/src/utils/sdlhelper.cpp
@@ -48,7 +48,8 @@ bool SDL::getAllVideoModes(StringVect &modeList)
logger->log("support mode: " + modeString);
modeList.push_back(modeString);
return true;
-#else
+#else // ANDROID
+
/* Check which modes are available */
if (modes == static_cast<SDL_Rect **>(nullptr))
{
@@ -72,7 +73,7 @@ bool SDL::getAllVideoModes(StringVect &modeList)
}
return true;
}
-#endif
+#endif // ANDROID
}
void SDL::SetWindowTitle(const SDL_Surface *const window A_UNUSED,
@@ -162,7 +163,8 @@ void SDL::makeCurrentContext(void *const context)
info.info.x11.display,
context);
}
-#else
+#else // defined(USE_X11) && defined(USE_OPENGL)
+
void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
const int major A_UNUSED,
const int minor A_UNUSED,
@@ -174,6 +176,6 @@ void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
void SDL::makeCurrentContext(void *const context A_UNUSED)
{
}
-#endif
+#endif // defined(USE_X11) && defined(USE_OPENGL)
#endif // USE_SDL2
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 66f4c2862..231959c80 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -68,6 +68,10 @@
#include <SDL.h>
+#ifndef SDL_BYTEORDER
+#error missing SDL_endian.h
+#endif // SDL_BYTEORDER
+
/**
* Puts a pixel on an SDL_Surface.
*
@@ -107,11 +111,13 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y,
p[0] = CAST_U8((pixel >> 16) & 0xff);
p[1] = CAST_U8((pixel >> 8) & 0xff);
p[2] = CAST_U8((pixel) & 0xff);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
p[0] = CAST_U8((pixel) & 0xff);
p[1] = CAST_U8((pixel >> 8) & 0xff);
p[2] = CAST_U8((pixel >> 16) & 0xff);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
case 4:
@@ -218,14 +224,16 @@ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
+ color.g * color.a) >> 8);
p[0] = CAST_U8((p[0] * (255 - color.a)
+ color.r * color.a) >> 8);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
p[0] = CAST_U8((p[0] * (255 - color.a)
+ color.b * color.a) >> 8);
p[1] = CAST_U8((p[1] * (255 - color.a)
+ color.g * color.a) >> 8);
p[2] = CAST_U8((p[2] * (255 - color.a)
+ color.r * color.a) >> 8);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
case 4:
diff --git a/src/utils/sdlsharedhelper.cpp b/src/utils/sdlsharedhelper.cpp
index 0f8e0a0d9..33f88dad8 100644
--- a/src/utils/sdlsharedhelper.cpp
+++ b/src/utils/sdlsharedhelper.cpp
@@ -25,7 +25,7 @@
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/mouse_cursor.h>
#include <ppapi_simple/ps.h>
-#endif
+#endif // __native_client__
#include <SDL_events.h>
@@ -43,7 +43,8 @@ void SDL::showCursor(const bool show)
pp::MouseCursor::SetCursor(
pp::InstanceHandle(PSGetInstanceId()),
cursor);
-#endif
+#endif // __native_client__
+
if (show)
SDL_ShowCursor(SDL_ENABLE);
else
diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp
index 99df90645..62695477b 100644
--- a/src/utils/specialfolder.cpp
+++ b/src/utils/specialfolder.cpp
@@ -56,4 +56,4 @@ std::string getSpecialFolderLocation(const int folderId)
return ret;
}
-#endif
+#endif // WIN32
diff --git a/src/utils/specialfolder.h b/src/utils/specialfolder.h
index 6b8f1bd43..31c69124b 100644
--- a/src/utils/specialfolder.h
+++ b/src/utils/specialfolder.h
@@ -28,6 +28,6 @@
#include "localconsts.h"
std::string getSpecialFolderLocation(const int folderId) A_WARN_UNUSED;
-#endif
+#endif // WIN32
#endif // UTILS_SPECIALFOLDER_H
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 3cde2f208..d1d9b7200 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -26,14 +26,14 @@
#include "resources/iteminfo.h"
#include "resources/db/itemdb.h"
-#endif
+#endif // DYECMD
#include <algorithm>
#include <sstream>
#ifdef WIN32
#include <sys/time.h>
-#endif
+#endif // WIN32
#include "utils/gettext.h"
@@ -1066,8 +1066,9 @@ void replaceItemLinks(std::string &msg)
start2 = msg.find('[', start2 + 1);
}
}
-#else
+#else // DYECMD
+
void replaceItemLinks(std::string &msg A_UNUSED)
{
}
-#endif
+#endif // DYECMD
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 5b0249cc1..1a4f6261c 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -103,10 +103,10 @@ std::string strprintf(const char *const format, ...) A_NONNULL(1) A_WARN_UNUSED
#ifdef __GNUC__
#ifdef __OpenBSD__
__attribute__((__format__(printf, 1, 2)))
-#else
+#else // __OpenBSD__
__attribute__((__format__(gnu_printf, 1, 2)))
-#endif
-#endif
+#endif // __OpenBSD__
+#endif // __GNUC__
;
/**
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
index dff2816a8..7100096c8 100644
--- a/src/utils/timer.cpp
+++ b/src/utils/timer.cpp
@@ -33,10 +33,11 @@ namespace
#ifdef USE_SDL2
SDL_TimerID mLogicCounterId(0);
SDL_TimerID mSecondsCounterId(0);
-#else
+#else // USE_SDL2
+
SDL_TimerID mLogicCounterId(nullptr);
SDL_TimerID mSecondsCounterId(nullptr);
-#endif
+#endif // USE_SDL2
} // namespace
/**
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
index ba199a6d6..400583e80 100644
--- a/src/utils/translation/podict.cpp
+++ b/src/utils/translation/podict.cpp
@@ -27,7 +27,7 @@ std::string empty;
PoDict *translator = nullptr;
#ifdef ENABLE_CUSTOMNLS
PoDict *mainTranslator = nullptr;
-#endif
+#endif // ENABLE_CUSTOMNLS
PoDict::PoDict(std::string lang) :
mPoLines(),
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
index 73948aeb4..b9a63258e 100644
--- a/src/utils/translation/podict.h
+++ b/src/utils/translation/podict.h
@@ -43,7 +43,7 @@ class PoDict final
#ifndef UNITTESTS
protected:
-#endif
+#endif // UNITTESTS
friend class PoParser;
PoMap *getMap()
@@ -63,6 +63,6 @@ class PoDict final
extern PoDict *translator;
#ifdef ENABLE_CUSTOMNLS
extern PoDict *mainTranslator;
-#endif
+#endif // ENABLE_CUSTOMNLS
#endif // UTILS_TRANSLATION_PODICT_H
diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc
index d75088ee2..a016c7a86 100644
--- a/src/utils/translation/poparser_unittest.cc
+++ b/src/utils/translation/poparser_unittest.cc
@@ -55,9 +55,10 @@ TEST_CASE("PoParser tests", "PoParser")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
ActorSprite::load();
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 4fa233990..022397401 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -50,7 +50,7 @@ void TranslationManager::loadGettextLang()
delete mainTranslator;
mainTranslator = loadLang(getLang(), "manaplus/");
}
-#endif
+#endif // ENABLE_CUSTOMNLS
void TranslationManager::close()
{
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
index e228b1e75..29cb5d2d7 100644
--- a/src/utils/translation/translationmanager.h
+++ b/src/utils/translation/translationmanager.h
@@ -43,7 +43,7 @@ class TranslationManager final
#ifdef ENABLE_CUSTOMNLS
static void loadGettextLang();
-#endif
+#endif // ENABLE_CUSTOMNLS
static bool translateFile(const std::string &fileName,
PoDict *const dict,
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index 21a24fc67..1e60ab4dc 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -42,10 +42,10 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
#ifdef __GNUC__
#ifdef __OpenBSD__
__attribute__((__format__(printf, 2, 3)))
-#else
+#else // __OpenBSD__
__attribute__((__format__(gnu_printf, 2, 3)))
-#endif
-#endif
+#endif // __OpenBSD__
+#endif // __GNUC__
;
static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
@@ -89,7 +89,8 @@ namespace XML
#ifdef USE_FUZZER
if (Fuzzer::conditionTerminate(filename.c_str()))
return;
-#endif
+#endif // USE_FUZZER
+
BLOCK_START("XML::Document::Document")
int size = 0;
char *data = nullptr;
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
index e60012a9e..4a0c072af 100644
--- a/src/utils/xml/pugixml.cpp
+++ b/src/utils/xml/pugixml.cpp
@@ -67,7 +67,8 @@ namespace XML
#ifdef USE_FUZZER
if (Fuzzer::conditionTerminate(filename.c_str()))
return;
-#endif
+#endif // USE_FUZZER
+
BLOCK_START("XML::Document::Document")
int size = 0;
char *data = nullptr;
diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc
index 3746736ca..cd8a55de9 100644
--- a/src/utils/xml_unittest.cc
+++ b/src/utils/xml_unittest.cc
@@ -53,9 +53,10 @@ TEST_CASE("xml doc")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
theme = new Theme;
Theme::selectSkin();