diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-07-29 20:20:51 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-07-29 20:20:51 +0200 |
commit | ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be (patch) | |
tree | 041646a78229772ae7bb55222659fc4826325c43 /src/resources/itemdb.cpp | |
parent | 2b1c0dcf269d617de1f6c203df547166661f089e (diff) | |
download | mana-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.tar.gz mana-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.tar.bz2 mana-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.tar.xz mana-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.zip |
Changed the items loading to handle a new 'attack-action' parameter.
The old behaviour was to load the weapon-type value and do many
unnecessary checks and transformation on it:
The weapon-type was transformed using hard-coded values into
an integer enum value.
The exact same thing was done on the opposite side in the animation
files before comparing the two.
As both data were string values, I simplified all of it by using
the value taken in items.xml to call the corresponding action.
This now also permit to set up new attack animation in items.xml
and in the playerset.xml without having the need
to modify the client code.
Last but not least, the weapon-type value was used by both the skills
and the actions and avoided the possibility to set up a definite action
for a weapon-type.
Note: The weapon-type parameter will become deprecated for the server
in favor of a 'skill' parameter to reflect more it's actual use.
This patch is the first step to fix Manasource issue: #157.
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r-- | src/resources/itemdb.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index cbccc4cd..a8eed123 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -85,22 +85,6 @@ static ItemType itemTypeFromString(const std::string &name, int id = 0) else return ITEM_UNUSABLE; } -static WeaponType weaponTypeFromString(const std::string &name) -{ - if (name=="knife") return WPNTYPE_KNIFE; - else if (name=="sword") return WPNTYPE_SWORD; - else if (name=="polearm") return WPNTYPE_POLEARM; - else if (name=="staff") return WPNTYPE_STAFF; - else if (name=="whip") return WPNTYPE_WHIP; - else if (name=="bow") return WPNTYPE_BOW; - else if (name=="shooting") return WPNTYPE_SHOOTING; - else if (name=="mace") return WPNTYPE_MACE; - else if (name=="axe") return WPNTYPE_AXE; - else if (name=="thrown") return WPNTYPE_THROWN; - - else return WPNTYPE_NONE; -} - static std::string normalized(const std::string &name) { std::string normalized = name; @@ -153,7 +137,7 @@ void ItemDB::load() std::string name = XML::getProperty(node, "name", ""); std::string image = XML::getProperty(node, "image", ""); std::string description = XML::getProperty(node, "description", ""); - int weaponType = weaponTypeFromString(XML::getProperty(node, "weapon-type", "")); + std::string attackAction = XML::getProperty(node, "attack-action", ""); int attackRange = XML::getProperty(node, "attack-range", 0); std::string missileParticle = XML::getProperty(node, "missile-particle", ""); @@ -167,7 +151,7 @@ void ItemDB::load() itemInfo->setType(itemTypeFromString(typeStr)); itemInfo->setView(view); itemInfo->setWeight(weight); - itemInfo->setWeaponType(weaponType); + itemInfo->setAttackAction(attackAction); itemInfo->setAttackRange(attackRange); itemInfo->setMissileParticle(missileParticle); @@ -231,7 +215,7 @@ void ItemDB::load() } } - if (weaponType > 0) + if (!attackAction.empty()) if (attackRange == 0) logger->log("ItemDB: Missing attack range from weapon %i!", id); |