diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-05-19 11:40:50 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:47 +0200 |
commit | 4d46079cd147e05513473860cb2e92fec0c31b8f (patch) | |
tree | 0f115a91debb6be766a174e8042ff800aff3a0ec /src/game-server/attributemanager.h | |
parent | 6d14024f3df86c05e94f2b4161faf8f5d97c2c0f (diff) | |
download | manaserv-4d46079cd147e05513473860cb2e92fec0c31b8f.tar.gz manaserv-4d46079cd147e05513473860cb2e92fec0c31b8f.tar.bz2 manaserv-4d46079cd147e05513473860cb2e92fec0c31b8f.tar.xz manaserv-4d46079cd147e05513473860cb2e92fec0c31b8f.zip |
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.
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; |