summaryrefslogtreecommitdiff
path: root/src/game-server/quest.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2022-08-19 16:55:29 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2022-08-19 17:34:55 +0200
commit109b602701578b9f2b29282f84bf2757544f8d32 (patch)
treea2fd70556c86385a75bfb7651e865beb0a05fd37 /src/game-server/quest.cpp
parent6c6090991e17276de09f5f82d2fc8a6c1adf5bf4 (diff)
downloadmanaserv-109b602701578b9f2b29282f84bf2757544f8d32.tar.gz
manaserv-109b602701578b9f2b29282f84bf2757544f8d32.tar.bz2
manaserv-109b602701578b9f2b29282f84bf2757544f8d32.tar.xz
manaserv-109b602701578b9f2b29282f84bf2757544f8d32.zip
Apply C++11 fixits
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
Diffstat (limited to 'src/game-server/quest.cpp')
-rw-r--r--src/game-server/quest.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/game-server/quest.cpp b/src/game-server/quest.cpp
index 4ed8a6fc..3a049eaa 100644
--- a/src/game-server/quest.cpp
+++ b/src/game-server/quest.cpp
@@ -31,8 +31,8 @@
#include <sigc++/connection.h>
-typedef std::list< QuestCallback * > QuestCallbacks;
-typedef std::map< std::string, QuestCallbacks > PendingVariables;
+using QuestCallbacks = std::list<QuestCallback *>;
+using PendingVariables = std::map<std::string, QuestCallbacks>;
struct PendingQuest
{
@@ -42,14 +42,13 @@ struct PendingQuest
PendingVariables variables;
};
-typedef std::map< int, PendingQuest > PendingQuests;
+using PendingQuests = std::map<int, PendingQuest>;
static PendingQuests pendingQuests;
bool getQuestVar(Entity *ch, const std::string &name, std::string &value)
{
- std::map< std::string, std::string >::iterator
- i = ch->getComponent<CharacterComponent>()->questCache.find(name);
+ auto i = ch->getComponent<CharacterComponent>()->questCache.find(name);
if (i == ch->getComponent<CharacterComponent>()->questCache.end())
return false;
value = i->second;
@@ -62,8 +61,7 @@ void setQuestVar(Entity *ch, const std::string &name,
auto *characterComponent =
ch->getComponent<CharacterComponent>();
- std::map< std::string, std::string >::iterator
- i = characterComponent->questCache.lower_bound(name);
+ auto i = characterComponent->questCache.lower_bound(name);
if (i == characterComponent->questCache.end() || i->first != name)
{
characterComponent->questCache.insert(i, std::make_pair(name, value));
@@ -98,7 +96,7 @@ static void partialRemove(Entity *t)
int id = t->getComponent<CharacterComponent>()->getDatabaseID();
PendingVariables &variables = pendingQuests[id].variables;
// Remove all the callbacks, but do not remove the variable names.
- for (PendingVariables::iterator i = variables.begin(),
+ for (auto i = variables.begin(),
i_end = variables.end(); i != i_end; ++i)
{
i->second.clear();
@@ -129,7 +127,7 @@ void recoverQuestVar(Entity *ch, const std::string &name,
assert(characterComponent->questCache.find(name) ==
characterComponent->questCache.end());
int id = ch->getComponent<CharacterComponent>()->getDatabaseID();
- PendingQuests::iterator i = pendingQuests.lower_bound(id);
+ auto i = pendingQuests.lower_bound(id);
if (i == pendingQuests.end() || i->first != id)
{
PendingQuest pendingQuest;
@@ -155,7 +153,7 @@ void recoveredQuestVar(int id,
const std::string &name,
const std::string &value)
{
- PendingQuests::iterator i = pendingQuests.find(id);
+ auto i = pendingQuests.find(id);
if (i == pendingQuests.end())
return;
@@ -164,7 +162,7 @@ void recoveredQuestVar(int id,
pendingQuest.disconnectedConnection.disconnect();
PendingVariables &variables = pendingQuest.variables;
- PendingVariables::iterator j = variables.find(name);
+ auto j = variables.find(name);
if (j == variables.end())
{
LOG_ERROR("Account server recovered an unexpected quest variable.");