summaryrefslogtreecommitdiff
path: root/src/resources
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/resources
parent89b267d6d73bbc59f7c313b8a22b97fbb27f99a8 (diff)
downloadmv-3c404128c4669a1f4f190e20a89553677717fc50.tar.gz
mv-3c404128c4669a1f4f190e20a89553677717fc50.tar.bz2
mv-3c404128c4669a1f4f190e20a89553677717fc50.tar.xz
mv-3c404128c4669a1f4f190e20a89553677717fc50.zip
Add missing comments into defines.
Diffstat (limited to 'src/resources')
-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
48 files changed, 369 insertions, 272 deletions
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"