summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-29 22:00:35 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-29 22:00:35 +0000
commit5352c44d1ab542c64c421afcc690b200f7231a9d (patch)
tree4695c79a788c3ab9daeaf2972052a6ea9821bf13
parent52a7af6227d0b2ff94ff2c8fecd708d4d6a71466 (diff)
downloadmana-client-5352c44d1ab542c64c421afcc690b200f7231a9d.tar.gz
mana-client-5352c44d1ab542c64c421afcc690b200f7231a9d.tar.bz2
mana-client-5352c44d1ab542c64c421afcc690b200f7231a9d.tar.xz
mana-client-5352c44d1ab542c64c421afcc690b200f7231a9d.zip
Clean up of the ConfigListener and Resource interfaces.
-rw-r--r--ChangeLog15
-rw-r--r--src/Makefile.am1
-rw-r--r--src/configlistener.cpp28
-rw-r--r--src/configlistener.h2
-rw-r--r--src/resources/image.cpp18
-rw-r--r--src/resources/image.h7
-rw-r--r--src/resources/music.cpp8
-rw-r--r--src/resources/music.h4
-rw-r--r--src/resources/resource.cpp10
-rw-r--r--src/resources/resource.h9
-rw-r--r--src/resources/resourcemanager.cpp7
-rw-r--r--src/resources/soundeffect.cpp8
-rw-r--r--src/resources/soundeffect.h5
13 files changed, 48 insertions, 74 deletions
diff --git a/ChangeLog b/ChangeLog
index 094bafd0..708bf050 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,20 @@
+2005-08-29 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * src/Makefile.am, src/configlistener.cpp, src/configlistener.h: Made
+ the destructor inline, as it is an interface, we don't need a .cpp
+ file, thus it was removed.
+ * src/resources/image.cpp, src/resources/image.h,
+ src/resources/music.cpp, src/resources/music.h,
+ src/resources/resource.cpp, src/resources/resource.h,
+ src/resources/resourcemanager.cpp, src/resources/soundeffect.cpp,
+ src/resources/soundeffect.h: Removed the setIdPath() method from the
+ Resource class and added the idPath as a Constructor parameter, as
+ that value is not meant to be changed.
+
2005-08-29 Eugenio Favalli <elvenprogrammer@gmail.com>
* data/maps/new_8-1.tmx.gz: Some layer and walkability fixes.
-
+
2005-08-28 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/openglgraphics.cpp, src/gui/browserbox.cpp,
diff --git a/src/Makefile.am b/src/Makefile.am
index 10758caf..e19d9cf6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -131,7 +131,6 @@ tmw_SOURCES = graphic/spriteset.cpp \
base64.h \
being.cpp \
being.h \
- configlistener.cpp \
configlistener.h \
configuration.cpp \
configuration.h \
diff --git a/src/configlistener.cpp b/src/configlistener.cpp
deleted file mode 100644
index 456a6845..00000000
--- a/src/configlistener.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "configlistener.h"
-
-ConfigListener::~ConfigListener()
-{
-}
diff --git a/src/configlistener.h b/src/configlistener.h
index a949ed0f..7ce5d949 100644
--- a/src/configlistener.h
+++ b/src/configlistener.h
@@ -39,7 +39,7 @@ class ConfigListener
/**
* Destructor.
*/
- virtual ~ConfigListener();
+ virtual ~ConfigListener() {};
/**
* Called when an option changed. The config listener will have to be
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 5ea45842..6910bd55 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -31,8 +31,8 @@
bool Image::useOpenGL = false;
#endif
-Image::Image(SDL_Surface *image):
- image(image)
+Image::Image(const std::string &idPath, SDL_Surface *image):
+ Resource(idPath), image(image)
{
// Default to opaque
alpha = 1.0f;
@@ -44,7 +44,9 @@ Image::Image(SDL_Surface *image):
}
#ifdef USE_OPENGL
-Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight):
+Image::Image(const std::string &idPath, GLuint glimage, int width, int height,
+ int texWidth, int texHeight):
+ Resource(idPath),
glimage(glimage),
texWidth(texWidth),
texHeight(texHeight)
@@ -64,7 +66,7 @@ Image::~Image()
unload();
}
-Image* Image::load(void* buffer, unsigned int bufferSize)
+Image* Image::load(void* buffer, unsigned int bufferSize, const std::string &idPath)
{
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
@@ -234,7 +236,7 @@ Image* Image::load(void* buffer, unsigned int bufferSize)
return NULL;
}
- return new Image(texture, width, height, realWidth, realHeight);
+ return new Image(idPath, texture, width, height, realWidth, realHeight);
}
#endif
@@ -254,7 +256,7 @@ Image* Image::load(void* buffer, unsigned int bufferSize)
return NULL;
}
- return new Image(image);
+ return new Image(idPath, image);
}
void Image::unload()
@@ -330,7 +332,7 @@ void Image::setLoadAsOpenGL(bool useOpenGL)
SubImage::SubImage(Image *parent, SDL_Surface *image,
int x, int y, int width, int height):
- Image(image), parent(parent)
+ Image("", image), parent(parent)
{
parent->incRef();
@@ -344,7 +346,7 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
#ifdef USE_OPENGL
SubImage::SubImage(Image *parent, GLuint image,
int x, int y, int width, int height, int texWidth, int texHeight):
- Image(image, width, height, texWidth, texHeight), parent(parent)
+ Image("", image, width, height, texWidth, texHeight), parent(parent)
{
parent->incRef();
diff --git a/src/resources/image.h b/src/resources/image.h
index a4a65787..6fc4e89a 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -58,7 +58,7 @@ class Image : public Resource
* otherwise.
*/
static Image*
- load(void* buffer, unsigned int bufferSize);
+ load(void* buffer, unsigned int bufferSize, const std::string &idPath);
/**
* Frees the resources created by SDL.
@@ -113,9 +113,10 @@ class Image : public Resource
* Constructor.
*/
#ifdef USE_OPENGL
- Image(GLuint glimage, int width, int height, int texWidth, int texHeight);
+ Image(const std::string &idPath, GLuint glimage, int width, int height,
+ int texWidth, int texHeight);
#endif
- Image(SDL_Surface *image);
+ Image(const std::string &idPath, SDL_Surface *image);
SDL_Rect bounds;
bool loaded;
diff --git a/src/resources/music.cpp b/src/resources/music.cpp
index 9cc848ad..ba9f6df7 100644
--- a/src/resources/music.cpp
+++ b/src/resources/music.cpp
@@ -23,8 +23,8 @@
#include "music.h"
-Music::Music(Mix_Chunk *music):
- music(music)
+Music::Music(const std::string &idPath, Mix_Chunk *music):
+ Resource(idPath), music(music)
{
channel = -1;
}
@@ -36,7 +36,7 @@ Music::~Music()
music = NULL;
}
-Music* Music::load(void* buffer, unsigned int bufferSize)
+Music* Music::load(void* buffer, unsigned int bufferSize, const std::string &idPath)
{
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
@@ -48,7 +48,7 @@ Music* Music::load(void* buffer, unsigned int bufferSize)
// Now free the SDL_RWops data
SDL_FreeRW(rw);
- return new Music(tmpMusic);
+ return new Music(idPath, tmpMusic);
}
bool Music::play(int loops)
diff --git a/src/resources/music.h b/src/resources/music.h
index b8d493e2..4858eb86 100644
--- a/src/resources/music.h
+++ b/src/resources/music.h
@@ -48,7 +48,7 @@ class Music : public Resource
* @return <code>NULL</code> if the an error occurred, a valid pointer
* otherwise.
*/
- static Music *load(void* buffer, unsigned int bufferSize);
+ static Music *load(void* buffer, unsigned int bufferSize, const std::string &idPath);
/**
* Plays the music.
@@ -72,7 +72,7 @@ class Music : public Resource
/**
* Constructor.
*/
- Music(Mix_Chunk *music);
+ Music(const std::string &idPath, Mix_Chunk *music);
//Mix_Music *music;
Mix_Chunk *music;
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index e13ec359..5c1df52d 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -28,8 +28,8 @@
#include "resourcemanager.h"
-Resource::Resource():
- mRefCount(0)
+Resource::Resource(const std::string &idPath):
+ mRefCount(0), mIdPath(idPath)
{
}
@@ -38,12 +38,6 @@ Resource::~Resource()
}
void
-Resource::setIdPath(const std::string &idPath)
-{
- mIdPath = idPath;
-}
-
-void
Resource::incRef()
{
mRefCount++;
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 09c12c90..ce3a62fb 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -35,14 +35,7 @@ class Resource
/**
* Constructor
*/
- Resource();
-
- /**
- * Sets the id path of this resource. This path is used to notify the
- * resource manager when this resource is deleted.
- */
- void
- setIdPath(const std::string &idPath);
+ Resource(const std::string &idPath);
/**
* Increments the internal reference count.
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index b443c715..3567ac35 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -150,19 +150,19 @@ ResourceManager::get(const E_RESOURCE_TYPE &type, const std::string &idPath)
case MUSIC:
{
// Let the music class load it
- resource = Music::load(buffer, fileSize);
+ resource = Music::load(buffer, fileSize, idPath);
}
break;
case IMAGE:
{
// Let the image class load it
- resource = Image::load(buffer, fileSize);
+ resource = Image::load(buffer, fileSize, idPath);
}
break;
case SOUND_EFFECT:
{
// Let the sound effect class load it
- resource = SoundEffect::load(buffer, fileSize);
+ resource = SoundEffect::load(buffer, fileSize, idPath);
}
break;
default:
@@ -174,7 +174,6 @@ ResourceManager::get(const E_RESOURCE_TYPE &type, const std::string &idPath)
if (resource) {
resource->incRef();
- resource->setIdPath(idPath);
resources[idPath] = resource;
}
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index 30d405d3..7c77d5b7 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -23,8 +23,8 @@
#include "soundeffect.h"
-SoundEffect::SoundEffect(Mix_Chunk *soundEffect):
- soundEffect(soundEffect)
+SoundEffect::SoundEffect(const std::string &idPath, Mix_Chunk *soundEffect):
+ Resource(idPath), soundEffect(soundEffect)
{
}
@@ -34,7 +34,7 @@ SoundEffect::~SoundEffect()
soundEffect = NULL;
}
-SoundEffect* SoundEffect::load(void* buffer, unsigned int bufferSize)
+SoundEffect* SoundEffect::load(void* buffer, unsigned int bufferSize, const std::string &idPath)
{
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
@@ -45,7 +45,7 @@ SoundEffect* SoundEffect::load(void* buffer, unsigned int bufferSize)
// Now free the SDL_RWops data
SDL_FreeRW(rw);
- return new SoundEffect(tmpSoundEffect);
+ return new SoundEffect(idPath, tmpSoundEffect);
}
bool SoundEffect::play(int loops, int volume)
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index 69d9823d..bd1c3c00 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -48,7 +48,8 @@ class SoundEffect : public Resource
* @return <code>NULL</code> if the an error occurred, a valid pointer
* otherwise.
*/
- static SoundEffect *load(void* buffer, unsigned int bufferSize);
+ static SoundEffect *load(void* buffer, unsigned int bufferSize,
+ const std::string &idPath);
/**
* Plays the sample.
@@ -65,7 +66,7 @@ class SoundEffect : public Resource
/**
* Constructor.
*/
- SoundEffect(Mix_Chunk *soundEffect);
+ SoundEffect(const std::string &idPath, Mix_Chunk *soundEffect);
Mix_Chunk *soundEffect;
};