summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp43
-rw-r--r--src/regchannel.cpp57
-rw-r--r--src/servers.cpp76
3 files changed, 92 insertions, 84 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 0f3a5650d..96771eff0 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -23,44 +23,9 @@ void introduce_user(const Anope::string &user)
throw FatalException("introduce_user loop detected");
lasttime = now;
- if (!user.empty())
+ User *u = finduser(user);
+ if (u)
{
- User *u = finduser(user);
- if (u)
- {
- ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
-
- BotInfo *bi = findbot(u->nick);
- if (bi)
- {
- XLine x(bi->nick, "Reserved for services");
- ircdproto->SendSQLine(NULL, &x);
-
- for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
- ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
- }
- }
-
- return;
- }
-
- ircdproto->SendBOB();
-
- for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
- {
- Server *s = Me->GetLinks()[i];
-
- if (s->HasFlag(SERVER_JUPED))
- {
- ircdproto->SendServer(s);
- }
- }
-
- /* We make the bots go online */
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
- {
- User *u = it->second;
-
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
BotInfo *bi = findbot(u->nick);
@@ -73,10 +38,6 @@ void introduce_user(const Anope::string &user)
ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
}
}
-
- /* Load MLock from the database now that we know what modes exist */
- for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
- it->second->LoadMLock();
}
/*************************************************************************/
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 1bd8807d9..be2746edf 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -542,6 +542,9 @@ void ChannelInfo::ClearBadWords()
*/
void ChannelInfo::LoadMLock()
{
+ if (!this->GetExt("db_mlock"))
+ return;
+
this->ClearMLock();
// Force +r
@@ -550,51 +553,27 @@ void ChannelInfo::LoadMLock()
this->SetMLock(chm, true);
std::vector<Anope::string> mlock;
- if (this->GetExtRegular("db_mlock", mlock))
+ this->GetExtRegular("db_mlock", mlock);
+ for (unsigned i = 0; i < mlock.size(); ++i)
{
- for (unsigned i = 0; i < mlock.size(); ++i)
- {
- std::vector<Anope::string> mlockv = BuildStringVector(mlock[i]);
-
- bool set = mlockv[0] == "1";
- ChannelMode *cm = ModeManager::FindChannelModeByString(mlockv[1]);
- const Anope::string &setter = mlockv[2];
- time_t created = Anope::CurTime;
- try
- {
- created = convertTo<time_t>(mlockv[3]);
- }
- catch (const ConvertException &) { }
- const Anope::string &param = mlockv.size() > 4 ? mlockv[4] : "";
-
- if (cm != NULL)
- this->SetMLock(cm, set, param, setter, created);
- }
+ std::vector<Anope::string> mlockv = BuildStringVector(mlock[i]);
- this->Shrink("db_mlock");
- }
-
- /* Create perm channel */
- if (this->HasFlag(CI_PERSIST) && !this->c)
- {
- this->c = new Channel(this->name, this->time_registered);
- if (ModeManager::FindChannelModeByName(CMODE_PERM) != NULL)
+ bool set = mlockv[0] == "1";
+ ChannelMode *cm = ModeManager::FindChannelModeByString(mlockv[1]);
+ const Anope::string &setter = mlockv[2];
+ time_t created = Anope::CurTime;
+ try
{
- /* At this point, CMODE_PERM *must* be locked on the channel, so this is fine */
- ircdproto->SendChannel(this->c);
- this->c->Reset();
+ created = convertTo<time_t>(mlockv[3]);
}
- else
- {
- if (!this->bi)
- this->WhoSends()->Assign(NULL, this);
- if (this->c->FindUser(this->bi) == NULL)
- this->bi->Join(this->c);
+ catch (const ConvertException &) { }
+ const Anope::string &param = mlockv.size() > 4 ? mlockv[4] : "";
- check_modes(this->c);
- this->RestoreTopic();
- }
+ if (cm != NULL)
+ this->SetMLock(cm, set, param, setter, created);
}
+
+ this->Shrink("db_mlock");
}
/** Check if a mode is mlocked
diff --git a/src/servers.cpp b/src/servers.cpp
index 763fed707..c57dda680 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -51,8 +51,44 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
/* Check to be sure this isn't a juped server */
if (Me == this->UplinkServer && !this->HasFlag(SERVER_JUPED))
{
- /* Bring in our pseudo-clients */
- introduce_user("");
+ /* Load MLock from the database now that we know what modes exist */
+ for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
+ it->second->LoadMLock();
+
+ ircdproto->SendBOB();
+
+ for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
+ {
+ Server *s = Me->GetLinks()[i];
+
+ if (s->HasFlag(SERVER_JUPED))
+ ircdproto->SendServer(s);
+ }
+
+ /* We make the bots go online */
+ for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ {
+ User *u = it->second;
+
+ ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
+
+ BotInfo *bi = findbot(u->nick);
+ if (bi)
+ {
+ XLine x(bi->nick, "Reserved for services");
+ ircdproto->SendSQLine(NULL, &x);
+ }
+ }
+
+ for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
+ {
+ Channel *c = it->second;
+ if (c->users.empty())
+ ircdproto->SendChannel(c);
+ else
+ for (CUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
+ ircdproto->SendJoin((*cit)->user, c, (*cit)->Status);
+ }
}
}
}
@@ -210,15 +246,47 @@ void Server::Sync(bool SyncLinks)
if (this->GetUplink() && this->GetUplink() == Me)
{
+ for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
+ {
+ ChannelInfo *ci = it->second;
+ if (ci->HasFlag(CI_PERSIST))
+ {
+ bool created = false;
+ if (!ci->c)
+ {
+ ci->c = new Channel(ci->name, ci->time_registered);
+ created = true;
+ }
+ if (ModeManager::FindChannelModeByName(CMODE_PERM) != NULL)
+ {
+ ci->c->SetMode(NULL, CMODE_PERM);
+ if (created)
+ ircdproto->SendChannel(ci->c);
+ }
+ else
+ {
+ if (!ci->bi)
+ ci->WhoSends()->Assign(NULL, ci);
+ if (ci->c->FindUser(ci->bi) == NULL)
+ ci->bi->Join(ci->c);
+ }
+ }
+ }
+
FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this));
+
ircdproto->SendEOB();
Me->Sync(false);
FOREACH_MOD(I_OnUplinkSync, OnUplinkSync(this));
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
- if (it->second->ci)
- it->second->ci->RestoreTopic();
+ {
+ Channel *c = it->second;
+ check_modes(c);
+ if (c->ci)
+ c->ci->RestoreTopic();
+ }
}
}