summaryrefslogtreecommitdiff
path: root/src/resources/itemdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r--src/resources/itemdb.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 5dfcfb87..7304f8a7 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -1,30 +1,29 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * 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.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * 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 The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cassert>
+
#include <libxml/tree.h>
#include "itemdb.h"
-
-#include "iteminfo.h"
#include "resourcemanager.h"
#include "../log.h"
@@ -32,6 +31,7 @@
#include "../utils/dtor.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
+#include "../utils/stringutils.h"
#include "../utils/xml.h"
namespace
@@ -95,13 +95,13 @@ void ItemDB::load()
logger->log("Initializing item database...");
- mUnknown = new ItemInfo();
- mUnknown->setName("Unknown item");
+ mUnknown = new ItemInfo;
+ mUnknown->setName(_("Unknown item"));
mUnknown->setImageName("");
mUnknown->setSprite("error.xml", GENDER_MALE);
mUnknown->setSprite("error.xml", GENDER_FEMALE);
- XML::Document doc("items.xml");
+ XML::Document doc(_("items.xml"));
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items"))
@@ -126,27 +126,37 @@ void ItemDB::load()
logger->log("ItemDB: Redefinition of item ID %d", id);
}
- int type = itemTypeFromString(XML::getProperty(node, "type", ""));
+ std::string typeStr = XML::getProperty(node, "type", "other");
int weight = XML::getProperty(node, "weight", 0);
int view = XML::getProperty(node, "view", 0);
std::string name = XML::getProperty(node, "name", "");
std::string image = XML::getProperty(node, "image", "");
std::string description = XML::getProperty(node, "description", "");
+#ifdef TMWSERV_SUPPORT
int weaponType = weaponTypeFromString(XML::getProperty(node, "weapon-type", ""));
+#else
+ int weaponType = XML::getProperty(node, "weapon_type", 0);
+#endif
int attackRange = XML::getProperty(node, "attack-range", 0);
ItemInfo *itemInfo = new ItemInfo;
itemInfo->setId(id);
itemInfo->setImageName(image);
- itemInfo->setName(name.empty() ? "Unnamed" : name);
+ itemInfo->setName(name.empty() ? _("Unnamed") : name);
itemInfo->setDescription(description);
+#ifdef TMWSERV_SUPPORT
+ int type = itemTypeFromString(typeStr);
itemInfo->setType(type);
+#else
+ itemInfo->setType(typeStr);
+#endif
itemInfo->setView(view);
itemInfo->setWeight(weight);
itemInfo->setWeaponType(weaponType);
itemInfo->setAttackRange(attackRange);
+#ifdef TMWSERV_SUPPORT
std::string effect;
for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i)
{
@@ -155,6 +165,9 @@ void ItemDB::load()
if (!effect.empty()) effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
+#else
+ std::string effect = XML::getProperty(node, "effect", "");
+#endif
itemInfo->setEffect(effect);
@@ -176,7 +189,10 @@ void ItemDB::load()
NamedItemInfoIterator itr = mNamedItemInfos.find(name);
if (itr == mNamedItemInfos.end())
{
- mNamedItemInfos[name] = itemInfo;
+ std::string temp = name;
+ toLower(trim(temp));
+
+ mNamedItemInfos[temp] = itemInfo;
}
else
{
@@ -191,7 +207,7 @@ void ItemDB::load()
CHECK_PARAM(name, "");
CHECK_PARAM(image, "");
CHECK_PARAM(description, "");
- CHECK_PARAM(effect, "");
+ // CHECK_PARAM(effect, "");
// CHECK_PARAM(type, 0);
// CHECK_PARAM(weight, 0);
// CHECK_PARAM(slot, 0);
@@ -216,7 +232,7 @@ void ItemDB::unload()
const ItemInfo& ItemDB::get(int id)
{
- assert(mLoaded && id);
+ assert(mLoaded);
ItemInfoIterator i = mItemInfos.find(id);
@@ -257,7 +273,6 @@ void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node)
{
itemInfo->setSprite(filename, GENDER_MALE);
}
-
if (gender == "female" || gender == "unisex")
{
itemInfo->setSprite(filename, GENDER_FEMALE);