summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 20:58:10 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 21:22:43 +0100
commit68760426532b9ca4c6939d7a7b8faa1586ee82e0 (patch)
tree891f475717294eef4c68af4bb830f35744643075 /src
parentddc93c461070fb3d868fbb5426e8361d1b93ee38 (diff)
downloadmana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.tar.gz
mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.tar.bz2
mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.tar.xz
mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.zip
Code reformatting
I wish I had never fallen for this weird style, and I hope removing it will prevent others from introducing new code like this. :-)
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp58
-rw-r--r--src/being.h73
-rw-r--r--src/gui/tabbedcontainer.cpp5
-rw-r--r--src/imageparticle.h3
-rw-r--r--src/particle.cpp72
-rw-r--r--src/particle.h81
-rw-r--r--src/resources/action.cpp11
-rw-r--r--src/resources/mapreader.cpp29
-rw-r--r--src/resources/mapreader.h19
-rw-r--r--src/resources/monsterdb.cpp11
-rw-r--r--src/resources/resourcemanager.cpp53
-rw-r--r--src/resources/resourcemanager.h54
-rw-r--r--src/textparticle.h4
13 files changed, 175 insertions, 298 deletions
diff --git a/src/being.cpp b/src/being.cpp
index e1c370c3..56764fed 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -18,6 +18,7 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#include "being.h"
#include <cassert>
@@ -111,8 +112,7 @@ Being::~Being()
delete mSpeech;
}
-void
-Being::setDestination(Uint16 destX, Uint16 destY)
+void Being::setDestination(Uint16 destX, Uint16 destY)
{
if (mMap)
{
@@ -120,14 +120,12 @@ Being::setDestination(Uint16 destX, Uint16 destY)
}
}
-void
-Being::clearPath()
+void Being::clearPath()
{
mPath.clear();
}
-void
-Being::setPath(const Path &path)
+void Being::setPath(const Path &path)
{
mPath = path;
@@ -138,23 +136,20 @@ Being::setPath(const Path &path)
}
}
-void
-Being::setHairStyle(int style, int color)
+void Being::setHairStyle(int style, int color)
{
mHairStyle = style < 0 ? mHairStyle : style % getHairStylesNr();
mHairColor = color < 0 ? mHairColor : color % getHairColorsNr();
}
-void
-Being::setSprite(int slot, int id, std::string color)
+void Being::setSprite(int slot, int id, std::string color)
{
assert(slot >= BASE_SPRITE && slot < VECTOREND_SPRITE);
mSpriteIDs[slot] = id;
mSpriteColors[slot] = color;
}
-void
-Being::setSpeech(const std::string &text, Uint32 time)
+void Being::setSpeech(const std::string &text, Uint32 time)
{
// don't introduce a memory leak
delete mSpeech;
@@ -165,8 +160,7 @@ Being::setSpeech(const std::string &text, Uint32 time)
mSpeechTime = 500;
}
-void
-Being::takeDamage(int amount)
+void Being::takeDamage(int amount)
{
gcn::Font *font;
std::string damage = amount ? toString(amount) : "miss";
@@ -197,16 +191,14 @@ Being::takeDamage(int amount)
mPx + 16, mPy + 16);
}
-void
-Being::handleAttack(Being *victim, int damage)
+void Being::handleAttack(Being *victim, int damage)
{
setAction(Being::ATTACK);
mFrame = 0;
mWalkTime = tick_time;
}
-void
-Being::setMap(Map *map)
+void Being::setMap(Map *map)
{
// Remove sprite from potential previous map
if (mMap)
@@ -226,14 +218,12 @@ Being::setMap(Map *map)
mChildParticleEffects.clear();
}
-void
-Being::controlParticle(Particle *particle)
+void Being::controlParticle(Particle *particle)
{
mChildParticleEffects.addLocally(particle);
}
-void
-Being::setAction(Uint8 action)
+void Being::setAction(Uint8 action)
{
SpriteAction currentAction = ACTION_INVALID;
switch (action)
@@ -287,8 +277,7 @@ Being::setAction(Uint8 action)
}
-void
-Being::setDirection(Uint8 direction)
+void Being::setDirection(Uint8 direction)
{
mDirection = direction;
SpriteDirection dir = getSpriteDirection();
@@ -324,8 +313,7 @@ Being::getSpriteDirection() const
return dir;
}
-void
-Being::nextStep()
+void Being::nextStep()
{
if (mPath.empty())
{
@@ -360,8 +348,7 @@ Being::nextStep()
mWalkTime += mWalkSpeed / 10;
}
-void
-Being::logic()
+void Being::logic()
{
// Reduce the time that speech is still displayed
if (mSpeechTime > 0 && mSpeech)
@@ -407,8 +394,7 @@ Being::logic()
mChildParticleEffects.setPositions((float)mPx + 16.0f, (float)mPy + 32.0f);
}
-void
-Being::draw(Graphics *graphics, int offsetX, int offsetY) const
+void Being::draw(Graphics *graphics, int offsetX, int offsetY) const
{
int px = mPx + offsetX;
int py = mPy + offsetY;
@@ -422,8 +408,7 @@ Being::draw(Graphics *graphics, int offsetX, int offsetY) const
}
}
-void
-Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
+void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
{
if (!mEmotion)
return;
@@ -436,8 +421,7 @@ Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
graphics->drawImage(emotionSet->get(emotionIndex), px, py);
}
-Being::Type
-Being::getType() const
+Being::Type Being::getType() const
{
return UNKNOWN;
}
@@ -528,8 +512,7 @@ Being::getOffset(char pos, char neg) const
}
-int
-Being::getWidth() const
+int Being::getWidth() const
{
if (mSprites[BASE_SPRITE])
{
@@ -541,8 +524,7 @@ Being::getWidth() const
}
-int
-Being::getHeight() const
+int Being::getHeight() const
{
if (mSprites[BASE_SPRITE])
{
diff --git a/src/being.h b/src/being.h
index abbd4c30..de558f83 100644
--- a/src/being.h
+++ b/src/being.h
@@ -164,8 +164,7 @@ class Being : public Sprite
*
* @param amount The amount of damage.
*/
- virtual void
- takeDamage(int amount);
+ virtual void takeDamage(int amount);
/**
* Handles an attack of another being by this being.
@@ -173,22 +172,21 @@ class Being : public Sprite
* @param victim The attacked being.
* @param damage The amount of damage dealt (0 means miss).
*/
- virtual void
- handleAttack(Being *victim, int damage);
+ virtual void handleAttack(Being *victim, int damage);
/**
* Returns the name of the being.
*/
- const std::string&
- getName() const { return mName; }
+ const std::string &getName() const
+ { return mName; }
/**
* Sets the name for the being.
*
* @param name The name that should appear.
*/
- virtual void
- setName(const std::string &name) { mName = name; }
+ virtual void setName(const std::string &name)
+ { mName = name; }
/**
* Gets the hair color for this being.
@@ -205,44 +203,37 @@ class Being : public Sprite
/**
* Sets the hair style and color for this being.
*/
- virtual void
- setHairStyle(int style, int color);
+ virtual void setHairStyle(int style, int color);
/**
* Sets visible equipments for this being.
*/
- virtual void
- setSprite(int slot, int id, std::string color = "");
+ virtual void setSprite(int slot, int id, std::string color = "");
/**
* Sets the gender of this being.
*/
- virtual void
- setGender(int gender) { mGender = gender; }
+ virtual void setGender(int gender) { mGender = gender; }
/**
* Gets the gender of this being.
*/
- int
- getGender() const { return mGender; }
+ int getGender() const { return mGender; }
/**
* Makes this being take the next step of his path.
*/
- virtual void
- nextStep();
+ virtual void nextStep();
/**
* Performs being logic.
*/
- virtual void
- logic();
+ virtual void logic();
/**
* Draws the emotion picture above the being.
*/
- void
- drawEmotion(Graphics *graphics, int offsetX, int offsetY);
+ void drawEmotion(Graphics *graphics, int offsetX, int offsetY);
/**
* Returns the type of the being.
@@ -252,26 +243,22 @@ class Being : public Sprite
/**
* Gets the walk speed.
*/
- Uint16
- getWalkSpeed() const { return mWalkSpeed; }
+ Uint16 getWalkSpeed() const { return mWalkSpeed; }
/**
* Sets the walk speed.
*/
- void
- setWalkSpeed(Uint16 speed) { mWalkSpeed = speed; }
+ void setWalkSpeed(Uint16 speed) { mWalkSpeed = speed; }
/**
* Gets the sprite id.
*/
- Uint32
- getId() const { return mId; }
+ Uint32 getId() const { return mId; }
/**
* Sets the sprite id.
*/
- void
- setId(Uint32 id) { mId = id; }
+ void setId(Uint32 id) { mId = id; }
/**
* Sets the map the being is on
@@ -281,8 +268,7 @@ class Being : public Sprite
/**
* Sets the current action.
*/
- virtual void
- setAction(Uint8 action);
+ virtual void setAction(Uint8 action);
/**
* Returns the current direction.
@@ -299,46 +285,41 @@ class Being : public Sprite
*
* @see Sprite::draw(Graphics, int, int)
*/
- virtual void
- draw(Graphics *graphics, int offsetX, int offsetY) const;
+ virtual void draw(Graphics *graphics, int offsetX, int offsetY) const;
/**
* Returns the pixel X coordinate.
*/
- int
- getPixelX() const { return mPx; }
+ int getPixelX() const { return mPx; }
/**
* Returns the pixel Y coordinate.
*
* @see Sprite::getPixelY()
*/
- int
- getPixelY() const { return mPy; }
+ int getPixelY() const { return mPy; }
/**
* Get the current X pixel offset.
*/
- int
- getXOffset() const { return getOffset(LEFT, RIGHT); }
+ int getXOffset() const
+ { return getOffset(LEFT, RIGHT); }
/**
* Get the current Y pixel offset.
*/
- int
- getYOffset() const { return getOffset(UP, DOWN); }
+ int getYOffset() const
+ { return getOffset(UP, DOWN); }
/**
* Returns the horizontal size of the current base sprite of the being
*/
- virtual int
- getWidth() const;
+ virtual int getWidth() const;
/**
* Returns the vertical size of the current base sprite of the being
*/
- virtual int
- getHeight() const;
+ virtual int getHeight() const;
/**
* Returns the required size of a target cursor for this being.
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index fba4e846..8c23f76f 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "tabbedcontainer.h"
#include "button.h"
@@ -38,8 +36,7 @@ TabbedContainer::TabbedContainer():
TabbedContainer::~TabbedContainer()
{
- for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs));
-
+ delete_all(mTabs);
mTabs.clear();
mContents.clear();
}
diff --git a/src/imageparticle.h b/src/imageparticle.h
index 91c5426c..c18b30b8 100644
--- a/src/imageparticle.h
+++ b/src/imageparticle.h
@@ -49,8 +49,7 @@ class ImageParticle : public Particle
/**
* Draws the particle image
*/
- virtual void
- draw(Graphics *graphics, int offsetX, int offsetY) const;
+ virtual void draw(Graphics *graphics, int offsetX, int offsetY) const;
protected:
Image *mImage; /**< The image used for this particle. */
diff --git a/src/particle.cpp b/src/particle.cpp
index d4266df2..e534527f 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -68,12 +68,21 @@ Particle::Particle(Map *map):
mMomentum(1.0f)
{
Particle::particleCount++;
- if (mMap) setSpriteIterator(mMap->addSprite(this));
+ if (mMap)
+ setSpriteIterator(mMap->addSprite(this));
}
+Particle::~Particle()
+{
+ // Remove from map sprite list
+ if (mMap)
+ mMap->removeSprite(mSpriteIterator);
+ // Delete child emitters and child particles
+ clear();
+ Particle::particleCount--;
+}
-void
-Particle::setupEngine()
+void Particle::setupEngine()
{
Particle::maxCount = (int)config.getValue("particleMaxCount", 3000);
Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0);
@@ -82,17 +91,17 @@ Particle::setupEngine()
logger->log("Particle engine set up");
}
-void Particle::draw(Graphics *, int, int) const {}
+void Particle::draw(Graphics *, int, int) const
+{
+}
-bool
-Particle::update()
+bool Particle::update()
{
- if (!mMap) return false;
+ if (!mMap)
+ return false;
if (mLifetimeLeft == 0)
- {
mAlive = false;
- }
Vector oldPos = mPos;
@@ -222,9 +231,8 @@ Particle::update()
return true;
}
-Particle*
-Particle::addEffect(const std::string &particleEffectFile,
- int pixelX, int pixelY)
+Particle *Particle::addEffect(const std::string &particleEffectFile,
+ int pixelX, int pixelY)
{
Particle *newParticle = NULL;
@@ -298,11 +306,9 @@ Particle::addEffect(const std::string &particleEffectFile,
return newParticle;
}
-
-Particle*
-Particle::addTextSplashEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font, int x, int y)
+Particle *Particle::addTextSplashEffect(const std::string &text,
+ int colorR, int colorG, int colorB,
+ gcn::Font *font, int x, int y)
{
Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB,
font);
@@ -320,9 +326,9 @@ Particle::addTextSplashEffect(const std::string &text,
return newParticle;
}
-Particle*
-Particle::addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font,
- int x, int y)
+Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
+ gcn::Font *font,
+ int x, int y)
{
Particle *newParticle = new TextParticle(mMap, text, 255, 255, 255, font);
newParticle->setPosition(x, y, 0);
@@ -337,32 +343,18 @@ Particle::addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font,
return newParticle;
}
-void
-Particle::setMap(Map *map)
+void Particle::setMap(Map *map)
{
mMap = map;
- if (mMap) setSpriteIterator(mMap->addSprite(this));
+ if (mMap)
+ setSpriteIterator(mMap->addSprite(this));
}
-
-Particle::~Particle()
-{
- // Remove from map sprite list
- if (mMap) mMap->removeSprite(mSpriteIterator);
- // Delete child emitters and child particles
- clear();
- Particle::particleCount--;
-}
-
-
-void
-Particle::clear()
+void Particle::clear()
{
- std::for_each(mChildEmitters.begin(), mChildEmitters.end(),
- make_dtor(mChildEmitters));
+ delete_all(mChildEmitters);
mChildEmitters.clear();
- std::for_each(mChildParticles.begin(), mChildParticles.end(),
- make_dtor(mChildParticles));
+ delete_all(mChildParticles);
mChildParticles.clear();
}
diff --git a/src/particle.h b/src/particle.h
index 6c00eadd..2077af43 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -67,22 +67,19 @@ class Particle : public Sprite
/**
* Deletes all child particles and emitters.
*/
- void
- clear();
+ void clear();
/**
* Gives a particle the properties of an engine root particle and loads
* the particle-related config settings.
*/
- void
- setupEngine();
+ void setupEngine();
/**
* Updates particle position, returns false when the particle should
* be deleted.
*/
- virtual bool
- update();
+ virtual bool update();
/**
* Draws the particle image.
@@ -92,8 +89,7 @@ class Particle : public Sprite
/**
* Necessary for sorting with the other sprites.
*/
- virtual int
- getPixelY() const
+ virtual int getPixelY() const
{ return (int) (mPos.y + mPos.z) - 64; }
/**
@@ -105,44 +101,39 @@ class Particle : public Sprite
* Creates a child particle that hosts some emitters described in the
* particleEffectFile.
*/
- Particle*
- addEffect(const std::string &particleEffectFile,
- int pixelX, int pixelY);
+ Particle *addEffect(const std::string &particleEffectFile,
+ int pixelX, int pixelY);
/**
* Creates a standalone text particle.
*/
- Particle*
- addTextSplashEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font, int x, int y);
+ Particle *addTextSplashEffect(const std::string &text,
+ int colorR, int colorG, int colorB,
+ gcn::Font *font, int x, int y);
/**
* Creates a standalone text particle.
*/
- Particle*
- addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font,
- int x, int y);
+ Particle *addTextRiseFadeOutEffect(const std::string &text,
+ gcn::Font *font,
+ int x, int y);
/**
* Adds an emitter to the particle.
*/
- void
- addEmitter (ParticleEmitter* emitter)
+ void addEmitter (ParticleEmitter* emitter)
{ mChildEmitters.push_back(emitter); }
/**
* Sets the position in 3 dimensional space in pixels relative to map.
*/
- void
- setPosition(float x, float y, float z)
+ void setPosition(float x, float y, float z)
{ mPos.x = x; mPos.y = y; mPos.z = z; }
/**
* Sets the position in 2 dimensional space in pixels relative to map.
*/
- void
- setPosition(float x, float y)
+ void setPosition(float x, float y)
{ mPos.x = x; mPos.y = y; }
/**
@@ -154,53 +145,45 @@ class Particle : public Sprite
/**
* Changes the particle position relative
*/
- void
- moveBy(float x, float y, float z)
+ void moveBy(float x, float y, float z)
{ mPos.x += x; mPos.y += y; mPos.z += z; }
- void
- moveChildren(Vector change);
+ void moveChildren(Vector change);
- void
- moveBy (Vector change)
+ void moveBy (Vector change)
{ mPos += change; }
/**
* Sets the time in game ticks until the particle is destroyed.
*/
- void
- setLifetime(int lifetime)
+ void setLifetime(int lifetime)
{ mLifetimeLeft = lifetime; mLifetimePast = 0; }
/**
* Sets the age of the pixel in game ticks where the particle has
* faded in completely.
*/
- void
- setFadeOut(int fadeOut)
+ void setFadeOut(int fadeOut)
{ mFadeOut = fadeOut; }
/**
* Sets the remaining particle lifetime where the particle starts to
* fade out.
*/
- void
- setFadeIn(int fadeIn)
+ void setFadeIn(int fadeIn)
{ mFadeIn = fadeIn; }
/**
* Sets the alpha value of the particle
*/
- void
- setAlpha(float alpha)
+ void setAlpha(float alpha)
{ mAlpha = alpha; }
/**
* Sets the sprite iterator of the particle on the current map to make
* it easier to remove the particle from the map when it is destroyed.
*/
- void
- setSpriteIterator(std::list<Sprite*>::iterator spriteIterator)
+ void setSpriteIterator(std::list<Sprite*>::iterator spriteIterator)
{ mSpriteIterator = spriteIterator; }
/**
@@ -213,44 +196,38 @@ class Particle : public Sprite
/**
* Sets the current velocity in 3 dimensional space.
*/
- void
- setVelocity(float x, float y, float z)
+ void setVelocity(float x, float y, float z)
{ mVelocity.x = x; mVelocity.y = y; mVelocity.z = z; }
/**
* Sets the downward acceleration.
*/
- void
- setGravity(float gravity)
+ void setGravity(float gravity)
{ mGravity = gravity; }
/**
* Sets the ammount of random vector changes
*/
- void
- setRandomness(int r)
+ void setRandomness(int r)
{ mRandomness = r; }
/**
* Sets the ammount of velocity particles retain after
* hitting the ground.
*/
- void
- setBounce(float bouncieness)
+ void setBounce(float bouncieness)
{ mBounce = bouncieness; }
/**
* Sets the flag if the particle is supposed to be moved by its parent
*/
- void
- setFollow(bool follow)
+ void setFollow(bool follow)
{ mFollow = follow; }
/**
* Gets the flag if the particle is supposed to be moved by its parent
*/
- bool
- doesFollow()
+ bool doesFollow()
{ return mFollow; }
/**
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index ffbbffb2..bbea45c9 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -21,8 +21,6 @@
#include "action.h"
-#include <algorithm>
-
#include "animation.h"
#include "../utils/dtor.h"
@@ -34,12 +32,10 @@ Action::Action()
Action::~Action()
{
- std::for_each(mAnimations.begin(), mAnimations.end(),
- make_dtor(mAnimations));
+ delete_all(mAnimations);
}
-Animation*
-Action::getAnimation(int direction) const
+Animation *Action::getAnimation(int direction) const
{
Animations::const_iterator i = mAnimations.find(direction);
@@ -53,8 +49,7 @@ Action::getAnimation(int direction) const
return (i == mAnimations.end()) ? NULL : i->second;
}
-void
-Action::setAnimation(int direction, Animation *animation)
+void Action::setAnimation(int direction, Animation *animation)
{
mAnimations[direction] = animation;
}
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 4c37c239..835e52b3 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -43,9 +43,8 @@ const unsigned int DEFAULT_TILE_HEIGHT = 32;
* Inflates either zlib or gzip deflated memory. The inflated memory is
* expected to be freed by the caller.
*/
-int
-inflateMemory(unsigned char *in, unsigned int inLength,
- unsigned char *&out, unsigned int &outLength)
+int inflateMemory(unsigned char *in, unsigned int inLength,
+ unsigned char *&out, unsigned int &outLength)
{
int bufferSize = 256 * 1024;
int ret;
@@ -109,9 +108,8 @@ inflateMemory(unsigned char *in, unsigned int inLength,
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
-int
-inflateMemory(unsigned char *in, unsigned int inLength,
- unsigned char *&out)
+int inflateMemory(unsigned char *in, unsigned int inLength,
+ unsigned char *&out)
{
unsigned int outLength = 0;
int ret = inflateMemory(in, inLength, out, outLength);
@@ -143,8 +141,7 @@ inflateMemory(unsigned char *in, unsigned int inLength,
return outLength;
}
-Map*
-MapReader::readMap(const std::string &filename)
+Map *MapReader::readMap(const std::string &filename)
{
// Load the file through resource manager
ResourceManager *resman = ResourceManager::getInstance();
@@ -201,8 +198,7 @@ MapReader::readMap(const std::string &filename)
return map;
}
-Map*
-MapReader::readMap(xmlNodePtr node, const std::string &path)
+Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
{
// Take the filename off the path
const std::string pathDir = path.substr(0, path.rfind("/") + 1);
@@ -289,8 +285,7 @@ MapReader::readMap(xmlNodePtr node, const std::string &path)
return map;
}
-void
-MapReader::readProperties(xmlNodePtr node, Properties* props)
+void MapReader::readProperties(xmlNodePtr node, Properties *props)
{
for_each_xml_child_node(childNode, node)
{
@@ -319,8 +314,7 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
}
}
-void
-MapReader::readLayer(xmlNodePtr node, Map *map)
+void MapReader::readLayer(xmlNodePtr node, Map *map)
{
// Layers are not necessarily the same size as the map
const int w = XML::getProperty(node, "width", map->getWidth());
@@ -454,10 +448,9 @@ MapReader::readLayer(xmlNodePtr node, Map *map)
}
}
-Tileset*
-MapReader::readTileset(xmlNodePtr node,
- const std::string &path,
- Map *map)
+Tileset *MapReader::readTileset(xmlNodePtr node,
+ const std::string &path,
+ Map *map)
{
if (xmlHasProp(node, BAD_CAST "source"))
{
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index 0142eb45..04e83b99 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -39,15 +39,13 @@ class MapReader
/**
* Read an XML map from a file.
*/
- static Map*
- readMap(const std::string &filename);
+ static Map *readMap(const std::string &filename);
/**
* Read an XML map from a parsed XML tree. The path is used to find the
* location of referenced tileset images.
*/
- static Map*
- readMap(xmlNodePtr node, const std::string &path);
+ static Map *readMap(xmlNodePtr node, const std::string &path);
private:
/**
@@ -57,26 +55,23 @@ class MapReader
* @param props The Properties instance to which the properties will
* be assigned.
*/
- static void
- readProperties(xmlNodePtr node, Properties* props);
+ static void readProperties(xmlNodePtr node, Properties* props);
/**
* Reads a map layer and adds it to the given map.
*/
- static void
- readLayer(xmlNodePtr node, Map *map);
+ static void readLayer(xmlNodePtr node, Map *map);
/**
* Reads a tile set.
*/
- static Tileset*
- readTileset(xmlNodePtr node, const std::string &path, Map *map);
+ static Tileset *readTileset(xmlNodePtr node, const std::string &path,
+ Map *map);
/**
* Gets an integer property from an xmlNodePtr.
*/
- static int
- getProperty(xmlNodePtr node, const char* name, int def);
+ static int getProperty(xmlNodePtr node, const char* name, int def);
};
#endif
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 11b2baf7..725b039e 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
-
#include "monsterdb.h"
#include "resourcemanager.h"
@@ -138,19 +136,16 @@ MonsterDB::load()
mLoaded = true;
}
-void
-MonsterDB::unload()
+void MonsterDB::unload()
{
- for_each(mMonsterInfos.begin(), mMonsterInfos.end(),
- make_dtor(mMonsterInfos));
+ delete_all(mMonsterInfos);
mMonsterInfos.clear();
mLoaded = false;
}
-const MonsterInfo&
-MonsterDB::get(int id)
+const MonsterInfo &MonsterDB::get(int id)
{
MonsterInfoIterator i = mMonsterInfos.find(id);
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 90b29374..a1965d57 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -93,8 +93,7 @@ ResourceManager::~ResourceManager()
}
}
-void
-ResourceManager::cleanUp(Resource *res)
+void ResourceManager::cleanUp(Resource *res)
{
if (res->mRefCount > 0)
{
@@ -140,14 +139,12 @@ void ResourceManager::cleanOrphans()
mOldestOrphan = oldest;
}
-bool
-ResourceManager::setWriteDir(const std::string &path)
+bool ResourceManager::setWriteDir(const std::string &path)
{
return (bool) PHYSFS_setWriteDir(path.c_str());
}
-bool
-ResourceManager::addToSearchPath(const std::string &path, bool append)
+bool ResourceManager::addToSearchPath(const std::string &path, bool append)
{
logger->log("Adding to PhysicsFS: %s", path.c_str());
if (!PHYSFS_addToSearchPath(path.c_str(), append ? 1 : 0)) {
@@ -157,8 +154,7 @@ ResourceManager::addToSearchPath(const std::string &path, bool append)
return true;
}
-void
-ResourceManager::searchAndAddArchives(const std::string &path,
+void ResourceManager::searchAndAddArchives(const std::string &path,
const std::string &ext,
bool append)
{
@@ -184,31 +180,27 @@ ResourceManager::searchAndAddArchives(const std::string &path,
PHYSFS_freeList(list);
}
-bool
-ResourceManager::mkdir(const std::string &path)
+bool ResourceManager::mkdir(const std::string &path)
{
return (bool) PHYSFS_mkdir(path.c_str());
}
-bool
-ResourceManager::exists(const std::string &path)
+bool ResourceManager::exists(const std::string &path)
{
return PHYSFS_exists(path.c_str());
}
-bool
-ResourceManager::isDirectory(const std::string &path)
+bool ResourceManager::isDirectory(const std::string &path)
{
return PHYSFS_isDirectory(path.c_str());
}
-std::string
-ResourceManager::getPath(const std::string &file)
+std::string ResourceManager::getPath(const std::string &file)
{
// get the real path to the file
const char* tmp = PHYSFS_getRealDir(file.c_str());
std::string path;
-
+
// if the file is not in the search path, then its NULL
if (tmp)
{
@@ -219,11 +211,12 @@ ResourceManager::getPath(const std::string &file)
// if not found in search path return the default path
path = std::string(TMW_DATADIR) + std::string("data") + "/" + file;
}
-
+
return path;
}
-Resource *ResourceManager::get(std::string const &idPath, generator fun, void *data)
+Resource *ResourceManager::get(std::string const &idPath, generator fun,
+ void *data)
{
// Check if the id exists, and return the value if it does.
ResourceIterator resIter = mResources.find(idPath);
@@ -280,14 +273,12 @@ Resource *ResourceManager::load(std::string const &path, loader fun)
return get(path, ResourceLoader::load, &l);
}
-Music*
-ResourceManager::getMusic(const std::string &idPath)
+Music *ResourceManager::getMusic(const std::string &idPath)
{
return static_cast<Music*>(load(idPath, Music::load));
}
-SoundEffect*
-ResourceManager::getSoundEffect(const std::string &idPath)
+SoundEffect *ResourceManager::getSoundEffect(const std::string &idPath)
{
return static_cast<SoundEffect*>(load(idPath, SoundEffect::load));
}
@@ -340,8 +331,8 @@ struct ImageSetLoader
}
};
-ImageSet*
-ResourceManager::getImageSet(const std::string &imagePath, int w, int h)
+ImageSet *ResourceManager::getImageSet(const std::string &imagePath,
+ int w, int h)
{
ImageSetLoader l = { this, imagePath, w, h };
std::stringstream ss;
@@ -387,23 +378,20 @@ void ResourceManager::release(Resource *res)
mResources.erase(resIter);
}
-ResourceManager*
-ResourceManager::getInstance()
+ResourceManager *ResourceManager::getInstance()
{
// Create a new instance if necessary.
if (instance == NULL) instance = new ResourceManager();
return instance;
}
-void
-ResourceManager::deleteInstance()
+void ResourceManager::deleteInstance()
{
delete instance;
instance = NULL;
}
-void*
-ResourceManager::loadFile(const std::string &fileName, int &fileSize)
+void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
{
// Attempt to open the specified file using PhysicsFS
PHYSFS_file *file = PHYSFS_openRead(fileName.c_str());
@@ -455,8 +443,7 @@ ResourceManager::loadTextFile(const std::string &fileName)
return lines;
}
-SDL_Surface*
-ResourceManager::loadSDLSurface(const std::string& filename)
+SDL_Surface *ResourceManager::loadSDLSurface(const std::string& filename)
{
int fileSize;
void *buffer = loadFile(filename, fileSize);
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index 66813a9c..c1007f4a 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -64,8 +64,7 @@ class ResourceManager
* @param path The path of the directory to be added.
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
- bool
- setWriteDir(const std::string &path);
+ bool setWriteDir(const std::string &path);
/**
* Adds a directory or archive to the search path. If append is true
@@ -74,35 +73,30 @@ class ResourceManager
*
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
- bool
- addToSearchPath(const std::string &path, bool append);
+ bool addToSearchPath(const std::string &path, bool append);
/**
* Searches for zip files and adds them to the search path.
*/
- void
- searchAndAddArchives(const std::string &path,
- const std::string &ext,
- bool append);
+ void searchAndAddArchives(const std::string &path,
+ const std::string &ext,
+ bool append);
/**
* Creates a directory in the write path
*/
- bool
- mkdir(const std::string &path);
+ bool mkdir(const std::string &path);
/**
* Checks whether the given file or directory exists in the search path
*/
- bool
- exists(const std::string &path);
+ bool exists(const std::string &path);
/**
* Checks whether the given path is a directory.
*/
- bool
- isDirectory(const std::string &path);
-
+ bool isDirectory(const std::string &path);
+
/**
* Returns the real path to a file
*
@@ -136,29 +130,25 @@ class ResourceManager
* Convenience wrapper around ResourceManager::get for loading
* images.
*/
- Image*
- getImage(const std::string &idPath);
+ Image *getImage(const std::string &idPath);
/**
* Convenience wrapper around ResourceManager::get for loading
* songs.
*/
- Music*
- getMusic(const std::string &idPath);
+ Music *getMusic(const std::string &idPath);
/**
* Convenience wrapper around ResourceManager::get for loading
* samples.
*/
- SoundEffect*
- getSoundEffect(const std::string &idPath);
+ SoundEffect *getSoundEffect(const std::string &idPath);
/**
* Creates a image set based on the image referenced by the given
* path and the supplied sprite sizes
*/
- ImageSet*
- getImageSet(const std::string &imagePath, int w, int h);
+ ImageSet *getImageSet(const std::string &imagePath, int w, int h);
/**
* Creates a sprite definition based on a given path and the supplied
@@ -181,41 +171,35 @@ class ResourceManager
* @return An allocated byte array containing the data that was loaded,
* or <code>NULL</code> on fail.
*/
- void*
- loadFile(const std::string &fileName, int &fileSize);
+ void *loadFile(const std::string &fileName, int &fileSize);
/**
* Retrieves the contents of a text file.
*/
- std::vector<std::string>
- loadTextFile(const std::string &fileName);
+ std::vector<std::string> loadTextFile(const std::string &fileName);
/**
* Loads the given filename as an SDL surface. The returned surface is
* expected to be freed by the caller using SDL_FreeSurface.
*/
- SDL_Surface*
- loadSDLSurface(const std::string& filename);
+ SDL_Surface *loadSDLSurface(const std::string& filename);
/**
* Returns an instance of the class, creating one if it does not
* already exist.
*/
- static ResourceManager*
- getInstance();
+ static ResourceManager *getInstance();
/**
* Deletes the class instance if it exists.
*/
- static void
- deleteInstance();
+ static void deleteInstance();
private:
/**
* Deletes the resource after logging a cleanup message.
*/
- static void
- cleanUp(Resource *resource);
+ static void cleanUp(Resource *resource);
void cleanOrphans();
diff --git a/src/textparticle.h b/src/textparticle.h
index 3a0ba674..d56dbf84 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -37,11 +37,11 @@ class TextParticle : public Particle
TextParticle(Map *map, const std::string &text,
int colorR, int colorG, int colorB,
gcn::Font *font);
+
/**
* Draws the particle image.
*/
- virtual void
- draw(Graphics *graphics, int offsetX, int offsetY) const;
+ virtual void draw(Graphics *graphics, int offsetX, int offsetY) const;
// hack to improve text visibility
virtual int getPixelY() const