summaryrefslogtreecommitdiff
path: root/src/game-server/monstermanager.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-08-05 23:02:40 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-08-06 09:27:29 +0200
commitaf59c9d650bc254683618e7b334795e5a75886b2 (patch)
tree36c57e41181b591b313467c244f4361e628e288e /src/game-server/monstermanager.cpp
parent5adb7120b01556c90750bd9db43fe56699c0078f (diff)
downloadmanaserv-af59c9d650bc254683618e7b334795e5a75886b2.tar.gz
manaserv-af59c9d650bc254683618e7b334795e5a75886b2.tar.bz2
manaserv-af59c9d650bc254683618e7b334795e5a75886b2.tar.xz
manaserv-af59c9d650bc254683618e7b334795e5a75886b2.zip
Allow monster name in <drop> tag
Reviewed-by: Stefan Beller.
Diffstat (limited to 'src/game-server/monstermanager.cpp')
-rw-r--r--src/game-server/monstermanager.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp
index 7612ddc1..2e772a38 100644
--- a/src/game-server/monstermanager.cpp
+++ b/src/game-server/monstermanager.cpp
@@ -120,12 +120,26 @@ void MonsterManager::initialize()
if (xmlStrEqual(subnode->name, BAD_CAST "drop"))
{
MonsterDrop drop;
- drop.item = itemManager->getItem(
- XML::getProperty(subnode, "item", 0));
+ std::string item = XML::getProperty(subnode, "item",
+ std::string());
+ ItemClass *itemClass;
+ if (utils::isNumeric(item))
+ itemClass = itemManager->getItem(utils::stringToInt(item));
+ else
+ itemClass = itemManager->getItemByName(item);
+
+ if (!itemClass)
+ {
+ LOG_WARN("Monster Manager: Invalid item name \"" << item
+ << "\"");
+ break;
+ }
+
+ drop.item = itemClass;
drop.probability = XML::getFloatProperty(subnode, "percent",
0.0) * 100 + 0.5;
- if (drop.item && drop.probability)
+ if (drop.probability)
drops.push_back(drop);
}
else if (xmlStrEqual(subnode->name, BAD_CAST "attributes"))