summaryrefslogtreecommitdiff
path: root/src/game-server/itemmanager.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-19 15:10:17 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-20 15:13:01 +0100
commit4059cb4fa545dda8b035a1033f5fefb99e978682 (patch)
tree37e526f9f80cbb9dda55ab19ae6d076c51c957da /src/game-server/itemmanager.h
parent318cb3a18ac4aa906b18ffd170bf0b1033c62d33 (diff)
downloadmanaserv-4059cb4fa545dda8b035a1033f5fefb99e978682.tar.gz
manaserv-4059cb4fa545dda8b035a1033f5fefb99e978682.tar.bz2
manaserv-4059cb4fa545dda8b035a1033f5fefb99e978682.tar.xz
manaserv-4059cb4fa545dda8b035a1033f5fefb99e978682.zip
Introduced separate functions for item database loading
This splits the huge ItemManager::reload() into readEquipSlotsFile() and readItemsFile(), the latter of which is further split up into multiple functions for reading the different elements. Just to keep the amount of nesting down and increase the readability. Removes the need for huge eye-catching comment blocks. Reviewed-by: Freeyorp
Diffstat (limited to 'src/game-server/itemmanager.h')
-rw-r--r--src/game-server/itemmanager.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/game-server/itemmanager.h b/src/game-server/itemmanager.h
index 00739785..c7033047 100644
--- a/src/game-server/itemmanager.h
+++ b/src/game-server/itemmanager.h
@@ -21,6 +21,8 @@
#ifndef ITEMMANAGER_H
#define ITEMMANAGER_H
+#include "utils/xml.h"
+
#include <string>
#include <map>
#include <vector>
@@ -31,9 +33,12 @@ class ItemManager
{
public:
ItemManager(const std::string &itemFile, const std::string &equipFile) :
- mItemReferenceFile(itemFile),
- mEquipCharSlotReferenceFile(equipFile),
- mItemDatabaseVersion(0) {}
+ mItemsFile(itemFile),
+ mEquipSlotsFile(equipFile),
+ mVisibleEquipSlotCount(0),
+ mItemDatabaseVersion(0)
+ {}
+
/**
* Loads item reference file.
*/
@@ -78,6 +83,15 @@ class ItemManager
bool isEquipSlotVisible(unsigned int id) const;
private:
+ /** Loads the equip slots that a character has available to them. */
+ void readEquipSlotsFile();
+
+ /** Loads the main item database. */
+ void readItemsFile();
+ void readItemNode(xmlNodePtr itemNode);
+ void readEquipNode(xmlNodePtr equipNode, ItemClass *item);
+ void readEffectNode(xmlNodePtr effectNode, ItemClass *item);
+
typedef std::map< int, ItemClass * > ItemClasses;
// Map a string (name of slot) with (str-id, max-per-equip-slot)
typedef std::vector< std::pair< std::string, unsigned int > > EquipSlots;
@@ -88,11 +102,12 @@ class ItemManager
EquipSlots equipSlots;
VisibleEquipSlots visibleEquipSlots;
- std::string mItemReferenceFile;
- std::string mEquipCharSlotReferenceFile;
+ std::string mItemsFile;
+ std::string mEquipSlotsFile;
mutable unsigned int mVisibleEquipSlotCount; // Cache
- unsigned int mItemDatabaseVersion; /**< Version of the loaded items database file.*/
+ /** Version of the loaded items database file.*/
+ unsigned int mItemDatabaseVersion;
};
extern ItemManager *itemManager;