summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--src/resources/itemdb.cpp40
-rw-r--r--src/resources/iteminfo.cpp13
-rw-r--r--src/resources/iteminfo.h43
4 files changed, 96 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index f672155c..7bdda19f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-01-10 Philipp Sehmisch <tmw@crushnet.org>
+
+ * src/resources/itemdb.cpp, src/resources/iteminfo.cpp,
+ src/resources/iteminfo.h: Item types and weapon types are now
+ identified by name instead of numbers in the items.xml.
+ * data/items.xml: Removed entries for eAthena compatiblity (the
+ database isn't eAthena compatible anymore), added item type and
+ weapon-type properties to all items. All healing items now have a
+ healing effect.
+
2007-01-09 Philipp Sehmisch <tmw@crushnet.org>
* data/items.xml: Added weapon_type properties to weapons so that
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index ff537bc3..6d7f5944 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -56,6 +56,42 @@ static char const *const fields[][2] =
{ "mp", N_("MP %+d") }
};
+ItemType itemTypeFromString (std::string name, int id = 0)
+{
+ if (name=="generic") return ITEM_UNUSABLE;
+ else if (name=="usable") return ITEM_USABLE;
+ else if (name=="equip-1hand") return ITEM_EQUIPMENT_ONE_HAND_WEAPON;
+ else if (name=="equip-2hand") return ITEM_EQUIPMENT_TWO_HANDS_WEAPON;
+ else if (name=="equip-torso") return ITEM_EQUIPMENT_TORSO;
+ else if (name=="equip-arms") return ITEM_EQUIPMENT_ARMS;
+ else if (name=="equip-head") return ITEM_EQUIPMENT_HEAD;
+ else if (name=="equip-legs") return ITEM_EQUIPMENT_LEGS;
+ else if (name=="equip-shield") return ITEM_EQUIPMENT_SHIELD;
+ else if (name=="equip-ring") return ITEM_EQUIPMENT_RING;
+ else if (name=="equip-necklace") return ITEM_EQUIPMENT_NECKLACE;
+ else if (name=="equip-feet") return ITEM_EQUIPMENT_FEET;
+ else if (name=="equip-ammo") return ITEM_EQUIPMENT_AMMO;
+ else return ITEM_UNUSABLE;
+}
+
+WeaponType weaponTypeFromString (std::string name, int id = 0)
+{
+ if (name=="knife") return WPNTYPE_KNIFE;
+ else if (name=="sword") return WPNTYPE_SWORD;
+ else if (name=="polearm") return WPNTYPE_POLEARM;
+ else if (name=="javelin") return WPNTYPE_JAVELIN;
+ else if (name=="staff") return WPNTYPE_STAFF;
+ else if (name=="whip") return WPNTYPE_WHIP;
+ else if (name=="boomerang") return WPNTYPE_BOOMERANG;
+ else if (name=="bow") return WPNTYPE_BOW;
+ else if (name=="sickle") return WPNTYPE_SICKLE;
+ else if (name=="crossbow") return WPNTYPE_CROSSBOW;
+ 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;
+}
+
void ItemDB::load()
{
if (mLoaded)
@@ -108,14 +144,14 @@ void ItemDB::load()
logger->log("ItemDB: Redefinition of item ID %d", id);
}
- int type = XML::getProperty(node, "type", 0);
+ int type = itemTypeFromString(XML::getProperty(node, "type", ""));
int weight = XML::getProperty(node, "weight", 0);
int view = XML::getProperty(node, "view", 0);
std::string name = XML::getProperty(node, "name", "");
std::string image = XML::getProperty(node, "image", "");
std::string description = XML::getProperty(node, "description", "");
- int weaponType = XML::getProperty(node, "weapon_type", 0);
+ int weaponType = itemTypeFromString(XML::getProperty(node, "weapon_type", ""));
ItemInfo *itemInfo = new ItemInfo;
itemInfo->setImageName(image);
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index f1ebd0a9..ade7f685 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -45,23 +45,22 @@ ItemInfo::getSprite(int gender) const
void ItemInfo::setWeaponType(int type)
{
- // See server item.hpp file for type values.
switch (type)
{
- case 0: // none
+ case WPNTYPE_NONE:
mAttackType = ACTION_DEFAULT;
break;
- case 1: // knife
- case 2: // sword
+ case WPNTYPE_KNIFE:
+ case WPNTYPE_SWORD:
mAttackType = ACTION_ATTACK_STAB;
break;
- case 8: // projectile
+ case WPNTYPE_THROWN:
mAttackType = ACTION_ATTACK_THROW;
break;
- case 10: // bow
+ case WPNTYPE_BOW:
mAttackType = ACTION_ATTACK_BOW;
break;
- case 11: // sickle
+ case WPNTYPE_SICKLE:
mAttackType = ACTION_ATTACK_SWING;
break;
default:
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 680c8d61..c637b010 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -37,6 +37,47 @@ enum EquipmentSoundEvent
};
/**
+ * Enumeration of available Item types.
+ */
+enum ItemType
+{
+ ITEM_UNUSABLE = 0,
+ ITEM_USABLE, // 1
+ ITEM_EQUIPMENT_ONE_HAND_WEAPON, // 2
+ ITEM_EQUIPMENT_TWO_HANDS_WEAPON,// 3
+ ITEM_EQUIPMENT_TORSO,// 4
+ ITEM_EQUIPMENT_ARMS,// 5
+ ITEM_EQUIPMENT_HEAD,// 6
+ ITEM_EQUIPMENT_LEGS,// 7
+ ITEM_EQUIPMENT_SHIELD,// 8
+ ITEM_EQUIPMENT_RING,// 9
+ ITEM_EQUIPMENT_NECKLACE,// 10
+ ITEM_EQUIPMENT_FEET,// 11
+ ITEM_EQUIPMENT_AMMO// 12
+};
+
+/**
+ * Enumeration of available weapon's types.
+ */
+enum WeaponType
+{
+ WPNTYPE_NONE = 0,
+ WPNTYPE_KNIFE,// 1
+ WPNTYPE_SWORD,// 2
+ WPNTYPE_POLEARM,// 3
+ WPNTYPE_JAVELIN,// 4
+ WPNTYPE_STAFF,// 5
+ WPNTYPE_WHIP,// 6
+ WPNTYPE_BOOMERANG,// 7
+ WPNTYPE_BOW,// 8
+ WPNTYPE_SICKLE,// 9
+ WPNTYPE_CROSSBOW,// 10
+ WPNTYPE_MACE,// 11
+ WPNTYPE_AXE,// 12
+ WPNTYPE_THROWN// 13
+};
+
+/**
* Defines a class for storing item infos. This includes information used when
* the item is equipped.
*/
@@ -47,7 +88,7 @@ class ItemInfo
* Constructor.
*/
ItemInfo():
- mType(0),
+ mType(ITEM_UNUSABLE),
mWeight(0),
mView(0),
mAttackType(ACTION_DEFAULT)