summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-02 17:23:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-02 17:23:32 +0300
commitf89de74b1ac1cd9a02a70dab9221d601296da8cd (patch)
tree444451eb017720bdc1d3457e6e7976a84e065351 /src
parentc2748e2217f0ac69e2f06f39e6411f5e77c11974 (diff)
downloadplus-f89de74b1ac1cd9a02a70dab9221d601296da8cd.tar.gz
plus-f89de74b1ac1cd9a02a70dab9221d601296da8cd.tar.bz2
plus-f89de74b1ac1cd9a02a70dab9221d601296da8cd.tar.xz
plus-f89de74b1ac1cd9a02a70dab9221d601296da8cd.zip
Add intmap defines.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/being.cpp9
-rw-r--r--src/being/playerinfo.h4
-rw-r--r--src/gui/windows/questswindow.cpp6
-rw-r--r--src/gui/windows/questswindow.h3
-rw-r--r--src/resources/db/itemdb.cpp14
-rw-r--r--src/resources/iteminfo.cpp6
-rw-r--r--src/resources/iteminfo.h10
-rw-r--r--src/utils/intmap.h30
10 files changed, 57 insertions, 27 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 75ff6fe9b..4a34b1c90 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -763,6 +763,7 @@ SET(SRCS
utils/gettexthelper.h
utils/glxhelper.cpp
utils/glxhelper.h
+ utils/intmap.h
utils/langs.cpp
utils/langs.h
utils/mathutils.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 7b1e9cffb..0f9670331 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -409,6 +409,7 @@ SRC += events/actionevent.h \
utils/gettexthelper.h \
utils/glxhelper.cpp \
utils/glxhelper.h \
+ utils/intmap.h \
utils/langs.cpp \
utils/langs.h \
utils/mathutils.h \
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 686b73f54..7a937ceaf 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -2972,7 +2972,7 @@ void Being::recalcSpritesOrder()
return;
std::vector<int> slotRemap;
- std::map<int, int> itemSlotRemap;
+ IntMap itemSlotRemap;
std::vector<int>::iterator it;
int oldHide[20];
@@ -3018,7 +3018,7 @@ void Being::recalcSpritesOrder()
FOR_EACHP (SpriteToItemMapCIter, itr, spriteToItems)
{
const int remSprite = itr->first;
- const std::map<int, int> &itemReplacer = itr->second;
+ const IntMap &itemReplacer = itr->second;
if (remSprite >= 0)
{ // slot known
if (itemReplacer.empty())
@@ -3027,7 +3027,7 @@ void Being::recalcSpritesOrder()
}
else if (mSpriteHide[remSprite] != 1)
{
- std::map<int, int>::const_iterator repIt
+ IntMapCIter repIt
= itemReplacer.find(mSpriteIDs[remSprite]);
if (repIt == itemReplacer.end())
{
@@ -3169,8 +3169,7 @@ void Being::recalcSpritesOrder()
int idx1 = -1;
// logger->log("item %d, id=%d", slot, id);
int reorder = 0;
- const std::map<int, int>::const_iterator
- orderIt = itemSlotRemap.find(id);
+ const IntMapCIter orderIt = itemSlotRemap.find(id);
if (orderIt != itemSlotRemap.end())
reorder = orderIt->second;
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index cba86bd79..3a74754e1 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -35,7 +35,8 @@
#include "enums/simpletypes/sfx.h"
#include "enums/simpletypes/trading.h"
-#include <map>
+#include "utils/intmap.h"
+
#ifdef EATHENA_SUPPORT
#include <string>
#endif
@@ -51,7 +52,6 @@ struct Stat final
int expNeed;
};
-typedef std::map<int, int> IntMap;
typedef std::map<AttributesT, int> AtrIntMap;
typedef std::map<AttributesT, Stat> StatMap;
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index 690781cea..8d4d1eebb 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -295,8 +295,7 @@ void QuestsWindow::rebuild(const bool playSound)
int updatedQuest = -1;
int newCompleteStatus = -1;
- for (std::map<int, int>::const_iterator it = mVars.begin(),
- it_end = mVars.end(); it != it_end; ++ it)
+ FOR_EACH (IntMapCIter, it, mVars)
{
const int var = (*it).first;
const int val = (*it).second;
@@ -454,8 +453,7 @@ void QuestsWindow::updateEffects()
const QuestEffect *const effect = *it;
if (effect)
{
- const std::map<int, int>::const_iterator
- varIt = mVars.find(effect->var);
+ const IntMapCIter varIt = mVars.find(effect->var);
if (varIt != mVars.end())
{
const std::set<int> &vals = effect->values;
diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h
index 031f239cd..d016a6a25 100644
--- a/src/gui/windows/questswindow.h
+++ b/src/gui/windows/questswindow.h
@@ -27,6 +27,7 @@
#include "gui/widgets/window.h"
+#include "utils/intmap.h"
#include "utils/xml.h"
#include "listeners/actionlistener.h"
@@ -87,7 +88,7 @@ class QuestsWindow final : public Window,
Image *mCompleteIcon;
Image *mIncompleteIcon;
// quest variables: var, value
- std::map<int, int> mVars;
+ IntMap mVars;
// quests: var, quests
std::map<int, std::vector<QuestItem*> > mQuests;
std::vector<QuestEffect*> mAllEffects;
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index da3444c0e..9de6b307e 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -589,11 +589,10 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
itr_end = spriteToItems->end(); itr != itr_end; ++ itr)
{
const int remSprite = itr->first;
- const std::map<int, int> &itemReplacer = itr->second;
+ const IntMap &itemReplacer = itr->second;
logger->log("sprite: %d", remSprite);
- for (std::map<int, int>::const_iterator
- repIt = itemReplacer.begin(),
+ for (IntMapCIter repIt = itemReplacer.begin(),
repIt_end = itemReplacer.end();
repIt != repIt_end; ++ repIt)
{
@@ -934,8 +933,7 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
{ // replace only given sprites
for (int f = 0; f < 10; f ++)
{
- std::map<int, int> *const mapList
- = itemInfo->addReplaceSprite(
+ IntMap *const mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), f);
if (!mapList)
continue;
@@ -969,7 +967,7 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
{
const int from = XML::getProperty(itemNode, "from", 0);
const int to = XML::getProperty(itemNode, "to", 1);
- std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ IntMap *mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), SpriteDirection::DOWN);
if (mapList)
(*mapList)[from] = to;
@@ -1002,7 +1000,7 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
{
const int from = XML::getProperty(itemNode, "from", 0);
const int to = XML::getProperty(itemNode, "to", 1);
- std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ IntMap *mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), SpriteDirection::UP);
if (mapList)
(*mapList)[from] = to;
@@ -1022,7 +1020,7 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
}
default:
{
- std::map<int, int> *const mapList = itemInfo->addReplaceSprite(
+ IntMap *const mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), direction);
if (!mapList)
return;
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 56b2e1fe0..9e3e4acfa 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -165,8 +165,8 @@ const SoundInfo &ItemInfo::getSound(const ItemSoundEvent::Type event) const
% i->second.size()] : empty;
}
-std::map<int, int> *ItemInfo::addReplaceSprite(const int sprite,
- const int direction)
+IntMap *ItemInfo::addReplaceSprite(const int sprite,
+ const int direction)
{
if (direction < 0 || direction >= 10)
return nullptr;
@@ -183,7 +183,7 @@ std::map<int, int> *ItemInfo::addReplaceSprite(const int sprite,
SpriteToItemMap::iterator it = spMap->find(sprite);
if (it == spMap->end())
{
- std::map<int, int> tmp;
+ IntMap tmp;
(*mSpriteToItemReplaceMap[direction])[sprite] = tmp;
it = mSpriteToItemReplaceMap[direction]->find(sprite);
}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index ebc267e15..1233daf73 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -33,13 +33,15 @@
#include "resources/soundinfo.h"
#include "resources/spritedisplay.h"
+#include "utils/intmap.h"
+
namespace ColorDB
{
class ItemColorData;
}
// sprite, <itemfrom, itemto>
-typedef std::map<int, std::map<int, int> > SpriteToItemMap;
+typedef std::map<int, IntMap> SpriteToItemMap;
typedef SpriteToItemMap::const_iterator SpriteToItemMapCIter;
/**
@@ -202,7 +204,7 @@ class ItemInfo final
void setDrawPriority(const int direction, const int n);
- const std::map<int, int> &getTags() const A_WARN_UNUSED
+ const IntMap &getTags() const A_WARN_UNUSED
{ return mTags; }
void addTag(const int tag)
@@ -239,8 +241,8 @@ class ItemInfo final
int getReplaceToSpriteId(int id) const A_WARN_UNUSED;
- std::map<int, int> *addReplaceSprite(const int sprite,
- const int direction);
+ IntMap *addReplaceSprite(const int sprite,
+ const int direction);
const SpriteToItemMap *getSpriteToItemReplaceMap(const int directions)
const A_WARN_UNUSED;
diff --git a/src/utils/intmap.h b/src/utils/intmap.h
new file mode 100644
index 000000000..1657181c1
--- /dev/null
+++ b/src/utils/intmap.h
@@ -0,0 +1,30 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012-2015 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 UTILS_INTMAP_H
+#define UTILS_INTMAP_H
+
+#include <map>
+
+typedef std::map<int, int> IntMap;
+typedef IntMap::iterator IntMapIter;
+typedef IntMap::const_iterator IntMapCIter;
+
+#endif // UTILS_INTMAP_H