summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-20 13:24:20 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-20 13:24:20 +0000
commita84133850af6d348c0c4e252b26618148702153b (patch)
treef4b8d7c9bbdeecd9c1976bdc3d3806909a25cd28 /src/resources
parent1afcf2608c0a466d2df21faea1530955cc8061fc (diff)
downloadmana-client-a84133850af6d348c0c4e252b26618148702153b.tar.gz
mana-client-a84133850af6d348c0c4e252b26618148702153b.tar.bz2
mana-client-a84133850af6d348c0c4e252b26618148702153b.tar.xz
mana-client-a84133850af6d348c0c4e252b26618148702153b.zip
Merged a bunch of small changes from trunk to 0.0 and set svn:eol-style
to native for some files that were still missing this property. This is a feeble attempt to reduce the amount of conflicts for future merges.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp4
-rw-r--r--src/resources/image.h1
-rw-r--r--src/resources/itemdb.h106
-rw-r--r--src/resources/mapreader.h5
-rw-r--r--src/resources/monsterdb.cpp350
-rw-r--r--src/resources/monsterdb.h3
-rw-r--r--src/resources/monsterinfo.cpp140
-rw-r--r--src/resources/music.h1
-rw-r--r--src/resources/resourcemanager.cpp5
-rw-r--r--src/resources/soundeffect.h1
10 files changed, 313 insertions, 303 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 2d5cbe82..ad280eeb 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -159,7 +159,7 @@ Image* Image::load(void *buffer, unsigned int bufferSize,
GLenum error = glGetError();
if (error)
{
- std::string errmsg = "Unkown error";
+ std::string errmsg = "Unknown error";
switch (error)
{
case GL_INVALID_ENUM:
@@ -343,5 +343,5 @@ SubImage::~SubImage()
Image *SubImage::getSubImage(int x, int y, int w, int h)
{
- return NULL;
+ return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
}
diff --git a/src/resources/image.h b/src/resources/image.h
index 1bdfbf48..23715ecb 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -60,6 +60,7 @@ class Image : public Resource
*
* @param buffer The memory buffer containing the image data.
* @param bufferSize The size of the memory buffer in bytes.
+ * @param idPath The path identifying the resource.
*
* @return <code>NULL</code> if the an error occurred, a valid pointer
* otherwise.
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 54a07c46..0029129c 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -1,53 +1,53 @@
-/*
- * 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$
- */
-
-#ifndef _TMW_ITEM_MANAGER_H
-#define _TMW_ITEM_MANAGER_H
-
-#include "iteminfo.h"
-
-#include <map>
-
-/**
- * The namespace that holds the item information.
- */
-namespace ItemDB
-{
- /**
- * Loads the item data from <code>items.xml</code>.
- */
- void load();
-
- /**
- * Frees item data.
- */
- void unload();
-
- const ItemInfo& get(int id);
-
- // Items database
- typedef std::map<int, ItemInfo*> ItemInfos;
- typedef ItemInfos::iterator ItemInfoIterator;
-}
-
-#endif
+/*
+ * 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$
+ */
+
+#ifndef _TMW_ITEM_MANAGER_H
+#define _TMW_ITEM_MANAGER_H
+
+#include "iteminfo.h"
+
+#include <map>
+
+/**
+ * The namespace that holds the item information.
+ */
+namespace ItemDB
+{
+ /**
+ * Loads the item data from <code>items.xml</code>.
+ */
+ void load();
+
+ /**
+ * Frees item data.
+ */
+ void unload();
+
+ const ItemInfo& get(int id);
+
+ // Items database
+ typedef std::map<int, ItemInfo*> ItemInfos;
+ typedef ItemInfos::iterator ItemInfoIterator;
+}
+
+#endif
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index ad21762d..d16ff1d5 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -55,8 +55,9 @@ class MapReader
/**
* Reads the properties element.
*
- * @param props the Properties instance to which the properties will
- * be assigned
+ * @param node The <code>properties</code> element.
+ * @param props The Properties instance to which the properties will
+ * be assigned.
*/
static void
readProperties(xmlNodePtr node, Properties* props);
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 2ea9aebe..f4864eea 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -1,175 +1,175 @@
-/*
- * 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 "monsterdb.h"
-
-#include "resourcemanager.h"
-
-#include "../log.h"
-
-#include "../utils/dtor.h"
-#include "../utils/xml.h"
-
-namespace
-{
- MonsterDB::MonsterInfos mMonsterInfos;
- MonsterInfo mUnknown;
- bool mLoaded = false;
-}
-
-void
-MonsterDB::load()
-{
- if (mLoaded)
- return;
-
- mUnknown.setSprite("error.xml");
- mUnknown.setName("unnamed");
-
- logger->log("Initializing monster database...");
-
- ResourceManager *resman = ResourceManager::getInstance();
- int size;
- char *data = (char*)resman->loadFile("monsters.xml", size);
-
- if (!data)
- {
- logger->error("Monster Database: Could not find monsters.xml!");
- }
-
- xmlDocPtr doc = xmlParseMemory(data, size);
- free(data);
-
- if (!doc)
- {
- logger->error("Monster Database: Error while parsing monster database (monsters.xml)!");
- }
-
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters"))
- {
- logger->error("Monster Database: monster.xml is not a valid database file!");
- }
-
- //iterate <monster>s
- for_each_xml_child_node(monsterNode, rootNode)
- {
- if (!xmlStrEqual(monsterNode->name, BAD_CAST "monster"))
- {
- continue;
- }
-
- MonsterInfo *currentInfo = new MonsterInfo();
-
- currentInfo->setName (XML::getProperty(monsterNode, "name", "unnamed"));
-
- std::string targetCursor;
- targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium");
- if (targetCursor == "small")
- {
- currentInfo->setTargetCursorSize(Being::TC_SMALL);
- }
- else if (targetCursor == "medium")
- {
- currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
- }
- else if (targetCursor == "large")
- {
- currentInfo->setTargetCursorSize(Being::TC_LARGE);
- }
- else
- {
- logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s - using medium sized one",
- targetCursor.c_str(), currentInfo->getName().c_str());
- currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
- }
-
- //iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, monsterNode)
- {
- if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
- {
- currentInfo->setSprite((const char*) spriteNode->xmlChildrenNode->content);
- }
-
- if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
- {
- std::string event = XML::getProperty(spriteNode, "event", "");
- const char *filename;
- filename = (const char*) spriteNode->xmlChildrenNode->content;
-
- if (event == "hit")
- {
- currentInfo->addSound(MONSTER_EVENT_HIT, filename);
- }
- else if (event == "miss")
- {
- currentInfo->addSound(MONSTER_EVENT_MISS, filename);
- }
- else if (event == "hurt")
- {
- currentInfo->addSound(MONSTER_EVENT_HURT, filename);
- }
- else if (event == "die")
- {
- currentInfo->addSound(MONSTER_EVENT_DIE, filename);
- }
- else
- {
- logger->log("MonsterDB: Warning, sound effect %s for unknown event %s of monster %s",
- filename, event.c_str(), currentInfo->getName().c_str());
- }
- }
- }
- mMonsterInfos[XML::getProperty(monsterNode, "id", 0)] = currentInfo;
- }
-
- mLoaded = true;
-}
-
-void
-MonsterDB::unload()
-{
- for_each ( mMonsterInfos.begin(), mMonsterInfos.end(),
- make_dtor(mMonsterInfos));
- mMonsterInfos.clear();
-
- mLoaded = false;
-}
-
-
-const MonsterInfo&
-MonsterDB::get (int id)
-{
- MonsterInfoIterator i = mMonsterInfos.find(id);
-
- if (i == mMonsterInfos.end())
- {
- logger->log("MonsterDB: Warning, unknown monster ID %d requested", id);
- return mUnknown;
- }
- else
- {
- return *(i->second);
- }
-}
+/*
+ * 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 "monsterdb.h"
+
+#include "resourcemanager.h"
+
+#include "../log.h"
+
+#include "../utils/dtor.h"
+#include "../utils/xml.h"
+
+namespace
+{
+ MonsterDB::MonsterInfos mMonsterInfos;
+ MonsterInfo mUnknown;
+ bool mLoaded = false;
+}
+
+void
+MonsterDB::load()
+{
+ if (mLoaded)
+ return;
+
+ mUnknown.setSprite("error.xml");
+ mUnknown.setName("unnamed");
+
+ logger->log("Initializing monster database...");
+
+ ResourceManager *resman = ResourceManager::getInstance();
+ int size;
+ char *data = (char*)resman->loadFile("monsters.xml", size);
+
+ if (!data)
+ {
+ logger->error("Monster Database: Could not find monsters.xml!");
+ }
+
+ xmlDocPtr doc = xmlParseMemory(data, size);
+ free(data);
+
+ if (!doc)
+ {
+ logger->error("Monster Database: Error while parsing monster database (monsters.xml)!");
+ }
+
+ xmlNodePtr rootNode = xmlDocGetRootElement(doc);
+ if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters"))
+ {
+ logger->error("Monster Database: monster.xml is not a valid database file!");
+ }
+
+ //iterate <monster>s
+ for_each_xml_child_node(monsterNode, rootNode)
+ {
+ if (!xmlStrEqual(monsterNode->name, BAD_CAST "monster"))
+ {
+ continue;
+ }
+
+ MonsterInfo *currentInfo = new MonsterInfo();
+
+ currentInfo->setName (XML::getProperty(monsterNode, "name", "unnamed"));
+
+ std::string targetCursor;
+ targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium");
+ if (targetCursor == "small")
+ {
+ currentInfo->setTargetCursorSize(Being::TC_SMALL);
+ }
+ else if (targetCursor == "medium")
+ {
+ currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
+ }
+ else if (targetCursor == "large")
+ {
+ currentInfo->setTargetCursorSize(Being::TC_LARGE);
+ }
+ else
+ {
+ logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s - using medium sized one",
+ targetCursor.c_str(), currentInfo->getName().c_str());
+ currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
+ }
+
+ //iterate <sprite>s and <sound>s
+ for_each_xml_child_node(spriteNode, monsterNode)
+ {
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
+ {
+ currentInfo->setSprite((const char*) spriteNode->xmlChildrenNode->content);
+ }
+
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
+ {
+ std::string event = XML::getProperty(spriteNode, "event", "");
+ const char *filename;
+ filename = (const char*) spriteNode->xmlChildrenNode->content;
+
+ if (event == "hit")
+ {
+ currentInfo->addSound(MONSTER_EVENT_HIT, filename);
+ }
+ else if (event == "miss")
+ {
+ currentInfo->addSound(MONSTER_EVENT_MISS, filename);
+ }
+ else if (event == "hurt")
+ {
+ currentInfo->addSound(MONSTER_EVENT_HURT, filename);
+ }
+ else if (event == "die")
+ {
+ currentInfo->addSound(MONSTER_EVENT_DIE, filename);
+ }
+ else
+ {
+ logger->log("MonsterDB: Warning, sound effect %s for unknown event %s of monster %s",
+ filename, event.c_str(), currentInfo->getName().c_str());
+ }
+ }
+ }
+ mMonsterInfos[XML::getProperty(monsterNode, "id", 0)] = currentInfo;
+ }
+
+ mLoaded = true;
+}
+
+void
+MonsterDB::unload()
+{
+ for_each ( mMonsterInfos.begin(), mMonsterInfos.end(),
+ make_dtor(mMonsterInfos));
+ mMonsterInfos.clear();
+
+ mLoaded = false;
+}
+
+
+const MonsterInfo&
+MonsterDB::get (int id)
+{
+ MonsterInfoIterator i = mMonsterInfos.find(id);
+
+ if (i == mMonsterInfos.end())
+ {
+ logger->log("MonsterDB: Warning, unknown monster ID %d requested", id);
+ return mUnknown;
+ }
+ else
+ {
+ return *(i->second);
+ }
+}
diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h
index 9757d7f1..f0cd7d08 100644
--- a/src/resources/monsterdb.h
+++ b/src/resources/monsterdb.h
@@ -28,6 +28,9 @@
#include "monsterinfo.h"
+/**
+ * Monster information database.
+ */
namespace MonsterDB
{
void
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp
index b5fe3d29..7b7bad70 100644
--- a/src/resources/monsterinfo.cpp
+++ b/src/resources/monsterinfo.cpp
@@ -1,70 +1,70 @@
-/*
- * 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: monsterinfo.cpp 2650 2006-09-03 15:00:47Z b_lindeijer $
- */
-
-#include "monsterinfo.h"
-
-#include "../utils/dtor.h"
-
-MonsterInfo::MonsterInfo():
- mSprite("error.xml")
-{
-
-}
-
-MonsterInfo::~MonsterInfo()
-{
- //kill vectors in mSoundEffects
- for_each ( mSounds.begin(), mSounds.end(),
- make_dtor(mSounds));
- mSounds.clear();
-}
-
-
-void
-MonsterInfo::addSound (MonsterSoundEvent event, std::string filename)
-{
- if (mSounds.find(event) == mSounds.end())
- {
- mSounds[event] = new std::vector<std::string>;
- }
-
- mSounds[event]->push_back("sfx/" + filename);
-}
-
-
-std::string
-MonsterInfo::getSound (MonsterSoundEvent event) const
-{
- std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i;
-
- i = mSounds.find(event);
-
- if (i == mSounds.end())
- {
- return "";
- }
- else
- {
- return i->second->at(rand()%i->second->size());
- }
-}
+/*
+ * 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: monsterinfo.cpp 2650 2006-09-03 15:00:47Z b_lindeijer $
+ */
+
+#include "monsterinfo.h"
+
+#include "../utils/dtor.h"
+
+MonsterInfo::MonsterInfo():
+ mSprite("error.xml")
+{
+
+}
+
+MonsterInfo::~MonsterInfo()
+{
+ //kill vectors in mSoundEffects
+ for_each ( mSounds.begin(), mSounds.end(),
+ make_dtor(mSounds));
+ mSounds.clear();
+}
+
+
+void
+MonsterInfo::addSound (MonsterSoundEvent event, std::string filename)
+{
+ if (mSounds.find(event) == mSounds.end())
+ {
+ mSounds[event] = new std::vector<std::string>;
+ }
+
+ mSounds[event]->push_back("sfx/" + filename);
+}
+
+
+std::string
+MonsterInfo::getSound (MonsterSoundEvent event) const
+{
+ std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i;
+
+ i = mSounds.find(event);
+
+ if (i == mSounds.end())
+ {
+ return "";
+ }
+ else
+ {
+ return i->second->at(rand()%i->second->size());
+ }
+}
diff --git a/src/resources/music.h b/src/resources/music.h
index 9cf75928..2888eaa0 100644
--- a/src/resources/music.h
+++ b/src/resources/music.h
@@ -44,6 +44,7 @@ class Music : public Resource
*
* @param buffer The memory buffer containing the music data.
* @param bufferSize The size of the memory buffer in bytes.
+ * @param idPath The path identifying the resource.
*
* @return <code>NULL</code> if the an error occurred, a valid pointer
* otherwise.
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 985c11dd..448e7f80 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -92,7 +92,10 @@ void
ResourceManager::cleanUp(Resource *res)
{
logger->log("ResourceManager::~ResourceManager() cleaning up %d "
- "references to %s", res->mRefCount, res->mIdPath.c_str());
+ "reference%s to %s",
+ res->mRefCount,
+ (res->mRefCount == 1) ? "" : "s",
+ res->mIdPath.c_str());
delete res;
}
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index 92b0016a..007f5a77 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -45,6 +45,7 @@ class SoundEffect : public Resource
*
* @param buffer The memory buffer containing the sample data.
* @param bufferSize The size of the memory buffer in bytes.
+ * @param idPath The path identifying the resource.
*
* @return <code>NULL</code> if the an error occurred, a valid pointer
* otherwise.