summaryrefslogtreecommitdiff
path: root/src/resources/itemdb.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-05 10:13:15 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-06 21:49:14 +0000
commit3ce39d2b497ab5356290a22b324181386af51c51 (patch)
tree1b923b8be7e4d2ce8ff70768dc7fff596487935c /src/resources/itemdb.cpp
parenta9df89bda908e3b3d443db7f3ca865b6f12c75e5 (diff)
downloadmana-3ce39d2b497ab5356290a22b324181386af51c51.tar.gz
mana-3ce39d2b497ab5356290a22b324181386af51c51.tar.bz2
mana-3ce39d2b497ab5356290a22b324181386af51c51.tar.xz
mana-3ce39d2b497ab5356290a22b324181386af51c51.zip
General code cleanups
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r--src/resources/itemdb.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 77fda11b..6ff3f58c 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -84,12 +84,11 @@ bool ItemDB::exists(int id) const
return mItemInfos.find(id) != mItemInfos.end();
}
-const ItemInfo &ItemDB::get(int id)
+const ItemInfo &ItemDB::get(int id) const
{
assert(mLoaded);
- ItemInfos::const_iterator i = mItemInfos.find(id);
-
+ auto i = mItemInfos.find(id);
if (i == mItemInfos.end())
{
logger->log("ItemDB: Warning, unknown item ID# %d", id);
@@ -99,12 +98,11 @@ const ItemInfo &ItemDB::get(int id)
return *(i->second);
}
-const ItemInfo &ItemDB::get(const std::string &name)
+const ItemInfo &ItemDB::get(const std::string &name) const
{
assert(mLoaded);
- NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalize(name));
-
+ auto i = mNamedItemInfos.find(normalize(name));
if (i == mNamedItemInfos.end())
{
if (!name.empty())
@@ -268,7 +266,7 @@ void ItemDB::addItem(ItemInfo *itemInfo)
{
std::string temp = normalize(itemName);
- NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp);
+ auto itr = mNamedItemInfos.find(temp);
if (itr == mNamedItemInfos.end())
mNamedItemInfos[temp] = itemInfo;
else
@@ -448,8 +446,7 @@ void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename)
if (trigger == "activation")
itemInfo->mActivatable = true;
- std::map<std::string, const char* >::const_iterator triggerLabel =
- triggerTable.find(trigger);
+ auto triggerLabel = triggerTable.find(trigger);
if (triggerLabel == triggerTable.end())
{
logger->log("Warning: unknown trigger %s in item %d!",
@@ -472,9 +469,8 @@ void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename)
logger->log("Warning: incomplete modifier definition in %s, skipping.", filename.c_str());
continue;
}
- std::list<ItemStat>::const_iterator
- it = extraStats.begin(),
- it_end = extraStats.end();
+ auto it = extraStats.cbegin();
+ auto it_end = extraStats.cend();
while (it != it_end && !(*it == attribute))
++it;
if (it == extraStats.end())
@@ -495,7 +491,7 @@ void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename)
effect.push_back(strprintf("This will be consumed%s.",
triggerLabel->second));
else if (xmlStrEqual(effectChild->name, BAD_CAST "label"))
- effect.push_back(
+ effect.emplace_back(
(const char*)effectChild->xmlChildrenNode->content);
}
}