diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-16 17:20:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-16 22:33:53 +0300 |
commit | ade168344165534061b8f184866e2808af7f5d48 (patch) | |
tree | 7316b20df44434085b4649453f07ce9702261c98 | |
parent | 08f2ee6470104c959f686504cc4324aee78cecaf (diff) | |
download | manaverse-ade168344165534061b8f184866e2808af7f5d48.tar.gz manaverse-ade168344165534061b8f184866e2808af7f5d48.tar.bz2 manaverse-ade168344165534061b8f184866e2808af7f5d48.tar.xz manaverse-ade168344165534061b8f184866e2808af7f5d48.zip |
Simplify skills loading.
Also putting in defines legacy manaserv code.
-rw-r--r-- | src/gui/skilldialog.cpp | 23 | ||||
-rw-r--r-- | src/gui/skilldialog.h | 4 | ||||
-rw-r--r-- | src/net/eathena/generalhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/generalhandler.cpp | 2 |
4 files changed, 20 insertions, 11 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 9f484de8d..97e2fbdf1 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -264,7 +264,7 @@ SkillDialog::SkillDialog() : SkillDialog::~SkillDialog() { // Clear gui - loadSkills(""); + clearSkills(); } void SkillDialog::action(const gcn::ActionEvent &event) @@ -358,18 +358,20 @@ void SkillDialog::update() } } -void SkillDialog::loadSkills(const std::string &file) +void SkillDialog::clearSkills() { mTabs->removeAll(); - delete_all(mSkills); mSkills.clear(); +} - if (file.length() == 0) - return; +void SkillDialog::loadSkills() +{ + clearSkills(); - XML::Document doc(file); - const XmlNodePtr root = doc.rootNode(); + XML::Document doc("ea-skills.xml"); + XML::Document doc2("skills.xml"); + XmlNodePtr root = doc.rootNode(); int setCount = 0; std::string setName; @@ -378,10 +380,15 @@ void SkillDialog::loadSkills(const std::string &file) SkillTab *tab; if (!root || !xmlNameEqual(root, "skills")) + root = doc2.rootNode(); + + if (!root || !xmlNameEqual(root, "skills")) { - logger->log("Error loading skills file: %s", file.c_str()); + logger->log("Error loading skills"); +#ifdef MANASERV_SUPPORT if (Net::getNetworkType() != ServerInfo::MANASERV) +#endif { SkillModel *const model = new SkillModel(); if (!mDefaultModel) diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 9e956703a..945ae318d 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -108,7 +108,9 @@ class SkillDialog final : public Window, public gcn::ActionListener */ void update(); - void loadSkills(const std::string &file); + void clearSkills(); + + void loadSkills(); bool updateSkill(const int id, const int range, const bool modifiable); diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index b95991f55..91f567548 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -247,7 +247,7 @@ void GeneralHandler::processEvent(Channels channel, if (inventoryWindow) inventoryWindow->setSplitAllowed(false); if (skillDialog) - skillDialog->loadSkills("ea-skills.xml"); + skillDialog->loadSkills(); if (!statusWindow) return; diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index b26a14daf..39e37f62e 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -256,7 +256,7 @@ void GeneralHandler::processEvent(Channels channel, if (inventoryWindow) inventoryWindow->setSplitAllowed(false); if (skillDialog) - skillDialog->loadSkills("ea-skills.xml"); + skillDialog->loadSkills(); if (!statusWindow) return; |