From d5fa4f03b3f09efd0551b0dfd8bc2dc7de4d4acc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 25 Sep 2014 16:34:34 +0300 Subject: Remove duplicate code from monsterdb, homunculusdb, mercenarydb. --- src/resources/db/monsterdb.cpp | 110 +---------------------------------------- 1 file changed, 2 insertions(+), 108 deletions(-) (limited to 'src/resources/db/monsterdb.cpp') diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp index 7897d6198..1cbfe66c5 100644 --- a/src/resources/db/monsterdb.cpp +++ b/src/resources/db/monsterdb.cpp @@ -135,114 +135,8 @@ void MonsterDB::loadXmlFile(const std::string &fileName) // iterate s and s for_each_xml_child_node(spriteNode, monsterNode) { - if (xmlNameEqual(spriteNode, "sprite")) - { - if (!spriteNode->xmlChildrenNode) - continue; - - SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast( - spriteNode->xmlChildrenNode->content); - - currentSprite->variant = XML::getProperty( - spriteNode, "variant", 0); - display.sprites.push_back(currentSprite); - } - else if (xmlNameEqual(spriteNode, "sound")) - { - if (!spriteNode->xmlChildrenNode) - continue; - - const std::string event = XML::getProperty( - spriteNode, "event", ""); - const int delay = XML::getProperty( - spriteNode, "delay", 0); - const char *const filename = reinterpret_cast( - spriteNode->xmlChildrenNode->content); - - if (event == "hit") - { - currentInfo->addSound(ItemSoundEvent::HIT, - filename, delay); - } - else if (event == "miss") - { - currentInfo->addSound(ItemSoundEvent::MISS, - filename, delay); - } - else if (event == "hurt") - { - currentInfo->addSound(ItemSoundEvent::HURT, - filename, delay); - } - else if (event == "die") - { - currentInfo->addSound(ItemSoundEvent::DIE, - filename, delay); - } - else if (event == "move") - { - currentInfo->addSound(ItemSoundEvent::MOVE, - filename, delay); - } - else if (event == "sit") - { - currentInfo->addSound(ItemSoundEvent::SIT, - filename, delay); - } - else if (event == "sittop") - { - currentInfo->addSound(ItemSoundEvent::SITTOP, - filename, delay); - } - else if (event == "spawn") - { - currentInfo->addSound(ItemSoundEvent::SPAWN, - filename, delay); - } - else - { - logger->log("MonsterDB: Warning, sound effect %s for " - "unknown event %s of monster %s", - filename, event.c_str(), - currentInfo->getName().c_str()); - } - } - else if (xmlNameEqual(spriteNode, "attack")) - { - const int attackId = XML::getProperty(spriteNode, "id", 0); - const int effectId = XML::getProperty( - spriteNode, "effect-id", paths.getIntValue("effectId")); - const int hitEffectId = XML::getProperty(spriteNode, - "hit-effect-id", paths.getIntValue("hitEffectId")); - const int criticalHitEffectId = XML::getProperty(spriteNode, - "critical-hit-effect-id", - paths.getIntValue("criticalHitEffectId")); - const int missEffectId = XML::getProperty(spriteNode, - "miss-effect-id", paths.getIntValue("missEffectId")); - - const std::string spriteAction = XML::getProperty( - spriteNode, "action", "attack"); - const std::string skySpriteAction = XML::getProperty( - spriteNode, "skyaction", "skyattack"); - const std::string waterSpriteAction = XML::getProperty( - spriteNode, "wateraction", "waterattack"); - - const std::string missileParticle = XML::getProperty( - spriteNode, "missile-particle", ""); - - currentInfo->addAttack(attackId, spriteAction, skySpriteAction, - waterSpriteAction, effectId, hitEffectId, - criticalHitEffectId, missEffectId, missileParticle); - } - else if (xmlNameEqual(spriteNode, "particlefx")) - { - if (!spriteNode->xmlChildrenNode) - continue; - - display.particles.push_back(reinterpret_cast( - spriteNode->xmlChildrenNode->content)); - } + BeingCommon::readObjectNodes(spriteNode, display, + currentInfo, "MonsterDB"); } currentInfo->setDisplay(display); -- cgit v1.2.3-60-g2f50