summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-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/resourcemanager.cpp12
-rw-r--r--src/resources/resourcemanager.h9
-rw-r--r--src/resources/spritedef.cpp31
-rw-r--r--src/resources/spritedef.h23
8 files changed, 41 insertions, 51 deletions
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 3be105d8..d180d725 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -26,7 +26,7 @@
#include "../log.h"
-Palette::Palette(std::string const &description)
+Palette::Palette(const std::string &description)
{
int size = description.length();
if (size == 0) return;
@@ -109,7 +109,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;
@@ -175,7 +175,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 528a1d91..f0bd7aab 100644
--- a/src/resources/dye.h
+++ b/src/resources/dye.h
@@ -36,7 +36,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 &);
+ Palette(const std::string &);
/**
* Gets a pixel color depending on its intensity.
@@ -63,7 +63,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(const std::string &);
/**
* Destroys the associated palettes.
@@ -79,7 +79,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 29458ba3..835ba100 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -88,7 +88,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 7979fd2f..821a0254 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/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 8c6d1376..bebd17f8 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -211,7 +211,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.
@@ -263,7 +263,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);
@@ -305,7 +305,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));
@@ -347,8 +347,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;
@@ -377,7 +376,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 c1007f4a..e70dfb9d 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -98,7 +98,8 @@ 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 5aea55fa..f5b763ea 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -33,8 +33,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);
@@ -47,7 +46,7 @@ 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;
@@ -122,7 +121,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", "");
@@ -147,8 +146,7 @@ void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes)
mImageSets[name] = imageSet;
}
-void
-SpriteDef::loadAction(xmlNodePtr node, int variant_offset)
+void SpriteDef::loadAction(xmlNodePtr node, int variant_offset)
{
const std::string actionName = XML::getProperty(node, "name", "");
const std::string imageSetName = XML::getProperty(node, "imageset", "");
@@ -188,10 +186,9 @@ SpriteDef::loadAction(xmlNodePtr node, int variant_offset)
}
}
-void
-SpriteDef::loadAnimation(xmlNodePtr animationNode,
- Action *action, ImageSet *imageSet,
- int variant_offset)
+void SpriteDef::loadAnimation(xmlNodePtr animationNode,
+ Action *action, ImageSet *imageSet,
+ int variant_offset)
{
const std::string directionName =
XML::getProperty(animationNode, "direction", "");
@@ -268,8 +265,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode,
} // for frameNode
}
-void
-SpriteDef::includeSprite(xmlNodePtr includeNode)
+void SpriteDef::includeSprite(xmlNodePtr includeNode)
{
// TODO: Perform circular dependency check, since it's easy to crash the
// client this way.
@@ -290,8 +286,7 @@ SpriteDef::includeSprite(xmlNodePtr includeNode)
loadSprite(rootNode, 0);
}
-void
-SpriteDef::substituteAction(SpriteAction complete, SpriteAction with)
+void SpriteDef::substituteAction(SpriteAction complete, SpriteAction with)
{
if (mActions.find(complete) == mActions.end())
{
@@ -325,8 +320,7 @@ SpriteDef::~SpriteDef()
}
}
-SpriteAction
-SpriteDef::makeSpriteAction(const std::string& action)
+SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
{
if (action == "" || action == "default") {
return ACTION_DEFAULT;
@@ -408,8 +402,7 @@ SpriteDef::makeSpriteAction(const std::string& action)
}
}
-SpriteDirection
-SpriteDef::makeSpriteDirection(const std::string& direction)
+SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction)
{
if (direction == "" || direction == "default") {
return DIRECTION_DEFAULT;
@@ -428,5 +421,5 @@ SpriteDef::makeSpriteDirection(const std::string& direction)
}
else {
return DIRECTION_INVALID;
- };
+ }
}
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 56b9a713..0c3e443b 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -81,7 +81,7 @@ 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.
@@ -91,8 +91,7 @@ class SpriteDef : public Resource
/**
* Converts a string into a SpriteAction enum.
*/
- static SpriteAction
- makeSpriteAction(const std::string &action);
+ static SpriteAction makeSpriteAction(const std::string &action);
private:
/**
@@ -114,27 +113,24 @@ 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.
*/
- void
- loadAction(xmlNodePtr node, int variant_offset);
+ void loadAction(xmlNodePtr node, int variant_offset);
/**
* Loads an animation element.
*/
- void
- loadAnimation(xmlNodePtr animationNode,
- Action *action, ImageSet *imageSet,
- int variant_offset);
+ void loadAnimation(xmlNodePtr animationNode,
+ Action *action, ImageSet *imageSet,
+ int variant_offset);
/**
* Include another sprite into this one.
*/
- void
- includeSprite(xmlNodePtr includeNode);
+ void includeSprite(xmlNodePtr includeNode);
/**
* Complete missing actions by copying existing ones.
@@ -145,8 +141,7 @@ class SpriteDef : public Resource
* When there are no animations defined for the action "complete", its
* animations become a copy of those of the action "with".
*/
- void
- substituteAction(SpriteAction complete, SpriteAction with);
+ void substituteAction(SpriteAction complete, SpriteAction with);
/**
* Converts a string into a SpriteDirection enum.