summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-02-24 14:53:34 -0500
committerAdam <Adam@anope.org>2012-02-24 14:53:34 -0500
commit2337b7717db05e0c8b53da2d61b5a66f58cc0297 (patch)
tree4e69f0cfcb64b477cf751403883ff8f4847d31f9 /src
parent24811e59705f2d8995f900f82066084bf22f15ec (diff)
Fixed calculating bots channel count of assigned channels and fixed the order of saving memos (among other things)
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp20
-rw-r--r--src/regchannel.cpp9
-rw-r--r--src/serialize.cpp10
3 files changed, 19 insertions, 20 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 30df962d8..242b7d4f2 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -25,7 +25,6 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
this->realname = nreal;
this->server = Me;
- this->chancount = 0;
this->lastmsg = this->created = Anope::CurTime;
this->introduced = false;
@@ -85,7 +84,6 @@ Serializable::serialized_data BotInfo::serialize()
data["host"] << this->host;
data["realname"] << this->realname;
data["created"] << this->created;
- data["chancount"] << this->chancount;
data["flags"] << this->ToString();
return data;
@@ -97,7 +95,6 @@ void BotInfo::unserialize(serialized_data &data)
if (bi == NULL)
bi = new BotInfo(data["nick"].astr(), data["user"].astr(), data["host"].astr(), data["realname"].astr());
data["created"] >> bi->created;
- data["chancount"] >> bi->chancount;
bi->FromString(data["flags"].astr());
}
@@ -142,8 +139,6 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
if (ci->bi)
ci->bi->UnAssign(u, ci);
- ++this->chancount;
-
ci->bi = this;
if (ci->c && ci->c->users.size() >= Config->BSMinUsers)
this->Join(ci->c, &Config->BotModeList);
@@ -164,11 +159,22 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
ci->bi->Part(ci->c);
}
- --this->chancount;
-
ci->bi = NULL;
}
+unsigned BotInfo::GetChannelCount()
+{
+ unsigned count = 0;
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
+ {
+ ChannelInfo *ci = it->second;
+
+ if (ci->bi == this)
+ ++count;
+ }
+ return count;
+}
+
void BotInfo::Join(Channel *c, ChannelStatus *status)
{
if (c->FindUser(this) != NULL)
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 25526ee8b..42feddc7b 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -246,9 +246,6 @@ ChannelInfo::ChannelInfo(ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(Chann
this->akick.clear();
this->badwords.clear();
- if (this->bi)
- ++this->bi->chancount;
-
for (int i = 0; i < TTB_SIZE; ++i)
this->ttb[i] = ci.ttb[i];
@@ -397,13 +394,7 @@ void ChannelInfo::unserialize(serialized_data &data)
ci->levels[v[i]] = convertTo<int16_t>(v[i + 1]);
}
if (data.count("bi") > 0)
- {
- if (ci->bi)
- ci->bi->chancount--;
ci->bi = findbot(data["bi"].astr());
- if (ci->bi)
- ci->bi->chancount++;
- }
data["capsmin"] >> ci->capsmin;
data["capspercent"] >> ci->capspercent;
data["floodlines"] >> ci->floodlines;
diff --git a/src/serialize.cpp b/src/serialize.cpp
index beaf5a8cc..3f8df0434 100644
--- a/src/serialize.cpp
+++ b/src/serialize.cpp
@@ -74,14 +74,16 @@ Serializable::Serializable()
{
if (serizliable_items == NULL)
serizliable_items = new std::list<Serializable *>();
- serizliable_items->push_front(this);
- this->s_iter = serizliable_items->begin();
+ serizliable_items->push_back(this);
+ this->s_iter = serizliable_items->end();
+ --this->s_iter;
}
Serializable::Serializable(const Serializable &)
{
- serizliable_items->push_front(this);
- this->s_iter = serizliable_items->begin();
+ serizliable_items->push_back(this);
+ this->s_iter = serizliable_items->end();
+ --this->s_iter;
}
Serializable::~Serializable()