summaryrefslogtreecommitdiff
path: root/src/compoundsprite.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-06-02 00:32:53 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-06-02 16:41:47 +0200
commit4e27937924766948d7ff9200f04a37fe4d59018c (patch)
treec1f5c255192c85a82c77c2f8f916984e2b863c44 /src/compoundsprite.cpp
parentc2eab288ecc7d7c5e26d02ccecf285cbc0c218ed (diff)
downloadmana-4e27937924766948d7ff9200f04a37fe4d59018c.tar.gz
mana-4e27937924766948d7ff9200f04a37fe4d59018c.tar.bz2
mana-4e27937924766948d7ff9200f04a37fe4d59018c.tar.xz
mana-4e27937924766948d7ff9200f04a37fe4d59018c.zip
Arbitrary code cleanups
Just some stuff that piles up while "looking" at the code, which eventually gets annoying to ignore while staging real changes. * Replaced a few NULL occurrences with 0 * Rely on default parameter for std::vector::resize. * Replaced a few "" with std::string() * Prefer .empty() to == "" * Removed a few comparisons with NULL * Don't check pointers before deleting them * Removed a bunch of redundant semicolons * Made some global variables static (local to their compilation unit) * Prefer prefix ++/-- operators to postfix versions when possible * Corrected location of a comment
Diffstat (limited to 'src/compoundsprite.cpp')
-rw-r--r--src/compoundsprite.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index e96137c4..d77005c7 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -184,7 +184,7 @@ void CompoundSprite::addSprite(Sprite* sprite)
mNeedsRedraw = true;
}
-void CompoundSprite::setSprite(int layer, Sprite* sprite)
+void CompoundSprite::setSprite(int layer, Sprite *sprite)
{
// Skip if it won't change anything
if (at(layer) == sprite)
@@ -199,7 +199,7 @@ void CompoundSprite::setSprite(int layer, Sprite* sprite)
void CompoundSprite::removeSprite(int layer)
{
// Skip if it won't change anything
- if (at(layer) == NULL)
+ if (!at(layer))
return;
delete at(layer);
@@ -223,7 +223,7 @@ void CompoundSprite::ensureSize(size_t layerCount)
if (size() >= layerCount)
return;
- resize(layerCount, NULL);
+ resize(layerCount);
}
/**
@@ -234,8 +234,7 @@ size_t CompoundSprite::getCurrentFrame(size_t layer)
if (layer >= size())
return 0;
- Sprite *s = getSprite(layer);
- if (s)
+ if (Sprite *s = getSprite(layer))
return s->getCurrentFrame();
return 0;