summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-26 19:09:31 -0600
committerIra Rice <irarice@gmail.com>2009-03-26 19:09:31 -0600
commit1a9d402bec2fd8166ce50e30a71ba0cf2f27281a (patch)
treee012433f561406ebd67d685f205c86c1c13681b3
parent2ec46b9a6e5ca1beb043da00cf2bb9d34722ec72 (diff)
downloadmana-1a9d402bec2fd8166ce50e30a71ba0cf2f27281a.tar.gz
mana-1a9d402bec2fd8166ce50e30a71ba0cf2f27281a.tar.bz2
mana-1a9d402bec2fd8166ce50e30a71ba0cf2f27281a.tar.xz
mana-1a9d402bec2fd8166ce50e30a71ba0cf2f27281a.zip
Some code style commits influenced by TMW commit
1715d0afe44a282a356ca88e47c92ec556f094dd Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/gui/scrollarea.cpp17
-rw-r--r--src/resources/action.cpp2
-rw-r--r--src/resources/ambientoverlay.h9
-rw-r--r--src/resources/colordb.cpp2
-rw-r--r--src/resources/dye.cpp54
-rw-r--r--src/resources/imagewriter.cpp3
-rw-r--r--src/shopitem.cpp3
7 files changed, 53 insertions, 37 deletions
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 43b27f23..156ff054 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -217,12 +217,12 @@ void ScrollArea::draw(gcn::Graphics *graphics)
void ScrollArea::drawFrame(gcn::Graphics *graphics)
{
- int bs = getFrameSize();
- int w = getWidth() + bs * 2;
- int h = getHeight() + bs * 2;
-
if (mOpaque)
{
+ const int bs = getFrameSize();
+ const int w = getWidth() + bs * 2;
+ const int h = getHeight() + bs * 2;
+
static_cast<Graphics*>(graphics)->
drawImageRect(0, 0, w, h, background);
}
@@ -232,14 +232,7 @@ void ScrollArea::setOpaque(bool opaque)
{
mOpaque = opaque;
- if (mOpaque)
- {
- setFrameSize(2);
- }
- else
- {
- setFrameSize(0);
- }
+ setFrameSize(mOpaque ? 2 : 0);
}
void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir)
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index 67acf1b1..27369def 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -41,9 +41,7 @@ Animation *Action::getAnimation(int direction) const
// When the given direction is not available, return the first one.
// (either DEFAULT, or more usually DOWN).
if (i == mAnimations.end())
- {
i = mAnimations.begin();
- }
return (i == mAnimations.end()) ? NULL : i->second;
}
diff --git a/src/resources/ambientoverlay.h b/src/resources/ambientoverlay.h
index bb61f826..142dfd2f 100644
--- a/src/resources/ambientoverlay.h
+++ b/src/resources/ambientoverlay.h
@@ -31,6 +31,11 @@ class AmbientOverlay
public:
/**
* Constructor.
+ *
+ * @param img the image this overlay displays
+ * @param parallax scroll factor based on camera position
+ * @param speedX scrolling speed in x-direction
+ * @param speedY scrolling speed in y-direction
*/
AmbientOverlay(Image *img, float parallax,
float speedX, float speedY);
@@ -49,8 +54,8 @@ class AmbientOverlay
float mParallax;
float mPosX; /**< Current layer X position. */
float mPosY; /**< Current layer Y position. */
- float mSpeedX; /**< Scroll speed in X direction. */
- float mSpeedY; /**< Scroll speed in Y direction. */
+ float mSpeedX; /**< Scrolling speed in X direction. */
+ float mSpeedY; /**< Scrolling speed in Y direction. */
};
#endif
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index b53798bb..c9252a8a 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -40,9 +40,7 @@ namespace
void ColorDB::load()
{
if (mLoaded)
- {
return;
- }
XML::Document *doc = new XML::Document(HAIR_COLOR_FILE);
xmlNodePtr root = doc->rootNode();
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 38249ddb..35a8ca89 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -29,33 +29,42 @@
DyePalette::DyePalette(const std::string &description)
{
int size = description.length();
- if (size == 0) return;
- if (description[0] != '#')
- {
+ if (size == 0 || description[0] != '#')
// TODO: load palette from file.
return;
- }
int pos = 1;
for (;;)
{
- if (pos + 6 > size) break;
+ if (pos + 6 > size)
+ break;
+
int v = 0;
for (int i = 0; i < 6; ++i)
{
char c = description[pos + i];
int n;
- if ('0' <= c && c <= '9') n = c - '0';
- else if ('A' <= c && c <= 'F') n = c - 'A' + 10;
- else if ('a' <= c && c <= 'f') n = c - 'a' + 10;
- else goto error;
+
+ if ('0' <= c && c <= '9')
+ n = c - '0';
+ else if ('A' <= c && c <= 'F')
+ n = c - 'A' + 10;
+ else if ('a' <= c && c <= 'f')
+ n = c - 'a' + 10;
+ else
+ goto error;
+
v = (v << 4) | n;
}
Color c = { { v >> 16, v >> 8, v } };
mColors.push_back(c);
pos += 6;
- if (pos == size) return;
- if (description[pos] != ',') break;
+
+ if (pos == size)
+ return;
+ if (description[pos] != ',')
+ break;
+
++pos;
}
@@ -114,21 +123,26 @@ Dye::Dye(const std::string &description)
for (int i = 0; i < 7; ++i)
mDyePalettes[i] = 0;
- if (description.empty()) return;
+ if (description.empty())
+ return;
std::string::size_type next_pos = 0, length = description.length();
do
{
std::string::size_type pos = next_pos;
next_pos = description.find(';', pos);
+
if (next_pos == std::string::npos)
next_pos = length;
+
if (next_pos <= pos + 3 || description[pos + 1] != ':')
{
logger->log("Error, invalid dye: %s", description.c_str());
return;
}
+
int i = 0;
+
switch (description[pos])
{
case 'R': i = 0; break;
@@ -142,7 +156,8 @@ Dye::Dye(const std::string &description)
logger->log("Error, invalid dye: %s", description.c_str());
return;
}
- mDyePalettes[i] = new DyePalette(description.substr(pos + 2, next_pos - pos - 2));
+ mDyePalettes[i] = new DyePalette(description.substr(pos + 2,
+ next_pos - pos - 2));
++next_pos;
}
while (next_pos < length);
@@ -157,7 +172,8 @@ Dye::~Dye()
void Dye::update(int color[3]) const
{
int cmax = std::max(color[0], std::max(color[1], color[2]));
- if (cmax == 0) return;
+ if (cmax == 0)
+ return;
int cmin = std::min(color[0], std::min(color[1], color[2]));
int intensity = color[0] + color[1] + color[2];
@@ -178,7 +194,10 @@ void Dye::update(int color[3]) const
void Dye::instantiate(std::string &target, const std::string &palettes)
{
std::string::size_type next_pos = target.find('|');
- if (next_pos == std::string::npos || palettes.empty()) return;
+
+ if (next_pos == std::string::npos || palettes.empty())
+ return;
+
++next_pos;
std::ostringstream s;
@@ -188,7 +207,10 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
{
std::string::size_type pos = next_pos;
next_pos = target.find(';', pos);
- if (next_pos == std::string::npos) next_pos = last_pos;
+
+ if (next_pos == std::string::npos)
+ next_pos = last_pos;
+
if (next_pos == pos + 1 && pal_pos != std::string::npos)
{
std::string::size_type pal_next_pos = palettes.find(';', pal_pos);
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index 5ddd24e3..854753c1 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -28,8 +28,7 @@
#include "../log.h"
-bool ImageWriter::writePNG(SDL_Surface *surface,
- const std::string &filename)
+bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
{
// TODO Maybe someone can make this look nice?
FILE *fp = fopen(filename.c_str(), "wb");
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 00875a2d..f1ef3dad 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -25,7 +25,8 @@
#include "utils/stringutils.h"
ShopItem::ShopItem (int inventoryIndex, int id, int quantity, int price) :
- Item (id, 0), mPrice(price)
+ Item (id, 0),
+ mPrice(price)
{
mDisplayName = getInfo().getName() + " (" + toString(mPrice) + " GP)";
setInvIndex(inventoryIndex);