summaryrefslogtreecommitdiff
path: root/src/nickcore.cpp
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/nickcore.cpp
parent51e95d72e3ca49bcb549cb27e8d6b489b8b0c7dd (diff)
Modernize the initialisation of NickAlias and NickCore.
Diffstat (limited to 'src/nickcore.cpp')
-rw-r--r--src/nickcore.cpp25
1 files changed, 11 insertions, 14 deletions
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));
}