summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/colordb.h2
-rw-r--r--src/resources/dye.cpp6
-rw-r--r--src/resources/dye.h6
-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/resourcemanager.cpp12
-rw-r--r--src/resources/resourcemanager.h6
-rw-r--r--src/resources/spritedef.cpp10
-rw-r--r--src/resources/spritedef.h25
10 files changed, 45 insertions, 43 deletions
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index 2166abcf..892411f8 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -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/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/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index a5d927dd..d005c212 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -213,7 +213,7 @@ std::string ResourceManager::getPath(const std::string &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 3a97c05f..c3c68d88 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -115,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.
@@ -125,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
@@ -155,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;