summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/ea/generalhandler.cpp21
-rw-r--r--src/net/tmwserv/generalhandler.cpp19
-rw-r--r--src/resources/itemdb.cpp24
-rw-r--r--src/resources/itemdb.h8
4 files changed, 67 insertions, 5 deletions
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 7d5a7d40..25987b8e 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -46,12 +46,16 @@
#include "net/messagein.h"
#include "net/messageout.h"
+#include "resources/itemdb.h"
+
#include "configuration.h"
#include "log.h"
#include "main.h"
#include "utils/gettext.h"
+#include <list>
+
Net::GeneralHandler *generalHandler;
namespace EAthena {
@@ -80,6 +84,23 @@ GeneralHandler::GeneralHandler():
};
handledMessages = _messages;
generalHandler = this;
+
+ std::list<ItemDB::Stat*> stats;
+ ItemDB::Stat stat;
+ stat.tag = "str"; stat.tag = N_("Strength: %d");
+ stats.push_back(&stat);
+ stat.tag = "agi"; stat.tag = N_("Agility: %d");
+ stats.push_back(&stat);
+ stat.tag = "vit"; stat.tag = N_("Vitality: %d");
+ stats.push_back(&stat);
+ stat.tag = "int"; stat.tag = N_("Intelligence: %d");
+ stats.push_back(&stat);
+ stat.tag = "dex"; stat.tag = N_("Dexterity: %d");
+ stats.push_back(&stat);
+ stat.tag = "luck"; stat.tag = N_("Luck: %d");
+ stats.push_back(&stat);
+
+ ItemDB::setStatsList(stats);
}
GeneralHandler::~GeneralHandler()
diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp
index 98c764c5..be05fa91 100644
--- a/src/net/tmwserv/generalhandler.cpp
+++ b/src/net/tmwserv/generalhandler.cpp
@@ -40,6 +40,8 @@
#include "net/tmwserv/playerhandler.h"
#include "net/tmwserv/tradehandler.h"
+#include <list>
+
Net::GeneralHandler *generalHandler;
Net::Connection *gameServerConnection = 0;
@@ -70,6 +72,23 @@ GeneralHandler::GeneralHandler():
chatServerConnection = Net::getConnection();
generalHandler = this;
+
+ std::list<ItemDB::Stat*> stats;
+ ItemDB::Stat stat;
+ stat.tag = "str"; stat.tag = N_("Strength: %d");
+ stats.push_back(&stat);
+ stat.tag = "agi"; stat.tag = N_("Agility: %d");
+ stats.push_back(&stat);
+ stat.tag = "dex"; stat.tag = N_("Dexterity: %d");
+ stats.push_back(&stat);
+ stat.tag = "vit"; stat.tag = N_("Vitality: %d");
+ stats.push_back(&stat);
+ stat.tag = "int"; stat.tag = N_("Intelligence: %d");
+ stats.push_back(&stat);
+ stat.tag = "will"; stat.tag = N_("Willpower: %d");
+ stats.push_back(&stat);
+
+ ItemDB::setStatsList(stats);
}
void GeneralHandler::load()
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 036bdea8..36be4d0c 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -56,6 +56,13 @@ static char const *const fields[][2] =
{ "mp", N_("MP %+d") }
};
+static std::list<ItemDB::Stat*> extraStats;
+
+void ItemDB::setStatsList(std::list<ItemDB::Stat*> stats)
+{
+ extraStats = stats;
+}
+
static ItemType itemTypeFromString(const std::string &name, int id = 0)
{
if (name=="generic") return ITEM_UNUSABLE;
@@ -149,7 +156,6 @@ void ItemDB::load()
itemInfo->setWeaponType(weaponType);
itemInfo->setAttackRange(attackRange);
-#ifdef TMWSERV_SUPPORT
std::string effect;
for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i)
{
@@ -158,12 +164,20 @@ void ItemDB::load()
if (!effect.empty()) effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
-#else
- std::string effect = XML::getProperty(node, "effect", "");
-#endif
+ for (std::list<Stat*>::iterator it = extraStats.begin();
+ it != extraStats.end(); it++)
+ {
+ int value = XML::getProperty(node, (*it)->tag.c_str(), 0);
+ if (!value) continue;
+ if (!effect.empty()) effect += " / ";
+ effect += strprintf((*it)->format.c_str(), value);
+ }
+ std::string temp = XML::getProperty(node, "effect", "");
+ if (!effect.empty() && !temp.empty())
+ effect += " / ";
+ effect += temp;
itemInfo->setEffect(effect);
-
for_each_xml_child_node(itemChild, node)
{
if (xmlStrEqual(itemChild->name, BAD_CAST "sprite"))
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index aa5edab5..2a76eecd 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -22,6 +22,7 @@
#ifndef ITEM_MANAGER_H
#define ITEM_MANAGER_H
+#include <list>
#include <map>
#include <string>
@@ -45,6 +46,13 @@ namespace ItemDB
const ItemInfo &get(int id);
const ItemInfo &get(const std::string &name);
+ struct Stat {
+ std::string tag;
+ std::string format;
+ };
+
+ void setStatsList(std::list<Stat*> stats);
+
// Items database
typedef std::map<int, ItemInfo*> ItemInfos;
typedef std::map<std::string, ItemInfo*> NamedItemInfos;