summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-09-23 23:47:32 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-09-23 23:47:32 +0000
commit7ca971f04907031b80ffbcb159e5af2f595e3af8 (patch)
treec7f0f210325acb35f63071797407d266ba7e9e35 /src/resources
parentc3d7827d18b725d2dff94e08a17474d607bb43dd (diff)
downloadmana-7ca971f04907031b80ffbcb159e5af2f595e3af8.tar.gz
mana-7ca971f04907031b80ffbcb159e5af2f595e3af8.tar.bz2
mana-7ca971f04907031b80ffbcb159e5af2f595e3af8.tar.xz
mana-7ca971f04907031b80ffbcb159e5af2f595e3af8.zip
Merged most of the changes in biggeruniverse's second memory cleanup patch.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/iteminfo.cpp4
-rw-r--r--src/resources/iteminfo.h8
-rw-r--r--src/resources/itemmanager.cpp18
-rw-r--r--src/resources/itemmanager.h2
4 files changed, 23 insertions, 9 deletions
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index e23be049..69090dcb 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -30,6 +30,10 @@ ItemInfo::ItemInfo() :
{
}
+ItemInfo::~ItemInfo()
+{
+}
+
void ItemInfo::setImage(short image)
{
this->image = image;
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index f634025f..937911af 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -31,13 +31,14 @@
*/
class ItemInfo
{
+ friend class ItemManager;
+
public:
/**
* Constructor.
*/
ItemInfo();
-
void setImage(short image);
short getImage();
@@ -70,21 +71,18 @@ class ItemInfo
char getSlot();
-
protected:
/**
* Destructor.
*/
~ItemInfo();
-
+
short image, art;
std::string name;
std::string description;
std::string effect;
short type, weight;
char slot;
-
-
};
#endif
diff --git a/src/resources/itemmanager.cpp b/src/resources/itemmanager.cpp
index 7d9c5ef5..caa26f5b 100644
--- a/src/resources/itemmanager.cpp
+++ b/src/resources/itemmanager.cpp
@@ -42,12 +42,16 @@ ItemManager::ItemManager()
xmlDocPtr doc = xmlParseMemory(data, size);
free(data);
- if (doc) {
+ if (doc)
+ {
xmlNodePtr node = xmlDocGetRootElement(doc);
- if (!node || !xmlStrEqual(node->name, BAD_CAST "items")) {
+ if (!node || !xmlStrEqual(node->name, BAD_CAST "items"))
+ {
logger->error("items.xml is not a valid database file!");
- } else {
+ }
+ else
+ {
for (node = node->xmlChildrenNode; node != NULL; node = node->next)
{
if (xmlStrEqual(node->name, BAD_CAST "item"))
@@ -112,6 +116,14 @@ ItemManager::ItemManager()
ItemManager::~ItemManager()
{
+ std::map<int, ItemInfo*>::iterator i;
+ for (i = db.begin(); i != db.end(); i++)
+ {
+ delete (*i).second;
+ }
+ db.clear();
+
+ delete unknown;
}
ItemInfo *ItemManager::getItemInfo(int id)
diff --git a/src/resources/itemmanager.h b/src/resources/itemmanager.h
index be861c01..6d969923 100644
--- a/src/resources/itemmanager.h
+++ b/src/resources/itemmanager.h
@@ -48,7 +48,7 @@ class ItemManager
protected:
// Items database
- std::map <int, ItemInfo *> db;
+ std::map<int, ItemInfo*> db;
ItemInfo *unknown;
};