diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-23 19:19:27 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:48 +0200 |
commit | 61766a59ad152ab6c9a6f3fd318ed9256b573be9 (patch) | |
tree | b1a3b383056f8c9673b654cf27db1dd65e5d858f | |
parent | 64837cfccc3039fdd25d2e34c5f81949d34e1c95 (diff) | |
download | manaserv-61766a59ad152ab6c9a6f3fd318ed9256b573be9.tar.gz manaserv-61766a59ad152ab6c9a6f3fd318ed9256b573be9.tar.bz2 manaserv-61766a59ad152ab6c9a6f3fd318ed9256b573be9.tar.xz manaserv-61766a59ad152ab6c9a6f3fd318ed9256b573be9.zip |
Moved AttributeInfo into a seperate file
-rw-r--r-- | src/game-server/attribute.cpp | 2 | ||||
-rw-r--r-- | src/game-server/attribute.h | 4 | ||||
-rw-r--r-- | src/game-server/attributemanager.cpp | 7 | ||||
-rw-r--r-- | src/game-server/attributemanager.h | 55 | ||||
-rw-r--r-- | src/game-server/being.cpp | 20 | ||||
-rw-r--r-- | src/game-server/being.h | 24 | ||||
-rw-r--r-- | src/game-server/buysell.h | 2 | ||||
-rw-r--r-- | src/game-server/character.cpp | 8 | ||||
-rw-r--r-- | src/game-server/character.h | 8 | ||||
-rw-r--r-- | src/game-server/item.h | 4 | ||||
-rw-r--r-- | src/game-server/monster.h | 10 | ||||
-rw-r--r-- | src/game-server/monstermanager.cpp | 2 | ||||
-rw-r--r-- | src/game-server/trade.h | 2 | ||||
-rw-r--r-- | src/scripting/luascript.cpp | 2 | ||||
-rw-r--r-- | src/scripting/luascript.h | 2 | ||||
-rw-r--r-- | src/scripting/luautil.cpp | 4 | ||||
-rw-r--r-- | src/scripting/luautil.h | 6 | ||||
-rw-r--r-- | src/scripting/script.h | 2 |
18 files changed, 57 insertions, 107 deletions
diff --git a/src/game-server/attribute.cpp b/src/game-server/attribute.cpp index 693c78dc..b15c2ec7 100644 --- a/src/game-server/attribute.cpp +++ b/src/game-server/attribute.cpp @@ -314,7 +314,7 @@ bool AttributeModifiersEffect::tick() return ret; } -Attribute::Attribute(const AttributeManager::AttributeInfo *info): +Attribute::Attribute(const AttributeInfo *info): mBase(0), mMinValue(info->minimum), mMaxValue(info->maximum) diff --git a/src/game-server/attribute.h b/src/game-server/attribute.h index 8ad357f7..0a677b5d 100644 --- a/src/game-server/attribute.h +++ b/src/game-server/attribute.h @@ -22,7 +22,7 @@ #define ATTRIBUTE_H #include "common/defines.h" -#include "attributemanager.h" +#include "attributeinfo.h" #include <vector> #include <list> @@ -138,7 +138,7 @@ class Attribute , mMaxValue(0) {throw;} // DEBUG; Find improper constructions - Attribute(const AttributeManager::AttributeInfo *info); + Attribute(const AttributeInfo *info); ~Attribute(); diff --git a/src/game-server/attributemanager.cpp b/src/game-server/attributemanager.cpp index 3eb36cb8..cb922511 100644 --- a/src/game-server/attributemanager.cpp +++ b/src/game-server/attributemanager.cpp @@ -21,6 +21,7 @@ #include "game-server/attributemanager.h" #include "common/defines.h" +#include "game-server/attributeinfo.h" #include "utils/string.h" #include "utils/logger.h" @@ -47,7 +48,7 @@ void AttributeManager::deinitialize() mAttributeScopes[i].clear(); } -AttributeManager::AttributeInfo *AttributeManager::getAttributeInfo( +AttributeInfo *AttributeManager::getAttributeInfo( int id) const { auto ret = mAttributeMap.find(id); @@ -56,7 +57,7 @@ AttributeManager::AttributeInfo *AttributeManager::getAttributeInfo( return ret->second; } -AttributeManager::AttributeInfo *AttributeManager::getAttributeInfo( +AttributeInfo *AttributeManager::getAttributeInfo( const std::string &name) const { if (mAttributeNameMap.contains(name)) @@ -64,7 +65,7 @@ AttributeManager::AttributeInfo *AttributeManager::getAttributeInfo( return 0; } -const std::set<AttributeManager::AttributeInfo *> +const std::set<AttributeInfo *> &AttributeManager::getAttributeScope(ScopeType type) const { return mAttributeScopes[type]; diff --git a/src/game-server/attributemanager.h b/src/game-server/attributemanager.h index c6782130..13dcf1fb 100644 --- a/src/game-server/attributemanager.h +++ b/src/game-server/attributemanager.h @@ -21,7 +21,6 @@ #ifndef ATTRIBUTEMANAGER_H #define ATTRIBUTEMANAGER_H -#include <limits> #include <map> #include <set> #include <string> @@ -30,6 +29,8 @@ #include "utils/string.h" #include "utils/xml.h" +class AttributeInfo; + enum ScopeType { BeingScope = 0, @@ -40,37 +41,6 @@ enum ScopeType }; /** - * Stackable types. - * @todo non-stackable malus layers - */ -enum StackableType -{ - Stackable, - NonStackable, - NonStackableBonus -}; - -/** - * Attribute augmentation methods. - */ -enum ModifierEffectType -{ - Multiplicative, - Additive -}; - -struct AttributeModifier -{ - AttributeModifier(StackableType s, ModifierEffectType effect) : - stackableType(s), - effectType(effect) - {} - - StackableType stackableType; - ModifierEffectType effectType; -}; - -/** * Identifies a modifier by the attribute id that it applies to and its layer * index in the stack of modifiers for that attribute. */ @@ -91,27 +61,6 @@ struct ModifierLocation class AttributeManager { public: - struct AttributeInfo { - AttributeInfo(int id, const std::string &name): - id(id), - name(name), - minimum(std::numeric_limits<double>::min()), - maximum(std::numeric_limits<double>::max()), - modifiable(false) - {} - - int id; - std::string name; - - /** 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<AttributeModifier> modifiers; - }; - AttributeManager() {} diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index 205a5778..8ef74c96 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -317,7 +317,7 @@ void BeingComponent::setAction(Entity &entity, BeingAction action) } } -void BeingComponent::applyModifier(Entity &entity, AttributeManager::AttributeInfo *attribute, +void BeingComponent::applyModifier(Entity &entity, AttributeInfo *attribute, double value, unsigned layer, unsigned duration, unsigned id) { @@ -325,7 +325,7 @@ void BeingComponent::applyModifier(Entity &entity, AttributeManager::AttributeIn updateDerivedAttributes(entity, attribute); } -bool BeingComponent::removeModifier(Entity &entity, AttributeManager::AttributeInfo *attribute, +bool BeingComponent::removeModifier(Entity &entity, AttributeInfo *attribute, double value, unsigned layer, unsigned id, bool fullcheck) { @@ -340,7 +340,7 @@ void BeingComponent::setGender(BeingGender gender) } void BeingComponent::setAttribute(Entity &entity, - AttributeManager::AttributeInfo *attribute, + AttributeInfo *attribute, double value) { auto attributeIt = mAttributes.find(attribute); @@ -361,13 +361,13 @@ void BeingComponent::setAttribute(Entity &entity, } } -void BeingComponent::createAttribute(AttributeManager::AttributeInfo *attributeInfo) +void BeingComponent::createAttribute(AttributeInfo *attributeInfo) { - mAttributes.insert(std::pair<AttributeManager::AttributeInfo *, Attribute> + mAttributes.insert(std::pair<AttributeInfo *, Attribute> (attributeInfo, Attribute(attributeInfo))); } -const Attribute *BeingComponent::getAttribute(AttributeManager::AttributeInfo *attribute) const +const Attribute *BeingComponent::getAttribute(AttributeInfo *attribute) const { AttributeMap::const_iterator ret = mAttributes.find(attribute); if (ret == mAttributes.end()) @@ -379,7 +379,7 @@ const Attribute *BeingComponent::getAttribute(AttributeManager::AttributeInfo *a return &ret->second; } -double BeingComponent::getAttributeBase(AttributeManager::AttributeInfo *attribute) const +double BeingComponent::getAttributeBase(AttributeInfo *attribute) const { AttributeMap::const_iterator ret = mAttributes.find(attribute); if (ret == mAttributes.end()) @@ -392,7 +392,7 @@ double BeingComponent::getAttributeBase(AttributeManager::AttributeInfo *attribu } -double BeingComponent::getModifiedAttribute(AttributeManager::AttributeInfo *attribute) const +double BeingComponent::getModifiedAttribute(AttributeInfo *attribute) const { AttributeMap::const_iterator ret = mAttributes.find(attribute); if (ret == mAttributes.end()) @@ -405,7 +405,7 @@ double BeingComponent::getModifiedAttribute(AttributeManager::AttributeInfo *att } void BeingComponent::recalculateBaseAttribute(Entity &entity, - AttributeManager::AttributeInfo *attribute) + AttributeInfo *attribute) { LOG_DEBUG("Being: Received update attribute recalculation request for " << attribute << "."); @@ -437,7 +437,7 @@ void BeingComponent::recalculateBaseAttribute(Entity &entity, } void BeingComponent::updateDerivedAttributes(Entity &entity, - AttributeManager::AttributeInfo *attribute) + AttributeInfo *attribute) { signal_attribute_changed.emit(&entity, attribute); diff --git a/src/game-server/being.h b/src/game-server/being.h index 908def6d..6c839d6f 100644 --- a/src/game-server/being.h +++ b/src/game-server/being.h @@ -38,7 +38,7 @@ class BeingComponent; class MapComposite; class StatusEffect; -typedef std::map<AttributeManager::AttributeInfo *, Attribute> AttributeMap; +typedef std::map<AttributeInfo *, Attribute> AttributeMap; struct Status { @@ -144,7 +144,7 @@ class BeingComponent : public Component /** * Sets an attribute. */ - void setAttribute(Entity &entity, AttributeManager::AttributeInfo *, double value); + void setAttribute(Entity &entity, AttributeInfo *, double value); /** * Creates an Attribute that did not exist before @@ -152,12 +152,12 @@ class BeingComponent : public Component * @param id The id of the attribute * @param attributeInfo The info that describes the attribute */ - void createAttribute(AttributeManager::AttributeInfo *); + void createAttribute(AttributeInfo *); /** * Gets an attribute or 0 if not existing. */ - const Attribute *getAttribute(AttributeManager::AttributeInfo *) const; + const Attribute *getAttribute(AttributeInfo *) const; const AttributeMap &getAttributes() const { return mAttributes; } @@ -165,19 +165,19 @@ class BeingComponent : public Component /** * Gets an attribute base. */ - double getAttributeBase(AttributeManager::AttributeInfo *) const; + double getAttributeBase(AttributeInfo *) const; /** * Gets an attribute after applying modifiers. */ - double getModifiedAttribute(AttributeManager::AttributeInfo *) const; + double getModifiedAttribute(AttributeInfo *) const; /** * Checks whether or not an attribute exists in this being. * @returns True if the attribute is present in the being, false otherwise. */ - bool checkAttributeExists(AttributeManager::AttributeInfo *attribute) const + bool checkAttributeExists(AttributeInfo *attribute) const { return mAttributes.count(attribute); } /** @@ -187,11 +187,11 @@ class BeingComponent : public Component * @param lvl If non-zero, indicates that a temporary modifier can be * dispelled prematuraly by a spell of given level. */ - void applyModifier(Entity &entity, AttributeManager::AttributeInfo *, + void applyModifier(Entity &entity, AttributeInfo *, double value, unsigned layer, unsigned duration = 0, unsigned id = 0); - bool removeModifier(Entity &entity, AttributeManager::AttributeInfo *, + bool removeModifier(Entity &entity, AttributeInfo *, double value, unsigned layer, unsigned id = 0, bool fullcheck = false); @@ -202,7 +202,7 @@ class BeingComponent : public Component * @returns Whether it was changed. */ void recalculateBaseAttribute(Entity &, - AttributeManager::AttributeInfo *); + AttributeInfo *); /** * Attribute has changed, recalculate base value of dependant @@ -210,7 +210,7 @@ class BeingComponent : public Component * attribute) */ void updateDerivedAttributes(Entity &entity, - AttributeManager::AttributeInfo *); + AttributeInfo *); /** * Sets a statuseffect on this being @@ -260,7 +260,7 @@ class BeingComponent : public Component { script->assignCallback(mRecalculateBaseAttributeCallback); } sigc::signal<void, Entity *> signal_died; - sigc::signal<void, Entity *, AttributeManager::AttributeInfo *> signal_attribute_changed; + sigc::signal<void, Entity *, AttributeInfo *> signal_attribute_changed; /** * Activate an emote flag on the being. diff --git a/src/game-server/buysell.h b/src/game-server/buysell.h index 524bec9b..259108f2 100644 --- a/src/game-server/buysell.h +++ b/src/game-server/buysell.h @@ -79,7 +79,7 @@ class BuySell typedef std::vector< TradedItem > TradedItems; /** The attribute ID of the currency to use. Hardcoded for now (FIXME) */ - AttributeManager::AttributeInfo *mCurrency; + AttributeInfo *mCurrency; Entity *mChar; /**< Character involved. */ TradedItems mItems; /**< Traded items. */ diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 82bb6c5d..74df2122 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -447,7 +447,7 @@ void CharacterComponent::sendStatus(Entity &entity) { auto *beingComponent = entity.getComponent<BeingComponent>(); MessageOut attribMsg(GPMSG_PLAYER_ATTRIBUTE_CHANGE); - for (AttributeManager::AttributeInfo *attribute : mModifiedAttributes) + for (AttributeInfo *attribute : mModifiedAttributes) { attribMsg.writeInt16(attribute->id); attribMsg.writeInt32(beingComponent->getAttributeBase(attribute) * 256); @@ -470,7 +470,7 @@ void CharacterComponent::modifiedAllAttributes(Entity &entity) } void CharacterComponent::attributeChanged(Entity *entity, - AttributeManager::AttributeInfo *attribute) + AttributeInfo *attribute) { auto *beingComponent = entity->getComponent<BeingComponent>(); @@ -505,7 +505,7 @@ int CharacterComponent::getKillCount(int monsterType) const } AttribmodResponseCode CharacterComponent::useCharacterPoint(Entity &entity, - AttributeManager::AttributeInfo *attribute) + AttributeInfo *attribute) { auto *beingComponent = entity.getComponent<BeingComponent>(); @@ -523,7 +523,7 @@ AttribmodResponseCode CharacterComponent::useCharacterPoint(Entity &entity, } AttribmodResponseCode CharacterComponent::useCorrectionPoint(Entity &entity, - AttributeManager::AttributeInfo *attribute) + AttributeInfo *attribute) { auto *beingComponent = entity.getComponent<BeingComponent>(); diff --git a/src/game-server/character.h b/src/game-server/character.h index a4f881d8..57e9d44c 100644 --- a/src/game-server/character.h +++ b/src/game-server/character.h @@ -178,7 +178,7 @@ class CharacterComponent : public Component * @param being th being of which the attribute was changed * @param attributeId the changed id */ - void attributeChanged(Entity *being, AttributeManager::AttributeInfo *); + void attributeChanged(Entity *being, AttributeInfo *); /** * Calls all the "disconnected" listener. @@ -221,14 +221,14 @@ class CharacterComponent : public Component * basic attribute */ AttribmodResponseCode useCharacterPoint(Entity &entity, - AttributeManager::AttributeInfo *); + AttributeInfo *); /** * Tries to use a correction point to reduce a * basic attribute and regain a character point */ AttribmodResponseCode useCorrectionPoint(Entity &entity, - AttributeManager::AttributeInfo *); + AttributeInfo *); void setAttributePoints(int points); int getAttributePoints() const; @@ -320,7 +320,7 @@ class CharacterComponent : public Component Possessions mPossessions; /**< Possesssions of the character. */ /** Attributes modified since last update. */ - std::set<AttributeManager::AttributeInfo *> mModifiedAttributes; + std::set<AttributeInfo *> mModifiedAttributes; std::set<unsigned> mModifiedAbilities; diff --git a/src/game-server/item.h b/src/game-server/item.h index 8f7b114a..5936530e 100644 --- a/src/game-server/item.h +++ b/src/game-server/item.h @@ -110,7 +110,7 @@ class ItemEffectInfo class ItemEffectAttrMod : public ItemEffectInfo { public: - ItemEffectAttrMod(AttributeManager::AttributeInfo *attribute, + ItemEffectAttrMod(AttributeInfo *attribute, unsigned layer, double value, unsigned modId, unsigned duration = 0) : mAttribute(attribute) @@ -124,7 +124,7 @@ class ItemEffectAttrMod : public ItemEffectInfo void dispell(Entity *itemUser); private: - AttributeManager::AttributeInfo *mAttribute; + AttributeInfo *mAttribute; unsigned mAttributeLayer; double mMod; unsigned mDuration; diff --git a/src/game-server/monster.h b/src/game-server/monster.h index ff534f58..618e1e9d 100644 --- a/src/game-server/monster.h +++ b/src/game-server/monster.h @@ -105,9 +105,9 @@ class MonsterClass /** * Sets a being base attribute. */ - void setAttribute(AttributeManager::AttributeInfo *attribute, double value); + void setAttribute(AttributeInfo *attribute, double value); - const std::map<AttributeManager::AttributeInfo *, double> + const std::map<AttributeInfo *, double> &getAttributes() const; /** Sets collision circle radius. */ @@ -137,7 +137,7 @@ class MonsterClass BeingGender mGender; MonsterDrops mDrops; - std::map<AttributeManager::AttributeInfo *, double> mAttributes; + std::map<AttributeInfo *, double> mAttributes; std::set<AbilityManager::AbilityInfo *> mAbilities; float mSpeed; /**< The monster class speed in tiles per second */ int mSize; @@ -189,12 +189,12 @@ class MonsterComponent : public Component Timeout mDecayTimeout; }; -inline void MonsterClass::setAttribute(AttributeManager::AttributeInfo *attribute, double value) +inline void MonsterClass::setAttribute(AttributeInfo *attribute, double value) { mAttributes[attribute] = value; } -inline const std::map<AttributeManager::AttributeInfo *, double> +inline const std::map<AttributeInfo *, double> &MonsterClass::getAttributes() const { return mAttributes; diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp index 1802a022..a5acd126 100644 --- a/src/game-server/monstermanager.cpp +++ b/src/game-server/monstermanager.cpp @@ -166,7 +166,7 @@ void MonsterManager::readMonsterNode(xmlNodePtr node, const std::string &filenam { std::string attributeIdString = XML::getProperty(subnode, "id", std::string()); - AttributeManager::AttributeInfo *info = nullptr; + AttributeInfo *info = nullptr; if (utils::isNumeric(attributeIdString)) { const int attributeId = utils::stringToInt(attributeIdString); diff --git a/src/game-server/trade.h b/src/game-server/trade.h index f9009113..70ae1095 100644 --- a/src/game-server/trade.h +++ b/src/game-server/trade.h @@ -104,7 +104,7 @@ class Trade TradedItems mItems1, mItems2; /**< Traded items. */ int mMoney1, mMoney2; /**< Traded money. */ TradeState mState; /**< State of transaction. */ - AttributeManager::AttributeInfo *mCurrencyAttribute; + AttributeInfo *mCurrencyAttribute; }; #endif diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp index 5ce55d13..6d22774a 100644 --- a/src/scripting/luascript.cpp +++ b/src/scripting/luascript.cpp @@ -113,7 +113,7 @@ void LuaScript::push(const std::list<InventoryItem> &itemList) ++nbArgs; } -void LuaScript::push(AttributeManager::AttributeInfo *attributeInfo) +void LuaScript::push(AttributeInfo *attributeInfo) { assert(nbArgs >= 0); ::push(mCurrentState, attributeInfo); diff --git a/src/scripting/luascript.h b/src/scripting/luascript.h index a30cbf08..2d47d8ea 100644 --- a/src/scripting/luascript.h +++ b/src/scripting/luascript.h @@ -57,7 +57,7 @@ class LuaScript : public Script void push(const std::string &); void push(Entity *); void push(const std::list<InventoryItem> &itemList); - void push(AttributeManager::AttributeInfo *); + void push(AttributeInfo *); int execute(const Context &context = Context()); diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index 5a0cf883..ed277ee0 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -226,9 +226,9 @@ AbilityManager::AbilityInfo *checkAbility(lua_State *s, int p) return abilityInfo; } -AttributeManager::AttributeInfo *checkAttribute(lua_State *s, int p) +AttributeInfo *checkAttribute(lua_State *s, int p) { - AttributeManager::AttributeInfo *attributeInfo; + AttributeInfo *attributeInfo; switch (lua_type(s, p)) { diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h index 03c4666e..45e075f1 100644 --- a/src/scripting/luautil.h +++ b/src/scripting/luautil.h @@ -165,7 +165,7 @@ typedef LuaUserData<MapObject> LuaMapObject; typedef LuaUserData<MonsterClass> LuaMonsterClass; typedef LuaUserData<StatusEffect> LuaStatusEffect; typedef LuaUserData<AbilityManager::AbilityInfo> LuaAbilityInfo; -typedef LuaUserData<AttributeManager::AttributeInfo> LuaAttributeInfo; +typedef LuaUserData<AttributeInfo> LuaAttributeInfo; Script * getScript(lua_State *s); @@ -180,7 +180,7 @@ Entity * checkMonster(lua_State *s, int p); MonsterClass * checkMonsterClass(lua_State *s, int p); Entity * checkNpc(lua_State *s, int p); AbilityManager::AbilityInfo * checkAbility(lua_State *s, int p); -AttributeManager::AttributeInfo * checkAttribute(lua_State *s, int p); +AttributeInfo * checkAttribute(lua_State *s, int p); unsigned char checkWalkMask(lua_State *s, int p); MapComposite * checkCurrentMap(lua_State *s, Script *script = 0); @@ -220,7 +220,7 @@ inline void push(lua_State *s, MonsterClass *val) LuaMonsterClass::push(s, val); } -inline void push(lua_State *s, AttributeManager::AttributeInfo *val) +inline void push(lua_State *s, AttributeInfo *val) { LuaAttributeInfo::push(s, val); } diff --git a/src/scripting/script.h b/src/scripting/script.h index 1f8c415e..d4b51345 100644 --- a/src/scripting/script.h +++ b/src/scripting/script.h @@ -195,7 +195,7 @@ class Script : public sigc::trackable */ virtual void push(const std::list<InventoryItem> &itemList) = 0; - virtual void push(AttributeManager::AttributeInfo *) = 0; + virtual void push(AttributeInfo *) = 0; /** * Executes the function being prepared. |