summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-02-13 12:49:39 -0500
committerAdam <Adam@anope.org>2013-02-14 01:20:18 -0500
commit225b7c38c127fbc6aac6724012f71c9483a4da77 (patch)
treee7eb4fc6f802119ec0ff55fd769a447b956e0439
parent994866461c44d57e9b1dd1813283185230c2da45 (diff)
Make NickCore::aliases a vector
-rw-r--r--include/account.h2
-rw-r--r--modules/commands/hs_del.cpp4
-rw-r--r--modules/commands/hs_group.cpp4
-rw-r--r--modules/commands/hs_set.cpp4
-rw-r--r--modules/commands/ns_group.cpp22
-rw-r--r--modules/commands/ns_suspend.cpp4
-rw-r--r--modules/pseudoclients/memoserv.cpp6
-rw-r--r--src/access.cpp4
-rw-r--r--src/nickalias.cpp24
-rw-r--r--src/nickcore.cpp2
10 files changed, 36 insertions, 40 deletions
diff --git a/include/account.h b/include/account.h
index c3d5800b4..8ce457a72 100644
--- a/include/account.h
+++ b/include/account.h
@@ -167,7 +167,7 @@ class CoreExport NickCore : public Serializable, public Extensible
/* Nicknames registered that are grouped to this account.
* for n in aliases, n->nc == this.
*/
- std::list<Serialize::Reference<NickAlias> > aliases;
+ Serialize::Checker<std::vector<NickAlias *> > aliases;
/* Set if this user is a services operattor. o->ot must exist. */
Oper *o;
diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp
index a2d26739d..5df23e721 100644
--- a/modules/commands/hs_del.cpp
+++ b/modules/commands/hs_del.cpp
@@ -64,9 +64,9 @@ class CommandHSDelAll : public Command
{
FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
const NickCore *nc = na->nc;
- for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
+ for (unsigned i = 0; i < nc->aliases->size(); ++i)
{
- na = *it;
+ na = nc->aliases->at(i);
na->RemoveVhost();
}
Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display;
diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp
index 9027fddac..ee997f704 100644
--- a/modules/commands/hs_group.cpp
+++ b/modules/commands/hs_group.cpp
@@ -20,9 +20,9 @@ class CommandHSGroup : public Command
if (!na || !na->HasVhost())
return;
- for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;)
+ for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
{
- NickAlias *nick = *it++;
+ NickAlias *nick = na->nc->aliases->at(i);
if (nick)
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp
index cfad860a3..11ecbca5a 100644
--- a/modules/commands/hs_set.cpp
+++ b/modules/commands/hs_set.cpp
@@ -108,9 +108,9 @@ class CommandHSSetAll : public Command
if (!na || !na->HasVhost())
return;
- for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;)
+ for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
{
- NickAlias *nick = *it++;
+ NickAlias *nick = na->nc->aliases->at(i);
if (nick)
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index f94fe2d86..1b21887a6 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -130,7 +130,7 @@ class CommandNSGroup : public Command
source.Reply(NICK_IDENTIFY_REQUIRED, Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str());
else if (na && Config->NSNoGroupChange)
source.Reply(_("Your nick is already registered."));
- else if (Config->NSMaxAliases && (target->nc->aliases.size() >= Config->NSMaxAliases) && !target->nc->IsServicesOper())
+ else if (Config->NSMaxAliases && (target->nc->aliases->size() >= Config->NSMaxAliases) && !target->nc->IsServicesOper())
source.Reply(_("There are too many nicks in %s's group."));
else if (u->nick.length() <= Config->NSGuestNickPrefix.length() + 7 &&
u->nick.length() >= Config->NSGuestNickPrefix.length() + 1 &&
@@ -214,7 +214,7 @@ class CommandNSUngroup : public Command
Anope::string nick = !params.empty() ? params[0] : "";
NickAlias *na = NickAlias::Find(!nick.empty() ? nick : u->nick);
- if (u->Account()->aliases.size() == 1)
+ if (u->Account()->aliases->size() == 1)
source.Reply(_("Your nick is not grouped to anything, you can't ungroup it."));
else if (!na)
source.Reply(NICK_X_NOT_REGISTERED, !nick.empty() ? nick.c_str() : u->nick.c_str());
@@ -224,16 +224,16 @@ class CommandNSUngroup : public Command
{
NickCore *oldcore = na->nc;
- std::list<Serialize::Reference<NickAlias> >::iterator it = std::find(oldcore->aliases.begin(), oldcore->aliases.end(), na);
- if (it != oldcore->aliases.end())
- oldcore->aliases.erase(it);
+ std::vector<NickAlias *>::iterator it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na);
+ if (it != oldcore->aliases->end())
+ oldcore->aliases->erase(it);
if (na->nick.equals_ci(oldcore->display))
- oldcore->SetDisplay(oldcore->aliases.front());
+ oldcore->SetDisplay(oldcore->aliases->front());
NickCore *nc = new NickCore(na->nick);
na->nc = nc;
- nc->aliases.push_back(na);
+ nc->aliases->push_back(na);
nc->pass = oldcore->pass;
if (!oldcore->email.empty())
@@ -300,11 +300,9 @@ class CommandNSGList : public Command
ListFormatter list;
list.AddColumn("Nick").AddColumn("Expires");
- for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
+ for (unsigned i = 0; i < nc->aliases->size(); ++i)
{
- const NickAlias *na2 = *it++;
- if (!na2)
- continue;
+ const NickAlias *na2 = nc->aliases->at(i);
ListFormatter::ListEntry entry;
entry["Nick"] = na2->nick;
@@ -319,7 +317,7 @@ class CommandNSGList : public Command
for (unsigned i = 0; i < replies.size(); ++i)
source.Reply(replies[i]);
- source.Reply(_("%d nicknames in the group."), nc->aliases.size());
+ source.Reply(_("%d nicknames in the group."), nc->aliases->size());
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp
index 675db1330..a4cc7f355 100644
--- a/modules/commands/ns_suspend.cpp
+++ b/modules/commands/ns_suspend.cpp
@@ -73,9 +73,9 @@ class CommandNSSuspend : public Command
nc->ExtendMetadata("suspend:expire", stringify(Anope::CurTime + expiry_secs));
- for (std::list<Serialize::Reference<NickAlias> >::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
+ for (unsigned i = 0; i < nc->aliases->size(); ++i)
{
- NickAlias *na2 = *it++;
+ NickAlias *na2 = nc->aliases->at(i);
if (na2 && *na2->nc == *na->nc)
{
diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp
index ca54f3378..73dd48b94 100644
--- a/modules/pseudoclients/memoserv.cpp
+++ b/modules/pseudoclients/memoserv.cpp
@@ -97,11 +97,9 @@ class MyMemoServService : public MemoServService
if (nc->HasExt("MEMO_RECEIVE"))
{
- for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
+ for (unsigned i = 0; i < nc->aliases->size(); ++i)
{
- const NickAlias *na = *it++;
- if (!na)
- continue;
+ const NickAlias *na = nc->aliases->at(i);
User *user = User::Find(na->nick);
if (user && user->IsIdentified())
user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), mi->memos->size());
diff --git a/src/access.cpp b/src/access.cpp
index 467f37047..fdaada75b 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -156,9 +156,9 @@ bool ChanAccess::Matches(const User *u, const NickCore *nc) const
else if (u && Anope::Match(u->GetDisplayedMask(), this->mask))
return true;
else if (nc)
- for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(); it != nc->aliases.end();)
+ for (unsigned i = nc->aliases->size(); i > 0; --i)
{
- const NickAlias *na = *it++;
+ const NickAlias *na = nc->aliases->at(i - 1);
if (na && Anope::Match(na->nick, this->mask))
return true;
}
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index 9c09c1c0a..dea888f07 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -31,7 +31,7 @@ NickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Serial
this->time_registered = this->last_seen = Anope::CurTime;
this->nick = nickname;
this->nc = nickcore;
- nickcore->aliases.push_back(this);
+ nickcore->aliases->push_back(this);
size_t old = NickAliasList->size();
(*NickAliasList)[this->nick] = this;
@@ -57,10 +57,10 @@ NickAlias::~NickAlias()
if (this->nc)
{
/* Next: see if our core is still useful. */
- std::list<Serialize::Reference<NickAlias> >::iterator it = std::find(this->nc->aliases.begin(), this->nc->aliases.end(), this);
- if (it != this->nc->aliases.end())
- this->nc->aliases.erase(it);
- if (this->nc->aliases.empty())
+ std::vector<NickAlias *>::iterator it = std::find(this->nc->aliases->begin(), this->nc->aliases->end(), this);
+ if (it != this->nc->aliases->end())
+ this->nc->aliases->erase(it);
+ if (this->nc->aliases->empty())
{
this->nc->Destroy();
this->nc = NULL;
@@ -69,7 +69,7 @@ NickAlias::~NickAlias()
{
/* Display updating stuff */
if (this->nick.equals_ci(this->nc->display))
- this->nc->SetDisplay(this->nc->aliases.front());
+ this->nc->SetDisplay(this->nc->aliases->front());
}
}
@@ -278,17 +278,17 @@ Serializable* NickAlias::Unserialize(Serializable *obj, Serialize::Data &data)
if (na->nc != core)
{
- std::list<Serialize::Reference<NickAlias> >::iterator it = std::find(na->nc->aliases.begin(), na->nc->aliases.end(), na);
- if (it != na->nc->aliases.end())
- na->nc->aliases.erase(it);
+ std::vector<NickAlias *>::iterator it = std::find(na->nc->aliases->begin(), na->nc->aliases->end(), na);
+ if (it != na->nc->aliases->end())
+ na->nc->aliases->erase(it);
- if (na->nc->aliases.empty())
+ if (na->nc->aliases->empty())
delete na->nc;
else if (na->nick.equals_ci(na->nc->display))
- na->nc->SetDisplay(na->nc->aliases.front());
+ na->nc->SetDisplay(na->nc->aliases->front());
na->nc = core;
- core->aliases.push_back(na);
+ core->aliases->push_back(na);
}
data["last_quit"] >> na->last_quit;
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index c906f5999..7dda6da5c 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -17,7 +17,7 @@
Serialize::Checker<nickcore_map> NickCoreList("NickCore");
-NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore")
+NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), aliases("NickAlias")
{
if (coredisplay.empty())
throw CoreException("Empty display passed to NickCore constructor");