summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-04 23:47:11 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-04 23:47:11 +0300
commitf24ddad3fa0f843eb29a281426151cf1a5f31f4b (patch)
tree6f3faaf38f069f1e88435b7c976ff4070b7a1dcb /src/resources
parent3a407bb6b73a186eafd99bcec570f88097c4b2e1 (diff)
downloadmanaverse-f24ddad3fa0f843eb29a281426151cf1a5f31f4b.tar.gz
manaverse-f24ddad3fa0f843eb29a281426151cf1a5f31f4b.tar.bz2
manaverse-f24ddad3fa0f843eb29a281426151cf1a5f31f4b.tar.xz
manaverse-f24ddad3fa0f843eb29a281426151cf1a5f31f4b.zip
add const to more classes,
fix other small style issues.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/ambientlayer.cpp3
-rw-r--r--src/resources/beinginfo.h4
-rw-r--r--src/resources/image.cpp3
-rw-r--r--src/resources/itemdb.cpp3
-rw-r--r--src/resources/mapreader.cpp3
-rw-r--r--src/resources/resourcemanager.cpp25
-rw-r--r--src/resources/resourcemanager.h11
-rw-r--r--src/resources/sdlimagehelper.cpp2
-rw-r--r--src/resources/sdlimagehelper.h2
-rw-r--r--src/resources/spritedef.cpp2
-rw-r--r--src/resources/spritedef.h2
-rw-r--r--src/resources/wallpaper.cpp2
12 files changed, 33 insertions, 29 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 9e919297b..99a3b76c4 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -102,7 +102,8 @@ void AmbientLayer::update(const int timePassed, const float dx, const float dy)
mPosY += static_cast<float>(imgH);
}
-void AmbientLayer::draw(Graphics *const graphics, const int x, const int y) const
+void AmbientLayer::draw(Graphics *const graphics, const int x,
+ const int y) const
{
if (!mImage)
return;
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 130cb26ea..2d5971f91 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -90,7 +90,7 @@ class BeingInfo
void setTargetCursorSize(const std::string &size);
void setTargetCursorSize(const ActorSprite::TargetCursorSize
- targetSize)
+ &targetSize)
{ mTargetCursorSize = targetSize; }
ActorSprite::TargetCursorSize getTargetCursorSize() const
@@ -115,7 +115,7 @@ class BeingInfo
unsigned char getWalkMask() const
{ return mWalkMask; }
- void setBlockType(const Map::BlockType blockType)
+ void setBlockType(const Map::BlockType &blockType)
{ mBlockType = blockType; }
Map::BlockType getBlockType() const
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 33b97b633..e70ee3de5 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -299,11 +299,10 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const
return nullptr;
Image* scaledImage = nullptr;
- SDL_Surface* scaledSurface = nullptr;
if (mSDLSurface)
{
- scaledSurface = zoomSurface(mSDLSurface,
+ SDL_Surface *const scaledSurface = zoomSurface(mSDLSurface,
static_cast<double>(width) / mBounds.w,
static_cast<double>(height) / mBounds.h,
1);
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 5905ef578..8fd4a9fdc 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -242,7 +242,8 @@ void ItemDB::load()
node, "missile-particle", "");
const int hitEffectId = XML::getProperty(node, "hit-effect-id",
paths.getIntValue("hitEffectId"));
- const int criticalEffectId = XML::getProperty(node, "critical-hit-effect-id",
+ const int criticalEffectId = XML::getProperty(
+ node, "critical-hit-effect-id",
paths.getIntValue("criticalHitEffectId"));
SpriteDisplay display;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 8a193a627..f133e273d 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -755,7 +755,8 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
continue;
std::string name = XML::getProperty(
propertyNode, "name", "");
- const int value = XML::getProperty(propertyNode, "value", 0);
+ const int value = XML::getProperty(
+ propertyNode, "value", 0);
if (!name.empty())
{
tileProperties[name] = value;
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 2f3d96d27..1edd7b6de 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -257,7 +257,7 @@ bool ResourceManager::removeFromSearchPath(const std::string &path) const
void ResourceManager::searchAndAddArchives(const std::string &path,
const std::string &ext,
- const bool append)
+ const bool append) const
{
const char *const dirSep = PHYSFS_getDirSeparator();
char **list = PHYSFS_enumerateFiles(path.c_str());
@@ -282,7 +282,7 @@ void ResourceManager::searchAndAddArchives(const std::string &path,
}
void ResourceManager::searchAndRemoveArchives(const std::string &path,
- const std::string &ext)
+ const std::string &ext) const
{
const char *const dirSep = PHYSFS_getDirSeparator();
char **list = PHYSFS_enumerateFiles(path.c_str());
@@ -398,7 +398,7 @@ Resource *ResourceManager::getFromCache(const std::string &idPath)
}
Resource *ResourceManager::get(const std::string &idPath, const generator fun,
- void *const data)
+ const void *const data)
{
#ifndef DISABLE_RESOURCE_CACHING
Resource *resource = getFromCache(idPath);
@@ -437,7 +437,7 @@ struct ResourceLoader
std::string path;
ResourceManager::loader fun;
- static Resource *load(void *const v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
@@ -471,7 +471,7 @@ struct DyedImageLoader
{
ResourceManager *manager;
std::string path;
- static Resource *load(void *const v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
@@ -528,7 +528,7 @@ struct ImageSetLoader
ResourceManager *manager;
std::string path;
int w, h;
- static Resource *load(void *const v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
@@ -562,7 +562,7 @@ struct SubImageSetLoader
ResourceManager *manager;
Image *parent;
int width, height;
- static Resource *load(void *v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
@@ -597,7 +597,7 @@ struct SubImageLoader
Image *parent;
int x, y;
int width, height;
- static Resource *load(void *const v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
@@ -632,7 +632,7 @@ struct SpriteDefLoader
{
std::string path;
int variant;
- static Resource *load(void *const v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
@@ -840,7 +840,7 @@ SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename) const
return surface;
}
-void ResourceManager::scheduleDelete(SDL_Surface* surface)
+void ResourceManager::scheduleDelete(SDL_Surface *const surface)
{
deletedSurfaces.insert(surface);
}
@@ -861,11 +861,12 @@ struct RescaledLoader
Image *image;
int width;
int height;
- static Resource *load(void *const v)
+ static Resource *load(const void *const v)
{
if (!v)
return nullptr;
- const RescaledLoader *const rl = static_cast< RescaledLoader * >(v);
+ const RescaledLoader *const rl
+ = static_cast<const RescaledLoader *const>(v);
if (!rl->manager || !rl->image)
return nullptr;
Image *const rescaled = rl->image->SDLgetScaledImage(
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index 540e5f882..dee7f5459 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -56,7 +56,7 @@ class ResourceManager
public:
typedef Resource *(*loader)(SDL_RWops *);
- typedef Resource *(*generator)(void *);
+ typedef Resource *(*generator)(const void *const);
ResourceManager();
@@ -95,13 +95,13 @@ class ResourceManager
*/
void searchAndAddArchives(const std::string &path,
const std::string &ext,
- const bool append);
+ const bool append) const;
/**
* Searches for zip files and remove them from the search path.
*/
void searchAndRemoveArchives(const std::string &path,
- const std::string &ext);
+ const std::string &ext) const;
/**
* Creates a directory in the write path
@@ -142,7 +142,8 @@ class ResourceManager
* @return A valid resource or <code>NULL</code> if the resource could
* not be generated.
*/
- Resource *get(const std::string &idPath, const generator fun, void *const data);
+ Resource *get(const std::string &idPath, const generator fun,
+ const void *const data);
Resource *getFromCache(const std::string &idPath);
@@ -255,7 +256,7 @@ class ResourceManager
*/
SDL_Surface *loadSDLSurface(const std::string &filename) const;
- void scheduleDelete(SDL_Surface* surface);
+ void scheduleDelete(SDL_Surface *const surface);
void clearScheduled();
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index 216d39390..9a1822e32 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -210,7 +210,7 @@ SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
}
-Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
+Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const
{
if (!tmpImage)
return nullptr;
diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h
index 995b0967e..183627435 100644
--- a/src/resources/sdlimagehelper.h
+++ b/src/resources/sdlimagehelper.h
@@ -78,7 +78,7 @@ class SDLImageHelper : public ImageHelper
protected:
/** SDL_Surface to SDL_Surface Image loader */
- Image *_SDLload(SDL_Surface *tmpImage);
+ Image *_SDLload(SDL_Surface *tmpImage) const;
static bool mEnableAlphaCache;
};
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index b55253c05..f54a332a7 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -250,7 +250,7 @@ void SpriteDef::loadAction(const XmlNodePtr node, const int variant_offset)
void SpriteDef::loadAnimation(const XmlNodePtr animationNode,
Action *const action, ImageSet *const imageSet,
- const int variant_offset)
+ const int variant_offset) const
{
if (!action || !imageSet)
return;
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 565c3a95a..86f2d7f12 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -172,7 +172,7 @@ class SpriteDef : public Resource
*/
void loadAnimation(const XmlNodePtr animationNode,
Action *const action, ImageSet *const imageSet,
- const int variant_offset);
+ const int variant_offset) const;
/**
* Include another sprite into this one.
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 3a5cd05b7..d89ad62eb 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -55,7 +55,7 @@ static std::string wallpaperFile;
// Search for the wallpaper path values sequentially..
static void initDefaultWallpaperPaths()
{
- ResourceManager *const resman = ResourceManager::getInstance();
+ const ResourceManager *const resman = ResourceManager::getInstance();
// Init the path
wallpaperPath = branding.getStringValue("wallpapersPath");