summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-04-16 21:15:38 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-04-16 21:15:38 +0200
commit3fb7414240a4dd48e39f840dc766e2bb29fad41d (patch)
treec7bed086d1c8821d843ae0867dd47b71c74447c3 /src/resources
parentdac1c9d9b9558053ab9fc96eac8772604b8eedf2 (diff)
parent19469fdabf9f66348da8e10a7187f634d0c0a7b7 (diff)
downloadmana-3fb7414240a4dd48e39f840dc766e2bb29fad41d.tar.gz
mana-3fb7414240a4dd48e39f840dc766e2bb29fad41d.tar.bz2
mana-3fb7414240a4dd48e39f840dc766e2bb29fad41d.tar.xz
mana-3fb7414240a4dd48e39f840dc766e2bb29fad41d.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/itemdb.cpp24
-rw-r--r--src/resources/itemdb.h8
2 files changed, 27 insertions, 5 deletions
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;