summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-09 12:20:15 +0000
committerSadie Powell <sadie@witchery.services>2024-03-09 22:22:55 +0000
commit272104af957b3dc38c11137d6c1e63f86e2cf64c (patch)
treeb226c491f6987a5aaf59c7f861f656fa8be39c63 /src
parent51e95d72e3ca49bcb549cb27e8d6b489b8b0c7dd (diff)
Modernize the initialisation of NickAlias and NickCore.
Diffstat (limited to 'src')
-rw-r--r--src/nickalias.cpp14
-rw-r--r--src/nickcore.cpp25
2 files changed, 17 insertions, 22 deletions
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index bdded5dba..cfd59094d 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -20,22 +20,20 @@
Serialize::Checker<nickalias_map> NickAliasList("NickAlias");
-NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) : Serializable("NickAlias")
+NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore)
+ : Serializable("NickAlias")
+ , nick(nickname)
+ , nc(nickcore)
{
if (nickname.empty())
throw CoreException("Empty nick passed to NickAlias constructor");
else if (!nickcore)
throw CoreException("Empty nickcore passed to NickAlias constructor");
- this->time_registered = this->last_seen = Anope::CurTime;
- this->nick = nickname;
- this->nc = nickcore;
nickcore->aliases->push_back(this);
- size_t old = NickAliasList->size();
- (*NickAliasList)[this->nick] = this;
- if (old == NickAliasList->size())
- Log(LOG_DEBUG) << "Duplicate nick " << nickname << " in nickalias table";
+ if (!NickAliasList->insert_or_assign(this->nick, this).second)
+ Log(LOG_DEBUG) << "Duplicate nick " << this->nick << " in NickAlias table";
if (this->nc->o == NULL)
{
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 77f4aaddf..c60a238b4 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -18,25 +18,22 @@
Serialize::Checker<nickcore_map> NickCoreList("NickCore");
nickcoreid_map NickCoreIdList;
-NickCore::NickCore(const Anope::string &coredisplay, uint64_t coreid) : Serializable("NickCore"), chanaccess("ChannelInfo"), aliases("NickAlias")
+NickCore::NickCore(const Anope::string &coredisplay, uint64_t coreid)
+ : Serializable("NickCore")
+ , chanaccess("ChannelInfo")
+ , id(coreid)
+ , display(coredisplay)
+ , aliases("NickAlias")
{
if (coredisplay.empty())
throw CoreException("Empty display passed to NickCore constructor");
- this->o = NULL;
- this->channelcount = 0;
- this->lastmail = 0;
+ if (!NickCoreList->insert_or_assign(this->display, this).second)
+ Log(LOG_DEBUG) << "Duplicate account " << this->display << " in NickCore table";
- this->display = coredisplay;
- this->id = coreid;
-
- size_t old = NickCoreList->size();
- (*NickCoreList)[this->display] = this;
- if (old == NickCoreList->size())
- Log(LOG_DEBUG) << "Duplicate account " << coredisplay << " in nickcore table?";
-
- if (this->id)
- NickCoreIdList[this->id] = this;
+ // Upgrading users may not have an account identifier.
+ if (this->id && !NickCoreIdList.insert_or_assign(this->id, this).second)
+ Log(LOG_DEBUG) << "Duplicate account id " << this->id << " in NickCore table";
FOREACH_MOD(OnNickCoreCreate, (this));
}