summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-10-10 22:14:45 +0300
committerAndrei Karas <akaras@inbox.ru>2017-10-10 22:15:57 +0300
commitaa3f63fd497558a02feb3ddbc44f31eac091f39b (patch)
tree0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/resources/db
parent7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff)
downloadplus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip
Remove most unused files.
Diffstat (limited to 'src/resources/db')
-rw-r--r--src/resources/db/avatardb.cpp146
-rw-r--r--src/resources/db/avatardb.h47
-rw-r--r--src/resources/db/badgesdb.cpp114
-rw-r--r--src/resources/db/badgesdb.h45
-rw-r--r--src/resources/db/chardb.cpp189
-rw-r--r--src/resources/db/chardb.h75
-rw-r--r--src/resources/db/colordb.cpp225
-rw-r--r--src/resources/db/colordb.h74
-rw-r--r--src/resources/db/commandsdb.cpp162
-rw-r--r--src/resources/db/commandsdb.h50
-rw-r--r--src/resources/db/deaddb.cpp108
-rw-r--r--src/resources/db/deaddb.h49
-rw-r--r--src/resources/db/elementaldb.cpp153
-rw-r--r--src/resources/db/elementaldb.h50
-rw-r--r--src/resources/db/emotedb.cpp317
-rw-r--r--src/resources/db/emotedb.h70
-rw-r--r--src/resources/db/groupdb.cpp394
-rw-r--r--src/resources/db/groupdb.h55
-rw-r--r--src/resources/db/homunculusdb.cpp159
-rw-r--r--src/resources/db/homunculusdb.h50
-rw-r--r--src/resources/db/horsedb.cpp302
-rw-r--r--src/resources/db/horsedb.h59
-rw-r--r--src/resources/db/itemdb.cpp1232
-rw-r--r--src/resources/db/itemdb.h78
-rw-r--r--src/resources/db/itemfielddb.cpp153
-rw-r--r--src/resources/db/itemfielddb.h49
-rw-r--r--src/resources/db/itemoptiondb.cpp151
-rw-r--r--src/resources/db/itemoptiondb.h49
-rw-r--r--src/resources/db/languagedb.cpp124
-rw-r--r--src/resources/db/languagedb.h44
-rw-r--r--src/resources/db/mapdb.cpp225
-rw-r--r--src/resources/db/mapdb.h72
-rw-r--r--src/resources/db/mercenarydb.cpp157
-rw-r--r--src/resources/db/mercenarydb.h50
-rw-r--r--src/resources/db/moddb.cpp118
-rw-r--r--src/resources/db/moddb.h46
-rw-r--r--src/resources/db/monsterdb.cpp160
-rw-r--r--src/resources/db/monsterdb.h50
-rw-r--r--src/resources/db/networkdb.cpp88
-rw-r--r--src/resources/db/networkdb.h56
-rw-r--r--src/resources/db/npcdb.cpp203
-rw-r--r--src/resources/db/npcdb.h52
-rw-r--r--src/resources/db/npcdialogdb.cpp229
-rw-r--r--src/resources/db/npcdialogdb.h60
-rw-r--r--src/resources/db/palettedb.cpp115
-rw-r--r--src/resources/db/palettedb.h39
-rw-r--r--src/resources/db/petdb.cpp167
-rw-r--r--src/resources/db/petdb.h47
-rw-r--r--src/resources/db/questdb.cpp264
-rw-r--r--src/resources/db/questdb.h55
-rw-r--r--src/resources/db/skillunitdb.cpp161
-rw-r--r--src/resources/db/skillunitdb.h47
-rw-r--r--src/resources/db/sounddb.cpp99
-rw-r--r--src/resources/db/sounddb.h42
-rw-r--r--src/resources/db/statdb.cpp235
-rw-r--r--src/resources/db/statdb.h50
-rw-r--r--src/resources/db/statuseffectdb.cpp251
-rw-r--r--src/resources/db/statuseffectdb.h76
-rw-r--r--src/resources/db/textdb.cpp104
-rw-r--r--src/resources/db/textdb.h44
-rw-r--r--src/resources/db/unitsdb.cpp400
-rw-r--r--src/resources/db/unitsdb.h68
-rw-r--r--src/resources/db/weaponsdb.cpp85
-rw-r--r--src/resources/db/weaponsdb.h44
64 files changed, 0 insertions, 8732 deletions
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp
deleted file mode 100644
index cfa1a4517..000000000
--- a/src/resources/db/avatardb.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/avatardb.h"
-
-#include "logger.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mAvatarInfos;
- bool mLoaded = false;
-} // namespace
-
-void AvatarDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing avatar database...");
- loadXmlFile(paths.getStringValue("avatarsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("avatarsPatchFile"), SkipError_true);
- loadXmlDir("avatarsPatchDir", loadXmlFile);
-}
-
-void AvatarDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "avatars"))
- {
- logger->log("Avatars Database: Error while loading %s!",
- fileName.c_str());
- mLoaded = true;
- return;
- }
-
- for_each_xml_child_node(avatarNode, rootNode)
- {
- if (xmlNameEqual(avatarNode, "include"))
- {
- const std::string name = XML::getProperty(avatarNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(avatarNode, "avatar"))
- continue;
-
- const BeingTypeId id = fromInt(XML::getProperty(
- avatarNode, "id", 0), BeingTypeId);
- BeingInfo *currentInfo = nullptr;
- if (mAvatarInfos.find(id) != mAvatarInfos.end())
- currentInfo = mAvatarInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- avatarNode, "name", _("unnamed")));
-
- currentInfo->setTargetOffsetX(XML::getProperty(avatarNode,
- "targetOffsetX", 0));
-
- currentInfo->setTargetOffsetY(XML::getProperty(avatarNode,
- "targetOffsetY", 0));
-
- currentInfo->setWidth(XML::getProperty(avatarNode,
- "width", 0));
- currentInfo->setHeight(XML::getProperty(avatarNode,
- "height", 0));
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, avatarNode)
- {
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant = XML::getProperty(
- spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- }
- currentInfo->setDisplay(display);
- mAvatarInfos[id] = currentInfo;
- }
-
- mLoaded = true;
-}
-
-void AvatarDB::unload()
-{
- logger->log1("Unloading avatar database...");
- delete_all(mAvatarInfos);
- mAvatarInfos.clear();
- mLoaded = false;
-}
-
-BeingInfo *AvatarDB::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mAvatarInfos.find(id);
- if (i == mAvatarInfos.end())
- return BeingInfo::unknown;
- return i->second;
-}
diff --git a/src/resources/db/avatardb.h b/src/resources/db/avatardb.h
deleted file mode 100644
index 537207a93..000000000
--- a/src/resources/db/avatardb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_AVATARDB_H
-#define RESOURCES_DB_AVATARDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-namespace AvatarDB
-{
- void load();
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-} // namespace AvatarDB
-
-#endif // RESOURCES_DB_AVATARDB_H
diff --git a/src/resources/db/badgesdb.cpp b/src/resources/db/badgesdb.cpp
deleted file mode 100644
index 1d41ba1e5..000000000
--- a/src/resources/db/badgesdb.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/badgesdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "utils/foreach.h"
-#include "utils/xmlutils.h"
-
-#include "debug.h"
-
-namespace
-{
- BadgesInfos mGuilds;
- BadgesInfos mNames;
- BadgesInfos mParties;
- bool mLoaded = false;
-} // namespace
-
-static void loadXmlFile(const std::string &file,
- const std::string &name,
- BadgesInfos &arr,
- const SkipError skipError)
-{
- readXmlStringMap(file,
- "badges",
- name,
- "badge",
- "name",
- "image",
- arr,
- skipError);
-}
-
-static void loadDB(const std::string &name, BadgesInfos &arr)
-{
- loadXmlFile(paths.getStringValue("badgesFile"),
- name, arr, SkipError_false);
- loadXmlFile(paths.getStringValue("badgesPatchFile"),
- name, arr, SkipError_true);
-
- StringVect listVect;
- VirtFs::getFilesInDir(paths.getStringValue(
- "badgesPatchDir"),
- listVect,
- ".xml");
- FOR_EACH (StringVectCIter, itVect, listVect)
- loadXmlFile(*itVect, name, arr, SkipError_true);
-}
-
-void BadgesDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing Badges database...");
- loadDB("guild", mGuilds);
- loadDB("name", mNames);
- loadDB("party", mParties);
-}
-
-void BadgesDB::unload()
-{
- logger->log1("Unloading Badges database...");
- mParties.clear();
- mGuilds.clear();
- mNames.clear();
- mLoaded = false;
-}
-
-const std::string BadgesDB::getPartyBadge(const std::string &name)
-{
- const BadgesInfosIter it = mParties.find(name);
- if (it == mParties.end())
- return std::string();
- return (*it).second;
-}
-
-const std::string BadgesDB::getNameBadge(const std::string &name)
-{
- const BadgesInfosIter it = mNames.find(name);
- if (it == mNames.end())
- return std::string();
- return (*it).second;
-}
-
-const std::string BadgesDB::getGuildBadge(const std::string &name)
-{
- const BadgesInfosIter it = mGuilds.find(name);
- if (it == mGuilds.end())
- return std::string();
- return (*it).second;
-}
diff --git a/src/resources/db/badgesdb.h b/src/resources/db/badgesdb.h
deleted file mode 100644
index ca8ac631e..000000000
--- a/src/resources/db/badgesdb.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_BADGESDB_H
-#define RESOURCES_DB_BADGESDB_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-typedef std::map<std::string, std::string> BadgesInfos;
-typedef BadgesInfos::const_iterator BadgesInfosIter;
-
-namespace BadgesDB
-{
- void load();
-
- void unload();
-
- const std::string getGuildBadge(const std::string &name);
-
- const std::string getNameBadge(const std::string &name);
-
- const std::string getPartyBadge(const std::string &name);
-} // namespace BadgesDB
-
-#endif // RESOURCES_DB_BADGESDB_H
diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp
deleted file mode 100644
index 2dd60270b..000000000
--- a/src/resources/db/chardb.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/chardb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- unsigned mMinHairColor = 0;
- unsigned mMaxHairColor = 0;
- unsigned mMinHairStyle = 0;
- unsigned mMaxHairStyle = 0;
- unsigned mMinStat = 0;
- unsigned mMaxStat = 0;
- unsigned mSumStat = 0;
- unsigned mMinLook = 0;
- unsigned mMaxLook = 0;
- unsigned mMinRace = 0;
- unsigned mMaxRace = 30;
- STD_VECTOR<BeingSlot> mDefaultItems;
-} // namespace
-
-void CharDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing char database...");
-
- XML::Document *doc = new XML::Document(
- paths.getStringValue("charCreationFile"),
- UseVirtFs_true,
- SkipError_false);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "chars"))
- {
- logger->log("CharDB: Failed to parse %s.",
- paths.getStringValue("charCreationFile").c_str());
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "haircolor"))
- {
- loadMinMax(node, &mMinHairColor, &mMaxHairColor);
- }
- else if (xmlNameEqual(node, "hairstyle"))
- {
- loadMinMax(node, &mMinHairStyle, &mMaxHairStyle);
- }
- else if (xmlNameEqual(node, "look"))
- {
- loadMinMax(node, &mMinLook, &mMaxLook);
- }
- else if (xmlNameEqual(node, "stat"))
- {
- loadMinMax(node, &mMinStat, &mMaxStat);
- mSumStat = XML::getProperty(node, "sum", 0);
- }
- else if (xmlNameEqual(node, "item"))
- {
- const int id = XML::getProperty(node, "id", 0);
- if (id > 0)
- {
- BeingSlot slot;
- slot.spriteId = id;
- for (int f = 0; f < maxCards; f ++)
- {
- const std::string cardName = strprintf("card%d", f + 1);
- slot.cardsId.cards[f] = XML::getProperty(node,
- cardName.c_str(),
- 0);
- }
- mDefaultItems.push_back(slot);
- }
- }
- else if (xmlNameEqual(node, "race"))
- {
- loadMinMax(node, &mMinRace, &mMaxRace);
- }
- }
-
- delete doc;
-
- mLoaded = true;
-}
-
-void CharDB::loadMinMax(XmlNodeConstPtr node,
- unsigned *restrict const min,
- unsigned *restrict const max)
-{
- if (min != nullptr)
- *min = XML::getProperty(node, "min", 1);
- if (max != nullptr)
- *max = XML::getProperty(node, "max", 10);
-}
-
-void CharDB::unload()
-{
- logger->log1("Unloading char database...");
-
- mLoaded = false;
-}
-
-unsigned CharDB::getMinHairColor()
-{
- return mMinHairColor;
-}
-
-unsigned CharDB::getMaxHairColor()
-{
- return mMaxHairColor;
-}
-
-unsigned CharDB::getMinHairStyle()
-{
- return mMinHairStyle;
-}
-
-unsigned CharDB::getMaxHairStyle()
-{
- return mMaxHairStyle;
-}
-
-unsigned CharDB::getMinStat()
-{
- return mMinStat;
-}
-
-unsigned CharDB::getMaxStat()
-{
- return mMaxStat;
-}
-
-unsigned CharDB::getSumStat()
-{
- return mSumStat;
-}
-
-unsigned CharDB::getMinLook()
-{
- return mMinLook;
-}
-
-unsigned CharDB::getMaxLook()
-{
- return mMaxLook;
-}
-
-unsigned CharDB::getMinRace()
-{
- return mMinRace;
-}
-
-unsigned CharDB::getMaxRace()
-{
- return mMaxRace;
-}
-
-const STD_VECTOR<BeingSlot> &CharDB::getDefaultItems()
-{
- return mDefaultItems;
-}
diff --git a/src/resources/db/chardb.h b/src/resources/db/chardb.h
deleted file mode 100644
index f940d3059..000000000
--- a/src/resources/db/chardb.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_CHARDB_H
-#define RESOURCES_DB_CHARDB_H
-
-#include "utils/xml.h"
-
-#include "utils/vector.h"
-
-#include "resources/beingslot.h"
-
-/**
- * Char information database.
- */
-namespace CharDB
-{
- /**
- * Loads the chars data.
- */
- void load();
-
- /**
- * Clear the chars data
- */
- void unload();
-
- void loadMinMax(XmlNodeConstPtr node,
- unsigned *restrict const min,
- unsigned *restrict const max);
-
- unsigned getMinHairColor() A_WARN_UNUSED;
-
- unsigned getMaxHairColor() A_WARN_UNUSED;
-
- unsigned getMinHairStyle() A_WARN_UNUSED;
-
- unsigned getMaxHairStyle() A_WARN_UNUSED;
-
- unsigned getMinStat() A_WARN_UNUSED;
-
- unsigned getMaxStat() A_WARN_UNUSED;
-
- unsigned getSumStat() A_WARN_UNUSED;
-
- unsigned getMinLook() A_WARN_UNUSED;
-
- unsigned getMaxLook() A_WARN_UNUSED;
-
- unsigned getMinRace() A_WARN_UNUSED;
-
- unsigned getMaxRace() A_WARN_UNUSED;
-
- const STD_VECTOR<BeingSlot> &getDefaultItems() A_WARN_UNUSED;
-} // namespace CharDB
-
-#endif // RESOURCES_DB_CHARDB_H
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
deleted file mode 100644
index 626ef78ae..000000000
--- a/src/resources/db/colordb.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/colordb.h"
-
-#include "configuration.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- int mHairColorsSize = 0;
- bool mLoaded = false;
- std::string mFail("#ffffff");
- ColorDB::ColorLists mColorLists;
-} // namespace
-
-void ColorDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing color database...");
-
- std::map<ItemColor, ItemColorData> colors;
- ColorListsIterator it = mColorLists.find("hair");
- if (it != mColorLists.end())
- colors = it->second;
- loadHair(paths.getStringValue("hairColorFile"),
- colors,
- SkipError_true);
- loadHair(paths.getStringValue("hairColorPatchFile"),
- colors,
- SkipError_true);
- StringVect list;
- VirtFs::getFilesInDir(paths.getStringValue(
- "hairColorPatchDir"), list, ".xml");
- FOR_EACH (StringVectCIter, it2, list)
- loadHair(*it2, colors, SkipError_true);
-
- mColorLists["hair"] = colors;
-
- loadColorLists(paths.getStringValue("itemColorsFile"),
- SkipError_false);
- loadColorLists(paths.getStringValue("itemColorsPatchFile"),
- SkipError_true);
- loadXmlDir("itemColorsPatchDir", loadColorLists);
-
- it = mColorLists.find("hair");
- if (it != mColorLists.end())
- mHairColorsSize = CAST_S32((*it).second.size());
- else
- mHairColorsSize = 0;
- mLoaded = true;
-}
-
-void ColorDB::loadHair(const std::string &fileName,
- std::map<ItemColor, ItemColorData> &colors,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "colors"))
- {
- logger->log("ColorDB: Failed to find hair colors file.");
- if (colors.find(ItemColor_zero) == colors.end())
- colors[ItemColor_zero] = ItemColorData(ItemColor_zero, "", "");
- delete doc;
- return;
- }
-
- reportAlways("Found legacy hair.xml");
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadHair(name, colors, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "color"))
- {
- const ItemColor id = fromInt(XML::getProperty(
- node, "id", 0), ItemColor);
-
- if (colors.find(id) != colors.end())
- {
- reportAlways("ColorDB: Redefinition of dye ID %d",
- toInt(id, int));
- }
-
- colors[id] = ItemColorData(id, XML::langProperty(node, "name", ""),
- XML::getProperty(node, "value", "#FFFFFF"));
- }
- }
-
- delete doc;
-}
-
-void ColorDB::loadColorLists(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadColorLists(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "list"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- continue;
-
- std::map <ItemColor, ItemColorData> colors;
- const ColorListsIterator it = mColorLists.find(name);
-
- if (it != mColorLists.end())
- colors = it->second;
-
- for_each_xml_child_node(colorNode, node)
- {
- if (xmlNameEqual(colorNode, "color"))
- {
- const int id = XML::getProperty(colorNode, "id", -1);
- if (id > -1)
- {
- ItemColorData c(fromInt(id, ItemColor),
- XML::langProperty(colorNode, "name", ""),
- XML::getProperty(colorNode, "value", ""));
- colors[c.id] = c;
- }
- }
- }
- mColorLists[name] = colors;
- }
- }
- delete doc;
-}
-
-void ColorDB::unload()
-{
- logger->log1("Unloading color database...");
-
- mColorLists.clear();
- mLoaded = false;
-}
-
-std::string &ColorDB::getHairColorName(const ItemColor id)
-{
- if (!mLoaded)
- load();
-
- const ColorListsIterator it = mColorLists.find("hair");
- if (it == mColorLists.end())
- {
- reportAlways("ColorDB: Error, hair colors list empty");
- return mFail;
- }
-
- const ColorIterator i = (*it).second.find(id);
-
- if (i == (*it).second.end())
- {
- reportAlways("ColorDB: Error, unknown dye ID# %d",
- toInt(id, int));
- return mFail;
- }
- return i->second.name;
-}
-
-int ColorDB::getHairSize()
-{
- return mHairColorsSize;
-}
-
-const std::map <ItemColor, ItemColorData>
- *ColorDB::getColorsList(const std::string &name)
-{
- const ColorListsIterator it = mColorLists.find(name);
-
- if (it != mColorLists.end())
- return &it->second;
- return nullptr;
-}
diff --git a/src/resources/db/colordb.h b/src/resources/db/colordb.h
deleted file mode 100644
index 5189d7c85..000000000
--- a/src/resources/db/colordb.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_COLORDB_H
-#define RESOURCES_DB_COLORDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "resources/itemcolordata.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-/**
- * Color information database.
- */
-namespace ColorDB
-{
- /**
- * Loads the color data from <code>colors.xml</code>.
- */
- void load();
-
- /**
- * Loads the color data from <code>colors.xml</code>.
- */
- void loadHair(const std::string &fileName,
- std::map<ItemColor, ItemColorData> &colors,
- const SkipError skipError);
-
- void loadColorLists(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the color data
- */
- void unload();
-
- std::string &getHairColorName(const ItemColor id) A_WARN_UNUSED;
-
- int getHairSize() A_WARN_UNUSED;
-
- const std::map <ItemColor, ItemColorData> *getColorsList(const std::string
- &name)
- A_WARN_UNUSED;
-
- // Color DB
- typedef std::map<ItemColor, ItemColorData> Colors;
- typedef Colors::iterator ColorIterator;
- typedef std::map <std::string, std::map <ItemColor, ItemColorData> >
- ColorLists;
- typedef ColorLists::iterator ColorListsIterator;
-} // namespace ColorDB
-
-#endif // RESOURCES_DB_COLORDB_H
diff --git a/src/resources/db/commandsdb.cpp b/src/resources/db/commandsdb.cpp
deleted file mode 100644
index 4fc5136c4..000000000
--- a/src/resources/db/commandsdb.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/commandsdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "textcommand.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- CommandsMap mCommands;
- bool mLoaded = false;
-} // namespace
-
-void CommandsDB::load()
-{
- if (mLoaded)
- unload();
- logger->log1("Initializing commands database...");
- loadXmlFile(paths.getStringValue("defaultCommandsFile"),
- SkipError_false);
- loadXmlFile(paths.getStringValue("defaultCommandsPatchFile"),
- SkipError_true);
- loadXmlDir("defaultCommandsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static CommandTargetT parseTarget(const std::string &text)
-{
- if (text == "allow target")
- return CommandTarget::AllowTarget;
- else if (text == "need target")
- return CommandTarget::NeedTarget;
- else
- return CommandTarget::NoTarget;
-}
-
-void CommandsDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "commands"))
- {
- logger->log("Commands Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(commandNode, rootNode)
- {
- if (xmlNameEqual(commandNode, "include"))
- {
- const std::string name = XML::getProperty(commandNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(commandNode, "command"))
- continue;
-
- const int id = XML::getProperty(commandNode, "id", -1);
- if (id == -1)
- continue;
-
- const CommandsMapIter it = mCommands.find(id);
- if (it != mCommands.end())
- {
- logger->log("Commands database: duplicate id: %d", id);
- TextCommand *tempCmd = (*it).second;
- mCommands.erase(it);
- delete tempCmd;
- }
- const std::string name = XML::langProperty(
- commandNode, "name", "?");
- const std::string command = XML::getProperty(
- commandNode, "command", "");
- const std::string comment = XML::getProperty(
- commandNode, "comment", "");
- const CommandTargetT targetType = parseTarget(XML::getProperty(
- commandNode, "target", ""));
- const std::string icon = XML::getProperty(
- commandNode, "icon", "");
-#ifdef TMWA_SUPPORT
- const int skill1 = XML::getIntProperty(
- commandNode, "skill1", 0, 0, 1000000);
- const int level1 = XML::getIntProperty(
- commandNode, "level1", 0, 0, 1000);
- const int skill2 = XML::getIntProperty(
- commandNode, "skill2", 0, 0, 1000000);
- const int level2 = XML::getIntProperty(
- commandNode, "level2", 0, 0, 1000);
- const int mana = XML::getIntProperty(
- commandNode, "mana", 0, 0, 100000);
-#endif // TMWA_SUPPORT
-
- TextCommand *cmd = nullptr;
-#ifdef TMWA_SUPPORT
- if (skill1 != 0)
- {
- cmd = new TextCommand(id,
- name,
- command,
- comment,
- targetType,
- icon,
- level1,
- static_cast<MagicSchoolT>(skill2),
- level2,
- mana);
- }
- else
-#endif // TMWA_SUPPORT
- {
- cmd = new TextCommand(id,
- name,
- command,
- comment,
- targetType,
- icon);
- }
- mCommands[id] = cmd;
- }
-}
-
-void CommandsDB::unload()
-{
- logger->log1("Unloading commands database...");
- mCommands.clear();
- mLoaded = false;
-}
-
-std::map<int, TextCommand*> &CommandsDB::getAll()
-{
- return mCommands;
-}
diff --git a/src/resources/db/commandsdb.h b/src/resources/db/commandsdb.h
deleted file mode 100644
index 8c50a4367..000000000
--- a/src/resources/db/commandsdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_COMMANDSDB_H
-#define RESOURCES_DB_COMMANDSDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class TextCommand;
-
-typedef std::map<int, TextCommand*> CommandsMap;
-typedef CommandsMap::iterator CommandsMapIter;
-
-namespace CommandsDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- CommandsMap &getAll();
-} // namespace CommandsDB
-
-#endif // RESOURCES_DB_COMMANDSDB_H
diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp
deleted file mode 100644
index 632c3a79f..000000000
--- a/src/resources/db/deaddb.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/deaddb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/translation/podict.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- STD_VECTOR<std::string> mMessages;
-} // namespace
-
-void DeadDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing dead database...");
-
- loadXmlFile(paths.getStringValue("deadMessagesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("deadMessagesPatchFile"), SkipError_true);
- loadXmlDir("deadMessagesPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void DeadDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "messages"))
- {
- logger->log("DeadDB: Failed to parse %s.",
- paths.getStringValue("deadMessagesFile").c_str());
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "message"))
- {
- XmlChar *const data = reinterpret_cast<XmlChar*>(
- XmlNodeGetContent(node));
- if (data == nullptr)
- continue;
- if (*data == 0)
- {
- XmlFree(data);
- continue;
- }
- mMessages.push_back(data);
- XmlFree(data);
- }
- }
-
- delete doc;
-}
-
-void DeadDB::unload()
-{
- logger->log1("Unloading dead database...");
- mMessages.clear();
- mLoaded = false;
-}
-
-std::string DeadDB::getRandomString()
-{
- const size_t sz = mMessages.size();
- if (sz == 0u)
- return std::string();
- return translator->getStr(mMessages[rand() % sz]);
-}
diff --git a/src/resources/db/deaddb.h b/src/resources/db/deaddb.h
deleted file mode 100644
index 4d2c3eab3..000000000
--- a/src/resources/db/deaddb.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_DEADDB_H
-#define RESOURCES_DB_DEADDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-/**
- * Char information database.
- */
-namespace DeadDB
-{
- /**
- * Loads the chars data.
- */
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the chars data
- */
- void unload();
-
- std::string getRandomString();
-} // namespace DeadDB
-
-#endif // RESOURCES_DB_DEADDB_H
diff --git a/src/resources/db/elementaldb.cpp b/src/resources/db/elementaldb.cpp
deleted file mode 100644
index 1bebf7633..000000000
--- a/src/resources/db/elementaldb.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/elementaldb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mElementalInfos;
- bool mLoaded = false;
-} // namespace
-
-void ElementalDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing elemental database...");
- loadXmlFile(paths.getStringValue("elementalsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("elementalsPatchFile"), SkipError_true);
- loadXmlDir("elementalsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void ElementalDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "elementals"))
- {
- logger->log("Elemental Database: Error while loading %s!",
- paths.getStringValue("elementalsFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode, "offset", 0);
-
- // iterate <elemental>s
- for_each_xml_child_node(elementalNode, rootNode)
- {
- if (xmlNameEqual(elementalNode, "include"))
- {
- const std::string name = XML::getProperty(
- elementalNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(elementalNode, "elemental"))
- continue;
-
- const int id = XML::getProperty(elementalNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mElementalInfos.find(fromInt(id + offset, BeingTypeId))
- != mElementalInfos.end())
- {
- logger->log("ElementalDb: Redefinition of elemental ID %d", id);
- currentInfo = mElementalInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- BeingCommon::readBasicAttributes(currentInfo,
- elementalNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo,
- elementalNode,
- 0);
-
- currentInfo->setMaxHP(XML::getProperty(elementalNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- elementalNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(elementalNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, elementalNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "ElementalDb");
- }
- currentInfo->setDisplay(display);
-
- mElementalInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void ElementalDb::unload()
-{
- logger->log1("Unloading elemental database...");
- delete_all(mElementalInfos);
- mElementalInfos.clear();
-
- mLoaded = false;
-}
-
-
-BeingInfo *ElementalDb::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mElementalInfos.find(id);
-
- if (i == mElementalInfos.end())
- {
- i = mElementalInfos.find(id);
- if (i == mElementalInfos.end())
- {
- reportAlways("ElementalDb: Warning, unknown elemental ID "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/elementaldb.h b/src/resources/db/elementaldb.h
deleted file mode 100644
index 50a67c183..000000000
--- a/src/resources/db/elementaldb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_ELEMENTALDB_H
-#define RESOURCES_DB_ELEMENTALDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Elemental information database.
- */
-namespace ElementalDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace ElementalDb
-
-#endif // RESOURCES_DB_ELEMENTALDB_H
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
deleted file mode 100644
index e519b531d..000000000
--- a/src/resources/db/emotedb.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/emotedb.h"
-
-#include "client.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-#include "resources/emoteinfo.h"
-#include "resources/emotesprite.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "debug.h"
-
-namespace
-{
- EmoteInfos mEmoteInfos;
- EmoteToEmote mEmotesAlt;
- EmoteInfo mUnknown;
- bool mLoaded = false;
- int mLastEmote = 0;
-} // namespace
-
-void EmoteDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing emote database...");
-
- EmoteSprite *const unknownSprite = new EmoteSprite;
- unknownSprite->sprite = AnimatedSprite::load(pathJoin(paths.getStringValue(
- "sprites"), paths.getStringValue(
- "spriteErrorFile")));
- unknownSprite->name = "unknown";
- unknownSprite->id = 0;
- mUnknown.sprites.push_back(unknownSprite);
-
- mLastEmote = 0;
- loadXmlFile(paths.getStringValue("emotesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("emotesPatchFile"), SkipError_true);
- loadXmlDir("emotesPatchDir", loadXmlFile);
- loadSpecialXmlFile("graphics/sprites/manaplus_emotes.xml",
- SkipError_false);
-
- mLoaded = true;
-}
-
-void EmoteDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodePtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "emotes"))
- {
- logger->log("Emote Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <emote>s
- for_each_xml_child_node(emoteNode, rootNode)
- {
- if (xmlNameEqual(emoteNode, "include"))
- {
- const std::string name = XML::getProperty(emoteNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(emoteNode, "emote"))
- {
- continue;
- }
-
- const int id = XML::getProperty(emoteNode, "id", -1);
- // skip hight images
- if (id > 19 || (Client::isTmw() && id > 13))
- continue;
-
- if (id == -1)
- {
- reportAlways("Emote Database: Emote with missing ID in %s!",
- paths.getStringValue("emotesFile").c_str());
- continue;
- }
- EmoteInfo *currentInfo = nullptr;
- if (mEmoteInfos.find(id) != mEmoteInfos.end())
- currentInfo = mEmoteInfos[id];
- else
- currentInfo = new EmoteInfo;
- if (currentInfo == nullptr)
- continue;
- currentInfo->time = XML::getProperty(emoteNode, "time", 500);
- currentInfo->effectId = XML::getProperty(emoteNode, "effect", -1);
-
- for_each_xml_child_node(spriteNode, emoteNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- EmoteSprite *const currentSprite = new EmoteSprite;
- currentSprite->sprite = AnimatedSprite::load(pathJoin(
- paths.getStringValue("sprites"),
- XmlChildContent(spriteNode)),
- XML::getProperty(spriteNode, "variant", 0));
- currentSprite->name = XML::langProperty(
- spriteNode, "name", "");
- currentSprite->id = id;
- currentInfo->sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- currentInfo->particles.push_back(XmlChildContent(spriteNode));
- }
- }
- mEmoteInfos[id] = currentInfo;
- if (id > mLastEmote)
- mLastEmote = id;
- }
-}
-
-void EmoteDB::loadSpecialXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodePtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "emotes"))
- {
- logger->log1("Emote Database: Error while loading"
- " manaplus_emotes.xml!");
- return;
- }
-
- // iterate <emote>s
- for_each_xml_child_node(emoteNode, rootNode)
- {
- if (xmlNameEqual(emoteNode, "include"))
- {
- const std::string name = XML::getProperty(emoteNode, "name", "");
- if (!name.empty())
- loadSpecialXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(emoteNode, "emote"))
- {
- continue;
- }
-
- const int id = XML::getProperty(emoteNode, "id", -1);
- if (id == -1)
- {
- reportAlways("Emote Database: Emote with missing ID in "
- "manaplus_emotes.xml!");
- continue;
- }
- const int altId = XML::getProperty(emoteNode, "altid", -1);
-
- EmoteInfo *currentInfo = nullptr;
- if (mEmoteInfos.find(id) != mEmoteInfos.end())
- currentInfo = mEmoteInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new EmoteInfo;
- currentInfo->time = XML::getProperty(emoteNode, "time", 500);
- currentInfo->effectId = XML::getProperty(emoteNode, "effect", -1);
-
- for_each_xml_child_node(spriteNode, emoteNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- EmoteSprite *const currentSprite = new EmoteSprite;
- currentSprite->sprite = AnimatedSprite::load(pathJoin(
- paths.getStringValue("sprites"),
- XmlChildContent(spriteNode)),
- XML::getProperty(spriteNode, "variant", 0));
- currentSprite->name = XML::langProperty(
- spriteNode, "name", "");
- currentSprite->id = id;
- currentInfo->sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- currentInfo->particles.push_back(XmlChildContent(spriteNode));
- }
- }
- mEmoteInfos[id] = currentInfo;
- if (altId != -1)
- mEmotesAlt[altId] = id;
-
- if (id > mLastEmote)
- mLastEmote = id;
- }
-}
-
-void EmoteDB::unload()
-{
- logger->log1("Unloading emote database...");
- FOR_EACH (EmoteInfos::const_iterator, i, mEmoteInfos)
- {
- if (i->second != nullptr)
- {
- std::list<EmoteSprite*> &sprites = i->second->sprites;
- while (!sprites.empty())
- {
- delete sprites.front()->sprite;
- delete sprites.front();
- sprites.pop_front();
- }
- delete i->second;
- }
- }
-
- mEmoteInfos.clear();
-
- std::list<EmoteSprite*> &sprites = mUnknown.sprites;
- while (!sprites.empty())
- {
- delete sprites.front()->sprite;
- delete sprites.front();
- sprites.pop_front();
- }
-
- mLoaded = false;
-}
-
-const EmoteInfo *EmoteDB::get(const int id, const bool allowNull)
-{
- const EmoteInfos::const_iterator i = mEmoteInfos.find(id);
-
- if (i == mEmoteInfos.end())
- {
- if (allowNull)
- return nullptr;
- reportAlways("EmoteDB: Warning, unknown emote ID %d requested",
- id);
- return &mUnknown;
- }
- return i->second;
-}
-
-const EmoteInfo *EmoteDB::get2(int id, const bool allowNull)
-{
- const EmoteToEmote::const_iterator it = mEmotesAlt.find(id);
- if (it != mEmotesAlt.end())
- id = (*it).second;
-
- const EmoteInfos::const_iterator i = mEmoteInfos.find(id);
-
- if (i == mEmoteInfos.end())
- {
- if (allowNull)
- return nullptr;
- reportAlways("EmoteDB: Warning, unknown emote ID %d requested",
- id);
- return &mUnknown;
- }
- return i->second;
-}
-
-const EmoteSprite *EmoteDB::getSprite(const int id, const bool allowNull)
-{
- const EmoteInfo *const info = get(id, allowNull);
- if (info == nullptr)
- return nullptr;
-
- return info->sprites.front();
-}
-
-const int &EmoteDB::getLast()
-{
- return mLastEmote;
-}
-
-int EmoteDB::size()
-{
- return static_cast<signed int>(mEmoteInfos.size());
-}
-
-int EmoteDB::getIdByIndex(const int index)
-{
- if (index < 0 || index >= static_cast<signed int>(mEmoteInfos.size()))
- return 0;
- EmoteInfos::const_iterator it = mEmoteInfos.begin();
- for (int f = 0; f < index; f ++)
- ++ it;
- return (*it).first;
-}
diff --git a/src/resources/db/emotedb.h b/src/resources/db/emotedb.h
deleted file mode 100644
index 6d5420b51..000000000
--- a/src/resources/db/emotedb.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_EMOTEDB_H
-#define RESOURCES_DB_EMOTEDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct EmoteInfo;
-struct EmoteSprite;
-
-typedef std::map<int, EmoteInfo*> EmoteInfos;
-typedef std::map<int, int> EmoteToEmote;
-
-/**
- * Emote information database.
- */
-namespace EmoteDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void loadSpecialXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- const EmoteInfo *get(const int id,
- const bool allowNull = false) A_WARN_UNUSED;
-
- const EmoteInfo *get2(int id, const bool allowNull = false) A_WARN_UNUSED;
-
- const EmoteSprite *getSprite(const int id, const bool allowNull = false)
- A_WARN_UNUSED;
-
- const int &getLast() A_CONST A_WARN_UNUSED;
-
- int getIdByIndex(const int index);
-
- int size();
-
- typedef EmoteInfos::iterator EmoteInfosIterator;
-} // namespace EmoteDB
-
-#endif // RESOURCES_DB_EMOTEDB_H
diff --git a/src/resources/db/groupdb.cpp b/src/resources/db/groupdb.cpp
deleted file mode 100644
index e4c909c9a..000000000
--- a/src/resources/db/groupdb.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/groupdb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-#include "resources/groupinfo.h"
-
-#include "debug.h"
-
-namespace
-{
- GroupDb::GroupInfos mGroups;
- const GroupInfo mEmptyGroup;
- bool mLoaded = false;
-} // namespace
-
-void GroupDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing group database...");
-
- loadXmlFile(paths.getStringValue("groupsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("groupsPatchFile"), SkipError_true);
- loadXmlDir("groupsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-#define servercommandFirst(name) \
- if (str == #name) \
- return ServerCommandType::name; \
- else
-#define servercommand(name) \
- if (str == #name) \
- return ServerCommandType::name; \
- else
-#define servercommand2(name1, name2) \
- if (str == #name2) \
- return ServerCommandType::name1; \
- else
-
-static ServerCommandTypeT parseCommand(const std::string &str,
- const int id)
-{
-#include "resources/servercommands.inc"
- {
- reportAlways("GroupsDb: unknown command name: '%s' in group id '%d'.",
- str.c_str(),
- id);
- }
-
- return ServerCommandType::Max;
-}
-
-SERVERCOMMANDS_VOID
-#undef servercommandFirst
-#undef servercommand
-#undef servercommand2
-
-#define serverpermissionFirst(name) \
- if (str == #name) \
- return ServerPermissionType::name; \
- else
-#define serverpermission(name) \
- if (str == #name) \
- return ServerPermissionType::name; \
- else
-
-static ServerPermissionTypeT parsePermission(const std::string &str,
- const int id)
-{
-#include "resources/serverpermissions.inc"
- {
- reportAlways("GroupsDb: unknown permission name: "
- "'%s' in group id '%d'.",
- str.c_str(),
- id);
- }
-
- return ServerPermissionType::Max;
-}
-
-SERVERPERMISSION_VOID
-#undef serverpermissionFirst
-#undef serverpermission
-
-static ServerCommandEnable::Type parseUseFlag(const std::string &str,
- const int id)
-{
- if (str == "self")
- {
- return ServerCommandEnable::Self;
- }
- else if (str == "other")
- {
- return ServerCommandEnable::Other;
- }
- else if (str == "both")
- {
- return ServerCommandEnable::Both;
- }
- else if (str == "false")
- {
- return ServerCommandEnable::No;
- }
- else
- {
- reportAlways("GroupsDb: unknown use flag: '%s' in group id '%d'."
- "Possible values 'self', 'other', 'both'.",
- str.c_str(),
- id);
- return ServerCommandEnable::No;
- }
-}
-
-static void loadCommands(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void loadCommands(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo)
-{
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "command"))
- {
- const std::string nameStr = XML::getProperty(node,
- "name",
- "");
- const std::string useStr = XML::getProperty(node,
- "use",
- "");
- ServerCommandTypeT name = parseCommand(nameStr, id);
- if (name == ServerCommandType::Max)
- continue;
- ServerCommandEnable::Type useFlag = parseUseFlag(useStr, id);
- if (useFlag == ServerCommandEnable::No)
- continue;
- groupInfo->mCommands[CAST_SIZE(name)] = useFlag;
- }
- }
-}
-
-static void loadPermissions(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void loadPermissions(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo)
-{
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "permission"))
- {
- const std::string nameStr = XML::getProperty(node,
- "name",
- "");
- ServerPermissionTypeT perm = parsePermission(nameStr, id);
- if (perm == ServerPermissionType::Max)
- continue;
- if (!XML::getBoolProperty(node,
- "enable",
- true))
- {
- continue;
- }
- groupInfo->mPermissions[CAST_SIZE(perm)] = Enable_true;
- }
- }
-}
-
-static void loadSubNodes(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void loadSubNodes(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo)
-{
- for_each_xml_child_node(node, groupNode)
- {
- if (xmlNameEqual(node, "commands"))
- loadCommands(node, id, groupInfo);
- if (xmlNameEqual(node, "permissions"))
- loadPermissions(node, id, groupInfo);
- }
-}
-
-static void parseInherit(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void parseInherit(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo)
-{
- const std::string inherit = XML::langProperty(groupNode,
- "inherit",
- "");
- STD_VECTOR<int> parts;
- splitToIntVector(parts, inherit, ',');
- FOR_EACH (STD_VECTOR<int>::const_iterator, it, parts)
- {
- const int id2 = *it;
- GroupDb::GroupInfos::const_iterator it2 = mGroups.find(id2);
- if (it2 == mGroups.end())
- {
- reportAlways("Unknown inherit group id '%d' in group '%d'",
- id2,
- id);
- continue;
- }
- GroupInfo *const groupInfo2 = (*it2).second;
- for (size_t f = 0; f < CAST_SIZE(ServerCommandType::Max); f ++)
- {
- ServerCommandEnable::Type enable = groupInfo2->mCommands[f];
- if (enable != ServerCommandEnable::No)
- groupInfo->mCommands[f] = enable;
- }
- for (size_t f = 0; f < CAST_SIZE(ServerPermissionType::Max); f ++)
- {
- if (groupInfo2->mPermissions[f] == Enable_true)
- groupInfo->mPermissions[f] = Enable_true;
- }
- }
-}
-
-void GroupDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr ||
- !xmlNameEqual(rootNode, "groups"))
- {
- if (skipError == SkipError_true)
- {
- logger->log("GroupsDb: Error while loading %s!",
- fileName.c_str());
- }
- else
- {
- reportAlways("GroupsDb: Error while loading %s!",
- fileName.c_str());
- }
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (xmlNameEqual(node, "group"))
- {
- const int id = XML::getProperty(node,
- "id",
- -1);
- if (id < 0)
- {
- reportAlways("Empty id field in GroupDb");
- continue;
- }
- GroupInfosIter it = mGroups.find(id);
- GroupInfo *group = nullptr;
- if (it != mGroups.end())
- {
- reportAlways("GroupDb: group with id %d already added",
- id);
- group = (*it).second;
- }
- else
- {
- group = new GroupInfo;
- mGroups[id] = group;
- }
- group->name = XML::langProperty(node,
- "name",
- "");
- group->longName = XML::langProperty(node,
- "longName",
- "");
- group->badge = XML::langProperty(node,
- "badge",
- paths.getStringValue("gmbadge"));
- group->showBadge = XML::getBoolProperty(node,
- "showBadge",
- false);
- loadSubNodes(node, id, group);
- parseInherit(node, id, group);
- }
- }
-}
-
-void GroupDb::unload()
-{
- logger->log1("Unloading group database...");
- FOR_EACH (GroupInfosIter, it, mGroups)
- {
- delete (*it).second;
- }
- mGroups.clear();
- mLoaded = false;
-}
-
-const std::string &GroupDb::getName(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.name;
- }
- return (*it).second->name;
-}
-
-const std::string &GroupDb::getLongName(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.longName;
- }
- return (*it).second->longName;
-}
-
-bool GroupDb::getShowBadge(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.showBadge;
- }
- return (*it).second->showBadge;
-}
-
-const std::string &GroupDb::getBadge(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.badge;
- }
- return (*it).second->badge;
-}
-
-const GroupInfo *GroupDb::getGroup(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return &mEmptyGroup;
- }
- return (*it).second;
-}
-
-#ifdef UNITTESTS
-GroupDb::GroupInfos &GroupDb::getGroups()
-{
- return mGroups;
-}
-#endif // UNITTESTS
diff --git a/src/resources/db/groupdb.h b/src/resources/db/groupdb.h
deleted file mode 100644
index 020649001..000000000
--- a/src/resources/db/groupdb.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_GROUPDB_H
-#define RESOURCES_DB_GROUPDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct GroupInfo;
-
-namespace GroupDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
- const std::string &getName(const int id) A_WARN_UNUSED;
- const std::string &getLongName(const int id) A_WARN_UNUSED;
- bool getShowBadge(const int id) A_WARN_UNUSED;
- const std::string &getBadge(const int id) A_WARN_UNUSED;
- const GroupInfo *getGroup(const int id) A_WARN_UNUSED RETURNS_NONNULL;
-
- typedef std::map<int, GroupInfo*> GroupInfos;
- typedef GroupInfos::iterator GroupInfosIter;
-
-#ifdef UNITTESTS
- GroupDb::GroupInfos &getGroups();
-#endif // UNITTESTS
-} // namespace GroupDb
-
-#endif // RESOURCES_DB_GROUPDB_H
diff --git a/src/resources/db/homunculusdb.cpp b/src/resources/db/homunculusdb.cpp
deleted file mode 100644
index 83912e936..000000000
--- a/src/resources/db/homunculusdb.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/homunculusdb.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mHomunculusInfos;
- bool mLoaded = false;
-} // namespace
-
-void HomunculusDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing homunculus database...");
- loadXmlFile(paths.getStringValue("homunculusesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("homunculusesPatchFile"), SkipError_true);
- loadXmlDir("homunculusesPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void HomunculusDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "homunculuses"))
- {
- logger->log("Homunculus Database: Error while loading %s!",
- paths.getStringValue("homunculusesFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode, "offset", 0);
-
- // iterate <homunculus>s
- for_each_xml_child_node(homunculusNode, rootNode)
- {
- if (xmlNameEqual(homunculusNode, "include"))
- {
- const std::string name = XML::getProperty(
- homunculusNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(homunculusNode, "homunculus"))
- continue;
-
- const int id = XML::getProperty(homunculusNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mHomunculusInfos.find(fromInt(id + offset, BeingTypeId))
- != mHomunculusInfos.end())
- {
- logger->log("HomunculusDB: Redefinition of homunculus ID %d", id);
- currentInfo = mHomunculusInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- homunculusNode, "name", _("unnamed")));
-
- BeingCommon::readBasicAttributes(currentInfo,
- homunculusNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo,
- homunculusNode,
- 0);
- BeingCommon::readAiAttributes(currentInfo,
- homunculusNode);
-
- currentInfo->setMaxHP(XML::getProperty(homunculusNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- homunculusNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(homunculusNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, homunculusNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "HomunculusDB");
- }
- currentInfo->setDisplay(display);
-
- mHomunculusInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void HomunculusDB::unload()
-{
- logger->log1("Unloading homunculus database...");
- delete_all(mHomunculusInfos);
- mHomunculusInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *HomunculusDB::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mHomunculusInfos.find(id);
-
- if (i == mHomunculusInfos.end())
- {
- i = mHomunculusInfos.find(id);
- if (i == mHomunculusInfos.end())
- {
- reportAlways("HomunculusDB: Warning, unknown homunculus ID "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/homunculusdb.h b/src/resources/db/homunculusdb.h
deleted file mode 100644
index 5a064567a..000000000
--- a/src/resources/db/homunculusdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_HOMUNCULUSDB_H
-#define RESOURCES_DB_HOMUNCULUSDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Homunculus information database.
- */
-namespace HomunculusDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace HomunculusDB
-
-#endif // RESOURCES_DB_HOMUNCULUSDB_H
diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp
deleted file mode 100644
index 00228ecd7..000000000
--- a/src/resources/db/horsedb.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/horsedb.h"
-
-#include "configuration.h"
-
-#include "enums/resources/spritedirection.h"
-
-#include "resources/beingcommon.h"
-#include "resources/horseinfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace
-{
- HorseInfos mHorseInfos;
- HorseInfo mUnknown;
- bool mLoaded = false;
-} // namespace
-
-#define loadSprite(name) \
- { \
- SpriteReference *const currentSprite = new SpriteReference; \
- currentSprite->sprite = pathJoin(paths.getStringValue("sprites"), \
- XmlChildContent(spriteNode)); \
- currentSprite->variant = XML::getProperty( \
- spriteNode, "variant", 0); \
- currentInfo->name.push_back(currentSprite); \
- }
-
-static void loadDownSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo);
-
-static void loadUpSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo);
-
-void HorseDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing horse database...");
-
- SpriteReference *currentSprite = new SpriteReference;
- currentSprite->sprite = pathJoin(paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile"));
- currentSprite->variant = 0;
- mUnknown.downSprites.push_back(currentSprite);
-
- currentSprite = new SpriteReference;
- currentSprite->sprite = pathJoin(paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile"));
- currentSprite->variant = 0;
- mUnknown.upSprites.push_back(currentSprite);
-
- loadXmlFile(paths.getStringValue("horsesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("horsesPatchFile"), SkipError_true);
- loadXmlDir("horsesPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-static int parseDirectionName(const std::string &name)
-{
- int id = -1;
- if (name == "down")
- {
- id = SpriteDirection::DOWN;
- }
- else if (name == "downleft" || name == "leftdown")
- {
- id = SpriteDirection::DOWNLEFT;
- }
- else if (name == "left")
- {
- id = SpriteDirection::LEFT;
- }
- else if (name == "upleft" || name == "leftup")
- {
- id = SpriteDirection::UPLEFT;
- }
- else if (name == "up")
- {
- id = SpriteDirection::UP;
- }
- else if (name == "upright" || name == "rightup")
- {
- id = SpriteDirection::UPRIGHT;
- }
- else if (name == "right")
- {
- id = SpriteDirection::RIGHT;
- }
- else if (name == "downright" || name == "rightdown")
- {
- id = SpriteDirection::DOWNRIGHT;
- }
- // hack for died action.
- else if (name == "died")
- {
- id = 9;
- }
-
- return id;
-}
-
-static void loadRiderOffset(XmlNodePtrConst node,
- HorseInfo *const currentInfo)
-{
- const std::string dirName = XML::getProperty(node,
- "direction", "");
- const int dir = parseDirectionName(dirName);
- if (dir == -1)
- {
- reportAlways("Wrong or missing horse rider direcion: %s",
- dirName.c_str());
- return;
- }
- HorseOffset &offset = currentInfo->offsets[dir];
- offset.riderOffsetX = XML::getProperty(node,
- "riderOffsetX", 0);
- offset.riderOffsetY = XML::getProperty(node,
- "riderOffsetY", 0);
-}
-
-void HorseDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodePtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "horses"))
- {
- logger->log("Horse Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <emote>s
- for_each_xml_child_node(horseNode, rootNode)
- {
- if (xmlNameEqual(horseNode, "include"))
- {
- const std::string name = XML::getProperty(horseNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(horseNode, "horse"))
- {
- continue;
- }
-
- const int id = XML::getProperty(horseNode, "id", -1);
-
- if (id == -1)
- {
- reportAlways("Horse Database: Horse with missing ID in %s!",
- paths.getStringValue("horsesFile").c_str());
- continue;
- }
- HorseInfo *currentInfo = nullptr;
- if (mHorseInfos.find(id) != mHorseInfos.end())
- currentInfo = mHorseInfos[id];
- else
- currentInfo = new HorseInfo;
-
- if (currentInfo == nullptr)
- continue;
- for_each_xml_child_node(spriteNode, horseNode)
- {
- if (xmlNameEqual(spriteNode, "down"))
- loadDownSprites(spriteNode, currentInfo);
- else if (xmlNameEqual(spriteNode, "up"))
- loadUpSprites(spriteNode, currentInfo);
- else if (xmlNameEqual(spriteNode, "offset"))
- loadRiderOffset(spriteNode, currentInfo);
- }
- mHorseInfos[id] = currentInfo;
- }
-}
-
-static void loadOffset(XmlNodePtrConst node,
- HorseInfo *const currentInfo,
- const bool isUp)
-{
- const std::string dirName = XML::getProperty(node,
- "direction", "");
- const int dir = parseDirectionName(dirName);
- if (dir == -1)
- {
- reportAlways("Wrong or missing horse direcion: %s",
- dirName.c_str());
- return;
- }
- HorseOffset &offset = currentInfo->offsets[dir];
- if (isUp)
- {
- offset.upOffsetX = XML::getProperty(node,
- "horseOffsetX", 0);
- offset.upOffsetY = XML::getProperty(node,
- "horseOffsetY", 0);
- }
- else
- {
- offset.downOffsetX = XML::getProperty(node,
- "horseOffsetX", 0);
- offset.downOffsetY = XML::getProperty(node,
- "horseOffsetY", 0);
- }
-}
-
-static void loadDownSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo)
-{
- for_each_xml_child_node(spriteNode, parentNode)
- {
- if (xmlNameEqual(spriteNode, "offset"))
- loadOffset(spriteNode, currentInfo, false);
- if (!XmlHaveChildContent(spriteNode))
- continue;
- if (xmlNameEqual(spriteNode, "sprite"))
- loadSprite(downSprites)
- }
-}
-
-static void loadUpSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo)
-{
- for_each_xml_child_node(spriteNode, parentNode)
- {
- if (xmlNameEqual(spriteNode, "offset"))
- loadOffset(spriteNode, currentInfo, true);
- if (!XmlHaveChildContent(spriteNode))
- continue;
- if (xmlNameEqual(spriteNode, "sprite"))
- loadSprite(upSprites)
- }
-}
-
-void HorseDB::unload()
-{
- logger->log1("Unloading horse database...");
- FOR_EACH (HorseInfos::const_iterator, i, mHorseInfos)
- {
- delete_all(i->second->upSprites);
- delete_all(i->second->downSprites);
- delete i->second;
- }
- mHorseInfos.clear();
-
- delete_all(mUnknown.upSprites);
- delete_all(mUnknown.downSprites);
- mUnknown.upSprites.clear();
- mUnknown.downSprites.clear();
-
- mLoaded = false;
-}
-
-HorseInfo *HorseDB::get(const int id, const bool allowNull)
-{
- const HorseInfos::const_iterator i = mHorseInfos.find(id);
-
- if (i == mHorseInfos.end())
- {
- if (allowNull)
- return nullptr;
- reportAlways("HorseDB: Warning, unknown horse ID %d requested",
- id);
- return &mUnknown;
- }
- return i->second;
-}
-
-int HorseDB::size()
-{
- return static_cast<signed int>(mHorseInfos.size());
-}
diff --git a/src/resources/db/horsedb.h b/src/resources/db/horsedb.h
deleted file mode 100644
index 226e53213..000000000
--- a/src/resources/db/horsedb.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_HORSEDB_H
-#define RESOURCES_DB_HORSEDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct HorseInfo;
-
-typedef std::map<int, HorseInfo*> HorseInfos;
-
-/**
- * Horse information database.
- */
-namespace HorseDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void loadSpecialXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- HorseInfo *get(const int id,
- const bool allowNull = false) A_WARN_UNUSED;
-
- int size();
-
- typedef HorseInfos::iterator HorseInfosIterator;
-} // namespace HorseDB
-
-#endif // RESOURCES_DB_HORSEDB_H
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
deleted file mode 100644
index 274b44bb2..000000000
--- a/src/resources/db/itemdb.cpp
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/itemdb.h"
-
-#include "const/resources/map/map.h"
-
-#include "configuration.h"
-
-#include "enums/resources/spritedirection.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "resources/iteminfo.h"
-#include "resources/itemmenuitem.h"
-#include "resources/itemtypemapdata.h"
-
-#include "resources/db/itemfielddb.h"
-
-#include "resources/item/itemfieldtype.h"
-
-#include "resources/sprite/spritereference.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/stdmove.h"
-#include "utils/stringmap.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- ItemDB::ItemInfos mItemInfos;
- ItemDB::NamedItemInfos mNamedItemInfos;
- ItemInfo *mUnknown = nullptr;
- bool mLoaded = false;
- bool mConstructed = false;
- StringVect mTagNames;
- StringIntMap mTags;
- std::map<std::string, ItemSoundEvent::Type> mSoundNames;
- int mNumberOfHairstyles = 1;
-} // namespace
-
-// Forward declarations
-static void loadSpriteRef(ItemInfo *const itemInfo,
- XmlNodeConstPtr node) A_NONNULL(1);
-static void loadSoundRef(ItemInfo *const itemInfo,
- XmlNodeConstPtr node) A_NONNULL(1);
-static void loadFloorSprite(SpriteDisplay &display,
- XmlNodeConstPtrConst node);
-static void loadReplaceSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr replaceNode) A_NONNULL(1);
-static void loadOrderSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr node,
- const bool drawAfter) A_NONNULL(1);
-static int parseSpriteName(const std::string &name);
-static int parseDirectionName(const std::string &name);
-
-static ItemDbTypeT itemTypeFromString(const std::string &name)
-{
- const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemTypeMap &type = itemTypeMap[f];
- if (type.name == name)
- return type.type;
- }
- logger->log("Unknown item type: " + name);
- return ItemDbType::UNUSABLE;
-}
-
-static std::string useButtonFromItemType(const ItemDbTypeT &type)
-{
- const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemTypeMap &item = itemTypeMap[f];
- if (item.type == type)
- {
- if (item.useButton.empty())
- return std::string();
- return gettext(item.useButton.c_str());
- }
- }
- logger->log("Unknown item type");
- return std::string();
-}
-
-static std::string useButton2FromItemType(const ItemDbTypeT &type)
-{
- const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemTypeMap &item = itemTypeMap[f];
- if (item.type == type)
- {
- if (item.useButton2.empty())
- return std::string();
- return gettext(item.useButton2.c_str());
- }
- }
- logger->log("Unknown item type");
- return std::string();
-}
-
-static void readFields(std::string &effect,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields)
-{
- if (translator == nullptr)
- return;
-
- FOR_EACH (ItemFieldDb::FieldInfos::const_iterator, it, fields)
- {
- const std::string fieldName = (*it).first;
- const ItemFieldType *const field = (*it).second;
-
- std::string value = XML::getProperty(node,
- fieldName.c_str(),
- "");
- if (value.empty())
- continue;
- if (!effect.empty())
- effect.append(" / ");
- if (field->sign && isDigit(value))
- value = std::string("+").append(value);
- const std::string format = translator->getStr(field->description);
- effect.append(strprintf(format.c_str(),
- value.c_str()));
- }
-}
-
-static void initStatic()
-{
- mConstructed = true;
- mSoundNames["hit"] = ItemSoundEvent::HIT;
- mSoundNames["strike"] = ItemSoundEvent::MISS;
- mSoundNames["miss"] = ItemSoundEvent::MISS;
- mSoundNames["use"] = ItemSoundEvent::USE;
- mSoundNames["equip"] = ItemSoundEvent::EQUIP;
- mSoundNames["unequip"] = ItemSoundEvent::UNEQUIP;
- mSoundNames["drop"] = ItemSoundEvent::DROP;
- mSoundNames["pickup"] = ItemSoundEvent::PICKUP;
- mSoundNames["take"] = ItemSoundEvent::TAKE;
- mSoundNames["put"] = ItemSoundEvent::PUT;
- mSoundNames["usecard"] = ItemSoundEvent::USECARD;
-}
-
-void ItemDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing item database...");
-
- if (!mConstructed)
- initStatic();
-
- int tagNum = 0;
-
- mTags.clear();
- mTagNames.clear();
- mTagNames.push_back("All");
- mTagNames.push_back("Usable");
- mTagNames.push_back("Unusable");
- mTagNames.push_back("Equipment");
- mTags["All"] = tagNum ++;
- mTags["Usable"] = tagNum ++;
- mTags["Unusable"] = tagNum ++;
- mTags["Equipment"] = tagNum ++;
-
- mUnknown = new ItemInfo;
- // TRANSLATORS: item name
- mUnknown->setName(_("Unknown item"));
- mUnknown->setDisplay(SpriteDisplay());
- std::string errFile = paths.getStringValue("spriteErrorFile");
- mUnknown->setSprite(errFile, Gender::MALE, 0);
- mUnknown->setSprite(errFile, Gender::FEMALE, 0);
- mUnknown->setSprite(errFile, Gender::OTHER, 0);
- mUnknown->addTag(mTags["All"]);
- loadXmlFile(paths.getStringValue("itemsFile"),
- tagNum,
- SkipError_false);
- loadXmlFile(paths.getStringValue("itemsPatchFile"),
- tagNum,
- SkipError_true);
-
- StringVect list;
- VirtFs::getFilesInDir(paths.getStringValue("itemsPatchDir"),
- list,
- ".xml");
- FOR_EACH (StringVectCIter, it, list)
- loadXmlFile(*it, tagNum, SkipError_true);
-
- // Hairstyles are encoded as negative numbers. Count how far negative
- // we can go.
- int hairstyles = 1;
- while (ItemDB::exists(-hairstyles) &&
- ItemDB::get(-hairstyles).getSprite(Gender::MALE,
- BeingTypeId_zero) != paths.getStringValue("spriteErrorFile"))
- {
- hairstyles ++;
- }
- mNumberOfHairstyles = hairstyles;
-
- int races = 100;
- while (ItemDB::exists(-races) &&
- ItemDB::get(-races).getSprite(Gender::MALE, BeingTypeId_zero) !=
- paths.getStringValue("spriteErrorFile"))
- {
- races ++;
- }
-}
-
-static void loadMenu(XmlNodePtrConst parentNode,
- STD_VECTOR<ItemMenuItem> &menu)
-{
- for_each_xml_child_node(node, parentNode)
- {
- if (xmlNameEqual(node, "menu"))
- {
- const std::string name1 = XML::langProperty(node,
- "name1", "");
- const std::string name2 = XML::langProperty(node,
- "name2", "");
- const std::string command1 = XML::getProperty(node,
- "command1", "");
- const std::string command2 = XML::getProperty(node,
- "command2", command1);
- menu.push_back(ItemMenuItem(name1,
- name2,
- command1,
- command2));
- }
- }
-}
-
-static bool getIsEquipment(const ItemDbTypeT type)
-{
- switch (type)
- {
- case ItemDbType::EQUIPMENT_ONE_HAND_WEAPON:
- case ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON:
- case ItemDbType::EQUIPMENT_TORSO:
- case ItemDbType::EQUIPMENT_ARMS:
- case ItemDbType::EQUIPMENT_HEAD:
- case ItemDbType::EQUIPMENT_LEGS:
- case ItemDbType::EQUIPMENT_SHIELD:
- case ItemDbType::EQUIPMENT_RING:
- case ItemDbType::EQUIPMENT_NECKLACE:
- case ItemDbType::EQUIPMENT_FEET:
- case ItemDbType::EQUIPMENT_AMMO:
- case ItemDbType::EQUIPMENT_CHARM:
- return true;
- case ItemDbType::UNUSABLE:
- case ItemDbType::USABLE:
- case ItemDbType::CARD:
- case ItemDbType::SPRITE_RACE:
- case ItemDbType::SPRITE_HAIR:
- default:
- return false;
- }
-}
-
-void ItemDB::loadXmlFile(const std::string &fileName,
- int &tagNum,
- const SkipError skipError)
-{
- if (fileName.empty())
- {
- mLoaded = true;
- return;
- }
-
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "items"))
- {
- logger->log("ItemDB: Error while loading %s!", fileName.c_str());
- mLoaded = true;
- return;
- }
-
- const ItemFieldDb::FieldInfos &requiredFields =
- ItemFieldDb::getRequiredFields();
- const ItemFieldDb::FieldInfos &addFields =
- ItemFieldDb::getAddFields();
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, tagNum, skipError);
- continue;
- }
- if (!xmlNameEqual(node, "item"))
- continue;
-
- const int id = XML::getProperty(node, "id", 0);
- ItemInfo *itemInfo = nullptr;
-
- if (id == 0)
- {
- reportAlways("ItemDB: Invalid or missing item ID in %s!",
- fileName.c_str());
- continue;
- }
- else if (mItemInfos.find(id) != mItemInfos.end())
- {
- logger->log("ItemDB: Redefinition of item ID %d", id);
- itemInfo = mItemInfos[id];
- }
- if (itemInfo == nullptr)
- itemInfo = new ItemInfo;
-
- const std::string typeStr = XML::getProperty(node, "type", "");
- int weight = XML::getProperty(node, "weight", 0);
- int view = XML::getProperty(node, "view", 0);
- const int cardColor = XML::getProperty(node, "cardColor", -1);
- const int inherit = XML::getProperty(node, "inherit", -1);
-
- std::string name = XML::langProperty(node, "name", "");
- std::string nameEn = XML::getProperty(node, "name", "");
- std::string image = XML::getProperty(node, "image", "");
- std::string floor = XML::getProperty(node, "floor", "");
- std::string description = XML::langProperty(node, "description", "");
- std::string attackAction = XML::getProperty(node, "attack-action", "");
- std::string skyAttackAction = XML::getProperty(
- node, "skyattack-action", "");
- std::string waterAttackAction = XML::getProperty(
- node, "waterattack-action", "");
- std::string rideAttackAction = XML::getProperty(
- node, "rideattack-action", "");
- std::string drawBefore = XML::getProperty(node, "drawBefore", "");
- std::string drawAfter = XML::getProperty(node, "drawAfter", "");
- const int maxFloorOffset = XML::getIntProperty(
- node, "maxFloorOffset", mapTileSize, 0, mapTileSize);
- const int maxFloorOffsetX = XML::getIntProperty(
- node, "maxFloorOffsetX", maxFloorOffset, 0, mapTileSize);
- const int maxFloorOffsetY = XML::getIntProperty(
- node, "maxFloorOffsetY", maxFloorOffset, 0, mapTileSize);
- std::string useButton = XML::langProperty(node, "useButton", "");
- std::string useButton2 = XML::langProperty(node, "useButton2", "");
- std::string colors = XML::getProperty(node, "colors", "");
- std::string iconColors = XML::getProperty(node, "iconColors", "");
- if (iconColors.empty())
- iconColors = colors;
-
- // check for empty hair palete
- if (id <= -1 && id > -100)
- {
- if (colors.empty())
- colors = "hair";
- if (iconColors.empty())
- iconColors = "hair";
- }
-
- std::string tags[3];
- tags[0] = XML::getProperty(node, "tag",
- XML::getProperty(node, "tag1", ""));
- tags[1] = XML::getProperty(node, "tag2", "");
- tags[2] = XML::getProperty(node, "tag3", "");
-
- const int drawPriority = XML::getProperty(node, "drawPriority", 0);
-
- int attackRange = XML::getProperty(node, "attack-range", 0);
- std::string missileParticle = XML::getProperty(
- node, "missile-particle", "");
- float missileZ = XML::getFloatProperty(
- node, "missile-z", 32.0f);
- int missileLifeTime = XML::getProperty(
- node, "missile-lifetime", 500);
- float missileSpeed = XML::getFloatProperty(
- node, "missile-speed", 7.0f);
- float missileDieDistance = XML::getFloatProperty(
- node, "missile-diedistance", 8.0f);
- int hitEffectId = XML::getProperty(node, "hit-effect-id",
- paths.getIntValue("hitEffectId"));
- int criticalEffectId = XML::getProperty(
- node, "critical-hit-effect-id",
- paths.getIntValue("criticalHitEffectId"));
- int missEffectId = XML::getProperty(node, "miss-effect-id",
- paths.getIntValue("missEffectId"));
-
- SpriteDisplay display;
- display.image = image;
- if (!floor.empty())
- display.floor = STD_MOVE(floor);
- else
- display.floor = image;
-
- const ItemInfo *inheritItemInfo = nullptr;
-
- if (inherit >= 0)
- {
- if (mItemInfos.find(inherit) != mItemInfos.end())
- {
- inheritItemInfo = mItemInfos[inherit];
- }
- else
- {
- reportAlways("Inherit item %d from not existing item %d",
- id,
- inherit);
- }
- }
-
- itemInfo->setId(id);
- if (name.empty() && (inheritItemInfo != nullptr))
- name = inheritItemInfo->getName();
- // TRANSLATORS: item info name
- itemInfo->setName(name.empty() ? _("unnamed") : name);
- if (nameEn.empty())
- {
- // TRANSLATORS: item info name
- itemInfo->setNameEn(name.empty() ? _("unnamed") : name);
- }
- else
- {
- itemInfo->setNameEn(nameEn);
- }
-
- if (description.empty() && (inheritItemInfo != nullptr))
- description = inheritItemInfo->getDescription();
- itemInfo->setDescription(description);
- if (typeStr.empty())
- {
- if (inheritItemInfo != nullptr)
- itemInfo->setType(inheritItemInfo->getType());
- else
- itemInfo->setType(itemTypeFromString("other"));
- }
- else
- {
- itemInfo->setType(itemTypeFromString(typeStr));
- }
- itemInfo->setType(itemTypeFromString(typeStr));
- if (useButton.empty() && (inheritItemInfo != nullptr))
- useButton = inheritItemInfo->getUseButton();
- if (useButton.empty())
- useButton = useButtonFromItemType(itemInfo->getType());
- itemInfo->setUseButton(useButton);
- if (useButton2.empty() && (inheritItemInfo != nullptr))
- useButton2 = inheritItemInfo->getUseButton();
- if (useButton2.empty())
- useButton2 = useButton2FromItemType(itemInfo->getType());
- itemInfo->setUseButton2(useButton2);
- itemInfo->addTag(mTags["All"]);
- itemInfo->setProtected(XML::getBoolProperty(
- node, "sellProtected", false));
- if (cardColor != -1)
- itemInfo->setCardColor(fromInt(cardColor, ItemColor));
- else if (inheritItemInfo != nullptr)
- itemInfo->setCardColor(inheritItemInfo->getCardColor());
-
- switch (itemInfo->getType())
- {
- case ItemDbType::USABLE:
- itemInfo->addTag(mTags["Usable"]);
- break;
- case ItemDbType::CARD:
- case ItemDbType::UNUSABLE:
- itemInfo->addTag(mTags["Unusable"]);
- break;
- default:
- case ItemDbType::EQUIPMENT_ONE_HAND_WEAPON:
- case ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON:
- case ItemDbType::EQUIPMENT_TORSO:
- case ItemDbType::EQUIPMENT_ARMS:
- case ItemDbType::EQUIPMENT_HEAD:
- case ItemDbType::EQUIPMENT_LEGS:
- case ItemDbType::EQUIPMENT_SHIELD:
- case ItemDbType::EQUIPMENT_RING:
- case ItemDbType::EQUIPMENT_NECKLACE:
- case ItemDbType::EQUIPMENT_FEET:
- case ItemDbType::EQUIPMENT_AMMO:
- case ItemDbType::EQUIPMENT_CHARM:
- case ItemDbType::SPRITE_RACE:
- case ItemDbType::SPRITE_HAIR:
- itemInfo->addTag(mTags["Equipment"]);
- break;
- }
- for (int f = 0; f < 3; f++)
- {
- if (!tags[f].empty())
- {
- if (mTags.find(tags[f]) == mTags.end())
- {
- mTagNames.push_back(tags[f]);
- mTags[tags[f]] = tagNum ++;
- }
- itemInfo->addTag(mTags[tags[f]]);
- }
- }
-
- std::string effect;
- readFields(effect, node, requiredFields);
- readFields(effect, node, addFields);
- std::string temp = XML::langProperty(node, "effect", "");
- if (!effect.empty() && !temp.empty())
- effect.append(" / ");
- effect.append(temp);
-
- if (inheritItemInfo != nullptr)
- {
- if (view == 0)
- view = inheritItemInfo->getView();
- if (weight == 0)
- weight = inheritItemInfo->getWeight();
- if (attackAction.empty())
- attackAction = inheritItemInfo->getAttackAction();
- if (skyAttackAction.empty())
- skyAttackAction = inheritItemInfo->getSkyAttackAction();
- if (waterAttackAction.empty())
- waterAttackAction = inheritItemInfo->getWaterAttackAction();
- if (rideAttackAction.empty())
- rideAttackAction = inheritItemInfo->getRideAttackAction();
- if (attackRange == 0)
- attackRange = inheritItemInfo->getAttackRange();
- if (hitEffectId == 0)
- hitEffectId = inheritItemInfo->getHitEffectId();
- if (criticalEffectId == 0)
- criticalEffectId = inheritItemInfo->getCriticalHitEffectId();
- if (missEffectId == 0)
- missEffectId = inheritItemInfo->getMissEffectId();
- if (colors.empty())
- colors = inheritItemInfo->getColorsListName();
- if (iconColors.empty())
- iconColors = inheritItemInfo->getIconColorsListName();
- if (effect.empty())
- effect = inheritItemInfo->getEffect();
-
- const MissileInfo &inheritMissile =
- inheritItemInfo->getMissileConst();
- if (missileParticle.empty())
- missileParticle = inheritMissile.particle;
- if (missileZ == 32.0F)
- missileZ = inheritMissile.z;
- if (missileLifeTime == 500)
- missileLifeTime = inheritMissile.lifeTime;
- if (missileSpeed == 7.0F)
- missileSpeed = inheritMissile.speed;
- if (missileDieDistance == 8.0F)
- missileDieDistance = inheritMissile.dieDistance;
- }
-
- itemInfo->setView(view);
- itemInfo->setWeight(weight);
- itemInfo->setAttackAction(attackAction);
- itemInfo->setSkyAttackAction(skyAttackAction);
- itemInfo->setWaterAttackAction(waterAttackAction);
- itemInfo->setRideAttackAction(rideAttackAction);
- itemInfo->setAttackRange(attackRange);
- itemInfo->setHitEffectId(hitEffectId);
- itemInfo->setCriticalHitEffectId(criticalEffectId);
- itemInfo->setMissEffectId(missEffectId);
- itemInfo->setDrawBefore(-1, parseSpriteName(drawBefore));
- itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter));
- itemInfo->setDrawPriority(-1, drawPriority);
- itemInfo->setColorsList(colors);
- itemInfo->setIconColorsList(iconColors);
- itemInfo->setMaxFloorOffsetX(maxFloorOffsetX);
- itemInfo->setMaxFloorOffsetY(maxFloorOffsetY);
- itemInfo->setPickupCursor(XML::getProperty(
- node, "pickupCursor", "pickup"));
- itemInfo->setEffect(effect);
-
- MissileInfo &missile = itemInfo->getMissile();
- missile.particle = STD_MOVE(missileParticle);
- missile.z = missileZ;
- missile.lifeTime = missileLifeTime;
- missile.speed = missileSpeed;
- missile.dieDistance = missileDieDistance;
-
- for_each_xml_child_node(itemChild, node)
- {
- if (xmlNameEqual(itemChild, "sprite"))
- {
- loadSpriteRef(itemInfo, itemChild);
- }
- else if (xmlNameEqual(itemChild, "particlefx"))
- {
- if (XmlHaveChildContent(itemChild))
- display.particles.push_back(XmlChildContent(itemChild));
- }
- else if (xmlNameEqual(itemChild, "sound"))
- {
- loadSoundRef(itemInfo, itemChild);
- }
- else if (xmlNameEqual(itemChild, "floor"))
- {
- loadFloorSprite(display, itemChild);
- }
- else if (xmlNameEqual(itemChild, "replace"))
- {
- loadReplaceSprite(itemInfo, itemChild);
- }
- else if (xmlNameEqual(itemChild, "drawAfter"))
- {
- loadOrderSprite(itemInfo, itemChild, true);
- }
- else if (xmlNameEqual(itemChild, "drawBefore"))
- {
- loadOrderSprite(itemInfo, itemChild, false);
- }
- else if (xmlNameEqual(itemChild, "inventory"))
- {
- loadMenu(itemChild, itemInfo->getInventoryMenu());
- }
- else if (xmlNameEqual(itemChild, "storage"))
- {
- loadMenu(itemChild, itemInfo->getStorageMenu());
- }
- else if (xmlNameEqual(itemChild, "cart"))
- {
- loadMenu(itemChild, itemInfo->getCartMenu());
- }
- }
-
-/*
- logger->log("start dump item: %d", id);
- if (itemInfo->isRemoveSprites())
- {
- for (int f = 0; f < 10; f ++)
- {
- logger->log("dir: %d", f);
- SpriteToItemMap *const spriteToItems
- = itemInfo->getSpriteToItemReplaceMap(f);
- if (!spriteToItems)
- {
- logger->log("null");
- continue;
- }
- for (SpriteToItemMapCIter itr = spriteToItems->begin(),
- itr_end = spriteToItems->end(); itr != itr_end; ++ itr)
- {
- const int remSprite = itr->first;
- const IntMap &itemReplacer = itr->second;
- logger->log("sprite: %d", remSprite);
-
- for (IntMapCIter repIt = itemReplacer.begin(),
- repIt_end = itemReplacer.end();
- repIt != repIt_end; ++ repIt)
- {
- logger->log("from %d to %d", repIt->first,
- repIt->second);
- }
- }
- }
- }
-
- logger->log("--------------------------------");
- logger->log("end dump item");
-*/
-
- itemInfo->setDisplay(display);
-
- mItemInfos[id] = itemInfo;
- if (!name.empty())
- {
- temp = normalize(name);
- mNamedItemInfos[temp] = itemInfo;
- }
- if (!nameEn.empty())
- {
- temp = normalize(nameEn);
- mNamedItemInfos[temp] = itemInfo;
- }
-
- if (!attackAction.empty())
- {
- if (attackRange == 0)
- {
- reportAlways("ItemDB: Missing attack range from weapon %i!",
- id);
- }
- }
-
- STD_VECTOR<ItemMenuItem> &inventoryMenu = itemInfo->getInventoryMenu();
-
- if (inventoryMenu.empty())
- {
- std::string name1 = itemInfo->getUseButton();
- std::string name2 = itemInfo->getUseButton2();
- const bool isEquipment = getIsEquipment(itemInfo->getType());
-
- if (isEquipment)
- {
- if (name1.empty())
- {
- // TRANSLATORS: popup menu item
- name1 = _("Equip");
- }
- if (name2.empty())
- {
- // TRANSLATORS: popup menu item
- name2 = _("Unequip");
- }
- }
- else
- {
- if (name1.empty())
- {
- // TRANSLATORS: popup menu item
- name1 = _("Use");
- }
- if (name2.empty())
- {
- // TRANSLATORS: popup menu item
- name2 = _("Use");
- }
- }
- inventoryMenu.push_back(ItemMenuItem(
- name1,
- name2,
- "useinv 'INVINDEX'",
- "useinv 'INVINDEX'"));
- }
-
-#define CHECK_PARAM(param) \
- if (param.empty()) \
- { \
- logger->log("ItemDB: Missing " #param " attribute for item %i!", \
- id); \
- }
-
- if (id >= 0 && typeStr != "other")
- {
- CHECK_PARAM(name)
- CHECK_PARAM(description)
- CHECK_PARAM(image)
- }
-#undef CHECK_PARAM
- }
-
- mLoaded = true;
-}
-
-const StringVect &ItemDB::getTags()
-{
- return mTagNames;
-}
-
-int ItemDB::getTagId(const std::string &tagName)
-{
- return mTags[tagName];
-}
-
-void ItemDB::unload()
-{
- logger->log1("Unloading item database...");
-
- delete2(mUnknown);
-
- delete_all(mItemInfos);
- mItemInfos.clear();
- mNamedItemInfos.clear();
- mTags.clear();
- mTagNames.clear();
- mLoaded = false;
-}
-
-bool ItemDB::exists(const int id)
-{
- if (!mLoaded)
- return false;
-
- const ItemInfos::const_iterator i = mItemInfos.find(id);
- return i != mItemInfos.end();
-}
-
-bool ItemDB::exists(const std::string &name)
-{
- if (!mLoaded)
- return false;
-
- const NamedItemInfos::const_iterator i = mNamedItemInfos.find(
- normalize(name));
- return i != mNamedItemInfos.end();
-}
-
-const ItemInfo &ItemDB::get(const int id)
-{
- if (!mLoaded)
- load();
-
- const ItemInfos::const_iterator i = mItemInfos.find(id);
-
- if (i == mItemInfos.end())
- {
- reportAlways("ItemDB: Warning, unknown item ID# %d", id);
- return *mUnknown;
- }
-
- return *(i->second);
-}
-
-const ItemInfo &ItemDB::get(const std::string &name)
-{
- if (!mLoaded)
- load();
-
- const NamedItemInfos::const_iterator i = mNamedItemInfos.find(
- normalize(name));
-
- if (i == mNamedItemInfos.end())
- {
- if (!name.empty())
- {
- reportAlways("ItemDB: Warning, unknown item name \"%s\"",
- name.c_str());
- }
- return *mUnknown;
- }
-
- return *(i->second);
-}
-
-const ItemDB::ItemInfos &ItemDB::getItemInfos()
-{
- return mItemInfos;
-}
-
-const ItemInfo &ItemDB::getEmpty()
-{
- return *mUnknown;
-}
-
-static int parseSpriteName(const std::string &name)
-{
- int id = -1;
- if (name == "race" || name == "type")
- {
- id = 0;
- }
- else if (name == "shoes" || name == "boot" || name == "boots")
- {
- id = 1;
- }
- else if (name == "bottomclothes" || name == "bottom" || name == "pants")
- {
- id = 2;
- }
- else if (name == "topclothes" || name == "top"
- || name == "torso" || name == "body")
- {
- id = 3;
- }
- else if (name == "misc1")
- {
- id = 4;
- }
- else if (name == "misc2" || name == "scarf" || name == "scarfs")
- {
- id = 5;
- }
- else if (name == "hair")
- {
- id = 6;
- }
- else if (name == "hat" || name == "hats")
- {
- id = 7;
- }
- else if (name == "wings")
- {
- id = 8;
- }
- else if (name == "glove" || name == "gloves")
- {
- id = 9;
- }
- else if (name == "weapon" || name == "weapons")
- {
- id = 10;
- }
- else if (name == "shield" || name == "shields")
- {
- id = 11;
- }
- else if (name == "amulet" || name == "amulets")
- {
- id = 12;
- }
- else if (name == "ring" || name == "rings")
- {
- id = 13;
- }
-
- return id;
-}
-
-static int parseDirectionName(const std::string &name)
-{
- int id = -1;
- if (name == "down")
- {
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- id = -2;
- else
-#endif
- id = SpriteDirection::DOWN;
- }
- else if (name == "downleft" || name == "leftdown")
- {
- id = SpriteDirection::DOWNLEFT;
- }
- else if (name == "left")
- {
- id = SpriteDirection::LEFT;
- }
- else if (name == "upleft" || name == "leftup")
- {
- id = SpriteDirection::UPLEFT;
- }
- else if (name == "up")
- {
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- id = -3;
- else
-#endif
- id = SpriteDirection::UP;
- }
- else if (name == "upright" || name == "rightup")
- {
- id = SpriteDirection::UPRIGHT;
- }
- else if (name == "right")
- {
- id = SpriteDirection::RIGHT;
- }
- else if (name == "downright" || name == "rightdown")
- {
- id = SpriteDirection::DOWNRIGHT;
- }
- else if (name == "downall")
- {
- id = -2;
- }
- else if (name == "upall")
- {
- id = -3;
- }
- // hack for died action.
- else if (name == "died")
- {
- id = 9;
- }
-
- return id;
-}
-
-static void loadSpriteRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
-{
- const std::string gender = XML::getProperty(node, "gender", "unisex");
- if ((node == nullptr) || !XmlHaveChildContent(node))
- return;
-
- const std::string filename = XmlChildContent(node);
-
- const int race = XML::getProperty(node, "race", 0);
- if (gender == "male" || gender == "unisex")
- itemInfo->setSprite(filename, Gender::MALE, race);
- if (gender == "female" || gender == "unisex")
- itemInfo->setSprite(filename, Gender::FEMALE, race);
- if (gender == "other" || gender == "unisex")
- itemInfo->setSprite(filename, Gender::OTHER, race);
-}
-
-static void loadSoundRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
-{
- if (node == nullptr ||
- !XmlHaveChildContent(node))
- {
- return;
- }
- const std::string event = XML::getProperty(node, "event", "");
- const int delay = XML::getProperty(node, "delay", 0);
-
- const std::map<std::string, ItemSoundEvent::Type>::const_iterator
- it = mSoundNames.find(event);
- if (it != mSoundNames.end())
- {
- const std::string filename = XmlChildContent(node);
- itemInfo->addSound((*it).second, filename, delay);
- }
- else
- {
- reportAlways("ItemDB: Ignoring unknown sound event '%s'",
- event.c_str());
- }
-}
-
-static void loadFloorSprite(SpriteDisplay &display,
- XmlNodeConstPtrConst floorNode)
-{
- if (floorNode == nullptr)
- return;
- for_each_xml_child_node(spriteNode, floorNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant
- = XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- display.particles.push_back(XmlChildContent(spriteNode));
- }
- }
-}
-
-static void loadReplaceSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr replaceNode)
-{
- if (replaceNode == nullptr)
- return;
- const std::string removeSprite = XML::getProperty(
- replaceNode, "sprite", "");
- const int direction = parseDirectionName(XML::getProperty(
- replaceNode, "direction", "all"));
-
- itemInfo->setRemoveSprites();
-
- switch (direction)
- {
- case -1:
- {
- if (removeSprite.empty())
- { // remove all sprites
- for (int f = 0; f < 10; f ++)
- {
- for (int sprite = 0; sprite < 13; sprite ++)
- itemInfo->addReplaceSprite(sprite, f);
- }
- }
- else
- { // replace only given sprites
- for (int f = 0; f < 10; f ++)
- {
- IntMap *const mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), f);
- if (mapList == nullptr)
- continue;
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(
- itemNode, "from", 0);
- const int to = XML::getProperty(
- itemNode, "to", 1);
- (*mapList)[from] = to;
- }
- }
- }
- }
- break;
- }
- case -2:
- {
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWN);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNLEFT);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNRIGHT);
-
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
- IntMap *mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), SpriteDirection::DOWN);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNLEFT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNRIGHT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
- }
- }
- break;
- }
- case -3:
- {
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UP);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPLEFT);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPRIGHT);
-
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
- IntMap *mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), SpriteDirection::UP);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPLEFT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPRIGHT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
- }
- }
- break;
- }
- default:
- {
- IntMap *const mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), direction);
- if (mapList == nullptr)
- return;
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
- (*mapList)[from] = to;
- }
- }
- break;
- }
- }
-}
-
-static void loadOrderSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr node,
- const bool drawAfter)
-{
- const int sprite = parseSpriteName(XML::getProperty(node, "name", ""));
- const int priority = XML::getProperty(node, "priority", 0);
-
- const int direction = parseDirectionName(XML::getProperty(
- node, "direction", "all"));
- if (drawAfter)
- itemInfo->setDrawAfter(direction, sprite);
- else
- itemInfo->setDrawBefore(direction, sprite);
- itemInfo->setDrawPriority(direction, priority);
-}
-
-std::string ItemDB::getNamesStr(const STD_VECTOR<int> &parts)
-{
- std::string str;
- FOR_EACH (STD_VECTOR<int>::const_iterator, it, parts)
- {
- const int id = *it;
- if (exists(id))
- {
- if (!str.empty())
- str.append(",");
- str.append(get(id).getName());
- }
- }
- return str;
-}
-
-int ItemDB::getNumOfHairstyles()
-{
- return mNumberOfHairstyles;
-}
-
-#ifdef UNITTESTS
-ItemDB::NamedItemInfos &ItemDB::getNamedItemInfosTest()
-{
- return mNamedItemInfos;
-}
-
-ItemDB::ItemInfos &ItemDB::getItemInfosTest()
-{
- return mItemInfos;
-}
-#endif // UNITTESTS
diff --git a/src/resources/db/itemdb.h b/src/resources/db/itemdb.h
deleted file mode 100644
index 1515d3ba0..000000000
--- a/src/resources/db/itemdb.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_ITEMDB_H
-#define RESOURCES_DB_ITEMDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/stringvector.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-class ItemInfo;
-
-/**
- * Item information database.
- */
-namespace ItemDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- int &tagNum,
- const SkipError skipError);
-
- const StringVect &getTags();
-
- bool exists(const int id) A_WARN_UNUSED;
- bool exists(const std::string &name) A_WARN_UNUSED;
-
- const ItemInfo &get(const int id) A_WARN_UNUSED;
- const ItemInfo &get(const std::string &name) A_WARN_UNUSED;
-
- const ItemInfo &getEmpty() A_WARN_UNUSED;
-
- int getNumOfHairstyles() A_WARN_UNUSED;
-
- // Items database
- typedef std::map<int, ItemInfo*> ItemInfos;
- typedef std::map<std::string, ItemInfo*> NamedItemInfos;
-
- const ItemDB::ItemInfos &getItemInfos();
-
- std::string getNamesStr(const STD_VECTOR<int> &parts);
-
-#ifdef UNITTESTS
- ItemDB::NamedItemInfos &getNamedItemInfosTest();
-
- ItemDB::ItemInfos &getItemInfosTest();
-#endif // UNITTESTS
-
- int getTagId(const std::string &tagName) A_WARN_UNUSED;
-} // namespace ItemDB
-
-#endif // RESOURCES_DB_ITEMDB_H
diff --git a/src/resources/db/itemfielddb.cpp b/src/resources/db/itemfielddb.cpp
deleted file mode 100644
index 8a32ccc02..000000000
--- a/src/resources/db/itemfielddb.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/itemfielddb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "resources/beingcommon.h"
-
-#include "resources/item/itemfieldtype.h"
-
-#include "debug.h"
-
-namespace
-{
- ItemFieldDb::FieldInfos mRequiredInfos;
- ItemFieldDb::FieldInfos mAddInfos;
- bool mLoaded = false;
-} // namespace
-
-void ItemFieldDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing item field database...");
-
- loadXmlFile(paths.getStringValue("itemFieldsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("itemFieldsPatchFile"), SkipError_true);
- loadXmlDir("itemFieldsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static void loadFields(XmlNodeConstPtr groupNode,
- ItemFieldDb::FieldInfos &fields1,
- ItemFieldDb::FieldInfos &fields2)
-{
- for_each_xml_child_node(node, groupNode)
- {
- if (!xmlNameEqual(node, "field"))
- continue;
-
- const std::string name = XML::getProperty(node,
- "name",
- "");
- if (name.empty())
- {
- reportAlways("Empty name field in ItemFieldDb");
- continue;
- }
- const std::string description = XML::langProperty(node,
- "description",
- "");
- if (description.empty())
- {
- reportAlways("Empty description field in ItemFieldDb");
- continue;
- }
- const bool sign = XML::getBoolProperty(node,
- "signed",
- true);
- if (fields2.find(name) != fields2.end())
- {
- reportAlways(
- "Same field name detected in requeted and add groups: %s",
- name.c_str());
- continue;
- }
- if (fields1.find(name) != fields1.end())
- {
- reportAlways(
- "Same field name detected: %s",
- name.c_str());
- continue;
- }
- fields1[name] = new ItemFieldType(name,
- description,
- sign);
- }
-}
-
-void ItemFieldDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "itemfields"))
- {
- logger->log("ItemFieldDb: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (xmlNameEqual(node, "required"))
- loadFields(node, mRequiredInfos, mAddInfos);
- else if (xmlNameEqual(node, "add"))
- loadFields(node, mAddInfos, mRequiredInfos);
- }
-}
-
-void ItemFieldDb::unload()
-{
- logger->log1("Unloading item database...");
-
- delete_all(mRequiredInfos);
- mRequiredInfos.clear();
- delete_all(mAddInfos);
- mAddInfos.clear();
- mLoaded = false;
-}
-
-const ItemFieldDb::FieldInfos &ItemFieldDb::getRequiredFields()
-{
- return mRequiredInfos;
-}
-
-const ItemFieldDb::FieldInfos &ItemFieldDb::getAddFields()
-{
- return mAddInfos;
-}
diff --git a/src/resources/db/itemfielddb.h b/src/resources/db/itemfielddb.h
deleted file mode 100644
index 9ccbce0fa..000000000
--- a/src/resources/db/itemfielddb.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_ITEMFIELDDB_H
-#define RESOURCES_DB_ITEMFIELDDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemFieldType;
-
-namespace ItemFieldDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- typedef std::map<std::string, ItemFieldType*> FieldInfos;
-
- const FieldInfos &getRequiredFields();
-
- const FieldInfos &getAddFields();
-} // namespace ItemFieldDb
-
-#endif // RESOURCES_DB_ITEMFIELDDB_H
diff --git a/src/resources/db/itemoptiondb.cpp b/src/resources/db/itemoptiondb.cpp
deleted file mode 100644
index b138e7521..000000000
--- a/src/resources/db/itemoptiondb.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/itemoptiondb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "resources/db/itemfielddb.h"
-
-#include "debug.h"
-
-namespace
-{
- ItemOptionDb::OptionInfos mOptions;
- const STD_VECTOR<ItemFieldType*> mEmptyOption;
- bool mLoaded = false;
-} // namespace
-
-void ItemOptionDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing item options database...");
- loadXmlFile(paths.getStringValue("itemOptionsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("itemOptionsPatchFile"), SkipError_true);
- loadXmlDir("itemOptionsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static void addFieldByName(STD_VECTOR<ItemFieldType*> &options,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields,
- const char *const name)
-{
- std::string value = XML::getProperty(node, name, "");
- if (value.empty())
- return;
-
- FOR_EACH (ItemFieldDb::FieldInfos::const_iterator, it, fields)
- {
- const std::string fieldName = (*it).first;
- if (fieldName == value)
- {
- options.push_back((*it).second);
- return;
- }
- }
-}
-
-static void readOptionFields(STD_VECTOR<ItemFieldType*> &options,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields)
-{
- addFieldByName(options, node, fields, "field");
- for (int f = 0; f < 15; f ++)
- {
- const std::string field = strprintf("field%d", f);
- addFieldByName(options, node, fields, field.c_str());
- }
-}
-
-void ItemOptionDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "itemoptions"))
- {
- if (skipError == SkipError_true)
- {
- logger->log("ItemFieldDb: Error while loading %s!",
- fileName.c_str());
- }
- else
- {
- reportAlways("ItemFieldDb: Error while loading %s!",
- fileName.c_str());
- }
- return;
- }
-
- const ItemFieldDb::FieldInfos &requiredFields =
- ItemFieldDb::getRequiredFields();
- const ItemFieldDb::FieldInfos &addFields =
- ItemFieldDb::getAddFields();
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (xmlNameEqual(node, "option"))
- {
- const int id = XML::getProperty(node,
- "id",
- 0);
- if (id <= 0)
- {
- reportAlways("Empty id field in ItemOptionDb");
- continue;
- }
- STD_VECTOR<ItemFieldType*> &options = mOptions[id];
- readOptionFields(options, node, requiredFields);
- readOptionFields(options, node, addFields);
- }
- }
-}
-
-void ItemOptionDb::unload()
-{
- logger->log1("Unloading item options database...");
- mOptions.clear();
- mLoaded = false;
-}
-
-const STD_VECTOR<ItemFieldType*> &ItemOptionDb::getFields(const int id)
-{
- OptionInfos::const_iterator it = mOptions.find(id);
- if (it == mOptions.end())
- return mEmptyOption;
- return (*it).second;
-}
diff --git a/src/resources/db/itemoptiondb.h b/src/resources/db/itemoptiondb.h
deleted file mode 100644
index 8d9bc9968..000000000
--- a/src/resources/db/itemoptiondb.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_ITEMOPTIONDB_H
-#define RESOURCES_DB_ITEMOPTIONDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemFieldType;
-
-namespace ItemOptionDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- const STD_VECTOR<ItemFieldType*> &getFields(const int id);
-
- typedef std::map<int, STD_VECTOR<ItemFieldType*> > OptionInfos;
-} // namespace ItemOptionDb
-
-#endif // RESOURCES_DB_ITEMOPTIONDB_H
diff --git a/src/resources/db/languagedb.cpp b/src/resources/db/languagedb.cpp
deleted file mode 100644
index 8d04e5c2e..000000000
--- a/src/resources/db/languagedb.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/languagedb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- std::string mDefaultIcon;
- std::string mDefaultPo;
- std::map<int, std::string> mIcons;
- std::map<int, std::string> mPo;
-} // namespace
-
-void LanguageDb::load()
-{
- unload();
- logger->log1("Initializing languages database...");
- loadXmlFile(paths.getStringValue("languagesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("languagesPatchFile"), SkipError_true);
- loadXmlDir("languagesPatchDir", loadXmlFile);
-}
-
-void LanguageDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "languages"))
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "lang"))
- {
- const int id = XML::getProperty(node, "id", -1);
- if (id < 0)
- {
- reportAlways("Missing lang id");
- continue;
- }
- const std::string icon = XML::getProperty(node, "icon", "");
- const std::string po = XML::getProperty(node, "po", "");
- if (icon.empty())
- {
- reportAlways("LanguageDb: empty icon field");
- }
- else
- {
- mIcons[id] = icon;
- }
- if (po.empty())
- {
- reportAlways("LanguageDb: empty po field");
- }
- else
- {
- mPo[id] = po;
- }
- }
- }
-
- delete doc;
-}
-
-void LanguageDb::unload()
-{
- logger->log1("Unloading languages database...");
- mIcons.clear();
- mPo.clear();
-}
-
-const std::string &LanguageDb::getIcon(const int id)
-{
- std::map<int, std::string>::const_iterator it = mIcons.find(id);
- if (it == mIcons.end())
- return mDefaultIcon;
- return (*it).second;
-}
-
-const std::string &LanguageDb::getPo(const int id)
-{
- std::map<int, std::string>::const_iterator it = mPo.find(id);
- if (it == mPo.end())
- return mDefaultPo;
- return (*it).second;
-}
diff --git a/src/resources/db/languagedb.h b/src/resources/db/languagedb.h
deleted file mode 100644
index 6b73d455e..000000000
--- a/src/resources/db/languagedb.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_LANGUAGEDB_H
-#define RESOURCES_DB_LANGUAGEDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace LanguageDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- const std::string &getIcon(const int id);
-
- const std::string &getPo(const int id);
-} // namespace LanguageDb
-
-#endif // RESOURCES_DB_LANGUAGEDB_H
diff --git a/src/resources/db/mapdb.cpp b/src/resources/db/mapdb.cpp
deleted file mode 100644
index 2b5dd2185..000000000
--- a/src/resources/db/mapdb.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/mapdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- MapDB::Maps mMaps;
- MapDB::MapInfos mInfos;
- MapDB::Atlases mAtlases;
-} // namespace
-
-namespace MapDB
-{
- void readMap(XmlNodePtrConst node);
- void readAtlas(XmlNodePtrConst node);
-} // namespace MapDB
-
-void MapDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing maps database...");
- loadRemapXmlFile(paths.getStringValue("mapsRemapFile"),
- SkipError_true);
- loadRemapXmlFile(paths.getStringValue("mapsRemapPatchFile"),
- SkipError_true);
- loadXmlDir("mapsRemapPatchDir", loadRemapXmlFile);
-
- loadInfo(paths.getStringValue("mapsFile"), SkipError_false);
- loadInfo(paths.getStringValue("mapsPatchFile"), SkipError_true);
- loadXmlDir("mapsPatchDir", loadInfo);
- mLoaded = true;
-}
-
-void MapDB::loadRemapXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *const doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
-
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "map"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- continue;
-
- const std::string value = XML::getProperty(node, "value", "");
- if (value.empty())
- continue;
-
- mMaps[name] = value;
- }
- else if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadRemapXmlFile(name, skipError);
- continue;
- }
- }
-
- delete doc;
-}
-
-void MapDB::readMap(XmlNodePtrConst node)
-{
- if (node == nullptr)
- return;
- const std::string map = XML::getProperty(node, "name", "");
- if (map.empty())
- return;
-
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "atlas"))
- {
- const std::string atlas = XML::getProperty(childNode, "name", "");
- if (atlas.empty())
- continue;
- mInfos[map].atlas = atlas;
- }
- }
-}
-
-void MapDB::readAtlas(XmlNodePtrConst node)
-{
- if (node == nullptr)
- return;
- const std::string atlas = XML::getProperty(node, "name", "");
- if (atlas.empty())
- return;
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "file"))
- {
- const std::string file = XML::getProperty(childNode, "name", "");
- if (file.empty())
- continue;
- mAtlases[atlas].push_back(file);
- }
- }
- if (atlas != "all" && atlas != paths.getStringValue("emptyAtlasName"))
- {
- const AtlasCIter &allAtlas = mAtlases.find("all");
- if (allAtlas != mAtlases.end())
- {
- FOR_EACH (StringVectCIter, it, (*allAtlas).second)
- mAtlases[atlas].push_back(*it);
- }
- }
-}
-
-void MapDB::loadInfo(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "map"))
- {
- readMap(node);
- }
- else if (xmlNameEqual(node, "atlas"))
- {
- readAtlas(node);
- }
- else if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadInfo(name, skipError);
- continue;
- }
- }
- delete doc;
-}
-
-void MapDB::unload()
-{
- logger->log1("Unloading map database...");
-
- mMaps.clear();
- mLoaded = false;
-}
-
-const std::string MapDB::getMapName(const std::string &name)
-{
- const MapIterator it = mMaps.find(name);
-
- if (it != mMaps.end())
- return it->second;
- return name;
-}
-
-const MapInfo *MapDB::getMapAtlas(const std::string &name)
-{
- const MapInfoIter it = mInfos.find(name);
- if (it == mInfos.end())
- return nullptr;
- MapInfo *const info = &(*it).second;
- const AtlasCIter it2 = mAtlases.find(info->atlas);
- if (it2 == mAtlases.end())
- return nullptr;
- info->files = &((*it2).second);
- return info;
-}
-
-const MapInfo *MapDB::getAtlas(const std::string &name)
-{
- const AtlasCIter it = mAtlases.find(name);
- if (it == mAtlases.end())
- return nullptr;
-
- MapInfo *const info = new MapInfo;
- info->atlas = name;
- info->files = &(*it).second;
- return info;
-}
diff --git a/src/resources/db/mapdb.h b/src/resources/db/mapdb.h
deleted file mode 100644
index 09cc05c03..000000000
--- a/src/resources/db/mapdb.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_MAPDB_H
-#define RESOURCES_DB_MAPDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "resources/mapinfo.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-/**
- * Color information database.
- */
-namespace MapDB
-{
- /**
- * Loads the map remap data from <code>maps\remap.xml</code>.
- */
- void load();
-
- void loadRemapXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void loadInfo(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the remap data
- */
- void unload();
-
- const std::string getMapName(const std::string &name) A_WARN_UNUSED;
-
- const MapInfo *getMapAtlas(const std::string &name) A_WARN_UNUSED;
-
- const MapInfo *getAtlas(const std::string &name) A_WARN_UNUSED;
-
- // Maps DB
- typedef std::map<std::string, std::string> Maps;
- typedef Maps::iterator MapIterator;
- // map to infos map
- typedef std::map<std::string, MapInfo> MapInfos;
- typedef MapInfos::iterator MapInfoIter;
- // atlas to files map
- typedef std::map<std::string, StringVect> Atlases;
- typedef Atlases::iterator AtlasIter;
- typedef Atlases::const_iterator AtlasCIter;
-} // namespace MapDB
-
-#endif // RESOURCES_DB_MAPDB_H
diff --git a/src/resources/db/mercenarydb.cpp b/src/resources/db/mercenarydb.cpp
deleted file mode 100644
index befbdafea..000000000
--- a/src/resources/db/mercenarydb.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/mercenarydb.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mMercenaryInfos;
- bool mLoaded = false;
-} // namespace
-
-void MercenaryDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing mercenary database...");
- loadXmlFile(paths.getStringValue("mercenariesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("mercenariesPatchFile"), SkipError_true);
- loadXmlDir("mercenariesPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void MercenaryDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "mercenaries"))
- {
- logger->log("MercenaryDB: Error while loading %s!",
- paths.getStringValue("mercenariesFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode, "offset", 0);
-
- // iterate <mercenary>s
- for_each_xml_child_node(mercenaryNode, rootNode)
- {
- if (xmlNameEqual(mercenaryNode, "include"))
- {
- const std::string name = XML::getProperty(
- mercenaryNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(mercenaryNode, "mercenary"))
- continue;
-
- const int id = XML::getProperty(mercenaryNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mMercenaryInfos.find(fromInt(id + offset, BeingTypeId))
- != mMercenaryInfos.end())
- {
- logger->log("MercenaryDB: Redefinition of mercenary ID %d", id);
- currentInfo = mMercenaryInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- mercenaryNode, "name", _("unnamed")));
- BeingCommon::readBasicAttributes(currentInfo, mercenaryNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo, mercenaryNode, 0);
- BeingCommon::readAiAttributes(currentInfo, mercenaryNode);
-
- currentInfo->setMaxHP(XML::getProperty(mercenaryNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- mercenaryNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(mercenaryNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, mercenaryNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "MonsterDB");
- }
- currentInfo->setDisplay(display);
-
- mMercenaryInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void MercenaryDB::unload()
-{
- logger->log1("Unloading mercenary database...");
- delete_all(mMercenaryInfos);
- mMercenaryInfos.clear();
-
- mLoaded = false;
-}
-
-
-BeingInfo *MercenaryDB::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mMercenaryInfos.find(id);
-
- if (i == mMercenaryInfos.end())
- {
- i = mMercenaryInfos.find(id);
- if (i == mMercenaryInfos.end())
- {
- reportAlways("MercenaryDB: Warning, unknown mercenary ID "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/mercenarydb.h b/src/resources/db/mercenarydb.h
deleted file mode 100644
index 1058a8f9e..000000000
--- a/src/resources/db/mercenarydb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_MERCENARYDB_H
-#define RESOURCES_DB_MERCENARYDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Mercenary information database.
- */
-namespace MercenaryDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace MercenaryDB
-
-#endif // RESOURCES_DB_MERCENARYDB_H
diff --git a/src/resources/db/moddb.cpp b/src/resources/db/moddb.cpp
deleted file mode 100644
index 4e0be461f..000000000
--- a/src/resources/db/moddb.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/moddb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "resources/beingcommon.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- ModInfos mModInfos;
- bool mLoaded = false;
-} // namespace
-
-void ModDB::load()
-{
- if (mLoaded)
- unload();
- logger->log1("Initializing mod database...");
- loadXmlFile(paths.getStringValue("modsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("modsPatchFile"), SkipError_true);
- loadXmlDir("modsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void ModDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "mods"))
- {
- logger->log("Mods Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(modNode, rootNode)
- {
- if (xmlNameEqual(modNode, "include"))
- {
- const std::string name = XML::getProperty(modNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(modNode, "mod"))
- continue;
-
- const std::string name = XML::langProperty(
- // TRANSLATORS: unknown info name
- modNode, "name", _("unnamed"));
- ModInfo *currentInfo = nullptr;
- if (mModInfos.find(name) != mModInfos.end())
- currentInfo = mModInfos[name];
- if (currentInfo == nullptr)
- currentInfo = new ModInfo;
-
- currentInfo->setName(name);
- currentInfo->setDescription(XML::langProperty(
- modNode, "description", ""));
- currentInfo->setHelp(XML::getProperty(
- modNode, "help", ""));
- currentInfo->setLocalDir(XML::getProperty(
- modNode, "localdir", ""));
-
- mModInfos[name] = currentInfo;
- }
-}
-
-void ModDB::unload()
-{
- logger->log1("Unloading mod database...");
- delete_all(mModInfos);
- mModInfos.clear();
- mLoaded = false;
-}
-
-ModInfo *ModDB::get(const std::string &name)
-{
- const ModInfoIterator i = mModInfos.find(name);
- if (i == mModInfos.end())
- return nullptr;
- return i->second;
-}
-
-const ModInfos &ModDB::getAll()
-{
- return mModInfos;
-}
diff --git a/src/resources/db/moddb.h b/src/resources/db/moddb.h
deleted file mode 100644
index d2a009e9c..000000000
--- a/src/resources/db/moddb.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_MODDB_H
-#define RESOURCES_DB_MODDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "resources/modinfo.h"
-
-#include "localconsts.h"
-
-namespace ModDB
-{
- void load();
-
- void unload();
-
- ModInfo *get(const std::string &name) A_WARN_UNUSED;
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- const ModInfos &getAll();
-} // namespace ModDB
-
-#endif // RESOURCES_DB_MODDB_H
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
deleted file mode 100644
index b6cdc4f53..000000000
--- a/src/resources/db/monsterdb.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/monsterdb.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-static const unsigned int OLD_TMWATHENA_OFFSET = 1002;
-
-namespace
-{
- BeingInfos mMonsterInfos;
- bool mLoaded = false;
-} // namespace
-
-void MonsterDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing monster database...");
- loadXmlFile(paths.getStringValue("monstersFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("monstersPatchFile"), SkipError_true);
- loadXmlDir("monstersPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void MonsterDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "monsters"))
- {
- logger->log("Monster Database: Error while loading %s!",
- paths.getStringValue("monstersFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode,
- "offset", OLD_TMWATHENA_OFFSET);
-
- // iterate <monster>s
- for_each_xml_child_node(monsterNode, rootNode)
- {
- if (xmlNameEqual(monsterNode, "include"))
- {
- const std::string name = XML::getProperty(monsterNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(monsterNode, "monster"))
- continue;
-
- const int id = XML::getProperty(monsterNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mMonsterInfos.find(fromInt(id + offset, BeingTypeId))
- != mMonsterInfos.end())
- {
- logger->log("MonsterDB: Redefinition of monster ID %d", id);
- currentInfo = mMonsterInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- monsterNode, "name", _("unnamed")));
-
- BeingCommon::readBasicAttributes(currentInfo, monsterNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo, monsterNode,
- BlockMask::MONSTERWALL);
-
- currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- monsterNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(monsterNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, monsterNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "MonsterDB");
- }
- currentInfo->setDisplay(display);
-
- mMonsterInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void MonsterDB::unload()
-{
- logger->log1("Unloading monster database...");
- delete_all(mMonsterInfos);
- mMonsterInfos.clear();
-
- mLoaded = false;
-}
-
-
-BeingInfo *MonsterDB::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mMonsterInfos.find(id);
-
- if (i == mMonsterInfos.end())
- {
- i = mMonsterInfos.find(fromInt(toInt(
- id, int) + OLD_TMWATHENA_OFFSET, BeingTypeId));
- if (i == mMonsterInfos.end())
- {
- reportAlways("MonsterDB: Warning, unknown monster ID %d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/monsterdb.h b/src/resources/db/monsterdb.h
deleted file mode 100644
index 076814e9d..000000000
--- a/src/resources/db/monsterdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_MONSTERDB_H
-#define RESOURCES_DB_MONSTERDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Monster information database.
- */
-namespace MonsterDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace MonsterDB
-
-#endif // RESOURCES_DB_MONSTERDB_H
diff --git a/src/resources/db/networkdb.cpp b/src/resources/db/networkdb.cpp
deleted file mode 100644
index 4ad9eb222..000000000
--- a/src/resources/db/networkdb.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/networkdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/xmlutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- NetworkInPacketInfos mInPackets;
- NetworkRemovePacketInfos mRemovePackets;
-} // namespace
-
-void NetworkDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing network database...");
- loadXmlFile(paths.getStringValue("networkFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("networkPatchFile"), SkipError_true);
- loadXmlDir("networkPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void NetworkDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- readXmlIntMap(fileName,
- "network",
- "inpackets",
- "fakepacket",
- "id",
- "len",
- mInPackets,
- skipError);
-
- readXmlIntVector(fileName,
- "network",
- "inpackets",
- "removepacket",
- "id",
- mRemovePackets,
- skipError);
-}
-
-void NetworkDb::unload()
-{
- logger->log1("Unloading network database...");
- mInPackets.clear();
- mRemovePackets.clear();
- mLoaded = false;
-}
-
-const NetworkInPacketInfos &NetworkDb::getFakePackets()
-{
- return mInPackets;
-}
-
-const NetworkRemovePacketInfos &NetworkDb::getRemovePackets()
-{
- return mRemovePackets;
-}
diff --git a/src/resources/db/networkdb.h b/src/resources/db/networkdb.h
deleted file mode 100644
index 0541f9c1f..000000000
--- a/src/resources/db/networkdb.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_NETWORKDB_H
-#define RESOURCES_DB_NETWORKDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <string>
-
-typedef std::map<int32_t, int32_t> NetworkInPacketInfos;
-typedef NetworkInPacketInfos::const_iterator NetworkInPacketInfosIter;
-typedef STD_VECTOR<int> NetworkRemovePacketInfos;
-typedef NetworkRemovePacketInfos::const_iterator NetworkRemovePacketInfosIter;
-
-namespace NetworkDb
-{
- /**
- * Loads the chars data.
- */
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the chars data
- */
- void unload();
-
- const NetworkInPacketInfos &getFakePackets();
-
- const NetworkRemovePacketInfos &getRemovePackets();
-} // namespace NetworkDb
-
-#endif // RESOURCES_DB_NETWORKDB_H
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp
deleted file mode 100644
index 26034de12..000000000
--- a/src/resources/db/npcdb.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/npcdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mNPCInfos;
- bool mLoaded = false;
-} // namespace
-
-void NPCDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing NPC database...");
-
- loadXmlFile(paths.getStringValue("npcsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("npcsPatchFile"), SkipError_true);
- loadXmlDir("npcsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void NPCDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "npcs"))
- {
- logger->log("NPC Database: Error while loading %s!",
- paths.getStringValue("npcsFile").c_str());
- mLoaded = true;
- return;
- }
-
- // iterate <npc>s
- for_each_xml_child_node(npcNode, rootNode)
- {
- if (xmlNameEqual(npcNode, "include"))
- {
- const std::string name = XML::getProperty(npcNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(npcNode, "npc"))
- continue;
-
- const BeingTypeId id = fromInt(XML::getProperty(
- npcNode, "id", 0), BeingTypeId);
- BeingInfo *currentInfo = nullptr;
- if (id == BeingTypeId_zero)
- {
- reportAlways("NPC Database: NPC with missing ID in %s!",
- paths.getStringValue("npcsFile").c_str());
- continue;
- }
- else if (mNPCInfos.find(id) != mNPCInfos.end())
- {
- logger->log("NpcDB: Redefinition of npc ID %d", toInt(id, int));
- currentInfo = mNPCInfos[id];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setTargetSelection(XML::getBoolProperty(npcNode,
- "targetSelection", true));
-
- BeingCommon::readBasicAttributes(currentInfo, npcNode, "talk");
- BeingCommon::readWalkingAttributes(currentInfo, npcNode, 0);
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(npcNode,
- "deadSortOffsetY", 31));
-
- currentInfo->setAvatarId(fromInt(XML::getProperty(
- npcNode, "avatar", 0), BeingTypeId));
-
- currentInfo->setAllowDelete(XML::getBoolProperty(npcNode,
- "allowDelete", true));
-
- const std::string currency = XML::getProperty(npcNode,
- "currency", "default");
- if (UnitsDb::existsCurrency(currency) == false)
- {
- reportAlways("Not found currency '%s' for npc %d",
- currency.c_str(),
- CAST_S32(id));
- }
- currentInfo->setCurrency(currency);
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, npcNode)
- {
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant =
- XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- display.particles.push_back(XmlChildContent(spriteNode));
- }
- else if (xmlNameEqual(spriteNode, "menu"))
- {
- std::string name = XML::langProperty(spriteNode, "name", "");
- std::string command = XML::getProperty(spriteNode,
- "command", "");
- currentInfo->addMenu(name, command);
- }
- }
-
- currentInfo->setDisplay(display);
- if (currentInfo->getMenu().empty())
- {
- // TRANSLATORS: npc context menu item
- currentInfo->addMenu(_("Talk"), "talk 'NAME'");
- // TRANSLATORS: npc context menu item
- currentInfo->addMenu(_("Buy"), "buy 'NAME'");
- // TRANSLATORS: npc context menu item
- currentInfo->addMenu(_("Sell"), "sell 'NAME'");
- }
- mNPCInfos[id] = currentInfo;
- }
-}
-
-void NPCDB::unload()
-{
- logger->log1("Unloading NPC database...");
- delete_all(mNPCInfos);
- mNPCInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *NPCDB::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mNPCInfos.find(id);
-
- if (i == mNPCInfos.end())
- {
- reportAlways("NPCDB: Warning, unknown NPC ID %d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- return i->second;
-}
-
-BeingTypeId NPCDB::getAvatarFor(const BeingTypeId id)
-{
- const BeingInfo *const info = get(id);
- if (info == nullptr)
- return BeingTypeId_zero;
- return info->getAvatarId();
-}
diff --git a/src/resources/db/npcdb.h b/src/resources/db/npcdb.h
deleted file mode 100644
index 248bd6039..000000000
--- a/src/resources/db/npcdb.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_NPCDB_H
-#define RESOURCES_DB_NPCDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-/**
- * NPC information database.
- */
-namespace NPCDB
-{
- void load();
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-
- BeingTypeId getAvatarFor(const BeingTypeId id);
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-} // namespace NPCDB
-
-#endif // RESOURCES_DB_NPCDB_H
diff --git a/src/resources/db/npcdialogdb.cpp b/src/resources/db/npcdialogdb.cpp
deleted file mode 100644
index 9d6825bfa..000000000
--- a/src/resources/db/npcdialogdb.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/npcdialogdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/npcdialoginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- NpcDialogDB::Dialogs mDialogs;
-} // namespace
-
-void NpcDialogDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Loading npc dialog database...");
- loadXmlFile(paths.getStringValue("npcDialogsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("npcDialogsPatchFile"), SkipError_true);
- loadXmlDir("npcDialogsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-static void loadNpcDialogMenu(NpcDialogInfo *const dialog,
- XmlNodeConstPtrConst node)
-{
- for_each_xml_child_node(childNode, node)
- {
- if (!xmlTypeEqual(childNode, XML_ELEMENT_NODE))
- continue;
-
- if (xmlNameEqual(childNode, "button"))
- {
- const std::string name = XML::getProperty(childNode, "name", "");
- const std::string value = XML::getProperty(childNode, "value", "");
- if (value.empty())
- continue;
-
- NpcButtonInfo *const button = new NpcButtonInfo;
- button->x = XML::getIntProperty(
- childNode, "x", 0, 0, 10000);
- button->y = XML::getIntProperty(
- childNode, "y", 0, 0, 10000);
- button->name = name;
- button->value = value;
- button->image = XML::getProperty(childNode, "image", "");
- if (button->name.empty() && button->image.empty())
- {
- reportAlways("Error: npc button without name or image");
- delete button;
- continue;
- }
- button->imageWidth = XML::getIntProperty(
- childNode, "imageWidth", 16, 1, 1000);
- button->imageHeight = XML::getIntProperty(
- childNode, "imageHeight", 16, 1, 1000);
- dialog->menu.buttons.push_back(button);
- }
- else if (xmlNameEqual(childNode, "image"))
- {
- const std::string image = XML::getProperty(childNode, "image", "");
- if (image.empty())
- {
- reportAlways("Error: no image attribute found in image tag.");
- continue;
- }
- NpcImageInfo *const imageInfo = new NpcImageInfo;
- imageInfo->name = image;
- imageInfo->x = XML::getIntProperty(
- childNode, "x", 0, 0, 10000);
- imageInfo->y = XML::getIntProperty(
- childNode, "y", 0, 0, 10000);
- dialog->menu.images.push_back(imageInfo);
- }
- else if (xmlNameEqual(childNode, "text"))
- {
- const std::string text = XML::getProperty(childNode, "text", "");
- if (text.empty())
- {
- reportAlways("Error: no text attribute found in text tag.");
- continue;
- }
- NpcTextInfo *const textInfo = new NpcTextInfo;
- textInfo->text = text;
- textInfo->x = XML::getIntProperty(
- childNode, "x", 0, 0, 10000);
- textInfo->y = XML::getIntProperty(
- childNode, "y", 0, 0, 10000);
- textInfo->width = XML::getIntProperty(
- childNode, "width", 20, 10, 10000);
- textInfo->height = XML::getIntProperty(
- childNode, "height", 20, 10, 10000);
- dialog->menu.texts.push_back(textInfo);
- }
- }
-}
-
-static void loadNpcDialogInventory(NpcDialogInfo *const dialog,
- XmlNodePtrConst node)
-{
- dialog->inventory.cell = XML::getProperty(node, "cell", "");
- dialog->inventory.columns = XML::getIntProperty(
- node, "columns", 10000, 1, 10000);
-}
-
-static void loadNpcDialog(NpcDialogInfo *const dialog,
- XmlNodeConstPtrConst node)
-{
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "menu"))
- {
- loadNpcDialogMenu(dialog, childNode);
- }
- else if (xmlNameEqual(childNode, "inventory"))
- {
- loadNpcDialogInventory(dialog, childNode);
- }
- }
-}
-
-void NpcDialogDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *const doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
-
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "dialog"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- continue;
-
- deleteDialog(name);
- NpcDialogInfo *const dialog = new NpcDialogInfo;
- dialog->name = name;
- dialog->hideText = XML::getBoolProperty(
- node, "hideText", false);
- mDialogs[name] = dialog;
- loadNpcDialog(dialog, node);
- }
- else if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- }
-
- delete doc;
-}
-
-void NpcDialogDB::deleteDialog(const std::string &name)
-{
- const DialogsIter it = mDialogs.find(name);
- if (it == mDialogs.end())
- return;
-
- NpcDialogInfo *dialog = (*it).second;
- delete_all(dialog->menu.buttons);
- delete_all(dialog->menu.images);
- delete_all(dialog->menu.texts);
- mDialogs.erase(it);
- delete dialog;
-}
-
-void NpcDialogDB::unload()
-{
- logger->log1("Unloading npc dialog database...");
-
- FOR_EACH (DialogsIter, it, mDialogs)
- {
- NpcDialogInfo *dialog = (*it).second;
- delete_all(dialog->menu.buttons);
- delete_all(dialog->menu.images);
- delete_all(dialog->menu.texts);
- delete dialog;
- }
- mDialogs.clear();
-
- mLoaded = false;
-}
-
-NpcDialogInfo *NpcDialogDB::getDialog(const std::string &name)
-{
- const DialogsIter it = mDialogs.find(name);
- if (it == mDialogs.end())
- return nullptr;
- return (*it).second;
-}
diff --git a/src/resources/db/npcdialogdb.h b/src/resources/db/npcdialogdb.h
deleted file mode 100644
index 8e6e241af..000000000
--- a/src/resources/db/npcdialogdb.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_NPCDIALOGDB_H
-#define RESOURCES_DB_NPCDIALOGDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct NpcDialogInfo;
-
-/**
- * Color information database.
- */
-namespace NpcDialogDB
-{
- /**
- * Loads the map remap data from <code>maps\remap.xml</code>.
- */
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the remap data
- */
- void unload();
-
- void deleteDialog(const std::string &name);
-
- NpcDialogInfo *getDialog(const std::string &name);
-
- typedef std::map<std::string, NpcDialogInfo*> Dialogs;
- typedef Dialogs::iterator DialogsIter;
-
-} // namespace NpcDialogDB
-
-#endif // RESOURCES_DB_NPCDIALOGDB_H
diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp
deleted file mode 100644
index d7ec6b78d..000000000
--- a/src/resources/db/palettedb.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/palettedb.h"
-
-#include "configuration.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/dye/dyecolor.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- std::map<std::string, DyeColor> mColors;
-} // namespace
-
-void PaletteDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing palette database...");
- loadPalette();
-}
-
-void PaletteDB::loadPalette()
-{
- mLoaded = true;
- StringVect lines;
- VirtFs::loadTextFile(paths.getStringValue("palettesDir") +
- paths.getStringValue("defaultPaletteFile"),
- lines);
- StringVectCIter it = lines.begin();
- if (it == lines.end())
- {
- logger->log("missing GIMP palette file");
- return;
- }
- if (*it != "GIMP Palette")
- {
- reportAlways("wrong GIMP palette file");
- return;
- }
- ++ it;
- // skip header
- while (it != lines.end())
- {
- const std::string line = *it;
- if (!line.empty() && line[0] == '#')
- break;
- ++ it;
- }
-
- char name[101];
-
- // process colors and ignore commets
- while (it != lines.end())
- {
- const std::string line = *it;
- ++ it;
-
- if (line.empty() || line[0] == '#')
- continue;
-
- unsigned int r;
- unsigned int g;
- unsigned int b;
-
- if (sscanf(line.c_str(), "%10u %10u %10u\t%100s",
- &r, &g, &b, name) == 4)
- {
- name[100] = 0;
- mColors[name] = DyeColor(CAST_U8(r),
- CAST_U8(g),
- CAST_U8(b));
- }
- }
-}
-
-void PaletteDB::unload()
-{
- logger->log1("Unloading palette database...");
- mColors.clear();
-}
-
-const DyeColor *PaletteDB::getColor(const std::string &name)
-{
- const std::map<std::string, DyeColor>::const_iterator it =
- mColors.find(name);
- if (it != mColors.end())
- return &(*it).second;
- return nullptr;
-}
diff --git a/src/resources/db/palettedb.h b/src/resources/db/palettedb.h
deleted file mode 100644
index 2dc54eb53..000000000
--- a/src/resources/db/palettedb.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_PALETTEDB_H
-#define RESOURCES_DB_PALETTEDB_H
-
-#include "localconsts.h"
-
-#include <string>
-
-struct DyeColor;
-
-namespace PaletteDB
-{
- void load();
- void unload();
- void loadPalette();
- const DyeColor *getColor(const std::string &name);
-
-} // namespace PaletteDB
-
-#endif // RESOURCES_DB_PALETTEDB_H
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
deleted file mode 100644
index 721b27bfb..000000000
--- a/src/resources/db/petdb.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/petdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mPETInfos;
- bool mLoaded = false;
-} // namespace
-
-void PETDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing PET database...");
- loadXmlFile(paths.getStringValue("petsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("petsPatchFile"), SkipError_true);
- loadXmlDir("petsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void PETDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "pets"))
- {
- logger->log("PET Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <pet>s
- for_each_xml_child_node(petNode, rootNode)
- {
- if (xmlNameEqual(petNode, "include"))
- {
- const std::string name = XML::getProperty(petNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(petNode, "pet"))
- {
- continue;
- }
-
- const BeingTypeId id = fromInt(XML::getProperty(
- petNode, "id", -1), BeingTypeId);
- if (id == BeingTypeId_negOne)
- {
- reportAlways("PET Database: PET with missing ID in %s!",
- paths.getStringValue("petsFile").c_str());
- continue;
- }
-
- BeingInfo *currentInfo = nullptr;
- if (mPETInfos.find(id) != mPETInfos.end())
- currentInfo = mPETInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setName(XML::langProperty(petNode,
- // TRANSLATORS: unknown info name
- "name", _("pet")));
-
- currentInfo->setTargetSelection(XML::getBoolProperty(petNode,
- "targetSelection", true));
-
- BeingCommon::readBasicAttributes(currentInfo, petNode, "talk");
- BeingCommon::readWalkingAttributes(currentInfo, petNode, 0);
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(petNode,
- "deadSortOffsetY", 31));
-
- const std::string returnMessage = XML::langProperty(petNode,
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet return to egg
- "removeMessage", _("Return to egg"));
- currentInfo->setString(0, returnMessage);
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, petNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant =
- XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- std::string particlefx = XmlChildContent(spriteNode);
- display.particles.push_back(particlefx);
- }
- }
-
- currentInfo->setDisplay(display);
-
- mPETInfos[id] = currentInfo;
- }
-}
-
-void PETDB::unload()
-{
- logger->log1("Unloading PET database...");
- delete_all(mPETInfos);
- mPETInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *PETDB::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mPETInfos.find(id);
-
- if (i == mPETInfos.end())
- {
- reportAlways("PETDB: Warning, unknown PET ID %d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- return i->second;
-}
diff --git a/src/resources/db/petdb.h b/src/resources/db/petdb.h
deleted file mode 100644
index 05d79d3eb..000000000
--- a/src/resources/db/petdb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_PETDB_H
-#define RESOURCES_DB_PETDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-namespace PETDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace PETDB
-
-#endif // RESOURCES_DB_PETDB_H
diff --git a/src/resources/db/questdb.cpp b/src/resources/db/questdb.cpp
deleted file mode 100644
index d932b656e..000000000
--- a/src/resources/db/questdb.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/questdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "utils/translation/podict.h"
-
-#include "resources/beingcommon.h"
-#include "resources/questeffect.h"
-#include "resources/questitem.h"
-
-#include "debug.h"
-
-namespace
-{
- // quest variables: var, (val1, val2, val3, time)
- NpcQuestVarMap mVars;
- // quests: var, quests
- std::map<int, STD_VECTOR<QuestItem*> > mQuests;
- STD_VECTOR<QuestEffect*> mAllEffects;
-} // namespace
-
-void QuestDb::load()
-{
- unload();
- logger->log1("Initializing quest database...");
- loadXmlFile(paths.getStringValue("questsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("questsPatchFile"), SkipError_true);
- loadXmlDir("questsPatchDir", loadXmlFile);
-}
-
-static void loadQuest(const int var,
- XmlNodeConstPtr node)
-{
- if (node == nullptr)
- return;
- QuestItem *const quest = new QuestItem;
- // TRANSLATORS: quests window quest name
- quest->name = XML::langProperty(node, "name", _("unknown"));
- quest->group = XML::getProperty(node, "group", "");
- std::string incompleteStr = XML::getProperty(node, "incomplete", "");
- std::string completeStr = XML::getProperty(node, "complete", "");
- if (incompleteStr.empty() && completeStr.empty())
- {
- logger->log("complete flags incorrect");
- delete quest;
- return;
- }
- splitToIntSet(quest->incomplete, incompleteStr, ',');
- splitToIntSet(quest->complete, completeStr, ',');
- if (quest->incomplete.empty() && quest->complete.empty())
- {
- logger->log("complete flags incorrect");
- delete quest;
- return;
- }
- if (quest->incomplete.empty() || quest->complete.empty())
- quest->broken = true;
-
- for_each_xml_child_node(dataNode, node)
- {
- if (!xmlTypeEqual(dataNode, XML_ELEMENT_NODE))
- continue;
- XmlChar *const data = reinterpret_cast<XmlChar*>(
- XmlNodeGetContent(dataNode));
- if (data == nullptr)
- continue;
- std::string str = translator->getStr(data);
- XmlFree(data);
-
- for (int f = 1; f < 100; f ++)
- {
- const std::string key = strprintf("text%d", f);
- const std::string val = XML::getProperty(dataNode,
- key.c_str(),
- "");
- if (val.empty())
- break;
- const std::string param = strprintf("{@@%d}", f);
- replaceAll(str, param, val);
- }
- replaceItemLinks(str);
- if (xmlNameEqual(dataNode, "text"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::TEXT,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "name"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::NAME,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "reward"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::REWARD,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "questgiver") ||
- xmlNameEqual(dataNode, "giver"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::GIVER,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "coordinates"))
- {
- const std::string str1 = toString(XML::getIntProperty(
- dataNode, "x", 0, 1, 1000));
- const std::string str2 = toString(XML::getIntProperty(
- dataNode, "y", 0, 1, 1000));
- quest->texts.push_back(QuestItemText(str,
- QuestType::COORDINATES,
- str1,
- str2));
- }
- else if (xmlNameEqual(dataNode, "npc"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::NPC,
- std::string(),
- std::string()));
- }
- }
- quest->var = var;
- mQuests[var].push_back(quest);
-}
-
-static void loadEffect(const int var,
- XmlNodeConstPtr node)
-{
- QuestEffect *const effect = new QuestEffect;
- effect->map = XML::getProperty(node, "map", "");
- effect->id = fromInt(XML::getProperty(node, "npc", -1), BeingTypeId);
- effect->effectId = XML::getProperty(node, "effect", -1);
- const std::string values = XML::getProperty(node, "value", "");
- splitToIntSet(effect->values, values, ',');
-
- if (effect->map.empty() || effect->id == BeingTypeId_negOne
- || effect->effectId == -1 || values.empty())
- {
- delete effect;
- return;
- }
- effect->var = var;
- mAllEffects.push_back(effect);
-}
-
-void QuestDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc.rootNode();
- if (root == nullptr)
- return;
-
- for_each_xml_child_node(varNode, root)
- {
- if (xmlNameEqual(varNode, "include"))
- {
- const std::string name = XML::getProperty(varNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(varNode, "var"))
- {
- const int id = XML::getProperty(varNode, "id", 0);
- if (id < 0)
- continue;
- mVars[id] = QuestVar();
- for_each_xml_child_node(questNode, varNode)
- {
- if (xmlNameEqual(questNode, "quest"))
- loadQuest(id, questNode);
- else if (xmlNameEqual(questNode, "effect"))
- loadEffect(id, questNode);
- }
- }
- }
-}
-
-
-void QuestDb::unload()
-{
- logger->log1("Unloading quest database...");
- for (std::map<int, STD_VECTOR<QuestItem*> >::iterator it
- = mQuests.begin(), it_end = mQuests.end(); it != it_end; ++ it)
- {
- STD_VECTOR<QuestItem*> &quests = (*it).second;
- for (STD_VECTOR<QuestItem*>::iterator it2 = quests.begin(),
- it2_end = quests.end(); it2 != it2_end; ++ it2)
- {
- delete *it2;
- }
- }
- delete_all(mAllEffects);
- mAllEffects.clear();
- mQuests.clear();
-}
-
-NpcQuestVarMap *QuestDb::getVars()
-{
- return &mVars;
-}
-
-std::map<int, STD_VECTOR<QuestItem*> > *QuestDb::getQuests()
-{
- return &mQuests;
-}
-
-STD_VECTOR<QuestEffect*> *QuestDb::getAllEffects()
-{
- return &mAllEffects;
-}
-
-std::string QuestDb::getName(const int id)
-{
- std::map<int, STD_VECTOR<QuestItem*> >::const_iterator it =
- mQuests.find(id);
- if (it == mQuests.end())
- {
- // TRANSLATORS: quests window quest name
- return _("unknown");
- }
- const STD_VECTOR<QuestItem*> &items = (*it).second;
- if (items.empty())
- {
- // TRANSLATORS: quests window quest name
- return _("unknown");
- }
- return items[0]->name;
-}
diff --git a/src/resources/db/questdb.h b/src/resources/db/questdb.h
deleted file mode 100644
index 865f917fe..000000000
--- a/src/resources/db/questdb.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_QUESTDB_H
-#define RESOURCES_DB_QUESTDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include "resources/questvar.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct QuestEffect;
-struct QuestItem;
-
-namespace QuestDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- NpcQuestVarMap *getVars();
-
- std::map<int, STD_VECTOR<QuestItem*> > *getQuests();
-
- STD_VECTOR<QuestEffect*> *getAllEffects();
-
- std::string getName(const int id);
-} // namespace QuestDb
-
-#endif // RESOURCES_DB_QUESTDB_H
diff --git a/src/resources/db/skillunitdb.cpp b/src/resources/db/skillunitdb.cpp
deleted file mode 100644
index 0150c4a16..000000000
--- a/src/resources/db/skillunitdb.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/skillunitdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mSkillUnitInfos;
- bool mLoaded = false;
-} // namespace
-
-void SkillUnitDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing skill unit database...");
- loadXmlFile(paths.getStringValue("skillUnitsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("skillUnitsPatchFile"), SkipError_true);
- loadXmlDir("skillUnitsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void SkillUnitDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "skillunits"))
- {
- logger->log("SkillUnitDb: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <skillunit>s
- for_each_xml_child_node(skillUnitNode, rootNode)
- {
- if (xmlNameEqual(skillUnitNode, "include"))
- {
- const std::string name = XML::getProperty(skillUnitNode,
- "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(skillUnitNode, "skillunit"))
- {
- continue;
- }
-
- const BeingTypeId id = fromInt(XML::getProperty(
- skillUnitNode, "id", -1), BeingTypeId);
- if (id == BeingTypeId_negOne)
- {
- reportAlways("SkillUnitDb: skill unit with missing ID in %s!",
- paths.getStringValue("skillUnitsFile").c_str());
- continue;
- }
-
- BeingInfo *currentInfo = nullptr;
- if (mSkillUnitInfos.find(id) != mSkillUnitInfos.end())
- currentInfo = mSkillUnitInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setName(XML::langProperty(skillUnitNode,
- // TRANSLATORS: unknown info name
- "name", _("skill")));
-
- currentInfo->setTargetSelection(XML::getBoolProperty(skillUnitNode,
- "targetSelection", true));
-
- BeingCommon::readBasicAttributes(currentInfo, skillUnitNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo, skillUnitNode, 0);
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(skillUnitNode,
- "deadSortOffsetY", 31));
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, skillUnitNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant =
- XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- std::string particlefx = XmlChildContent(spriteNode);
- display.particles.push_back(particlefx);
- }
- }
-
- currentInfo->setDisplay(display);
-
- mSkillUnitInfos[id] = currentInfo;
- }
-}
-
-void SkillUnitDb::unload()
-{
- logger->log1("Unloading skill unit database...");
- delete_all(mSkillUnitInfos);
- mSkillUnitInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *SkillUnitDb::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mSkillUnitInfos.find(id);
-
- if (i == mSkillUnitInfos.end())
- {
- reportAlways("SkillUnitDb: Warning, unknown skill unit id "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- return i->second;
-}
diff --git a/src/resources/db/skillunitdb.h b/src/resources/db/skillunitdb.h
deleted file mode 100644
index cdbd5354a..000000000
--- a/src/resources/db/skillunitdb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_SKILLUNITDB_H
-#define RESOURCES_DB_SKILLUNITDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-namespace SkillUnitDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace SkillUnitDb
-
-#endif // RESOURCES_DB_SKILLUNITDB_H
diff --git a/src/resources/db/sounddb.cpp b/src/resources/db/sounddb.cpp
deleted file mode 100644
index 7c9ecbdd0..000000000
--- a/src/resources/db/sounddb.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/sounddb.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "notifymanager.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- std::string mDefault;
- STD_VECTOR<std::string> mSounds;
-} // namespace
-
-void SoundDB::load()
-{
- unload();
- logger->log1("Initializing sound database...");
- loadXmlFile(paths.getStringValue("soundsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("soundsPatchFile"), SkipError_true);
- loadXmlDir("soundsPatchDir", loadXmlFile);
-}
-
-void SoundDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "sounds"))
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "sound"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- const int id = NotifyManager::getIndexBySound(name);
- if (id != 0)
- {
- const std::string value = XML::getProperty(node, "value", "");
- mSounds[id] = value;
- }
- }
- }
-
- delete doc;
-}
-
-void SoundDB::unload()
-{
- logger->log1("Unloading sound database...");
- mSounds.resize(NotifyTypes::TYPE_END);
- for (int f = 0; f < NotifyTypes::TYPE_END; f ++)
- mSounds[f].clear();
-}
-
-std::string &SoundDB::getSound(const int id)
-{
- if (id < 0 || id >= NotifyTypes::TYPE_END)
- return mDefault;
- return mSounds[id];
-}
diff --git a/src/resources/db/sounddb.h b/src/resources/db/sounddb.h
deleted file mode 100644
index dc6dddb0b..000000000
--- a/src/resources/db/sounddb.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_SOUNDDB_H
-#define RESOURCES_DB_SOUNDDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace SoundDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- std::string &getSound(const int id);
-} // namespace SoundDB
-
-#endif // RESOURCES_DB_SOUNDDB_H
diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp
deleted file mode 100644
index 08fef09d6..000000000
--- a/src/resources/db/statdb.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/statdb.h"
-
-#include "configuration.h"
-
-#include "enums/being/attributesstrings.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- STD_VECTOR<BasicStat> mBasicStats;
- std::map<std::string, STD_VECTOR<BasicStat> > mStats;
- STD_VECTOR<std::string> mPages;
-} // namespace
-
-void StatDb::addDefaultStats()
-{
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_STR,
- "str",
- // TRANSLATORS: player stat
- _("Strength")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_AGI,
- "agi",
- // TRANSLATORS: player stat
- _("Agility")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_VIT,
- "vit",
- // TRANSLATORS: player stat
- _("Vitality")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_INT,
- "int",
- // TRANSLATORS: player stat
- _("Intelligence")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_DEX,
- "dex",
- // TRANSLATORS: player stat
- _("Dexterity")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_LUK,
- "luk",
- // TRANSLATORS: player stat
- _("Luck")));
-}
-
-const STD_VECTOR<BasicStat> &StatDb::getBasicStats()
-{
- return mBasicStats;
-}
-
-const STD_VECTOR<BasicStat> &StatDb::getStats(const std::string &page)
-{
- return mStats[page];
-}
-
-const STD_VECTOR<std::string> &StatDb::getPages()
-{
- return mPages;
-}
-
-void StatDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing stat database...");
-
- loadXmlFile(paths.getStringValue("statFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("statPatchFile"), SkipError_true);
- loadXmlDir("statPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static void loadBasicStats(XmlNodeConstPtr rootNode)
-{
- const int maxAttr = static_cast<int>(Attributes::MAX_ATTRIBUTE);
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "stat"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- const std::string attr = XML::getProperty(node, "attr", "");
- if (attr.empty() || AttributesEnum::find(attr) == false)
- {
- const int id = XML::getProperty(node, "id", 0);
- if (id <= 0 || id >= maxAttr)
- {
- reportAlways("Wrong attr or id for basic "
- "stat with name %s",
- name.c_str());
- continue;
- }
- const std::string tag = XML::getProperty(node, "tag", "");
- mBasicStats.push_back(BasicStat(static_cast<AttributesT>(id),
- tag,
- name));
- }
- else
- {
- const std::string tag = XML::getProperty(node, "tag", "");
- mBasicStats.push_back(BasicStat(AttributesEnum::get(attr),
- tag,
- name));
- }
- }
- }
-}
-
-static void loadStats(XmlNodeConstPtr rootNode,
- const std::string &page)
-{
- const int maxAttr = static_cast<int>(Attributes::MAX_ATTRIBUTE);
- STD_VECTOR<BasicStat> &stats = mStats[page];
- mPages.push_back(page);
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "stat"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- const std::string attr = XML::getProperty(node, "attr", "");
- if (attr.empty() || AttributesEnum::find(attr) == false)
- {
- const int id = XML::getProperty(node, "id", 0);
- if (id <= 0 || id >= maxAttr)
- {
- reportAlways("Wrong attr or id for extended "
- "stat with name %s",
- name.c_str());
- continue;
- }
- stats.push_back(BasicStat(static_cast<AttributesT>(id),
- std::string(),
- name));
- }
- else
- {
- stats.push_back(BasicStat(AttributesEnum::get(attr),
- std::string(),
- name));
- }
- }
- }
-}
-
-void StatDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "stats"))
- {
- logger->log("StatDb: Error while loading %s!",
- fileName.c_str());
- if (skipError == SkipError_false)
- addDefaultStats();
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "basic"))
- {
- loadBasicStats(node);
- }
- else if (xmlNameEqual(node, "extended"))
- {
- // TRANSLATORS: stats page name
- loadStats(node, _("Extended"));
- }
- else if (xmlNameEqual(node, "page"))
- {
- std::string page = XML::langProperty(node, "name", "");
- if (page.empty())
- {
- reportAlways("Page without name in stats.xml");
- page = "Unknown";
- }
- loadStats(node, page);
- }
- }
- if (skipError == SkipError_false)
- {
- if (mBasicStats.empty() &&
- mStats.empty())
- {
- reportAlways("StatDb: no stats found");
- addDefaultStats();
- }
- }
-}
-
-void StatDb::unload()
-{
- logger->log1("Unloading stat database...");
-
- mBasicStats.clear();
- mStats.clear();
- mPages.clear();
- mLoaded = false;
-}
diff --git a/src/resources/db/statdb.h b/src/resources/db/statdb.h
deleted file mode 100644
index 73b24894b..000000000
--- a/src/resources/db/statdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_STATDB_H
-#define RESOURCES_DB_STATDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include "resources/basicstat.h"
-
-#include "localconsts.h"
-
-namespace StatDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void addDefaultStats();
-
- const STD_VECTOR<BasicStat> &getBasicStats();
-
- const STD_VECTOR<BasicStat> &getStats(const std::string &page);
-
- const STD_VECTOR<std::string> &getPages();
-} // namespace StatDb
-
-#endif // RESOURCES_DB_STATDB_H
diff --git a/src/resources/db/statuseffectdb.cpp b/src/resources/db/statuseffectdb.cpp
deleted file mode 100644
index b02c666d6..000000000
--- a/src/resources/db/statuseffectdb.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/statuseffectdb.h"
-
-#include "configuration.h"
-#include "settings.h"
-#include "statuseffect.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- typedef std::map<int, StatusEffect *> IdToEffectMap[2];
- bool mLoaded = false;
- int fakeId = 10000;
- IdToEffectMap statusEffects;
- OptionsMap optionToIdMap;
- OptionsMap opt1ToIdMap;
- OptionsMap opt2ToIdMap;
- OptionsMap opt3ToIdMap;
-
- OptionsMap blockIdToIdMap;
-} // namespace
-
-int StatusEffectDB::blockIdToId(const int blockIndex)
-{
- if (blockIdToIdMap.find(blockIndex) == blockIdToIdMap.end())
- return -1;
- return blockIdToIdMap[blockIndex];
-}
-
-StatusEffect *StatusEffectDB::getStatusEffect(const int index,
- const Enable enabling)
-{
- std::map<int, StatusEffect *> &effects
- = statusEffects[enabling == Enable_true];
- const std::map<int, StatusEffect *>::iterator it = effects.find(index);
- if (it != effects.end())
- return (*it).second;
- reportAlways("Missing status effect: %d",
- index);
- return nullptr;
-}
-
-void StatusEffectDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing status effect database...");
-
- loadXmlFile(paths.getStringValue("statusEffectsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("statusEffectsPatchFile"),
- SkipError_true);
- loadXmlDir("statusEffectsPatchDir", loadXmlFile);
-
- if (!blockIdToIdMap.empty())
- {
- reportAlways("Detected legacy attribute block-id "
- "in status-effects.xml");
- }
- mLoaded = true;
-}
-
-void StatusEffectDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "status-effects"))
- {
- logger->log("Error loading status effects file: " + fileName);
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string incName = XML::getProperty(node, "name", "");
- if (!incName.empty())
- loadXmlFile(incName, skipError);
- continue;
- }
- else if (!xmlNameEqual(node, "status-effect"))
- {
- continue;
- }
-
- int id = XML::getProperty(node, "id", -1);
-
- // legacy field. Only for clients 1.6.3.12 and older
- const int blockId = XML::getProperty(node, "block-id", -1);
- if (id >= 0 && blockId >= 0)
- blockIdToIdMap[blockId] = id;
-
- if (id == -1)
- {
- id = fakeId;
- fakeId ++;
- }
- const int option = XML::getProperty(node, "option", 0);
- const int opt1 = XML::getProperty(node, "opt1", 0);
- const int opt2 = XML::getProperty(node, "opt2", 0);
- const int opt3 = XML::getProperty(node, "opt3", 0);
- if (option != 0)
- {
- optionToIdMap[option] = id;
- settings.legacyEffects = false;
- }
- if (opt1 != 0)
- {
- opt1ToIdMap[opt1] = id;
- settings.legacyEffects = false;
- }
- if (opt2 != 0)
- {
- opt2ToIdMap[opt2] = id;
- settings.legacyEffects = false;
- }
- if (opt3 != 0)
- {
- opt3ToIdMap[opt3] = id;
- settings.legacyEffects = false;
- }
-
- StatusEffect *startEffect = statusEffects[1][id];
- StatusEffect *endEffect = statusEffects[0][id];
- const std::string name = XML::getProperty(node, "name", "");
- const std::string name2 = XML::langProperty(node, "name", "");
- if (startEffect == nullptr)
- startEffect = new StatusEffect;
- if (endEffect == nullptr)
- endEffect = new StatusEffect;
-
- startEffect->mName = name2;
- startEffect->mIsPoison =
- (name == paths.getStringValue("poisonEffectName"));
- startEffect->mIsCart =
- (name == paths.getStringValue("cartEffectName"));
- startEffect->mIsRiding =
- (name == paths.getStringValue("ridingEffectName"));
- startEffect->mIsTrickDead =
- (name == paths.getStringValue("trickDeadEffectName"));
- startEffect->mIsPostDelay =
- (name == paths.getStringValue("postDelayName"));
- startEffect->mMessage = XML::getProperty(
- node, "start-message", "");
- startEffect->mSFXEffect = XML::getProperty(
- node, "start-audio", "");
- startEffect->mStartParticleEffect = XML::getProperty(
- node, "start-particle", "");
- startEffect->mParticleEffect = XML::getProperty(
- node, "particle", "");
-
- startEffect->mIcon = XML::getProperty(node, "icon", "");
- startEffect->mAction = XML::getProperty(node, "action", "");
- startEffect->mIsPersistent = (XML::getProperty(
- node, "persistent-particle-effect", "no")) != "no";
-
- endEffect->mName = startEffect->mName;
- endEffect->mIsPoison = startEffect->mIsPoison;
- endEffect->mIsCart = startEffect->mIsCart;
- endEffect->mIsRiding = startEffect->mIsRiding;
- endEffect->mIsTrickDead = startEffect->mIsTrickDead;
- endEffect->mIsPostDelay = startEffect->mIsPostDelay;
- endEffect->mMessage = XML::getProperty(node, "end-message", "");
- endEffect->mSFXEffect = XML::getProperty(node, "end-audio", "");
- endEffect->mStartParticleEffect = XML::getProperty(
- node, "end-particle", "");
-
- statusEffects[1][id] = startEffect;
- statusEffects[0][id] = endEffect;
- }
-}
-
-static void unloadMap(std::map<int, StatusEffect *> &map)
-{
- for (std::map<int, StatusEffect *>::iterator it = map.begin();
- it != map.end(); ++it)
- {
- delete (*it).second;
- }
-
- map.clear();
-}
-
-void StatusEffectDB::unload()
-{
- if (!mLoaded)
- return;
-
- logger->log1("Unloading status effect database...");
-
- fakeId = 10000;
- unloadMap(statusEffects[0]);
- unloadMap(statusEffects[1]);
-
- optionToIdMap.clear();
- opt1ToIdMap.clear();
- opt2ToIdMap.clear();
- opt3ToIdMap.clear();
- blockIdToIdMap.clear();
-
- mLoaded = false;
-}
-
-const OptionsMap& StatusEffectDB::getOptionMap()
-{
- return optionToIdMap;
-}
-
-const OptionsMap& StatusEffectDB::getOpt1Map()
-{
- return opt1ToIdMap;
-}
-
-const OptionsMap& StatusEffectDB::getOpt2Map()
-{
- return opt2ToIdMap;
-}
-
-const OptionsMap& StatusEffectDB::getOpt3Map()
-{
- return opt3ToIdMap;
-}
diff --git a/src/resources/db/statuseffectdb.h b/src/resources/db/statuseffectdb.h
deleted file mode 100644
index 39af1f0e7..000000000
--- a/src/resources/db/statuseffectdb.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_STATUSEFFECTDB_H
-#define RESOURCES_DB_STATUSEFFECTDB_H
-
-#include "enums/simpletypes/enable.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class StatusEffect;
-
-typedef std::map<uint32_t, uint32_t> OptionsMap;
-typedef OptionsMap::const_iterator OptionsMapCIter;
-
-namespace StatusEffectDB
-{
- /**
- * Retrieves a status effect.
- *
- * \param index Index of the status effect.
- * \param enabling Whether to retrieve the activating effect (true) or
- * the deactivating effect (false).
- */
- StatusEffect *getStatusEffect(const int index,
- const Enable enabling) A_WARN_UNUSED;
-
- /**
- * Maps a block effect index to its corresponding effect index. Block
- * effect indices are used for opt2/opt3/status.option blocks; their
- * mapping to regular effect indices is handled in the config file.
- *
- * Returns -1 on failure.
- */
- int blockIdToId(const int blocKIndex) A_WARN_UNUSED;
-
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- const OptionsMap& getOptionMap();
-
- const OptionsMap& getOpt1Map();
-
- const OptionsMap& getOpt2Map();
-
- const OptionsMap& getOpt3Map();
-} // namespace StatusEffectDB
-
-#endif // RESOURCES_DB_STATUSEFFECTDB_H
diff --git a/src/resources/db/textdb.cpp b/src/resources/db/textdb.cpp
deleted file mode 100644
index cfd5faf76..000000000
--- a/src/resources/db/textdb.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/textdb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- StringVect mTexts;
-} // namespace
-
-void TextDb::load()
-{
- unload();
- logger->log1("Initializing text database...");
- loadXmlFile(paths.getStringValue("textsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("textsPatchFile"), SkipError_true);
- loadXmlDir("textsPatchDir", loadXmlFile);
-}
-
-void TextDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "texts"))
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "text"))
- {
- const bool show = XML::getBoolProperty(node, "show", false);
- if (show == true)
- {
- if (!XmlHaveChildContent(node))
- continue;
-
- std::string text = XmlChildContent(node);
- mTexts.push_back(text);
- }
- }
- }
-
- delete doc;
-}
-
-void TextDb::unload()
-{
- logger->log1("Unloading text database...");
- mTexts.clear();
-}
-
-const StringVect &TextDb::getTexts()
-{
- return mTexts;
-}
-
-std::string TextDb::getByIndex(const int index)
-{
- if (index < 0 ||
- static_cast<size_t>(index) >= mTexts.size())
- {
- return std::string();
- }
- return mTexts[index];
-}
diff --git a/src/resources/db/textdb.h b/src/resources/db/textdb.h
deleted file mode 100644
index 2eb438336..000000000
--- a/src/resources/db/textdb.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_TEXTDB_H
-#define RESOURCES_DB_TEXTDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace TextDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- std::string getByIndex(const int index);
-
- const StringVect &getTexts();
-
- void unload();
-} // namespace TextDb
-
-#endif // RESOURCES_DB_TEXTDB_H
diff --git a/src/resources/db/unitsdb.cpp b/src/resources/db/unitsdb.cpp
deleted file mode 100644
index a32786b84..000000000
--- a/src/resources/db/unitsdb.cpp
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/unitsdb.h"
-
-#include "configuration.h"
-
-#include "const/resources/currency.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/stdmove.h"
-
-#include "resources/beingcommon.h"
-
-#include <climits>
-
-#include "debug.h"
-
-namespace
-{
- struct UnitLevel final
- {
- A_DEFAULT_COPY(UnitLevel)
-
- std::string symbol;
- int count;
- int round;
- std::string separator;
- };
-
- struct UnitDescription final
- {
- A_DEFAULT_COPY(UnitDescription)
-
- STD_VECTOR<struct UnitLevel> levels;
- double conversion;
- bool mix;
- };
-
- UnitDescription defaultCurrency;
- UnitDescription defaultWeight;
-
- std::map<std::string, UnitDescription> mCurrencies;
-} // namespace
-
-static std::string formatUnit(const int value,
- const UnitDescription &ud);
-
-static std::string splitNumber(std::string str,
- const std::string &separator);
-
-void UnitsDb::load()
-{
- logger->log1("Initializing unit database...");
- { // Setup default weight
- UnitDescription ud;
-
- ud.conversion = 1.0;
- ud.mix = false;
-
- const UnitLevel bu =
- {
- "g",
- 1,
- 0,
- ""
- };
- ud.levels.push_back(bu);
-
- const UnitLevel ul =
- {
- "kg",
- 1000,
- 2,
- ""
- };
- ud.levels.push_back(ul);
-
- defaultWeight = ud;
- }
-
- { // Setup default currency
- UnitDescription ud;
-
- ud.conversion = 1.0;
- ud.mix = false;
-
- const UnitLevel bu = {"¤", 1, 0, ""};
- ud.levels.push_back(bu);
-
- defaultCurrency = ud;
- }
-
- loadXmlFile(paths.getStringValue("unitsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("unitsPatchFile"), SkipError_true);
- loadXmlDir("unitsPatchDir", loadXmlFile);
-}
-
-void UnitsDb::unload()
-{
- logger->log1("Unloading unit database...");
- mCurrencies.clear();
-}
-
-static UnitDescription loadUnit(XmlNodePtr node)
-{
- UnitDescription ud;
- int level = 1;
- ud.conversion = XML::getProperty(node, "conversion", 1);
- ud.mix = XML::getProperty(node, "mix", "no") == "yes";
-
- UnitLevel bu;
- bu.symbol = XML::getProperty(node, "base", "¤");
- bu.count = 1;
- bu.round = XML::getProperty(node, "round", 2);
- bu.separator = XML::getProperty(node, "separator", " ");
-
- ud.levels.push_back(bu);
-
- for_each_xml_child_node(uLevel, node)
- {
- if (xmlNameEqual(uLevel, "level"))
- {
- const UnitLevel ul =
- {
- XML::getProperty(uLevel, "symbol",
- strprintf("¤%d", level)),
- XML::getProperty(uLevel, "count", -1),
- XML::getProperty(uLevel, "round", bu.round),
- XML::getProperty(uLevel, "separator", bu.separator)
- };
-
- if (ul.count > 0)
- {
- ud.levels.push_back(ul);
- level++;
- }
- else
- {
- logger->log("Error bad unit count: %d for %s in %s",
- ul.count,
- ul.symbol.c_str(),
- bu.symbol.c_str());
- }
- }
- }
-
- // Add one more level for saftey
- const UnitLevel lev =
- {
- "",
- INT_MAX,
- 0,
- ""
- };
- ud.levels.push_back(lev);
- return ud;
-}
-
-static void loadCurrencies(XmlNodePtr parentNode)
-{
- for_each_xml_child_node(node, parentNode)
- {
- if (xmlNameEqual(node, "unit"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- {
- reportAlways("Error: unknown currency name.");
- continue;
- }
- mCurrencies[name] = loadUnit(node);
- if (name == DEFAULT_CURRENCY)
- defaultCurrency = mCurrencies[name];
- }
- }
-}
-
-void UnitsDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst root = doc.rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "units"))
- {
- logger->log("Error loading unit definition file: "
- + paths.getStringValue("unitsFile"));
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "unit"))
- {
- const std::string type = XML::getProperty(node, "type", "");
- UnitDescription ud = loadUnit(node);
- if (type == "weight")
- {
- defaultWeight = ud;
- }
- else if (type == "currency")
- {
- defaultCurrency = ud;
- mCurrencies[DEFAULT_CURRENCY] = ud;
- }
- else
- {
- logger->log("Error unknown unit type: %s", type.c_str());
- }
- }
- else if (xmlNameEqual(node, "currency"))
- {
- loadCurrencies(node);
- }
- }
-}
-
-static std::string formatUnit(const int value,
- const UnitDescription &ud)
-{
- UnitLevel ul;
-
- // Shortcut for 0; do the same for values less than 0 (for now)
- if (value <= 0)
- {
- ul = ud.levels[0];
- return strprintf("0%s", ul.symbol.c_str());
- }
-
- double amount = ud.conversion * value;
- const unsigned int sz = CAST_U32(ud.levels.size());
-
- // If only the first level is needed, act like mix if false
- if (ud.mix && !ud.levels.empty() && ud.levels[1].count < amount)
- {
- std::string output;
- UnitLevel pl = ud.levels[0];
- ul = ud.levels[1];
- int levelAmount = CAST_S32(amount);
- int nextAmount = 0;
-
- if (ul.count != 0)
- levelAmount /= ul.count;
-
- amount -= static_cast<double>(levelAmount * ul.count);
-
- if (amount > 0)
- {
- output = splitNumber(strprintf("%.*f", pl.round,
- amount), pl.separator).append(pl.symbol);
- }
-
- for (unsigned int i = 2; i < sz; i++)
- {
- pl = ul;
- ul = ud.levels[i];
-
- if (ul.count != 0)
- {
- nextAmount = levelAmount / ul.count;
- levelAmount %= ul.count;
- }
-
- if (levelAmount > 0)
- {
- output = splitNumber(strprintf("%d", levelAmount),
- pl.separator).append(pl.symbol).append(output);
- }
-
- if (nextAmount == 0)
- break;
- levelAmount = nextAmount;
- }
-
- return output;
- }
-
- ul.round = 0;
- for (unsigned int i = 0; i < sz; i++)
- {
- ul = ud.levels[i];
- if (amount < ul.count && ul.count > 0)
- {
- ul = ud.levels[i - 1];
- break;
- }
- if (ul.count != 0)
- amount /= ul.count;
- }
-
- return splitNumber(strprintf("%.*f", ul.round, amount),
- ul.separator).append(ul.symbol);
-}
-
-std::string UnitsDb::formatCurrency(const int value)
-{
- return formatUnit(value, defaultCurrency);
-}
-
-std::string UnitsDb::formatCurrency64(const int64_t value)
-{
- return formatUnit(CAST_S32(value),
- defaultCurrency);
-}
-
-std::string UnitsDb::formatCurrency(std::string name,
- const int value)
-{
- if (mCurrencies.find(name) == mCurrencies.end())
- name = DEFAULT_CURRENCY;
- return formatUnit(value, mCurrencies[name]);
-}
-
-std::string UnitsDb::formatCurrency64(std::string name,
- const int64_t value)
-{
- if (mCurrencies.find(name) == mCurrencies.end())
- name = DEFAULT_CURRENCY;
- return formatUnit(CAST_S32(value),
- mCurrencies[name]);
-}
-
-std::string UnitsDb::formatWeight(const int value)
-{
- return formatUnit(value, defaultWeight);
-}
-
-bool UnitsDb::existsCurrency(const std::string &name)
-{
- return mCurrencies.find(name) != mCurrencies.end();
-}
-
-static std::string splitNumber(std::string str,
- const std::string &separator)
-{
- std::string lastPart;
- const size_t point = str.find('.');
- if (point != std::string::npos)
- {
- lastPart = str.substr(point);
- str = str.substr(0, point);
- }
- std::string result;
-
- if (!str.empty())
- {
- size_t sz = str.size();
- while (sz >= 3)
- {
- if (sz >= 6)
- {
- result = std::string(separator).append(str.substr(
- sz - 3)).append(result);
- }
- else
- {
- result = str.substr(sz - 3).append(result);
- }
- str = str.substr(0, str.size() - 3);
- sz = str.size();
- }
- if (!str.empty())
- {
- if (!result.empty())
- result = std::string(str).append(separator).append(result);
- else
- result = STD_MOVE(str);
- }
- }
-
- return result + lastPart;
-}
diff --git a/src/resources/db/unitsdb.h b/src/resources/db/unitsdb.h
deleted file mode 100644
index 859adaabc..000000000
--- a/src/resources/db/unitsdb.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_UNITSDB_H
-#define RESOURCES_DB_UNITSDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace UnitsDb
-{
- /**
- * Loads and parses the units.xml file (if found).
- */
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Formats the given number in the correct currency format.
- */
- std::string formatCurrency(const int value) A_WARN_UNUSED;
-
- std::string formatCurrency64(const int64_t value) A_WARN_UNUSED;
-
- /**
- * Formats the given number in the correct currency format.
- */
- std::string formatCurrency(std::string name,
- const int value) A_WARN_UNUSED;
-
- std::string formatCurrency64(std::string name,
- const int64_t value) A_WARN_UNUSED;
-
- /**
- * Formats the given number in the correct weight/mass format.
- */
- std::string formatWeight(const int value) A_WARN_UNUSED;
-
- bool existsCurrency(const std::string &name) A_WARN_UNUSED;
-} // namespace UnitsDb
-
-#endif // RESOURCES_DB_UNITSDB_H
diff --git a/src/resources/db/weaponsdb.cpp b/src/resources/db/weaponsdb.cpp
deleted file mode 100644
index f23a0dfc3..000000000
--- a/src/resources/db/weaponsdb.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 "resources/db/weaponsdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/xmlutils.h"
-
-#include "debug.h"
-
-namespace
-{
- WeaponsInfos mBows;
- WeaponsInfos mSwords;
- WeaponsInfos mShields;
- bool mLoaded = false;
-} // namespace
-
-static void loadDB(const std::string &name,
- WeaponsInfos &arr)
-{
- readXmlIntVector(paths.getStringValue("weaponsFile"),
- "weapons",
- name,
- "item",
- "id",
- arr,
- SkipError_false);
-}
-
-void WeaponsDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing weapon database...");
-
- loadDB("swords", mSwords);
- loadDB("bows", mBows);
- loadDB("shields", mShields);
-}
-
-void WeaponsDB::unload()
-{
- logger->log1("Unloading weapon database...");
-
- mBows.clear();
- mSwords.clear();
- mShields.clear();
- mLoaded = false;
-}
-
-const WeaponsInfos &WeaponsDB::getBows()
-{
- return mBows;
-}
-
-const WeaponsInfos &WeaponsDB::getSwords()
-{
- return mSwords;
-}
-
-const WeaponsInfos &WeaponsDB::getShields()
-{
- return mShields;
-}
diff --git a/src/resources/db/weaponsdb.h b/src/resources/db/weaponsdb.h
deleted file mode 100644
index a957347bc..000000000
--- a/src/resources/db/weaponsdb.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus 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 RESOURCES_DB_WEAPONSDB_H
-#define RESOURCES_DB_WEAPONSDB_H
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-typedef STD_VECTOR<int> WeaponsInfos;
-typedef WeaponsInfos::const_iterator WeaponsInfosIter;
-
-namespace WeaponsDB
-{
- void load();
-
- void unload();
-
- const WeaponsInfos &getBows();
-
- const WeaponsInfos &getSwords();
-
- const WeaponsInfos &getShields();
-} // namespace WeaponsDB
-
-#endif // RESOURCES_DB_WEAPONSDB_H