summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/buddylist.cpp4
-rw-r--r--src/resources/colordb.cpp4
-rw-r--r--src/resources/colordb.h4
-rw-r--r--src/resources/dye.cpp6
-rw-r--r--src/resources/dye.h6
-rw-r--r--src/resources/emotedb.cpp2
-rw-r--r--src/resources/emotedb.h2
-rw-r--r--src/resources/imageloader.cpp2
-rw-r--r--src/resources/imageloader.h3
-rw-r--r--src/resources/mapreader.cpp16
-rw-r--r--src/resources/monsterinfo.h8
-rw-r--r--src/resources/resourcemanager.cpp14
-rw-r--r--src/resources/resourcemanager.h11
-rw-r--r--src/resources/spritedef.cpp10
-rw-r--r--src/resources/spritedef.h25
15 files changed, 60 insertions, 57 deletions
diff --git a/src/resources/buddylist.cpp b/src/resources/buddylist.cpp
index 541acabe..719ecab1 100644
--- a/src/resources/buddylist.cpp
+++ b/src/resources/buddylist.cpp
@@ -55,9 +55,9 @@ void BuddyList::loadFile()
char *buddy = new char[LEN_MAX_USERNAME];
inputStream.getline(buddy, LEN_MAX_USERNAME);
// Ugly ?
- if(strcmp(buddy,"")) mBuddylist.push_back(buddy);
+ if (strcmp(buddy, "")) mBuddylist.push_back(buddy);
delete [] buddy;
- } while(!inputStream.eof());
+ } while (!inputStream.eof());
// Read buddy and close file
inputStream.close();
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 7456f0e4..61ea4bc0 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Aethyra; if not, write to the Free Software Foundation,
+ * along with Aethyra; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -101,7 +101,7 @@ void ColorDB::unload()
std::string& ColorDB::get(int id)
{
- if(!mLoaded)
+ if (!mLoaded)
load();
ColorIterator i = mColors.find(id);
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index da36048a..892411f8 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Aethyra; if not, write to the Free Software Foundation,
+ * along with Aethyra; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -47,6 +47,6 @@ namespace ColorDB
// Color DB
typedef std::map<int, std::string> Colors;
typedef Colors::iterator ColorIterator;
-};
+}
#endif
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 63d85501..22bd2411 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -25,7 +25,7 @@
#include "../log.h"
-Palette::Palette(std::string const &description)
+Palette::Palette(const std::string &description)
{
int size = description.length();
if (size == 0) return;
@@ -108,7 +108,7 @@ void Palette::getColor(int intensity, int color[3]) const
color[2] = ((255 - t) * b1 + t * b2) / 255;
}
-Dye::Dye(std::string const &description)
+Dye::Dye(const std::string &description)
{
for (int i = 0; i < 7; ++i)
mPalettes[i] = 0;
@@ -174,7 +174,7 @@ void Dye::update(int color[3]) const
mPalettes[i - 1]->getColor(cmax, color);
}
-void Dye::instantiate(std::string &target, std::string const &palettes)
+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;
diff --git a/src/resources/dye.h b/src/resources/dye.h
index 1db16c6a..3cef334a 100644
--- a/src/resources/dye.h
+++ b/src/resources/dye.h
@@ -37,7 +37,7 @@ class Palette
* The string is either a file name or a sequence of hexadecimal RGB
* values separated by ',' and starting with '#'.
*/
- Palette(std::string const &pallete);
+ Palette(const std::string &pallete);
/**
* Gets a pixel color depending on its intensity.
@@ -64,7 +64,7 @@ class Dye
* The parts of string are separated by semi-colons. Each part starts
* by an uppercase letter, followed by a colon and then a palette name.
*/
- Dye(std::string const &dye);
+ Dye(const std::string &dye);
/**
* Destroys the associated palettes.
@@ -80,7 +80,7 @@ class Dye
* Fills the blank in a dye placeholder with some palette names.
*/
static void instantiate(std::string &target,
- std::string const &palettes);
+ const std::string &palettes);
private:
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index adc1635c..ac41b59c 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Aethyra; if not, write to the Free Software Foundation,
+ * along with Aethyra; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h
index 0962edad..2b9dbbc2 100644
--- a/src/resources/emotedb.h
+++ b/src/resources/emotedb.h
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Aethyra; if not, write to the Free Software Foundation,
+ * along with Aethyra; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index c182b44c..40d62797 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -87,7 +87,7 @@ void ProxyImage::convertToDisplayFormat()
mSDLImage = NULL;
}
-gcn::Image *ImageLoader::load(std::string const &filename, bool convert)
+gcn::Image *ImageLoader::load(const std::string &filename, bool convert)
{
ResourceManager *resman = ResourceManager::getInstance();
ProxyImage *i = new ProxyImage(resman->loadSDLSurface(filename));
diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h
index 0ac7c899..1d6c9ae4 100644
--- a/src/resources/imageloader.h
+++ b/src/resources/imageloader.h
@@ -61,7 +61,8 @@ class ProxyImage : public gcn::Image
class ImageLoader : public gcn::ImageLoader
{
public:
- gcn::Image *load(std::string const &filename, bool convertToDisplayFormat);
+ gcn::Image *load(const std::string &filename,
+ bool convertToDisplayFormat);
};
#endif
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 2278dc67..3270c665 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -359,12 +359,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
xmlNodePtr dataChild = childNode->xmlChildrenNode;
if (!dataChild)
continue;
-
+
int len = strlen((const char*)dataChild->content) + 1;
unsigned char *charData = new unsigned char[len + 1];
const char *charStart = (const char*)dataChild->content;
unsigned char *charIndex = charData;
-
+
while (*charStart) {
if (*charStart != ' ' && *charStart != '\t' &&
*charStart != '\n')
@@ -426,10 +426,10 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
}
}
else {
- // Read plain XML map file
- for_each_xml_child_node(childNode2, childNode)
- {
- if (!xmlStrEqual(childNode2->name, BAD_CAST "tile"))
+ // Read plain XML map file
+ for_each_xml_child_node(childNode2, childNode)
+ {
+ if (!xmlStrEqual(childNode2->name, BAD_CAST "tile"))
continue;
const int gid = XML::getProperty(childNode2, "gid", -1);
@@ -443,12 +443,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
}
}
}
-
+
if (y < h)
std::cerr << "TOO SMALL!\n";
if (x)
std::cerr << "TOO SMALL!\n";
-
+
// There can be only one data element
break;
}
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h
index 75464035..359791fd 100644
--- a/src/resources/monsterinfo.h
+++ b/src/resources/monsterinfo.h
@@ -67,13 +67,13 @@ class MonsterInfo
void addParticleEffect(std::string filename);
- const std::string& getName() const
+ const std::string& getName() const
{ return mName; }
- const std::list<std::string>& getSprites() const
+ const std::list<std::string>& getSprites() const
{ return mSprites; }
- Being::TargetCursorSize getTargetCursorSize() const
+ Being::TargetCursorSize getTargetCursorSize() const
{ return mTargetCursorSize; }
std::string getSound(MonsterSoundEvent event) const;
@@ -83,7 +83,7 @@ class MonsterInfo
void addAttackParticleEffect(const std::string &particleEffect)
{ mAttackParticle = particleEffect; }
- const std::list<std::string>& getParticleEffects() const
+ const std::list<std::string>& getParticleEffects() const
{ return mParticleEffects; }
private:
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index f193d55d..3f58076e 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -207,13 +207,13 @@ std::string ResourceManager::getPath(const std::string &file)
else
{
// if not found in search path return the default path
- path = std::string(AETHYRA_DATADIR) + std::string("data") + "/" + file;
+ path = std::string(TMW_DATADIR) + std::string("data") + "/" + file;
}
return path;
}
-Resource *ResourceManager::get(std::string const &idPath, generator fun,
+Resource *ResourceManager::get(const std::string &idPath, generator fun,
void *data)
{
// Check if the id exists, and return the value if it does.
@@ -265,7 +265,7 @@ struct ResourceLoader
}
};
-Resource *ResourceManager::load(std::string const &path, loader fun)
+Resource *ResourceManager::load(const std::string &path, loader fun)
{
ResourceLoader l = { this, path, fun };
return get(path, ResourceLoader::load, &l);
@@ -307,7 +307,7 @@ struct DyedImageLoader
}
};
-Image *ResourceManager::getImage(std::string const &idPath)
+Image *ResourceManager::getImage(const std::string &idPath)
{
DyedImageLoader l = { this, idPath };
return static_cast<Image*>(get(idPath, DyedImageLoader::load, &l));
@@ -349,8 +349,7 @@ struct SpriteDefLoader
}
};
-SpriteDef *ResourceManager::getSprite
- (std::string const &path, int variant)
+SpriteDef *ResourceManager::getSprite(const std::string &path, int variant)
{
SpriteDefLoader l = { path, variant };
std::stringstream ss;
@@ -379,7 +378,8 @@ void ResourceManager::release(Resource *res)
ResourceManager *ResourceManager::getInstance()
{
// Create a new instance if necessary.
- if (instance == NULL) instance = new ResourceManager();
+ if (!instance)
+ instance = new ResourceManager();
return instance;
}
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index 7996e816..c3c68d88 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -98,8 +98,9 @@ class ResourceManager
bool isDirectory(const std::string &path);
/**
- * Returns the real path to a file
- *
+ * Returns the real path to a file. Note that this method will always
+ * return a path, it does not check whether the file exists.
+ *
* @param file The file to get the real path to.
* @return The real path.
*/
@@ -114,7 +115,7 @@ class ResourceManager
* @return A valid resource or <code>NULL</code> if the resource could
* not be generated.
*/
- Resource *get(std::string const &idPath, generator fun, void *data);
+ Resource *get(const std::string &idPath, generator fun, void *data);
/**
* Loads a resource from a file and adds it to the resource map.
@@ -124,7 +125,7 @@ class ResourceManager
* @return A valid resource or <code>NULL</code> if the resource could
* not be loaded.
*/
- Resource *load(std::string const &path, loader fun);
+ Resource *load(const std::string &path, loader fun);
/**
* Convenience wrapper around ResourceManager::get for loading
@@ -154,7 +155,7 @@ class ResourceManager
* Creates a sprite definition based on a given path and the supplied
* variant.
*/
- SpriteDef *getSprite(std::string const &path, int variant = 0);
+ SpriteDef *getSprite(const std::string &path, int variant = 0);
/**
* Releases a resource, placing it in the set of orphaned resources.
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index e8d064d4..af3281be 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -32,7 +32,7 @@
#include "../log.h"
#include "../utils/xml.h"
-Action* SpriteDef::getAction(SpriteAction action) const
+Action *SpriteDef::getAction(SpriteAction action) const
{
Actions::const_iterator i = mActions.find(action);
@@ -45,7 +45,7 @@ Action* SpriteDef::getAction(SpriteAction action) const
return i->second;
}
-SpriteDef *SpriteDef::load(std::string const &animationFile, int variant)
+SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
{
std::string::size_type pos = animationFile.find('|');
std::string palettes;
@@ -120,7 +120,7 @@ void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant,
}
}
-void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes)
+void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes)
{
const std::string name = XML::getProperty(node, "name", "");
@@ -319,7 +319,7 @@ SpriteDef::~SpriteDef()
}
}
-SpriteAction SpriteDef::makeSpriteAction(const std::string& action)
+SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
{
if (action == "" || action == "default") {
return ACTION_DEFAULT;
@@ -390,5 +390,5 @@ SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction)
}
else {
return DIRECTION_INVALID;
- };
+ }
}
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 99d570f1..b9d7b85d 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -71,13 +71,24 @@ class SpriteDef : public Resource
/**
* Loads a sprite definition file.
*/
- static SpriteDef *load(std::string const &file, int variant);
+ static SpriteDef *load(const std::string &file, int variant);
/**
* Returns the specified action.
*/
Action *getAction(SpriteAction action) const;
+ /**
+ * Converts a string into a SpriteAction enum.
+ */
+ static SpriteAction makeSpriteAction(const std::string &action);
+
+ /**
+ * Converts a string into a SpriteDirection enum.
+ */
+ static SpriteDirection
+ makeSpriteDirection(const std::string &direction);
+
private:
/**
* Constructor.
@@ -98,7 +109,7 @@ class SpriteDef : public Resource
/**
* Loads an imageset element.
*/
- void loadImageSet(xmlNodePtr node, std::string const &palettes);
+ void loadImageSet(xmlNodePtr node, const std::string &palettes);
/**
* Loads an action element.
@@ -128,16 +139,6 @@ class SpriteDef : public Resource
*/
void substituteAction(SpriteAction complete, SpriteAction with);
- /**
- * Converts a string into a SpriteAction enum.
- */
- static SpriteAction makeSpriteAction(const std::string &action);
-
- /**
- * Converts a string into a SpriteDirection enum.
- */
- static SpriteDirection makeSpriteDirection(const std::string &direction);
-
typedef std::map<std::string, ImageSet*> ImageSets;
typedef ImageSets::iterator ImageSetIterator;