summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-18 19:00:38 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-18 19:00:38 +0000
commit54ac35bc5a1484757efeae9b342469b9a00fe2a2 (patch)
tree73917e6a43f0a90a9f25aaaad24c214c37bf52c4 /src/resources
parent03b2efa5973db10c3e6366aa0bd2990eee60d8b9 (diff)
downloadmana-client-54ac35bc5a1484757efeae9b342469b9a00fe2a2.tar.gz
mana-client-54ac35bc5a1484757efeae9b342469b9a00fe2a2.tar.bz2
mana-client-54ac35bc5a1484757efeae9b342469b9a00fe2a2.tar.xz
mana-client-54ac35bc5a1484757efeae9b342469b9a00fe2a2.zip
Removed player looks from generic beings. Prevented client termination on missing sprites. Merged weapon-type and attack-type fields for items.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/itemdb.cpp4
-rw-r--r--src/resources/iteminfo.cpp45
-rw-r--r--src/resources/iteminfo.h2
-rw-r--r--src/resources/resourcemanager.cpp7
-rw-r--r--src/resources/spritedef.cpp4
5 files changed, 33 insertions, 29 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 157e522c..4e978093 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -107,7 +107,7 @@ void ItemDB::load()
std::string image = XML::getProperty(node, "image", "");
std::string description = XML::getProperty(node, "description", "");
std::string effect = XML::getProperty(node, "effect", "");
- std::string attackType = XML::getProperty(node, "attacktype", "");
+ int weaponType = XML::getProperty(node, "weapon_type", 0);
if (id)
{
@@ -120,7 +120,7 @@ void ItemDB::load()
itemInfo->setView(view);
itemInfo->setWeight(weight);
itemInfo->setSlot(slot);
- itemInfo->setAttackType(attackType);
+ itemInfo->setWeaponType(weaponType);
for_each_xml_child_node(itemChild, node)
{
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index b5b25ac0..6654ccca 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -71,32 +71,29 @@ ItemInfo::getSprite(int gender) const
}
}
-void
-ItemInfo::setAttackType(const std::string &attackType)
+void ItemInfo::setWeaponType(int type)
{
- if (attackType == "swing")
- {
- mAttackType = ACTION_ATTACK_SWING;
- }
- else if (attackType == "stab")
- {
- mAttackType = ACTION_ATTACK_STAB;
- }
- else if (attackType == "bow")
- {
- mAttackType = ACTION_ATTACK_BOW;
- }
- else if (attackType == "throw")
- {
- mAttackType = ACTION_ATTACK_THROW;
- }
- else if (attackType == "none")
- {
- mAttackType = ACTION_DEFAULT;
- }
- else
+ // See server item.hpp file for type values.
+ switch (type)
{
- mAttackType = ACTION_ATTACK;
+ case 0: // none
+ mAttackType = ACTION_DEFAULT;
+ break;
+ case 1: // knife
+ case 2: // sword
+ mAttackType = ACTION_ATTACK_STAB;
+ break;
+ case 8: // projectile
+ mAttackType = ACTION_ATTACK_THROW;
+ break;
+ case 10: // bow
+ mAttackType = ACTION_ATTACK_BOW;
+ break;
+ case 11: // sickle
+ mAttackType = ACTION_ATTACK_SWING;
+ break;
+ default:
+ mAttackType = ACTION_ATTACK;
}
}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 4fd1638e..4cab66fa 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -113,7 +113,7 @@ class ItemInfo
const std::string& getSprite(int gender) const;
- void setAttackType(const std::string &attackType);
+ void setWeaponType(int);
const SpriteAction getAttackType() const
{ return mAttackType; }
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 448e7f80..5e3f3bc7 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -275,6 +275,13 @@ ResourceManager::getSprite(const std::string &path, int variant)
return dynamic_cast<SpriteDef*>(resIter->second);
}
+ // FIXME: modify SpriteDef so that it gracefully fails on missing sprite.
+ if (!exists(path) || isDirectory(path))
+ {
+ logger->log("Failed to load file: %s", path.c_str());
+ return NULL;
+ }
+
SpriteDef *sprite = new SpriteDef(idPath, path, variant);
sprite->incRef();
mResources[idPath] = sprite;
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 24156be1..d90d4067 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -73,13 +73,13 @@ SpriteDef::load(const std::string &animationFile, int variant)
if (!doc) {
logger->error(
- "Animation: Error while parsing animation definition file!");
+ "Animation: Error while parsing " + animationFile + " file!");
}
xmlNodePtr rootNode = xmlDocGetRootElement(doc);
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) {
logger->error(
- "Animation: this is not a valid animation definition file!");
+ "Animation: this is not a valid " + animationFile + " file!");
}
// Get the variant