diff options
Diffstat (limited to 'src/game-server/attributemanager.h')
-rw-r--r-- | src/game-server/attributemanager.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/game-server/attributemanager.h b/src/game-server/attributemanager.h index 9bc40e1f..2972cd77 100644 --- a/src/game-server/attributemanager.h +++ b/src/game-server/attributemanager.h @@ -26,6 +26,7 @@ #include <string> #include <limits> +#include "utils/string.h" #include "utils/xml.h" enum ScopeType @@ -91,18 +92,21 @@ class AttributeManager public: struct AttributeInfo { AttributeInfo(): + id(0), minimum(std::numeric_limits<double>::min()), maximum(std::numeric_limits<double>::max()), modifiable(false) {} + int id; + /** The minimum and maximum permitted attribute values. */ double minimum; double maximum; /** Tells whether the base attribute is modifiable by the player */ bool modifiable; /** Effect modifier type: stackability and modification type. */ - std::vector<struct AttributeModifier> modifiers; + std::vector<AttributeModifier> modifiers; }; AttributeManager() @@ -117,13 +121,12 @@ class AttributeManager * Reloads attribute reference file. */ void reload(); + void deinitialize(); - const std::vector<AttributeModifier> *getAttributeInfo(int id) const; - - // being type id -> (*{ stackable type, effect type })[] - typedef std::map<int, AttributeInfo*> AttributeScope; + const AttributeInfo *getAttributeInfo(int id) const; + const AttributeInfo *getAttributeInfo(const std::string &name) const; - const AttributeScope &getAttributeScope(ScopeType) const; + const std::map<int, AttributeInfo *> &getAttributeScope(ScopeType) const; bool isAttributeDirectlyModifiable(int id) const; @@ -136,17 +139,15 @@ class AttributeManager void checkStatus(); private: - void readModifierNode(xmlNodePtr modifierNode, int attributeId); + void readModifierNode(xmlNodePtr modifierNode, int attributeId, + AttributeInfo *info); - // Attribute id -> { modifiable, min, max, { stackable type, effect type }[] } - typedef std::map<int, AttributeInfo> AttributeMap; + std::map<int, AttributeInfo *> mAttributeScopes[MaxScope]; - /** Maps tag names to specific modifiers. */ - typedef std::map<std::string, ModifierLocation> TagMap; + std::map<int, AttributeInfo *> mAttributeMap; + utils::NameMap<AttributeInfo *> mAttributeNameMap; - AttributeScope mAttributeScopes[MaxScope]; - AttributeMap mAttributeMap; - TagMap mTagMap; + std::map<std::string, ModifierLocation> mTagMap; }; extern AttributeManager *attributeManager; |