diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-09 23:47:02 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-09 23:47:02 +0100 |
commit | fa2f3ac593a792c32095c2e885665ec91bb4019d (patch) | |
tree | f44aee845f0229dfcc6b2ad3c74613e0352f36c2 /src/resources | |
parent | 07f7d52f661a74e6d0c780ca53e724651e3dcc48 (diff) | |
parent | 40edf4e91558cffd83d9015a2cf4a16360e27855 (diff) | |
download | mana-fa2f3ac593a792c32095c2e885665ec91bb4019d.tar.gz mana-fa2f3ac593a792c32095c2e885665ec91bb4019d.tar.bz2 mana-fa2f3ac593a792c32095c2e885665ec91bb4019d.tar.xz mana-fa2f3ac593a792c32095c2e885665ec91bb4019d.zip |
Merged with Aethyra master as of 2009-02-09
Conflicts:
A lot of files...
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/animation.cpp | 2 | ||||
-rw-r--r-- | src/resources/buddylist.h | 3 | ||||
-rw-r--r-- | src/resources/colordb.cpp | 2 | ||||
-rw-r--r-- | src/resources/dye.cpp | 1 | ||||
-rw-r--r-- | src/resources/emotedb.cpp | 2 | ||||
-rw-r--r-- | src/resources/image.cpp | 43 | ||||
-rw-r--r-- | src/resources/image.h | 16 | ||||
-rw-r--r-- | src/resources/imageloader.cpp | 1 | ||||
-rw-r--r-- | src/resources/imagewriter.h | 2 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 16 | ||||
-rw-r--r-- | src/resources/itemdb.h | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 12 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 1 | ||||
-rw-r--r-- | src/resources/mapreader.h | 2 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/monsterdb.h | 2 | ||||
-rw-r--r-- | src/resources/npcdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/resource.h | 3 | ||||
-rw-r--r-- | src/resources/soundeffect.h | 3 |
19 files changed, 55 insertions, 62 deletions
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 8d7156a9..54c319de 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <algorithm> - #include "animation.h" #include "../utils/dtor.h" diff --git a/src/resources/buddylist.h b/src/resources/buddylist.h index d769b2b8..f0758c25 100644 --- a/src/resources/buddylist.h +++ b/src/resources/buddylist.h @@ -27,7 +27,8 @@ #include <guichan/listmodel.hpp> -class BuddyList : public gcn::ListModel { +class BuddyList : public gcn::ListModel +{ public: /** * Constructor diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 34c48496..61ea4bc0 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -19,14 +19,12 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> #include <libxml/tree.h> #include "colordb.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 1b34a403..22bd2411 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <algorithm> #include <sstream> #include "dye.h" diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index bbc6b634..ac41b59c 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -20,11 +20,9 @@ */ #include "emotedb.h" -#include "resourcemanager.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/image.cpp b/src/resources/image.cpp index c3310849..7a7e6ac8 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -167,7 +167,8 @@ Image *Image::load(SDL_Surface *tmpImage) tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, 32, rmask, gmask, bmask, amask); - if (!tmpImage) { + if (!tmpImage) + { logger->log("Error, image convert failed: out of memory"); return NULL; } @@ -178,9 +179,8 @@ Image *Image::load(SDL_Surface *tmpImage) glGenTextures(1, &texture); glBindTexture(mTextureType, texture); - if (SDL_MUSTLOCK(tmpImage)) { + if (SDL_MUSTLOCK(tmpImage)) SDL_LockSurface(tmpImage); - } glTexImage2D( mTextureType, 0, 4, @@ -255,14 +255,13 @@ Image *Image::load(SDL_Surface *tmpImage) SDL_Surface *image; // Convert the surface to the current display format - if (hasAlpha) { + if (hasAlpha) image = SDL_DisplayFormatAlpha(tmpImage); - } - else { + else image = SDL_DisplayFormat(tmpImage); - } - if (!image) { + if (!image) + { logger->log("Error: Image convert failed."); return NULL; } @@ -274,14 +273,16 @@ void Image::unload() { mLoaded = false; - if (mImage) { + if (mImage) + { // Free the image surface. SDL_FreeSurface(mImage); mImage = NULL; } #ifdef USE_OPENGL - if (mGLImage) { + if (mGLImage) + { glDeleteTextures(1, &mGLImage); mGLImage = 0; } @@ -292,10 +293,9 @@ Image *Image::getSubImage(int x, int y, int width, int height) { // Create a new clipped sub-image #ifdef USE_OPENGL - if (mUseOpenGL) { + if (mUseOpenGL) return new SubImage(this, mGLImage, x, y, width, height, mTexWidth, mTexHeight); - } #endif return new SubImage(this, mImage, x, y, width, height); @@ -303,13 +303,13 @@ Image *Image::getSubImage(int x, int y, int width, int height) void Image::setAlpha(float a) { - if (mAlpha == a) { + if (mAlpha == a) return; - } mAlpha = a; - if (mImage) { + if (mImage) + { // Set the alpha value this image is drawn at SDL_SetAlpha(mImage, SDL_SRCALPHA, (int) (255 * mAlpha)); } @@ -321,14 +321,12 @@ float Image::getAlpha() } #ifdef USE_OPENGL -void -Image::setLoadAsOpenGL(bool useOpenGL) +void Image::setLoadAsOpenGL(bool useOpenGL) { Image::mUseOpenGL = useOpenGL; } -int -Image::powerOfTwo(int input) +int Image::powerOfTwo(int input) { int value; if (mTextureType == GL_TEXTURE_2D) @@ -353,7 +351,8 @@ Image::powerOfTwo(int input) SubImage::SubImage(Image *parent, SDL_Surface *image, int x, int y, int width, int height): - Image(image), mParent(parent) + Image(image), + mParent(parent) { mParent->incRef(); @@ -368,7 +367,8 @@ SubImage::SubImage(Image *parent, SDL_Surface *image, SubImage::SubImage(Image *parent, GLuint image, int x, int y, int width, int height, int texWidth, int texHeight): - Image(image, width, height, texWidth, texHeight), mParent(parent) + Image(image, width, height, texWidth, texHeight), + mParent(parent) { mParent->incRef(); @@ -394,3 +394,4 @@ Image *SubImage::getSubImage(int x, int y, int w, int h) { return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h); } + diff --git a/src/resources/image.h b/src/resources/image.h index a4048803..9af10fda 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -40,6 +40,8 @@ #include "resource.h" class Dye; +class SDL_Rect; +class SDL_Surface; /** * Defines a class for loading and storing images. @@ -92,6 +94,12 @@ class Image : public Resource virtual void unload(); /** + * Returns the image. + */ + virtual const Image* getImage() const + { return this; } + + /** * Returns the width of the image. */ virtual int getWidth() const @@ -114,7 +122,7 @@ class Image : public Resource /** * Sets the alpha value of this image. */ - void setAlpha(float alpha); + virtual void setAlpha(float alpha); /** * Returns the alpha value of this image. @@ -181,6 +189,12 @@ class SubImage : public Image ~SubImage(); /** + * Returns the image. + */ + virtual const Image* getImage() const + { return mParent; } + + /** * Creates a new image with the desired clipping rectangle. * * @return <code>NULL</code> if creation failed and a valid diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 7895d33d..40d62797 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -20,7 +20,6 @@ */ #include <cassert> -#include <string> #include <guichan/color.hpp> #include <guichan/sdl/sdlpixel.hpp> diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h index a9133846..039d3afb 100644 --- a/src/resources/imagewriter.h +++ b/src/resources/imagewriter.h @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <iosfwd> - struct SDL_Surface; class ImageWriter diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 773febd7..9976f0d4 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -24,13 +24,12 @@ #include <libxml/tree.h> #include "itemdb.h" -#include "iteminfo.h" -#include "resourcemanager.h" #include "../log.h" #include "../utils/dtor.h" #include "../utils/gettext.h" +#include "../utils/trim.h" #include "../utils/xml.h" namespace @@ -83,7 +82,7 @@ void ItemDB::load() logger->log(_("ItemDB: Redefinition of item ID %d"), id); } - int type = XML::getProperty(node, "type", 0); + std::string type = XML::getProperty(node, "type", "other"); int weight = XML::getProperty(node, "weight", 0); int view = XML::getProperty(node, "view", 0); @@ -125,14 +124,7 @@ void ItemDB::load() if (itr == mNamedItemInfos.end()) { std::string temp = name; - while (temp[0] == ' ') - { - temp = temp.substr(1, temp.size()); - } - while (temp[temp.size()] == ' ') - { - temp = temp.substr(0, temp.size() - 1); - } + trim(temp); for (unsigned int i = 0; i < temp.size(); i++) { @@ -158,7 +150,7 @@ void ItemDB::load() CHECK_PARAM(description, ""); // CHECK_PARAM(effect, ""); // CHECK_PARAM(type, 0); - CHECK_PARAM(weight, 0); + // CHECK_PARAM(weight, 0); // CHECK_PARAM(slot, 0); #undef CHECK_PARAM diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index e7c23ca2..08a7acd0 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -26,6 +26,8 @@ #include "iteminfo.h" +class ItemInfo; + /** * The namespace that holds the item information. */ diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 86725ca2..c03dec28 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -47,7 +47,7 @@ class ItemInfo * Constructor. */ ItemInfo(): - mType(0), + mType(""), mWeight(0), mView(0), mAttackType(ACTION_DEFAULT) @@ -81,14 +81,12 @@ class ItemInfo void setEffect(const std::string &effect) { mEffect = effect; } - const std::string& - getEffect() const { return mEffect; } + const std::string& getEffect() const { return mEffect; } - void setType(short type) + void setType(const std::string& type) { mType = type; } - short getType() const - { return mType; } + const std::string& getType() const { return mType; } void setWeight(short weight) { mWeight = weight; } @@ -118,7 +116,7 @@ class ItemInfo std::string mName; std::string mDescription; /**< Short description. */ std::string mEffect; /**< Description of effects. */ - char mType; /**< Item type. */ + std::string mType; /**< Item type. */ short mWeight; /**< Weight in grams. */ int mView; /**< Item ID of how this item looks. */ int mId; /**< Item ID */ diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index ddf48df0..3270c665 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -23,6 +23,7 @@ #include <iostream> #include <zlib.h> +#include "animation.h" #include "image.h" #include "mapreader.h" #include "resourcemanager.h" diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index ef945c3f..0ed553c3 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -22,8 +22,6 @@ #ifndef MAPREADER_H #define MAPREADER_H -#include <iosfwd> - #include <libxml/tree.h> class Map; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index c7926260..c7824a5d 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -20,7 +20,7 @@ */ #include "monsterdb.h" -#include "resourcemanager.h" +#include "monsterinfo.h" #include "../log.h" diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 6fbde55f..0a218661 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -24,7 +24,7 @@ #include <map> -#include "monsterinfo.h" +class MonsterInfo; /** * Monster information database. diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 88572481..73c3939d 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -20,11 +20,9 @@ */ #include "npcdb.h" -#include "resourcemanager.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/resource.h b/src/resources/resource.h index 303b82c8..7c5f989e 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -62,8 +62,7 @@ class Resource /** * Destructor. */ - virtual - ~Resource(); + virtual ~Resource(); private: std::string mIdPath; /**< Path identifying this resource. */ diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 05ec9e54..116df930 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -35,8 +35,7 @@ class SoundEffect : public Resource /** * Destructor. */ - virtual - ~SoundEffect(); + virtual ~SoundEffect(); /** * Loads a sample from a buffer in memory. |