summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/main.cpp11
-rw-r--r--src/resources/equipmentdb.cpp3
-rw-r--r--src/resources/itemdb.cpp8
-rw-r--r--src/resources/itemdb.h6
-rw-r--r--src/resources/monsterdb.cpp8
6 files changed, 32 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index ce03c9a3..1a0cd200 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,10 @@
sounds from the release. They will be released dynamically only.
* data/graphics/tiles/snow_x3.png: Added bottom of Christmas tree by
pauan.
+ * src/main.cpp, src/resources/itemdb.h, src/resources/monsterdb.cpp,
+ src/resources/itemdb.cpp, src/resources/equipmentdb.cpp: Load the
+ databases at the start of the LOGIN state, after the updates are
+ loaded.
2006-12-22 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/main.cpp b/src/main.cpp
index f54b0792..1a171d84 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -286,11 +286,6 @@ void init_engine(const Options &options)
errorMessage = err;
logger->log("Warning: %s", err);
}
-
- // Load XML databases
- EquipmentDB::load();
- ItemDB::load();
- MonsterDB::load();
}
/** Clear the engine */
@@ -625,6 +620,12 @@ int main(int argc, char *argv[])
switch (state) {
case LOGIN_STATE:
logger->log("State: LOGIN");
+
+ // Load XML databases
+ EquipmentDB::load();
+ ItemDB::load();
+ MonsterDB::load();
+
if (!loginData.password.empty()) {
state = ACCOUNT_STATE;
} else {
diff --git a/src/resources/equipmentdb.cpp b/src/resources/equipmentdb.cpp
index 78ae3b6a..52a9fbd3 100644
--- a/src/resources/equipmentdb.cpp
+++ b/src/resources/equipmentdb.cpp
@@ -40,6 +40,9 @@ namespace
void
EquipmentDB::load()
{
+ if (mLoaded)
+ return;
+
logger->log("Initializing equipment database...");
mUnknown.setSprite("error.xml", 0);
mUnknown.setSprite("error.xml", 1);
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index b91e34cc..f914af47 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -37,11 +37,15 @@ namespace
{
ItemDB::ItemInfos mItemInfos;
ItemInfo mUnknown;
+ bool mLoaded = false;
}
void ItemDB::load()
{
+ if (mLoaded)
+ return;
+
logger->log("Initializing item database...");
mUnknown.setName("Unknown item");
@@ -150,6 +154,8 @@ void ItemDB::load()
}
xmlFreeDoc(doc);
+
+ mLoaded = true;
}
void ItemDB::unload()
@@ -159,6 +165,8 @@ void ItemDB::unload()
delete i->second;
}
mItemInfos.clear();
+
+ mLoaded = false;
}
const ItemInfo&
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 5922984a..c080194b 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -29,17 +29,17 @@
#include <map>
/**
- * The namespace that holds the item information
+ * The namespace that holds the item information.
*/
namespace ItemDB
{
/**
- * Loads the item data from Items.xml
+ * Loads the item data from <code>items.xml</code>.
*/
void load();
/**
- * Frees item data
+ * Frees item data.
*/
void unload();
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index fb03f6c1..e4406f9c 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -34,11 +34,15 @@ namespace
{
MonsterDB::MonsterInfos mMonsterInfos;
MonsterInfo mUnknown;
+ bool mLoaded = false;
}
void
MonsterDB::load()
{
+ if (mLoaded)
+ return;
+
mUnknown.setSprite("error.xml");
mUnknown.setName("unnamed");
@@ -123,6 +127,8 @@ MonsterDB::load()
}
mMonsterInfos[XML::getProperty(monsterNode, "id", 0)] = currentInfo;
}
+
+ mLoaded = true;
}
void
@@ -131,6 +137,8 @@ MonsterDB::unload()
for_each ( mMonsterInfos.begin(), mMonsterInfos.end(),
make_dtor(mMonsterInfos));
mMonsterInfos.clear();
+
+ mLoaded = false;
}