From 4d46079cd147e05513473860cb2e92fec0c31b8f Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sun, 19 May 2013 11:40:50 +0200 Subject: Allow names instead of ids for attributes + cleanup I did not adapt the scripts yet since we need some special handling for the attributes which are required by the server directly. So you still have to use the ids for those. I will change that later. In the future I want to use the AttributeInfo class instead of the int id everywhere possible. So I did a small start on that too. --- src/game-server/attributemanager.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/game-server/attributemanager.h') 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 #include +#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::min()), maximum(std::numeric_limits::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 modifiers; + std::vector modifiers; }; AttributeManager() @@ -117,13 +121,12 @@ class AttributeManager * Reloads attribute reference file. */ void reload(); + void deinitialize(); - const std::vector *getAttributeInfo(int id) const; - - // being type id -> (*{ stackable type, effect type })[] - typedef std::map AttributeScope; + const AttributeInfo *getAttributeInfo(int id) const; + const AttributeInfo *getAttributeInfo(const std::string &name) const; - const AttributeScope &getAttributeScope(ScopeType) const; + const std::map &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 AttributeMap; + std::map mAttributeScopes[MaxScope]; - /** Maps tag names to specific modifiers. */ - typedef std::map TagMap; + std::map mAttributeMap; + utils::NameMap mAttributeNameMap; - AttributeScope mAttributeScopes[MaxScope]; - AttributeMap mAttributeMap; - TagMap mTagMap; + std::map mTagMap; }; extern AttributeManager *attributeManager; -- cgit v1.2.3-70-g09d2