diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2006-10-20 00:51:25 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2006-10-20 00:51:25 +0000 |
commit | 80f7db7a84fb73d8266d872f56af108ed49ba2eb (patch) | |
tree | 1629aa705ebdc1a5c38a2e2e6091bcec715fd346 | |
parent | f258986ba1184a0199e0bc241d68919a438eef29 (diff) | |
download | manaserv-80f7db7a84fb73d8266d872f56af108ed49ba2eb.tar.gz manaserv-80f7db7a84fb73d8266d872f56af108ed49ba2eb.tar.bz2 manaserv-80f7db7a84fb73d8266d872f56af108ed49ba2eb.tar.xz manaserv-80f7db7a84fb73d8266d872f56af108ed49ba2eb.zip |
Simplified item status effect implementation. Made it all work, and filled items.xml with about 100 items. To come: maxPerSlot and weaponType parameters.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | data/items.xml | 128 | ||||
-rw-r--r-- | data/items.xsd | 22 | ||||
-rw-r--r-- | src/item.h | 84 | ||||
-rw-r--r-- | src/itemmanager.cpp | 208 | ||||
-rw-r--r-- | src/main.cpp | 4 |
6 files changed, 278 insertions, 181 deletions
@@ -1,3 +1,16 @@ +2006-10-19 Yohann Ferreira <bertram@cegetel.net> + + * data/items.xsd, data/items.xml, src/item.h, src/itemmanager.cpp, + src/main.cpp: Simplified item reference a bit and filled the reference + items.xml file. + +2006-10-19 Yohann Ferreira <bertram@cegetel.net> + + * data/items.xsd, src/main.cpp, src/Makefile.am, src/item.h, + src/item.cpp, itemmanager.cpp, itemmanager.h, being.h, player.cpp, + dalstorage.cpp: Added a backend to get item reference information. + The xml file isn't ready yet. + 2006-10-03 Eugenio Favalli <elvenprogrammer@gmail.com> * src/itemhandler.h, tmwserv.cbp, tmwserv.dev: Updated project files diff --git a/data/items.xml b/data/items.xml new file mode 100644 index 00000000..a41e9bba --- /dev/null +++ b/data/items.xml @@ -0,0 +1,128 @@ +<?xml version="1.0"?> +<items> + <!-- Item Definition: id, type, weight, value, script_name --> + <!-- element, lifetime --> + <!-- Modifiers: --> + <!-- strength, agility, vitality, intelligence, dexterity, luck --> + <!-- heat, attack, defence, magic, accuracy, speed --> + <!-- hp, mp, range, status_effect --> + + <item id="501" name="Cactus drink" hp="15" type="1" weight="10" /> + <item id="502" name="Cactus potion" hp="25" mp="10" type="1" weight="10" /> + <item id="503" name="Casino coins" type="0" weight="10" /> + <item id="504" name="Decor candy" type="0" weight="10" /> + <item id="505" name="Maggot slime" type="0" weight="10" /> + <item id="506" name="Candy cane" hp="10" type="1" weight="10" /> + <item id="507" name="Scorpion stinger" type="0" weight="10" /> + <item id="508" name="Xmas cake" hp="10" type="1" weight="10" /> + <item id="509" name="Chocolate bar" hp="20" type="1" weight="10" /> + <item id="510" name="Candy" hp="5" type="1" weight="10" /> + <item id="511" name="Santa hat" defence="2" type="6" weight="10" /> + <item id="512" name="Ginger bread man" hp="25" type="1" weight="10" /> + <item id="513" name="Cake" hp="15" type="1" weight="10" /> + <item id="514" name="Xmas candy cane" hp="10" type="1" weight="10" /> + <item id="515" name="Purple present box" type="0" weight="10" /> + <item id="516" name="Blue present box" type="0" weight="10" /> + <item id="517" name="Red scorpion stinger" type="0" weight="10" /> + <item id="518" name="Bug leg" type="0" weight="10" /> + <item id="519" name="Cherry cake" hp="35" type="1" weight="10" /> + <item id="520" name="Easter egg" hp="100" type="1" weight="10" /> + <item id="521" name="Dagger" attack="15" range="1" type="2" weight="10" /> + <item id="522" name="Sharp knife" attack="10" range="1" type="2" weight="10" /> + <item id="523" name="Leather shirt" defence="4" type="4" weight="10" /> + <item id="524" name="Fancy hat" defence="5" type="6" weight="10" /> + <item id="525" name="Miners hat" defence="4" type="6" weight="10" /> + <item id="526" name="Coin bag" type="0" weight="10" /> + <item id="527" name="Milk" hp="150" type="1" weight="10" /> + <item id="528" name="Boots" defense="2" type="11" weight="10" /> + <item id="529" name="Iron arrow" attack="50" type="0" weight="10" /> + <item id="530" name="Short bow" attack="50" range="5" type="3" weight="10" /> + <item id="531" name="Miner gloves" defence="2" type="5" weight="10" /> + <item id="532" name="Leather gloves" defence="3" type="5" weight="10" /> + <item id="533" name="Roasted maggot" hp="150" type="1" weight="10" /> + <item id="534" name="Orange cupcake" hp="100" mp="10" type="1" weight="10" /> + <item id="535" name="Apple" hp="50" type="1" weight="10" /> + <item id="536" name="Short sword" attack="100" range="1" type="2" weight="10" /> + <item id="537" name="Treasure key" type="0" weight="10" script_name="treasureKey.rb" /> + <item id="538" name="Green present box" type="0" weight="10" /> + <item id="539" name="Beer" hp="200" type="1" weight="10" /> + <item id="540" name="Empty bottle" type="0" weight="10" slot="0"/> + <item id="541" name="Bottle of water" hp="250" type="1" weight="10" /> + <item id="542" name="Bottle of sand" type="0" weight="10" /> + <item id="543" name="Standard headband" defense="1" type="6" weight="10" /> + <item id="544" name="Silk headband" defense="3" type="6" weight="10" /> + <item id="545" name="Forest bow" attack="65" range="5" type="3" weight="10" /> + <item id="546" name="Desert shirt" defense="6" type="4" weight="10" /> + <item id="547" name="Bardiche" attack="100" type="3" weight="10" /> + <item id="548" name="Halberd" attack="100" type="3" weight="10" /> + <item id="549" name="Axe" attack="100" type="2" weight="10" /> + <item id="550" name="Blacksmith's axe" attack="100" type="2" weight="10" /> + <item id="551" name="Hint" type="0" weight="10" /> + <item id="552" name="Hint" type="0" weight="10" /> + <item id="553" name="Hint" type="0" weight="10" /> + <item id="554" name="Hint" type="0" weight="10" /> + <item id="555" name="Hint" type="0" weight="10" /> + <item id="556" name="Hint" type="0" weight="10" /> + <item id="557" name="Hint" type="0" weight="10" /> + <item id="558" name="Hint" type="0" weight="10" /> + <item id="559" name="Hint" type="0" weight="10" /> + <item id="560" name="Hint" type="0" weight="10" /> + <item id="561" name="Sabre" type="0" weight="10" /> + <item id="562" name="Chicken leg" type="0" weight="10" /> + <item id="563" name="Winter gloves" type="0" weight="10" /> + <item id="564" name="Wool sweater" type="0" weight="10" /> + <item id="565" name="Petal" type="0" weight="10" /> + <item id="566" name="Small mushroom" type="0" weight="10" /> + <item id="567" name="Iron potion" strength="5" lifetime="60" type="1" weight="10" /> + <item id="568" name="Concentration potion" accuracy="20" lifetime="60" type="1" weight="10" /> + <item id="569" name="Raw log" type="0" weight="10" /> + <item id="570" name="Bone knife" attack="50" type="2" weight="10" /> + <item id="571" name="Setzer" attack="50" type="2" weight="10" /> + <item id="572" name="Scimitar" attack="50" type="2" weight="10" /> + <item id="573" name="Falcion" attack="50" type="2" weight="10" /> + <item id="574" name="Scorpion" attack="50" type="2" weight="10" /> + <item id="575" name="Desert bow" attack="50" type="2" weight="10" /> + <item id="576" name="Beheader" attack="50" type="2" weight="10" /> + <item id="577" name="Bone darts" attack="50" type="2" weight="10" /> + <item id="578" name="Sand cutter" attack="50 " type="2" weight="10" /> + <item id="579" name="Rock knife" attack="300" type="2" weight="10" /> + <item id="580" name="Staff of life" attack="50" magic="10" type="2" weight="10" /> + <item id="581" name="Crescent rod" attack="50" type="2" weight="10" /> + <item id="582" name="Staff of fire" element="1" attack="50" type="2" weight="10" /> + <item id="583" name="Staff of ice" element="2" attack="50" type="2" weight="10" /> + <item id="584" name="Jackal" attack="50" type="2" weight="10" /> + <item id="585" name="Scarab Armlet" defence="50" type="5" weight="10" /> + <item id="586" name="Cotton shorts" defense="2" type="7" weight="10" /> + <item id="587" name="Sword" type="0" weight="10" /> + <item id="588" name="Bastard Sword" type="0" weight="10" /> + <item id="589" name="Broad Sword" type="0" weight="10" /> + <item id="588" name="Baselard" type="0" weight="10" /> + <item id="591" name="Long Sword" type="0" weight="10" /> + <item id="592" name="Stiletto" type="0" weight="10" /> + <item id="593" name="Rapier" type="0" weight="10" /> + <item id="594" name="Spear" type="0" weight="10" /> + <item id="595" name="Heavy Spear" type="0" weight="10" /> + <item id="596" name="Pike" type="0" weight="10" /> + <item id="597" name="Heavy Pike" type="0" weight="10" /> + <item id="598" name="Dual Spear" type="0" weight="10" /> + <item id="599" name="Fire Sword" element="1" type="0" weight="10" /> + <item id="600" name="Brit Shield" effect="Cooking: -50" type="0" weight="10" /> + <item id="601" name="Steel Shield" type="0" weight="10" /> + <item id="602" name="Wooden Shield" type="0" weight="10" /> + <item id="603" name="Leather Shield" type="0" weight="10" /> + <item id="604" name="Knight Shield" type="0" weight="10" /> + <item id="605" name="Meat Cleaver" type="0" weight="10" /> + <item id="606" name="Hatchet" type="0" weight="10" /> + <item id="607" name="Trident" type="0" weight="10" /> + <item id="608" name="A shield made of blades" type="0" weight="10" /> + <item id="609" name="Club" type="0" weight="10" /> + <item id="610" name="Jeans shorts" defence="4" type="7" weight="10" /> + <item id="611" name="White fur" type="0" weight="10" /> + <item id="612" name="Cave snake lamp" type="0" weight="10" /> + <item id="613" name="Hard spike" type="0" weight="10" /> + <item id="614" name="Pink antennae" type="0" weight="10" /> + <item id="1199" name="Arrow" attack="25" type="0" weight="10" /> + <item id="1200" name="Bow" attack="15" range="5" type="3" weight="10" /> + <item id="1201" name="Knife" attack="5" range="1" type="2" weight="10" /> + <item id="1202" name="Cotton shirt" defence="2" type="7" weight="10" /> +</items> diff --git a/data/items.xsd b/data/items.xsd index e0bf4ed2..020a9837 100644 --- a/data/items.xsd +++ b/data/items.xsd @@ -13,6 +13,7 @@ <xsd:extension base="xsd:positiveInteger"> <!-- General --> <xsd:attribute name="id" type="xsd:positiveInteger" /> + <xsd:attribute name="type" type="xsd:integer" /> <xsd:attribute name="weight" type="xsd:integer" /> <xsd:attribute name="value" type="xsd:integer" /> <xsd:attribute name="script_name" type="xsd:string" /> @@ -39,26 +40,7 @@ <!-- Equipment --> <xsd:attribute name="range" type="xsd:integer" /> <!-- Status Effects Addition --> - <xsd:attribute name="status_normal" type="xsd:boolean" /> - <xsd:attribute name="status_poisoned" type="xsd:boolean" /> - <xsd:attribute name="status_stoned" type="xsd:boolean" /> - <xsd:attribute name="status_stunned" type="xsd:boolean" /> - <xsd:attribute name="status_slowed" type="xsd:boolean" /> - <xsd:attribute name="status_tired" type="xsd:boolean" /> - <xsd:attribute name="status_mad" type="xsd:boolean" /> - <xsd:attribute name="status_berserk" type="xsd:boolean" /> - <xsd:attribute name="status_hasted" type="xsd:boolean" /> - <xsd:attribute name="status_floating" type="xsd:boolean" /> - <!-- Status Effects Deletion --> - <xsd:attribute name="status_not_poisoned" type="xsd:boolean" /> - <xsd:attribute name="status_not_stoned" type="xsd:boolean" /> - <xsd:attribute name="status_not_stunned" type="xsd:boolean" /> - <xsd:attribute name="status_not_slowed" type="xsd:boolean" /> - <xsd:attribute name="status_not_tired" type="xsd:boolean" /> - <xsd:attribute name="status_not_mad" type="xsd:boolean" /> - <xsd:attribute name="status_not_berserk" type="xsd:boolean" /> - <xsd:attribute name="status_not_hasted" type="xsd:boolean" /> - <xsd:attribute name="status_not_floating" type="xsd:boolean" /> + <xsd:attribute name="status_effect" type="xsd:integer" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType> @@ -30,48 +30,47 @@ * Enumeration of available Item types. */ typedef enum { - ITEM_USABLE = 1, - ITEM_EQUIPMENT_ONE_HAND_WEAPON, - ITEM_EQUIPMENT_TWO_HANDS_WEAPON, - ITEM_EQUIPMENT_ONE_HAND_RANGED_WEAPON, - ITEM_EQUIPMENT_TWO_HANDS_RANGED_WEAPON, - ITEM_EQUIPMENT_BREST, - ITEM_EQUIPMENT_ARMS, - ITEM_EQUIPMENT_HEAD, - ITEM_EQUIPMENT_LEGS, - ITEM_EQUIPMENT_SHIELD, - ITEM_EQUIPMENT_RING, - ITEM_EQUIPMENT_NECKLACE + ITEM_UNUSABLE = 0, + ITEM_USABLE, // 1 + ITEM_EQUIPMENT_ONE_HAND_WEAPON, // 2 + ITEM_EQUIPMENT_TWO_HANDS_WEAPON, // 3 + ITEM_EQUIPMENT_BREST, // 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 } ItemType; /** * States attribute effects to beings, and actors. * States can be multiple for the same being. */ -struct BeingStateEffects { - bool STATE_NORMAL; - bool STATE_POISONED; - bool STATE_STONED; - bool STATE_STUNNED; - bool STATE_SLOWED; - bool STATE_TIRED; - bool STATE_MAD; - bool STATE_BERSERK; - bool STATE_HASTED; - bool STATE_FLOATING; - - bool STATE_NOT_POISONED; - bool STATE_NOT_STONED; - bool STATE_NOT_STUNNED; - bool STATE_NOT_SLOWED; - bool STATE_NOT_TIRED; - bool STATE_NOT_MAD; - bool STATE_NOT_BERSERK; - bool STATE_NOT_HASTED; - bool STATE_NOT_FLOATING; +typedef enum BeingStateEffect { + STATE_NORMAL = 0, + STATE_POISONED, + STATE_STONED, + STATE_STUNNED, + STATE_SLOWED, + STATE_TIRED, + STATE_MAD, + STATE_BERSERK, + STATE_HASTED, + STATE_FLOATING, + + STATE_NOT_POISONED, + STATE_NOT_STONED, + STATE_NOT_STUNNED, + STATE_NOT_SLOWED, + STATE_NOT_TIRED, + STATE_NOT_MAD, + STATE_NOT_BERSERK, + STATE_NOT_HASTED, + STATE_NOT_FLOATING }; - /** * statistics modifiers. * once for usables. @@ -80,20 +79,19 @@ struct BeingStateEffects { struct Modifiers { // General - Element element; /** Item Element */ - BeingStateEffects beingStateEffects; /** Being State (dis)alteration */ - unsigned short lifetime; /** Modifiers lifetime in seconds. */ + Element element; /**< Item Element */ + BeingStateEffect beingStateEffect; /**< Being State (dis)alteration */ + unsigned short lifetime; /**< Modifiers lifetime in seconds. */ // Caracteristics Modifiers - short rawStats[NB_RSTAT]; - short computedStats[NB_CSTAT]; + short rawStats[NB_RSTAT]; /**< Raw Stats modifiers */ + short computedStats[NB_CSTAT]; /**< Computed Stats modifiers */ - int hpMod; /**< HP modifier */ - int mpMod; /**< MP Modifier */ + int hp; /**< HP modifier */ + int mp; /**< MP Modifier */ // Equipment - unsigned short range; /** Weapon Item Range */ - /**< More to come */ + unsigned short range; /**< Weapon Item Range */ }; diff --git a/src/itemmanager.cpp b/src/itemmanager.cpp index 2b480397..d30fd276 100644 --- a/src/itemmanager.cpp +++ b/src/itemmanager.cpp @@ -34,7 +34,7 @@ xmlFree(prop); \ } -ItemManager::ItemManager(std::string itemReferenceFile) +ItemManager::ItemManager(const std::string &itemReferenceFile) { ResourceManager *resman = ResourceManager::getInstance(); int size; @@ -62,127 +62,105 @@ ItemManager::ItemManager(std::string itemReferenceFile) LOG_ERROR("Item Manager: " << itemReferenceFile << " is not a valid database file!", 0); } - - unsigned int nbItems = 0; - for (node = node->xmlChildrenNode; node != NULL; node = node->next) + else { - // Properties - unsigned int id = 0; - unsigned short itemType = 0; - unsigned int weight = 0; - unsigned int value = 0; - std::string scriptName = ""; - Modifiers modifiers; - - if (!xmlStrEqual(node->name, BAD_CAST "item")) { - continue; - } - - xmlChar *prop = NULL; - // Properties - READ_PROP(node, prop, "id", id, atoi); - READ_PROP(node, prop, "type", itemType, atoi); - READ_PROP(node, prop, "weight", weight, atoi); - READ_PROP(node, prop, "value", value, atoi); - READ_PROP(node, prop, "script_name", scriptName, ); - - // --- Modifiers - // General - READ_PROP(node, prop, "element", modifiers.element, (Element)atoi); - READ_PROP(node, prop, "lifetime", modifiers.lifetime, atoi); - // Raw Statistics - READ_PROP(node, prop, "strength", modifiers.rawStats[STAT_STRENGTH], atoi); - READ_PROP(node, prop, "agility", modifiers.rawStats[STAT_AGILITY], atoi); - READ_PROP(node, prop, "vitality", modifiers.rawStats[STAT_VITALITY], atoi); - READ_PROP(node, prop, "intelligence", modifiers.rawStats[STAT_INTELLIGENCE], atoi); - READ_PROP(node, prop, "dexterity", modifiers.rawStats[STAT_DEXTERITY], atoi); - READ_PROP(node, prop, "luck", modifiers.rawStats[STAT_LUCK], atoi); - // Computed Statistics - READ_PROP(node, prop, "heat", modifiers.computedStats[STAT_HEAT], atoi); - READ_PROP(node, prop, "attack", modifiers.computedStats[STAT_ATTACK], atoi); - READ_PROP(node, prop, "defence", modifiers.computedStats[STAT_DEFENCE], atoi); - READ_PROP(node, prop, "magic", modifiers.computedStats[STAT_MAGIC], atoi); - READ_PROP(node, prop, "accuracy", modifiers.computedStats[STAT_ACCURACY], atoi); - READ_PROP(node, prop, "speed", modifiers.computedStats[STAT_SPEED], atoi); - // Main Values - READ_PROP(node, prop, "hp", modifiers.hpMod, atoi); - READ_PROP(node, prop, "mp", modifiers.mpMod, atoi); - // Equipment - READ_PROP(node, prop, "range", modifiers.range, atoi); - // Status effects addition - READ_PROP(node, prop, "status_normal", - modifiers.beingStateEffects.STATE_NORMAL, (bool)atoi); - READ_PROP(node, prop, "status_poisoned", - modifiers.beingStateEffects.STATE_POISONED, (bool)atoi); - READ_PROP(node, prop, "status_stoned", - modifiers.beingStateEffects.STATE_STONED, (bool)atoi); - READ_PROP(node, prop, "status_stunned", - modifiers.beingStateEffects.STATE_STUNNED, (bool)atoi); - READ_PROP(node, prop, "status_slowed", - modifiers.beingStateEffects.STATE_SLOWED, (bool)atoi); - READ_PROP(node, prop, "status_tired", - modifiers.beingStateEffects.STATE_TIRED, (bool)atoi); - READ_PROP(node, prop, "status_mad", - modifiers.beingStateEffects.STATE_MAD, (bool)atoi); - READ_PROP(node, prop, "status_berserk", - modifiers.beingStateEffects.STATE_BERSERK, (bool)atoi); - READ_PROP(node, prop, "status_hasted", - modifiers.beingStateEffects.STATE_HASTED, (bool)atoi); - READ_PROP(node, prop, "status_floating", - modifiers.beingStateEffects.STATE_FLOATING, (bool)atoi); - // Status Effects deletion - READ_PROP(node, prop, "status_not_poisoned", - modifiers.beingStateEffects.STATE_NOT_POISONED, (bool)atoi); - READ_PROP(node, prop, "status_not_stoned", - modifiers.beingStateEffects.STATE_NOT_STONED, (bool)atoi); - READ_PROP(node, prop, "status_not_stunned", - modifiers.beingStateEffects.STATE_NOT_STUNNED, (bool)atoi); - READ_PROP(node, prop, "status_not_slowed", - modifiers.beingStateEffects.STATE_NOT_SLOWED, (bool)atoi); - READ_PROP(node, prop, "status_not_tired", - modifiers.beingStateEffects.STATE_NOT_TIRED, (bool)atoi); - READ_PROP(node, prop, "status_not_mad", - modifiers.beingStateEffects.STATE_NOT_MAD, (bool)atoi); - READ_PROP(node, prop, "status_not_berserk", - modifiers.beingStateEffects.STATE_NOT_BERSERK, (bool)atoi); - READ_PROP(node, prop, "status_not_hasted", - modifiers.beingStateEffects.STATE_NOT_HASTED, (bool)atoi); - READ_PROP(node, prop, "status_not_floating", - modifiers.beingStateEffects.STATE_NOT_FLOATING, (bool)atoi); - - // Checks - if (id != 0) - { - ItemPtr item(new Item(modifiers, itemType, weight, value, scriptName)); - mItemReference[id] = item; - nbItems++; - } - - if (id == 0) + LOG_INFO("Loading item reference...", 0); + unsigned int nbItems = 0; + for (node = node->xmlChildrenNode; node != NULL; node = node->next) { - LOG_WARN("Item Manager: An (ignored) item has no ID in " - << itemReferenceFile << "!", 0); - } - if (itemType == 0) - { - LOG_WARN("Item Manager: Missing Item Type for item: " - << id << " in " << itemReferenceFile << ".", 0); - } - if (weight == 0) - { - LOG_WARN("Item Manager: Missing weight for item: " - << id << " in " << itemReferenceFile << ".", 0); + // Properties + unsigned int id = 0; + unsigned short itemType = 0; + unsigned int weight = 0; + unsigned int value = 0; + std::string scriptName = ""; + Modifiers modifiers; + + if (!xmlStrEqual(node->name, BAD_CAST "item")) { + continue; + } + + xmlChar *prop = NULL; + // Properties + READ_PROP(node, prop, "id", id, atoi); + READ_PROP(node, prop, "type", itemType, atoi); + READ_PROP(node, prop, "weight", weight, atoi); + READ_PROP(node, prop, "value", value, atoi); + READ_PROP(node, prop, "script_name", scriptName, ); + + // --- Modifiers + // General + READ_PROP(node, prop, "element", modifiers.element, + (Element)atoi); + READ_PROP(node, prop, "lifetime", modifiers.lifetime, atoi); + // Raw Statistics + READ_PROP(node, prop, "strength", + modifiers.rawStats[STAT_STRENGTH], atoi); + READ_PROP(node, prop, "agility", + modifiers.rawStats[STAT_AGILITY], atoi); + READ_PROP(node, prop, "vitality", + modifiers.rawStats[STAT_VITALITY], atoi); + READ_PROP(node, prop, "intelligence", + modifiers.rawStats[STAT_INTELLIGENCE], atoi); + READ_PROP(node, prop, "dexterity", + modifiers.rawStats[STAT_DEXTERITY], atoi); + READ_PROP(node, prop, "luck", + modifiers.rawStats[STAT_LUCK], atoi); + // Computed Statistics + READ_PROP(node, prop, "heat", + modifiers.computedStats[STAT_HEAT], atoi); + READ_PROP(node, prop, "attack", + modifiers.computedStats[STAT_ATTACK], atoi); + READ_PROP(node, prop, "defence", + modifiers.computedStats[STAT_DEFENCE], atoi); + READ_PROP(node, prop, "magic", + modifiers.computedStats[STAT_MAGIC], atoi); + READ_PROP(node, prop, "accuracy", + modifiers.computedStats[STAT_ACCURACY], atoi); + READ_PROP(node, prop, "speed", + modifiers.computedStats[STAT_SPEED], atoi); + // Main Values + READ_PROP(node, prop, "hp", modifiers.hp, atoi); + READ_PROP(node, prop, "mp", modifiers.mp, atoi); + // Equipment + READ_PROP(node, prop, "range", modifiers.range, atoi); + // Status effect + READ_PROP(node, prop, "status_effect", + modifiers.beingStateEffect, (BeingStateEffect)atoi); + + // Checks + if (id != 0) + { + ItemPtr item(new Item(modifiers, itemType, weight, + value, scriptName)); + mItemReference[id] = item; + nbItems++; + } + + if (id == 0) + { + LOG_WARN("Item Manager: An (ignored) item has no ID in " + << itemReferenceFile << "!", 0); + } + if (weight == 0) + { + LOG_WARN("Item Manager: Missing weight for item: " + << id << " in " << itemReferenceFile << ".", 0); + } + + LOG_INFO("Item: ID: " << id << ", itemType: " << itemType + << ", weight: " << weight << ", value: " << value << + ", scriptName: " << scriptName << ".", 3); + //TODO: Log level 5 with everything } - LOG_INFO("Item: ID: " << id << ", itemType: " << itemType - << ", weight: " << weight << ", value: " << value << - ", scriptName: " << scriptName << ".", 3); - //TODO: Log level 5 with everything - } + LOG_INFO("Loaded " << nbItems << " items from " + << itemReferenceFile << ".", 0); - LOG_INFO("Loaded " << nbItems << " items from " << itemReferenceFile << ".", 0); + } // End if node "items" xmlFreeDoc(doc); + } // End if doc? } // End if data? } diff --git a/src/main.cpp b/src/main.cpp index 9516efbd..08475d4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,8 +76,6 @@ std::string scriptLanugage = "none"; #define DEFAULT_LOG_FILE "tmwserv.log" #define DEFAULT_CONFIG_FILE "tmwserv.xml" #define DEFAULT_ITEMSDB_FILE "items.xml" -#define DEFAULT_MAP_FOLDER "maps" -#define DEFAULT_DATA_FOLDER "data" #ifndef DEFAULT_SERVER_PORT #define DEFAULT_SERVER_PORT 9601 // Meaning Account Handler Port is 9601 @@ -177,7 +175,7 @@ void initialize() // Initialize the Chat channels manager chatChannelManager = new ChatChannelManager(); // Initialize the Item Manager - itemManager = new ItemManager(DEFAULT_DATA_FOLDER"/"DEFAULT_ITEMSDB_FILE); + itemManager = new ItemManager(DEFAULT_ITEMSDB_FILE); // --- Initialize the global handlers // FIXME: Make the global handlers global vars or part of a bigger |