summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 20:58:10 +0100
committerIra Rice <irarice@gmail.com>2008-12-08 13:48:10 -0700
commit48c3263aa2540cd895b72edb0337e0717e136e3a (patch)
treef5b93df0b4bf209e73876161c30ef5fe4a00ff3b /src/resources
parent81cdc7b2d880f44df6e0a6de74183f36c53836a0 (diff)
downloadmana-48c3263aa2540cd895b72edb0337e0717e136e3a.tar.gz
mana-48c3263aa2540cd895b72edb0337e0717e136e3a.tar.bz2
mana-48c3263aa2540cd895b72edb0337e0717e136e3a.tar.xz
mana-48c3263aa2540cd895b72edb0337e0717e136e3a.zip
Code reformatting
I wish I had never fallen for this weird style, and I hope removing it will prevent others from introducing new code like this. :-)
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/action.cpp6
-rw-r--r--src/resources/mapreader.cpp27
-rw-r--r--src/resources/mapreader.h19
-rw-r--r--src/resources/monsterdb.cpp6
-rw-r--r--src/resources/resourcemanager.cpp49
-rw-r--r--src/resources/resourcemanager.h54
6 files changed, 59 insertions, 102 deletions
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();