summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mana.cbp2
-rw-r--r--mana.files2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/statuswindow.cpp3
-rw-r--r--src/gui/statuswindow.h3
-rw-r--r--src/net/manaserv/generalhandler.cpp27
-rw-r--r--src/net/manaserv/stats.cpp202
-rw-r--r--src/net/manaserv/stats.h36
-rw-r--r--src/net/tmwa/generalhandler.cpp40
10 files changed, 280 insertions, 39 deletions
diff --git a/mana.cbp b/mana.cbp
index 3d3b85e0..cc12f237 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -469,6 +469,8 @@
<Unit filename="src\net\manaserv\protocol.h" />
<Unit filename="src\net\manaserv\specialhandler.cpp" />
<Unit filename="src\net\manaserv\specialhandler.h" />
+ <Unit filename="src\net\manaserv\stats.cpp" />
+ <Unit filename="src\net\manaserv\stats.h" />
<Unit filename="src\net\manaserv\tradehandler.cpp" />
<Unit filename="src\net\manaserv\tradehandler.h" />
<Unit filename="src\net\messagehandler.h" />
diff --git a/mana.files b/mana.files
index 552ab8a6..1a6026f3 100644
--- a/mana.files
+++ b/mana.files
@@ -407,6 +407,8 @@
./src/net/manaserv/protocol.h
./src/net/manaserv/specialhandler.cpp
./src/net/manaserv/specialhandler.h
+./src/net/manaserv/stats.cpp
+./src/net/manaserv/stats.h
./src/net/manaserv/tradehandler.cpp
./src/net/manaserv/tradehandler.h
./src/net/messagehandler.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 02a08bfe..8172311e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -599,6 +599,8 @@ SET(SRCS_MANA
net/manaserv/protocol.h
net/manaserv/specialhandler.cpp
net/manaserv/specialhandler.h
+ net/manaserv/stats.cpp
+ net/manaserv/stats.h
net/manaserv/tradehandler.cpp
net/manaserv/tradehandler.h
)
diff --git a/src/Makefile.am b/src/Makefile.am
index 9748dd67..d12a9a56 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -451,6 +451,8 @@ mana_SOURCES += \
net/manaserv/protocol.h \
net/manaserv/specialhandler.cpp \
net/manaserv/specialhandler.h \
+ net/manaserv/stats.cpp \
+ net/manaserv/stats.h \
net/manaserv/tradehandler.cpp \
net/manaserv/tradehandler.h
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 498a4523..2439a213 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -283,7 +283,8 @@ void StatusWindow::setPointsNeeded(int id, int needed)
}
void StatusWindow::addAttribute(int id, const std::string &name,
- bool modifiable)
+ bool modifiable,
+ const std::string &description)
{
AttrDisplay *disp;
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 13ee9a68..a1fc4b4b 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -61,7 +61,8 @@ class StatusWindow : public Window
void setPointsNeeded(int id, int needed);
- void addAttribute(int id, const std::string &name, bool modifiable);
+ void addAttribute(int id, const std::string &name, bool modifiable,
+ const std::string &description);
static void updateHPBar(ProgressBar *bar, bool showMax = false);
static void updateMPBar(ProgressBar *bar, bool showMax = false);
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 454052f7..09f68c1e 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -29,7 +29,6 @@
#include "gui/register.h"
#include "gui/skilldialog.h"
#include "gui/specialswindow.h"
-#include "gui/statuswindow.h"
#include "net/manaserv/beinghandler.h"
#include "net/manaserv/buysellhandler.h"
@@ -47,6 +46,7 @@
#include "net/manaserv/partyhandler.h"
#include "net/manaserv/playerhandler.h"
#include "net/manaserv/specialhandler.h"
+#include "net/manaserv/stats.h"
#include "net/manaserv/tradehandler.h"
#include "utils/gettext.h"
@@ -90,16 +90,6 @@ GeneralHandler::GeneralHandler():
chatServerConnection = getConnection();
generalHandler = this;
-
- std::list<ItemDB::Stat> stats;
- stats.push_back(ItemDB::Stat("str", N_("Strength %+d")));
- stats.push_back(ItemDB::Stat("agi", N_("Agility %+d")));
- stats.push_back(ItemDB::Stat("dex", N_("Dexterity %+d")));
- stats.push_back(ItemDB::Stat("vit", N_("Vitality %+d")));
- stats.push_back(ItemDB::Stat("int", N_("Intelligence %+d")));
- stats.push_back(ItemDB::Stat("will", N_("Willpower %+d")));
-
- ItemDB::setStatsList(stats);
}
void GeneralHandler::load()
@@ -118,6 +108,9 @@ void GeneralHandler::load()
registerHandler(mPartyHandler.get());
registerHandler(mPlayerHandler.get());
registerHandler(mTradeHandler.get());
+
+ Stats::load();
+ Stats::informItemDB();
}
void GeneralHandler::reload()
@@ -136,6 +129,10 @@ void GeneralHandler::reload()
netToken.clear();
gameServer.clear();
chatServer.clear();
+
+ Stats::unload();
+ Stats::load();
+ Stats::informItemDB();
}
void GeneralHandler::unload()
@@ -153,6 +150,7 @@ void GeneralHandler::unload()
delete gameServerConnection;
delete chatServerConnection;
+ Stats::unload();
finalize();
}
@@ -176,12 +174,7 @@ void GeneralHandler::guiWindowsLoaded()
player_node->setExpNeeded(100);
- statusWindow->addAttribute(16, _("Strength"), true);
- statusWindow->addAttribute(17, _("Agility"), true);
- statusWindow->addAttribute(18, _("Dexterity"), true);
- statusWindow->addAttribute(19, _("Vitality"), true);
- statusWindow->addAttribute(20, _("Intelligence"), true);
- statusWindow->addAttribute(21, _("Willpower"), true);
+ Stats::informStatusWindow();
}
void GeneralHandler::guiWindowsUnloaded()
diff --git a/src/net/manaserv/stats.cpp b/src/net/manaserv/stats.cpp
new file mode 100644
index 00000000..b79b1fd9
--- /dev/null
+++ b/src/net/manaserv/stats.cpp
@@ -0,0 +1,202 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2010 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/manaserv/stats.h"
+
+#include "log.h"
+
+#include "gui/statuswindow.h"
+
+#include "resources/itemdb.h"
+
+#include "utils/gettext.h"
+#include "utils/xml.h"
+
+#include <list>
+#include <map>
+
+namespace ManaServ {
+namespace Stats {
+ typedef struct {
+ unsigned int id;
+ std::string name;
+ std::string tag;
+ std::string effect;
+ std::string description;
+ bool modifiable;
+ } Stat;
+
+ typedef std::map<unsigned int, Stat> StatMap;
+ StatMap stats;
+
+ static void loadBuiltins()
+ {
+ {
+ Stat s;
+ s.id = 16;
+ s.name = _("Strength");
+ s.tag = "str";
+ s.effect = _("Strength %+d");
+ s.description = "";
+ s.modifiable = true;
+
+ stats[s.id] = s;
+ }
+
+ {
+ Stat s;
+ s.id = 17;
+ s.name = _("Agility");
+ s.tag = "agi";
+ s.effect = _("Agility %+d");
+ s.description = "";
+ s.modifiable = true;
+
+ stats[s.id] = s;
+ }
+
+ {
+ Stat s;
+ s.id = 18;
+ s.name = _("Dexterity");
+ s.tag = "dex";
+ s.effect = _("Dexterity %+d");
+ s.description = "";
+ s.modifiable = true;
+
+ stats[s.id] = s;
+ }
+
+ {
+ Stat s;
+ s.id = 19;
+ s.name = _("Vitality");
+ s.tag = "vit";
+ s.effect = _("Vitality %+d");
+ s.description = "";
+ s.modifiable = true;
+
+ stats[s.id] = s;
+ }
+
+ {
+ Stat s;
+ s.id = 20;
+ s.name = _("Intelligence");
+ s.tag = "int";
+ s.effect = _("Intelligence %+d");
+ s.description = "";
+ s.modifiable = true;
+
+ stats[s.id] = s;
+ }
+
+ {
+ Stat s;
+ s.id = 21;
+ s.name = _("Willpower");
+ s.tag = "will";
+ s.effect = _("Willpower %+d");
+ s.description = "";
+ s.modifiable = true;
+
+ stats[s.id] = s;
+ }
+ }
+
+ void load()
+ {
+ XML::Document doc("stats.xml");
+ xmlNodePtr rootNode = doc.rootNode();
+
+ if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "stats"))
+ {
+ logger->log("Stats: Error while loading stats.xml!");
+ loadBuiltins();
+ return;
+ }
+
+ for_each_xml_child_node(node, rootNode)
+ {
+ if (!xmlStrEqual(node->name, BAD_CAST "stat"))
+ continue;
+
+ int id = XML::getProperty(node, "id", 0);
+
+ if (id == 0)
+ {
+ logger->log("Stats: Invalid or missing stat ID in stats.xml!");
+ continue;
+ }
+ else if (stats.find(id) != stats.end())
+ {
+ logger->log("Stats: Redefinition of stat ID %d", id);
+ }
+
+ std::string name = XML::getProperty(node, "name", "");
+
+ if (name.empty())
+ {
+ logger->log("Stats: Invalid or missing stat name in "
+ "stats.xml!");
+ continue;
+ }
+
+ Stat s;
+ s.id = id;
+ s.name = name;
+ s.tag = XML::getProperty(node, "tag", "");
+ s.effect = XML::getProperty(node, "effect", "");
+ s.description = XML::getProperty(node, "desc", "");
+ s.modifiable = XML::getProperty(node, "modifiable", "false")
+ == "true";
+
+ stats[id] = s;
+ }
+ }
+
+ void unload()
+ {
+ stats.clear();
+ }
+
+ void informItemDB()
+ {
+ std::list<ItemDB::Stat> dbStats;
+
+ StatMap::const_iterator it, it_end;
+ for (it = stats.begin(), it_end = stats.end(); it != it_end; it++)
+ if (!it->second.tag.empty())
+ dbStats.push_back(ItemDB::Stat(it->second.tag,
+ it->second.effect));
+
+ ItemDB::setStatsList(dbStats);
+ }
+
+ void informStatusWindow()
+ {
+ StatMap::const_iterator it, it_end;
+ for (it = stats.begin(), it_end = stats.end(); it != it_end; it++)
+ statusWindow->addAttribute(it->second.id, it->second.name,
+ it->second.modifiable,
+ it->second.description);
+ }
+} // namespace Stats
+} // namespace ManaServ
diff --git a/src/net/manaserv/stats.h b/src/net/manaserv/stats.h
new file mode 100644
index 00000000..c4afbd79
--- /dev/null
+++ b/src/net/manaserv/stats.h
@@ -0,0 +1,36 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2010 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_MANASERV_STATS_H
+#define NET_MANASERV_STATS_H
+
+namespace ManaServ {
+namespace Stats {
+ void load();
+
+ void unload();
+
+ void informItemDB();
+
+ void informStatusWindow();
+} // namespace Stats
+} // namespace ManaServ
+
+#endif // NET_MANASERV_STATS_H
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index a975abe8..14f48055 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -98,12 +98,12 @@ GeneralHandler::GeneralHandler():
generalHandler = this;
std::list<ItemDB::Stat> stats;
- stats.push_back(ItemDB::Stat("str", N_("Strength %+d")));
- stats.push_back(ItemDB::Stat("agi", N_("Agility %+d")));
- stats.push_back(ItemDB::Stat("vit", N_("Vitality %+d")));
- stats.push_back(ItemDB::Stat("int", N_("Intelligence %+d")));
- stats.push_back(ItemDB::Stat("dex", N_("Dexterity %+d")));
- stats.push_back(ItemDB::Stat("luck", N_("Luck %+d")));
+ stats.push_back(ItemDB::Stat("str", _("Strength %+d")));
+ stats.push_back(ItemDB::Stat("agi", _("Agility %+d")));
+ stats.push_back(ItemDB::Stat("vit", _("Vitality %+d")));
+ stats.push_back(ItemDB::Stat("int", _("Intelligence %+d")));
+ stats.push_back(ItemDB::Stat("dex", _("Dexterity %+d")));
+ stats.push_back(ItemDB::Stat("luck", _("Luck %+d")));
ItemDB::setStatsList(stats);
}
@@ -214,20 +214,20 @@ void GeneralHandler::guiWindowsLoaded()
inventoryWindow->setSplitAllowed(false);
skillDialog->loadSkills("ea-skills.xml");
- statusWindow->addAttribute(STR, _("Strength"), true);
- statusWindow->addAttribute(AGI, _("Agility"), true);
- statusWindow->addAttribute(VIT, _("Vitality"), true);
- statusWindow->addAttribute(INT, _("Intelligence"), true);
- statusWindow->addAttribute(DEX, _("Dexterity"), true);
- statusWindow->addAttribute(LUK, _("Luck"), true);
-
- statusWindow->addAttribute(ATK, _("Attack"), false);
- statusWindow->addAttribute(DEF, _("Defense"), false);
- statusWindow->addAttribute(MATK, _("M.Attack"), false);
- statusWindow->addAttribute(MDEF, _("M.Defense"), false);
- statusWindow->addAttribute(HIT, _("% Accuracy"), false);
- statusWindow->addAttribute(FLEE, _("% Evade"), false);
- statusWindow->addAttribute(CRIT, _("% Critical"), false);
+ statusWindow->addAttribute(STR, _("Strength"), true, "");
+ statusWindow->addAttribute(AGI, _("Agility"), true, "");
+ statusWindow->addAttribute(VIT, _("Vitality"), true, "");
+ statusWindow->addAttribute(INT, _("Intelligence"), true, "");
+ statusWindow->addAttribute(DEX, _("Dexterity"), true, "");
+ statusWindow->addAttribute(LUK, _("Luck"), true, "");
+
+ statusWindow->addAttribute(ATK, _("Attack"), false, "");
+ statusWindow->addAttribute(DEF, _("Defense"), false, "");
+ statusWindow->addAttribute(MATK, _("M.Attack"), false, "");
+ statusWindow->addAttribute(MDEF, _("M.Defense"), false, "");
+ statusWindow->addAttribute(HIT, _("% Accuracy"), false, "");
+ statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
+ statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
}
void GeneralHandler::guiWindowsUnloaded()