diff options
-rw-r--r-- | src/game-server/attribute.h | 10 | ||||
-rw-r--r-- | src/game-server/attributemanager.cpp | 10 | ||||
-rw-r--r-- | src/game-server/attributemanager.h | 26 | ||||
-rw-r--r-- | src/game-server/being.cpp | 6 | ||||
-rw-r--r-- | src/game-server/character.cpp | 6 | ||||
-rw-r--r-- | src/game-server/monster.cpp | 6 | ||||
-rw-r--r-- | src/game-server/monstermanager.cpp | 6 |
7 files changed, 36 insertions, 34 deletions
diff --git a/src/game-server/attribute.h b/src/game-server/attribute.h index 2725fad3..cc7302d4 100644 --- a/src/game-server/attribute.h +++ b/src/game-server/attribute.h @@ -36,9 +36,6 @@ class AttributeModifierState , mId(id) {} - ~AttributeModifierState() - {} - bool tick() { return mDuration ? !--mDuration : false; } private: @@ -77,7 +74,6 @@ class AttributeModifiersEffect /** * remove() - as with Attribute::remove(). */ - bool remove(double value, unsigned int id, bool fullCheck); /** @@ -128,6 +124,10 @@ class AttributeModifiersEffect const ModifierEffectType mEffectType; }; +/** + * Represents some attribute of a being. Is has a base value and a modified + * value, subject to modifiers that can be added and removed. + */ class Attribute { public: @@ -177,13 +177,11 @@ class Attribute /** * clearMods() removes *all* modifications present in this Attribute (!) */ - void clearMods(); /** * tick() processes all timers associated with modifiers for this attribute. */ - bool tick(); private: diff --git a/src/game-server/attributemanager.cpp b/src/game-server/attributemanager.cpp index 3680844b..c1537ad0 100644 --- a/src/game-server/attributemanager.cpp +++ b/src/game-server/attributemanager.cpp @@ -35,7 +35,7 @@ void AttributeManager::reload() { mTagMap.clear(); mAttributeMap.clear(); - for (unsigned int i = 0; i < ATTR_MAX; ++i) + for (unsigned int i = 0; i < MaxScope; ++i) mAttributeScopes[i].clear(); std::string absPathFile = ResourceManager::resolve(mAttributeReferenceFile); @@ -159,19 +159,19 @@ void AttributeManager::reload() } else if (scope == "CHARACTER") { - mAttributeScopes[ATTR_CHAR][id] = &mAttributeMap.at(id).second; + mAttributeScopes[CharacterScope][id] = &mAttributeMap.at(id).second; LOG_DEBUG("Attribute manager: attribute '" << id << "' added to default character scope."); } else if (scope == "MONSTER") { - mAttributeScopes[ATTR_MOB][id] = &mAttributeMap.at(id).second; + mAttributeScopes[MonsterScope][id] = &mAttributeMap.at(id).second; LOG_DEBUG("Attribute manager: attribute '" << id << "' added to default monster scope."); } else if (scope == "BEING") { - mAttributeScopes[ATTR_BEING][id] = &mAttributeMap.at(id).second; + mAttributeScopes[BeingScope][id] = &mAttributeMap.at(id).second; LOG_DEBUG("Attribute manager: attribute '" << id << "' added to default being scope."); } @@ -227,7 +227,7 @@ const std::vector<struct AttributeInfoType> *AttributeManager::getAttributeInfo( return &ret->second.second; } -const AttributeScopes &AttributeManager::getAttributeInfoForType(SCOPE_TYPES type) const +const AttributeScope &AttributeManager::getAttributeScope(ScopeType type) const { return mAttributeScopes[type]; } diff --git a/src/game-server/attributemanager.h b/src/game-server/attributemanager.h index a87ba901..7e05c914 100644 --- a/src/game-server/attributemanager.h +++ b/src/game-server/attributemanager.h @@ -25,22 +25,24 @@ #include <vector> #include <string> -typedef struct AttributeInfoType AttributeInfoType_t; - -enum SCOPE_TYPES { - ATTR_BEING = 0, - ATTR_CHAR, - ATTR_MOB, +enum ScopeType +{ + BeingScope = 0, + CharacterScope, + MonsterScope, // Add new types here as needed - ATTR_MAX + MaxScope }; -typedef std::map< int, std::vector<struct AttributeInfoType> * > AttributeScopes; +typedef std::map< int, std::vector<struct AttributeInfoType> * > AttributeScope; class AttributeManager { public: - AttributeManager(const std::string &file) : mAttributeReferenceFile(file) {} + AttributeManager(const std::string &file) : + mAttributeReferenceFile(file) + {} + /** * Loads attribute reference file. */ @@ -50,15 +52,17 @@ class AttributeManager * Reloads attribute reference file. */ void reload(); + const std::vector<struct AttributeInfoType> *getAttributeInfo(unsigned int) const; - const AttributeScopes &getAttributeInfoForType(SCOPE_TYPES) const; + const AttributeScope &getAttributeScope(ScopeType) const; bool isAttributeDirectlyModifiable(unsigned int) const; std::pair<unsigned int,unsigned int> getInfoFromTag(const std::string &) const; const std::string *getTagFromInfo(unsigned int, unsigned int) const; + private: // modifiable, { stackable type, effect type }[] typedef std::pair< bool, @@ -71,7 +75,7 @@ class AttributeManager std::pair<unsigned int, unsigned int> > TagMap; // being type id -> (*{ stackable type, effect type })[] - AttributeScopes mAttributeScopes[ATTR_MAX]; + AttributeScope mAttributeScopes[MaxScope]; AttributeMap mAttributeMap; TagMap mTagMap; diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index b8cda8a3..d27eb179 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -41,9 +41,9 @@ Being::Being(ThingType type): mTarget(NULL), mDirection(DOWN) { - const AttributeScopes &attr = attributeManager->getAttributeInfoForType(ATTR_BEING); + const AttributeScope &attr = attributeManager->getAttributeScope(BeingScope); LOG_DEBUG("Being creation: initialisation of " << attr.size() << " attributes."); - for (AttributeScopes::const_iterator it1 = attr.begin(), + for (AttributeScope::const_iterator it1 = attr.begin(), it1_end = attr.end(); it1 != it1_end; ++it1) @@ -541,7 +541,7 @@ bool Being::recalculateBaseAttribute(unsigned int attr) void Being::updateDerivedAttributes(unsigned int attr) { - switch(attr) + switch (attr) { case ATTR_MAX_HP: updateDerivedAttributes(ATTR_HP); diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 4688956f..46f9eade 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -68,11 +68,11 @@ Character::Character(MessageIn &msg): mParty(0), mTransaction(TRANS_NONE) { - const AttributeScopes &attr = - attributeManager->getAttributeInfoForType(ATTR_CHAR); + const AttributeScope &attr = + attributeManager->getAttributeScope(CharacterScope); LOG_DEBUG("Character creation: initialisation of " << attr.size() << " attributes."); - for (AttributeScopes::const_iterator it1 = attr.begin(), + for (AttributeScope::const_iterator it1 = attr.begin(), it1_end = attr.end(); it1 != it1_end; ++it1) mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second))); diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index f77cca0b..f2914da7 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -74,10 +74,10 @@ Monster::Monster(MonsterClass *specy): /* * Initialise the attribute structures. */ - const AttributeScopes &mobAttr = attributeManager->getAttributeInfoForType( - ATTR_MOB); + const AttributeScope &mobAttr = attributeManager->getAttributeScope( + MonsterScope); - for (AttributeScopes::const_iterator it = mobAttr.begin(), + for (AttributeScope::const_iterator it = mobAttr.begin(), it_end = mobAttr.end(); it != it_end; ++it) { mAttributes.insert(std::pair< unsigned int, Attribute > diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp index a719e1a8..a98126e0 100644 --- a/src/game-server/monstermanager.cpp +++ b/src/game-server/monstermanager.cpp @@ -164,10 +164,10 @@ void MonsterManager::reload() } bool attributesComplete = true; - const AttributeScopes &mobAttr = - attributeManager->getAttributeInfoForType(ATTR_MOB); + const AttributeScope &mobAttr = + attributeManager->getAttributeScope(MonsterScope); - for (AttributeScopes::const_iterator it = mobAttr.begin(), + for (AttributeScope::const_iterator it = mobAttr.begin(), it_end = mobAttr.end(); it != it_end; ++it) { if (!monster->mAttributes.count(it->first)) |