summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-23 16:12:22 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-23 16:12:22 +0300
commit4ea8f4bb0c2645940d7d0f5b5e6990346d474ce4 (patch)
tree9c5547054193f815503dcc30029ea28b9f6ac137
parent26c14e5269feafec782166f80c31fe1a7c2b3d53 (diff)
downloadplus-4ea8f4bb0c2645940d7d0f5b5e6990346d474ce4.tar.gz
plus-4ea8f4bb0c2645940d7d0f5b5e6990346d474ce4.tar.bz2
plus-4ea8f4bb0c2645940d7d0f5b5e6990346d474ce4.tar.xz
plus-4ea8f4bb0c2645940d7d0f5b5e6990346d474ce4.zip
Fix code style in map layer.
-rw-r--r--src/resources/map/maplayer.cpp100
-rw-r--r--src/resources/map/maplayer.h16
2 files changed, 70 insertions, 46 deletions
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 89629ea65..b35960965 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -46,8 +46,10 @@
#include "debug.h"
-MapLayer::MapLayer(const int x, const int y,
- const int width, const int height,
+MapLayer::MapLayer(const int x,
+ const int y,
+ const int width,
+ const int height,
const bool fringeLayer,
const int mask,
const int tileCondition) :
@@ -76,9 +78,6 @@ MapLayer::~MapLayer()
{
config.removeListener("highlightAttackRange", this);
CHECKLISTENERS
-// const int sz = mWidth * mHeight;
-// for (int f = 0; f < sz; f ++)
-// delete mTiles[f].image;
delete []mTiles;
delete_all(mTempRows);
mTempRows.clear();
@@ -93,14 +92,20 @@ void MapLayer::optionChanged(const std::string &value)
}
}
-void MapLayer::setTile(const int x, const int y, Image *const img)
+void MapLayer::setTile(const int x,
+ const int y,
+ Image *const img)
{
mTiles[x + y * mWidth].image = img;
}
void MapLayer::draw(Graphics *const graphics,
- int startX, int startY, int endX, int endY,
- const int scrollX, const int scrollY) const
+ int startX,
+ int startY,
+ int endX,
+ int endY,
+ const int scrollX,
+ const int scrollY) const
{
if (!localPlayer)
return;
@@ -144,7 +149,8 @@ void MapLayer::draw(Graphics *const graphics,
{
const int px = x32 + dx;
const int py = py0 - img->mBounds.h;
- if (mSpecialFlag || img->mBounds.h <= mapTileSize)
+ if (mSpecialFlag ||
+ img->mBounds.h <= mapTileSize)
{
int width = 0;
// here need not draw over player position
@@ -191,9 +197,12 @@ void MapLayer::drawSDL(Graphics *const graphics) const
#ifdef USE_OPENGL
void MapLayer::updateSDL(const Graphics *const graphics,
- int startX, int startY,
- int endX, int endY,
- const int scrollX, const int scrollY)
+ int startX,
+ int startY,
+ int endX,
+ int endY,
+ const int scrollX,
+ const int scrollY)
{
BLOCK_START("MapLayer::updateSDL")
delete_all(mTempRows);
@@ -237,7 +246,8 @@ void MapLayer::updateSDL(const Graphics *const graphics,
{
const int px = x * mapTileSize + dx;
const int py = py0 - img->mBounds.h;
- if (mSpecialFlag || img->mBounds.h <= mapTileSize)
+ if (mSpecialFlag ||
+ img->mBounds.h <= mapTileSize)
{
if (lastImage != img)
{
@@ -255,9 +265,12 @@ void MapLayer::updateSDL(const Graphics *const graphics,
}
void MapLayer::updateOGL(Graphics *const graphics,
- int startX, int startY,
- int endX, int endY,
- const int scrollX, const int scrollY)
+ int startX,
+ int startY,
+ int endX,
+ int endY,
+ const int scrollX,
+ const int scrollY)
{
BLOCK_START("MapLayer::updateOGL")
delete_all(mTempRows);
@@ -302,9 +315,11 @@ void MapLayer::updateOGL(Graphics *const graphics,
const int px = x * mapTileSize + dx;
const int py = py0 - img->mBounds.h;
const GLuint imgGlImage = img->mGLImage;
- if (mSpecialFlag || img->mBounds.h <= mapTileSize)
+ if (mSpecialFlag ||
+ img->mBounds.h <= mapTileSize)
{
- if (!lastImage || lastImage->mGLImage != imgGlImage)
+ if (!lastImage ||
+ lastImage->mGLImage != imgGlImage)
{
if (img->mBounds.w > mapTileSize)
imgSet.clear();
@@ -335,12 +350,6 @@ void MapLayer::updateOGL(Graphics *const graphics,
{
graphics->finalize(*it);
}
-/*
- FOR_EACH (ImageVertexesMap::iterator, it, imgSet)
- {
- graphics->finalize((*it).second);
- }
-*/
BLOCK_END("MapLayer::updateOGL")
}
@@ -369,13 +378,18 @@ void MapLayer::drawOGL(Graphics *const graphics) const
#endif
void MapLayer::drawFringe(Graphics *const graphics,
- int startX, int startY,
- int endX, int endY,
- const int scrollX, const int scrollY,
+ int startX,
+ int startY,
+ int endX,
+ int endY,
+ const int scrollX,
+ const int scrollY,
const Actors &actors) const
{
BLOCK_START("MapLayer::drawFringe")
- if (!localPlayer || !mSpecialLayer || !mTempLayer)
+ if (!localPlayer ||
+ !mSpecialLayer ||
+ !mTempLayer)
{
BLOCK_END("MapLayer::drawFringe")
return;
@@ -404,9 +418,9 @@ void MapLayer::drawFringe(Graphics *const graphics,
const int specialWidth = mSpecialLayer->mWidth;
const int specialHeight = mSpecialLayer->mHeight;
- const bool flag = mDrawLayerFlags == MapType::SPECIAL3
- || mDrawLayerFlags == MapType::SPECIAL4
- || mDrawLayerFlags == MapType::BLACKWHITE;
+ const bool flag = mDrawLayerFlags == MapType::SPECIAL3 ||
+ mDrawLayerFlags == MapType::SPECIAL4 ||
+ mDrawLayerFlags == MapType::BLACKWHITE;
const int minEndY = std::min(specialHeight, endY);
@@ -484,7 +498,8 @@ void MapLayer::drawFringe(Graphics *const graphics,
BLOCK_START("MapLayer::drawFringe drawmobs")
// If drawing the fringe layer, make sure all actors above this
// row of tiles have been drawn
- while (ai != ai_end && (*ai)->getSortPixelY() <= y32s)
+ while (ai != ai_end &&
+ (*ai)->getSortPixelY() <= y32s)
{
(*ai)->draw(graphics, -scrollX, -scrollY);
++ ai;
@@ -506,7 +521,8 @@ void MapLayer::drawFringe(Graphics *const graphics,
const Image *const img = tilePtr->image;
if (img)
{
- if (mSpecialFlag || img->mBounds.h <= mapTileSize)
+ if (mSpecialFlag ||
+ img->mBounds.h <= mapTileSize)
{
const int px = x32 + dx;
const int py = py0 - img->mBounds.h;
@@ -593,7 +609,8 @@ void MapLayer::drawFringe(Graphics *const graphics,
{
const int px = x32 + dx;
const int py = py0 - img->mBounds.h;
- if (mSpecialFlag || img->mBounds.h <= mapTileSize)
+ if (mSpecialFlag ||
+ img->mBounds.h <= mapTileSize)
{
int width = 0;
// here need not draw over player position
@@ -619,8 +636,8 @@ void MapLayer::drawFringe(Graphics *const graphics,
} // !flag
// Draw any remaining actors
- if (mDrawLayerFlags != MapType::SPECIAL3
- && mDrawLayerFlags != MapType::SPECIAL4)
+ if (mDrawLayerFlags != MapType::SPECIAL3 &&
+ mDrawLayerFlags != MapType::SPECIAL4)
{
BLOCK_START("MapLayer::drawFringe drawmobs")
while (ai != ai_end)
@@ -629,7 +646,7 @@ void MapLayer::drawFringe(Graphics *const graphics,
++ai;
}
BLOCK_END("MapLayer::drawFringe drawmobs")
- if (mHighlightAttackRange && localPlayer)
+ if (mHighlightAttackRange)
{
const int px = localPlayer->getPixelX()
- scrollX - mapTileSize / 2;
@@ -694,13 +711,14 @@ int MapLayer::getTileDrawWidth(const TileInfo *tilePtr,
void MapLayer::setDrawLayerFlags(const MapTypeT &n)
{
mDrawLayerFlags = n;
- mSpecialFlag = (mDrawLayerFlags != MapType::SPECIAL
- && mDrawLayerFlags != MapType::SPECIAL2
- && mDrawLayerFlags != MapType::SPECIAL4);
+ mSpecialFlag = (mDrawLayerFlags != MapType::SPECIAL &&
+ mDrawLayerFlags != MapType::SPECIAL2 &&
+ mDrawLayerFlags != MapType::SPECIAL4);
}
void MapLayer::updateConditionTiles(MetaTile *const metaTiles,
- const int width, const int height)
+ const int width,
+ const int height)
{
const int width1 = width < mWidth ? width : mWidth;
const int height1 = height < mHeight ? height : mHeight;
diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h
index 9c0fc12c0..fbfc524da 100644
--- a/src/resources/map/maplayer.h
+++ b/src/resources/map/maplayer.h
@@ -60,8 +60,10 @@ class MapLayer final: public ConfigListener
* fringe layer. The fringe layer is the layer that draws the actors.
* There can be only one fringe layer per map.
*/
- MapLayer(const int x, const int y,
- const int width, const int height,
+ MapLayer(const int x,
+ const int y,
+ const int width,
+ const int height,
const bool isFringeLayer,
const int mask,
const int tileCondition);
@@ -76,12 +78,15 @@ class MapLayer final: public ConfigListener
/**
* Set tile image, with x and y in layer coordinates.
*/
- void setTile(const int x, const int y, Image *const img);
+ void setTile(const int x,
+ const int y,
+ Image *const img);
/**
* Set tile image with x + y * width already known.
*/
- void setTile(const int index, Image *const img)
+ void setTile(const int index,
+ Image *const img)
{ mTiles[index].image = img; }
/**
@@ -159,7 +164,8 @@ class MapLayer final: public ConfigListener
int &width) A_WARN_UNUSED;
void updateConditionTiles(MetaTile *const metaTiles,
- const int width, const int height);
+ const int width,
+ const int height);
private:
const int mX;