diff options
-rw-r--r-- | src/being.h | 6 | ||||
-rw-r--r-- | src/gui/tabbedcontainer.cpp | 5 | ||||
-rw-r--r-- | src/imageparticle.h | 3 | ||||
-rw-r--r-- | src/particle.cpp | 66 | ||||
-rw-r--r-- | src/particle.h | 81 | ||||
-rw-r--r-- | src/resources/action.cpp | 6 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 27 | ||||
-rw-r--r-- | src/resources/mapreader.h | 19 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 6 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 49 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 54 | ||||
-rw-r--r-- | src/textparticle.h | 4 |
12 files changed, 128 insertions, 198 deletions
diff --git a/src/being.h b/src/being.h index 7202701a..ca051811 100644 --- a/src/being.h +++ b/src/being.h @@ -234,6 +234,12 @@ class Being : public Sprite */ virtual void nextStep(); + /** + * Triggers whether or not to show the name as a GM name. + * NOTE: This doesn't mean that just anyone can use this. + * If the server doesn't acknowlege you, you won't be shown + * as a GM on other people's clients. + */ virtual void setGM() { mIsGM = true; } /** diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp index 8e95aa7c..f8bc451d 100644 --- a/src/gui/tabbedcontainer.cpp +++ b/src/gui/tabbedcontainer.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <algorithm> - #include "button.h" #include "tabbedcontainer.h" @@ -43,8 +41,7 @@ TabbedContainer::TabbedContainer(int width, int padX, int buttonHeight, TabbedContainer::~TabbedContainer() { - for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); - + delete_all(mTabs); mTabs.clear(); mContents.clear(); } diff --git a/src/imageparticle.h b/src/imageparticle.h index 91c5426c..c18b30b8 100644 --- a/src/imageparticle.h +++ b/src/imageparticle.h @@ -49,8 +49,7 @@ class ImageParticle : public Particle /** * Draws the particle image */ - virtual void - draw(Graphics *graphics, int offsetX, int offsetY) const; + virtual void draw(Graphics *graphics, int offsetX, int offsetY) const; protected: Image *mImage; /**< The image used for this particle. */ diff --git a/src/particle.cpp b/src/particle.cpp index f1896ae2..fd86195c 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -67,12 +67,21 @@ Particle::Particle(Map *map): mMomentum(1.0f) { Particle::particleCount++; - if (mMap) setSpriteIterator(mMap->addSprite(this)); + if (mMap) + setSpriteIterator(mMap->addSprite(this)); } +Particle::~Particle() +{ + // Remove from map sprite list + if (mMap) + mMap->removeSprite(mSpriteIterator); + // Delete child emitters and child particles + clear(); + Particle::particleCount--; +} -void -Particle::setupEngine() +void Particle::setupEngine() { Particle::maxCount = (int)config.getValue("particleMaxCount", 3000); Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0); @@ -81,17 +90,17 @@ Particle::setupEngine() logger->log("Particle engine set up"); } -void Particle::draw(Graphics *, int, int) const {} +void Particle::draw(Graphics *, int, int) const +{ +} -bool -Particle::update() +bool Particle::update() { - if (!mMap) return false; + if (!mMap) + return false; if (mLifetimeLeft == 0) - { mAlive = false; - } Vector oldPos = mPos; @@ -221,9 +230,8 @@ Particle::update() return true; } -Particle* -Particle::addEffect(const std::string &particleEffectFile, - int pixelX, int pixelY, int rotation) +Particle* Particle::addEffect(const std::string &particleEffectFile, + int pixelX, int pixelY, int rotation) { Particle *newParticle = NULL; @@ -297,11 +305,9 @@ Particle::addEffect(const std::string &particleEffectFile, return newParticle; } - -Particle* -Particle::addTextSplashEffect(const std::string &text, - int colorR, int colorG, int colorB, - gcn::Font *font, int x, int y) +Particle *Particle::addTextSplashEffect(const std::string &text, + int colorR, int colorG, int colorB, + gcn::Font *font, int x, int y) { Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB, font); @@ -319,9 +325,9 @@ Particle::addTextSplashEffect(const std::string &text, return newParticle; } -Particle* -Particle::addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font, - int x, int y) +Particle *Particle::addTextRiseFadeOutEffect(const std::string &text, + gcn::Font *font, + int x, int y) { Particle *newParticle = new TextParticle(mMap, text, 255, 255, 255, font); newParticle->setPosition(x, y, 0); @@ -336,26 +342,14 @@ Particle::addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font, return newParticle; } -void -Particle::setMap(Map *map) +void Particle::setMap(Map *map) { mMap = map; - if (mMap) setSpriteIterator(mMap->addSprite(this)); + if (mMap) + setSpriteIterator(mMap->addSprite(this)); } - -Particle::~Particle() -{ - // Remove from map sprite list - if (mMap) mMap->removeSprite(mSpriteIterator); - // Delete child emitters and child particles - clear(); - Particle::particleCount--; -} - - -void -Particle::clear() +void Particle::clear() { delete_all(mChildEmitters); mChildEmitters.clear(); diff --git a/src/particle.h b/src/particle.h index 0a53f5af..ab08968f 100644 --- a/src/particle.h +++ b/src/particle.h @@ -67,22 +67,19 @@ class Particle : public Sprite /** * Deletes all child particles and emitters. */ - void - clear(); + void clear(); /** * Gives a particle the properties of an engine root particle and loads * the particle-related config settings. */ - void - setupEngine(); + void setupEngine(); /** * Updates particle position, returns false when the particle should * be deleted. */ - virtual bool - update(); + virtual bool update(); /** * Draws the particle image. @@ -92,8 +89,7 @@ class Particle : public Sprite /** * Necessary for sorting with the other sprites. */ - virtual int - getPixelY() const + virtual int getPixelY() const { return (int) (mPos.y + mPos.z) - 64; } /** @@ -105,44 +101,39 @@ class Particle : public Sprite * Creates a child particle that hosts some emitters described in the * particleEffectFile. */ - Particle* - addEffect(const std::string &particleEffectFile, - int pixelX, int pixelY, int rotation = 0); + Particle* addEffect(const std::string &particleEffectFile, + int pixelX, int pixelY, int rotation = 0); /** * Creates a standalone text particle. */ - Particle* - addTextSplashEffect(const std::string &text, - int colorR, int colorG, int colorB, - gcn::Font *font, int x, int y); + Particle *addTextSplashEffect(const std::string &text, + int colorR, int colorG, int colorB, + gcn::Font *font, int x, int y); /** * Creates a standalone text particle. */ - Particle* - addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font, - int x, int y); + Particle *addTextRiseFadeOutEffect(const std::string &text, + gcn::Font *font, + int x, int y); /** * Adds an emitter to the particle. */ - void - addEmitter (ParticleEmitter* emitter) + void addEmitter (ParticleEmitter* emitter) { mChildEmitters.push_back(emitter); } /** * Sets the position in 3 dimensional space in pixels relative to map. */ - void - setPosition(float x, float y, float z) + void setPosition(float x, float y, float z) { mPos.x = x; mPos.y = y; mPos.z = z; } /** * Sets the position in 2 dimensional space in pixels relative to map. */ - void - setPosition(float x, float y) + void setPosition(float x, float y) { mPos.x = x; mPos.y = y; } /** @@ -154,53 +145,45 @@ class Particle : public Sprite /** * Changes the particle position relative */ - void - moveBy(float x, float y, float z) + void moveBy(float x, float y, float z) { mPos.x += x; mPos.y += y; mPos.z += z; } - void - moveChildren(Vector change); + void moveChildren(Vector change); - void - moveBy (Vector change) + void moveBy (Vector change) { mPos += change; } /** * Sets the time in game ticks until the particle is destroyed. */ - void - setLifetime(int lifetime) + void setLifetime(int lifetime) { mLifetimeLeft = lifetime; mLifetimePast = 0; } /** * Sets the age of the pixel in game ticks where the particle has * faded in completely. */ - void - setFadeOut(int fadeOut) + void setFadeOut(int fadeOut) { mFadeOut = fadeOut; } /** * Sets the remaining particle lifetime where the particle starts to * fade out. */ - void - setFadeIn(int fadeIn) + void setFadeIn(int fadeIn) { mFadeIn = fadeIn; } /** * Sets the alpha value of the particle */ - void - setAlpha(float alpha) + void setAlpha(float alpha) { mAlpha = alpha; } /** * Sets the sprite iterator of the particle on the current map to make * it easier to remove the particle from the map when it is destroyed. */ - void - setSpriteIterator(std::list<Sprite*>::iterator spriteIterator) + void setSpriteIterator(std::list<Sprite*>::iterator spriteIterator) { mSpriteIterator = spriteIterator; } /** @@ -213,44 +196,38 @@ class Particle : public Sprite /** * Sets the current velocity in 3 dimensional space. */ - void - setVelocity(float x, float y, float z) + void setVelocity(float x, float y, float z) { mVelocity.x = x; mVelocity.y = y; mVelocity.z = z; } /** * Sets the downward acceleration. */ - void - setGravity(float gravity) + void setGravity(float gravity) { mGravity = gravity; } /** * Sets the ammount of random vector changes */ - void - setRandomness(int r) + void setRandomness(int r) { mRandomness = r; } /** * Sets the ammount of velocity particles retain after * hitting the ground. */ - void - setBounce(float bouncieness) + void setBounce(float bouncieness) { mBounce = bouncieness; } /** * Sets the flag if the particle is supposed to be moved by its parent */ - void - setFollow(bool follow) + void setFollow(bool follow) { mFollow = follow; } /** * Gets the flag if the particle is supposed to be moved by its parent */ - bool - doesFollow() + bool doesFollow() { return mFollow; } /** diff --git a/src/resources/action.cpp b/src/resources/action.cpp index f40d3109..a017e11c 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -33,8 +33,7 @@ Action::~Action() delete_all(mAnimations); } -Animation* -Action::getAnimation(int direction) const +Animation *Action::getAnimation(int direction) const { Animations::const_iterator i = mAnimations.find(direction); @@ -48,8 +47,7 @@ Action::getAnimation(int direction) const return (i == mAnimations.end()) ? NULL : i->second; } -void -Action::setAnimation(int direction, Animation *animation) +void Action::setAnimation(int direction, Animation *animation) { mAnimations[direction] = animation; } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index b4beb558..bb444330 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -42,9 +42,8 @@ const unsigned int DEFAULT_TILE_HEIGHT = 32; * Inflates either zlib or gzip deflated memory. The inflated memory is * expected to be freed by the caller. */ -int -inflateMemory(unsigned char *in, unsigned int inLength, - unsigned char *&out, unsigned int &outLength) +int inflateMemory(unsigned char *in, unsigned int inLength, + unsigned char *&out, unsigned int &outLength) { int bufferSize = 256 * 1024; int ret; @@ -108,9 +107,8 @@ inflateMemory(unsigned char *in, unsigned int inLength, return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; } -int -inflateMemory(unsigned char *in, unsigned int inLength, - unsigned char *&out) +int inflateMemory(unsigned char *in, unsigned int inLength, + unsigned char *&out) { unsigned int outLength = 0; int ret = inflateMemory(in, inLength, out, outLength); @@ -142,7 +140,7 @@ inflateMemory(unsigned char *in, unsigned int inLength, return outLength; } -Map* MapReader::readMap(const std::string &filename) +Map *MapReader::readMap(const std::string &filename) { // Load the file through resource manager ResourceManager *resman = ResourceManager::getInstance(); @@ -199,8 +197,7 @@ Map* MapReader::readMap(const std::string &filename) return map; } -Map* -MapReader::readMap(xmlNodePtr node, const std::string &path) +Map *MapReader::readMap(xmlNodePtr node, const std::string &path) { // Take the filename off the path const std::string pathDir = path.substr(0, path.rfind("/") + 1); @@ -284,7 +281,7 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) return map; } -void MapReader::readProperties(xmlNodePtr node, Properties* props) +void MapReader::readProperties(xmlNodePtr node, Properties *props) { for_each_xml_child_node(childNode, node) { @@ -313,8 +310,7 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, int gid) } } -void -MapReader::readLayer(xmlNodePtr node, Map *map) +void MapReader::readLayer(xmlNodePtr node, Map *map) { // Layers are not necessarily the same size as the map const int w = XML::getProperty(node, "width", map->getWidth()); @@ -448,10 +444,9 @@ MapReader::readLayer(xmlNodePtr node, Map *map) } } -Tileset* -MapReader::readTileset(xmlNodePtr node, - const std::string &path, - Map *map) +Tileset *MapReader::readTileset(xmlNodePtr node, + const std::string &path, + Map *map) { int firstGid = XML::getProperty(node, "firstgid", 0); XML::Document* doc = NULL; diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index ef52564e..c85e00d9 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -39,15 +39,13 @@ class MapReader /** * Read an XML map from a file. */ - static Map* - readMap(const std::string &filename); + static Map *readMap(const std::string &filename); /** * Read an XML map from a parsed XML tree. The path is used to find the * location of referenced tileset images. */ - static Map* - readMap(xmlNodePtr node, const std::string &path); + static Map *readMap(xmlNodePtr node, const std::string &path); private: /** @@ -57,26 +55,23 @@ class MapReader * @param props The Properties instance to which the properties will * be assigned. */ - static void - readProperties(xmlNodePtr node, Properties* props); + static void readProperties(xmlNodePtr node, Properties* props); /** * Reads a map layer and adds it to the given map. */ - static void - readLayer(xmlNodePtr node, Map *map); + static void readLayer(xmlNodePtr node, Map *map); /** * Reads a tile set. */ - static Tileset* - readTileset(xmlNodePtr node, const std::string &path, Map *map); + static Tileset *readTileset(xmlNodePtr node, const std::string &path, + Map *map); /** * Gets an integer property from an xmlNodePtr. */ - static int - getProperty(xmlNodePtr node, const char* name, int def); + static int getProperty(xmlNodePtr node, const char* name, int def); }; #endif diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 4d52b8ad..7e2d7a1d 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -141,8 +141,7 @@ MonsterDB::load() mLoaded = true; } -void -MonsterDB::unload() +void MonsterDB::unload() { delete_all(mMonsterInfos); mMonsterInfos.clear(); @@ -151,8 +150,7 @@ MonsterDB::unload() } -const MonsterInfo& -MonsterDB::get(int id) +const MonsterInfo &MonsterDB::get(int id) { MonsterInfoIterator i = mMonsterInfos.find(id); diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 510a16bd..a317e445 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -91,8 +91,7 @@ ResourceManager::~ResourceManager() } } -void -ResourceManager::cleanUp(Resource *res) +void ResourceManager::cleanUp(Resource *res) { if (res->mRefCount > 0) { @@ -138,14 +137,12 @@ void ResourceManager::cleanOrphans() mOldestOrphan = oldest; } -bool -ResourceManager::setWriteDir(const std::string &path) +bool ResourceManager::setWriteDir(const std::string &path) { return (bool) PHYSFS_setWriteDir(path.c_str()); } -bool -ResourceManager::addToSearchPath(const std::string &path, bool append) +bool ResourceManager::addToSearchPath(const std::string &path, bool append) { logger->log("Adding to PhysicsFS: %s", path.c_str()); if (!PHYSFS_addToSearchPath(path.c_str(), append ? 1 : 0)) { @@ -155,8 +152,7 @@ ResourceManager::addToSearchPath(const std::string &path, bool append) return true; } -void -ResourceManager::searchAndAddArchives(const std::string &path, +void ResourceManager::searchAndAddArchives(const std::string &path, const std::string &ext, bool append) { @@ -182,26 +178,22 @@ ResourceManager::searchAndAddArchives(const std::string &path, PHYSFS_freeList(list); } -bool -ResourceManager::mkdir(const std::string &path) +bool ResourceManager::mkdir(const std::string &path) { return (bool) PHYSFS_mkdir(path.c_str()); } -bool -ResourceManager::exists(const std::string &path) +bool ResourceManager::exists(const std::string &path) { return PHYSFS_exists(path.c_str()); } -bool -ResourceManager::isDirectory(const std::string &path) +bool ResourceManager::isDirectory(const std::string &path) { return PHYSFS_isDirectory(path.c_str()); } -std::string -ResourceManager::getPath(const std::string &file) +std::string ResourceManager::getPath(const std::string &file) { // get the real path to the file const char* tmp = PHYSFS_getRealDir(file.c_str()); @@ -221,7 +213,8 @@ ResourceManager::getPath(const std::string &file) return path; } -Resource *ResourceManager::get(std::string const &idPath, generator fun, void *data) +Resource *ResourceManager::get(std::string const &idPath, generator fun, + void *data) { // Check if the id exists, and return the value if it does. ResourceIterator resIter = mResources.find(idPath); @@ -278,14 +271,12 @@ Resource *ResourceManager::load(std::string const &path, loader fun) return get(path, ResourceLoader::load, &l); } -Music* -ResourceManager::getMusic(const std::string &idPath) +Music *ResourceManager::getMusic(const std::string &idPath) { return static_cast<Music*>(load(idPath, Music::load)); } -SoundEffect* -ResourceManager::getSoundEffect(const std::string &idPath) +SoundEffect *ResourceManager::getSoundEffect(const std::string &idPath) { return static_cast<SoundEffect*>(load(idPath, SoundEffect::load)); } @@ -338,8 +329,8 @@ struct ImageSetLoader } }; -ImageSet* -ResourceManager::getImageSet(const std::string &imagePath, int w, int h) +ImageSet *ResourceManager::getImageSet(const std::string &imagePath, + int w, int h) { ImageSetLoader l = { this, imagePath, w, h }; std::stringstream ss; @@ -385,23 +376,20 @@ void ResourceManager::release(Resource *res) mResources.erase(resIter); } -ResourceManager* -ResourceManager::getInstance() +ResourceManager *ResourceManager::getInstance() { // Create a new instance if necessary. if (instance == NULL) instance = new ResourceManager(); return instance; } -void -ResourceManager::deleteInstance() +void ResourceManager::deleteInstance() { delete instance; instance = NULL; } -void* -ResourceManager::loadFile(const std::string &fileName, int &fileSize) +void *ResourceManager::loadFile(const std::string &fileName, int &fileSize) { // Attempt to open the specified file using PhysicsFS PHYSFS_file *file = PHYSFS_openRead(fileName.c_str()); @@ -453,8 +441,7 @@ ResourceManager::loadTextFile(const std::string &fileName) return lines; } -SDL_Surface* -ResourceManager::loadSDLSurface(const std::string& filename) +SDL_Surface *ResourceManager::loadSDLSurface(const std::string& filename) { int fileSize; void *buffer = loadFile(filename, fileSize); diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index c814d752..95519da3 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -64,8 +64,7 @@ class ResourceManager * @param path The path of the directory to be added. * @return <code>true</code> on success, <code>false</code> otherwise. */ - bool - setWriteDir(const std::string &path); + bool setWriteDir(const std::string &path); /** * Adds a directory or archive to the search path. If append is true @@ -74,35 +73,30 @@ class ResourceManager * * @return <code>true</code> on success, <code>false</code> otherwise. */ - bool - addToSearchPath(const std::string &path, bool append); + bool addToSearchPath(const std::string &path, bool append); /** * Searches for zip files and adds them to the search path. */ - void - searchAndAddArchives(const std::string &path, - const std::string &ext, - bool append); + void searchAndAddArchives(const std::string &path, + const std::string &ext, + bool append); /** * Creates a directory in the write path */ - bool - mkdir(const std::string &path); + bool mkdir(const std::string &path); /** * Checks whether the given file or directory exists in the search path */ - bool - exists(const std::string &path); + bool exists(const std::string &path); /** * Checks whether the given path is a directory. */ - bool - isDirectory(const std::string &path); - + bool isDirectory(const std::string &path); + /** * Returns the real path to a file * @@ -136,29 +130,25 @@ class ResourceManager * Convenience wrapper around ResourceManager::get for loading * images. */ - Image* - getImage(const std::string &idPath); + Image *getImage(const std::string &idPath); /** * Convenience wrapper around ResourceManager::get for loading * songs. */ - Music* - getMusic(const std::string &idPath); + Music *getMusic(const std::string &idPath); /** * Convenience wrapper around ResourceManager::get for loading * samples. */ - SoundEffect* - getSoundEffect(const std::string &idPath); + SoundEffect *getSoundEffect(const std::string &idPath); /** * Creates a image set based on the image referenced by the given * path and the supplied sprite sizes */ - ImageSet* - getImageSet(const std::string &imagePath, int w, int h); + ImageSet *getImageSet(const std::string &imagePath, int w, int h); /** * Creates a sprite definition based on a given path and the supplied @@ -181,41 +171,35 @@ class ResourceManager * @return An allocated byte array containing the data that was loaded, * or <code>NULL</code> on fail. */ - void* - loadFile(const std::string &fileName, int &fileSize); + void *loadFile(const std::string &fileName, int &fileSize); /** * Retrieves the contents of a text file. */ - std::vector<std::string> - loadTextFile(const std::string &fileName); + std::vector<std::string> loadTextFile(const std::string &fileName); /** * Loads the given filename as an SDL surface. The returned surface is * expected to be freed by the caller using SDL_FreeSurface. */ - SDL_Surface* - loadSDLSurface(const std::string& filename); + SDL_Surface *loadSDLSurface(const std::string& filename); /** * Returns an instance of the class, creating one if it does not * already exist. */ - static ResourceManager* - getInstance(); + static ResourceManager *getInstance(); /** * Deletes the class instance if it exists. */ - static void - deleteInstance(); + static void deleteInstance(); private: /** * Deletes the resource after logging a cleanup message. */ - static void - cleanUp(Resource *resource); + static void cleanUp(Resource *resource); void cleanOrphans(); diff --git a/src/textparticle.h b/src/textparticle.h index f662621f..039c18d7 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -36,11 +36,11 @@ class TextParticle : public Particle TextParticle(Map *map, const std::string &text, int colorR, int colorG, int colorB, gcn::Font *font); + /** * Draws the particle image. */ - virtual void - draw(Graphics *graphics, int offsetX, int offsetY) const; + virtual void draw(Graphics *graphics, int offsetX, int offsetY) const; // hack to improve text visibility virtual int getPixelY() const |