summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp32
-rw-r--r--src/channels.cpp22
-rw-r--r--src/chanserv.cpp3
-rw-r--r--src/commands.cpp10
-rw-r--r--src/config.cpp5
-rw-r--r--src/init.cpp4
-rw-r--r--src/logger.cpp8
-rw-r--r--src/modes.cpp29
-rw-r--r--src/protocol.cpp5
-rw-r--r--src/regchannel.cpp10
-rw-r--r--src/users.cpp2
11 files changed, 42 insertions, 88 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 254e987a1..1f3f29009 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -175,7 +175,7 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
ci->bi = NULL;
}
-void BotInfo::Join(Channel *c, bool update_ts)
+void BotInfo::Join(Channel *c, ChannelStatus *status)
{
if (Config->BSSmartJoin)
{
@@ -202,35 +202,15 @@ void BotInfo::Join(Channel *c, bool update_ts)
}
c->JoinUser(this);
- ChannelContainer *cc = this->FindChannel(c);
- for (unsigned i = 0; i < Config->BotModeList.size(); ++i)
- {
- if (!update_ts)
- {
- c->SetMode(this, Config->BotModeList[i], this->nick, false);
- }
- else
- {
- cc->Status->SetFlag(Config->BotModeList[i]->Name);
- c->SetModeInternal(Config->BotModeList[i], this->nick, false);
- }
- }
- if (!update_ts)
- ircdproto->SendJoin(this, c->name, c->creation_time);
- /* This is sent later, when we burst to the uplink */
- else if (Me && Me->IsSynced())
- {
- ircdproto->SendJoin(this, cc);
-
- c->Reset();
- }
- FOREACH_MOD(I_OnBotJoin, OnBotJoin(c->ci, this));
+ ircdproto->SendJoin(this, c, status);
+
+ FOREACH_MOD(I_OnBotJoin, OnBotJoin(c, this));
}
-void BotInfo::Join(const Anope::string &chname, bool update_ts)
+void BotInfo::Join(const Anope::string &chname, ChannelStatus *status)
{
Channel *c = findchan(chname);
- return this->Join(c ? c : new Channel(chname), update_ts);
+ return this->Join(c ? c : new Channel(chname), status);
}
void BotInfo::Part(Channel *c, const Anope::string &reason)
diff --git a/src/channels.cpp b/src/channels.cpp
index 72b09ae1e..c68fd3ba0 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -126,7 +126,7 @@ void Channel::JoinUser(User *user)
{
Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered;
this->creation_time = this->ci->time_registered;
- ircdproto->SendChannel(this, "");
+ ircdproto->SendChannel(this);
this->Reset();
}
@@ -147,7 +147,7 @@ void Channel::JoinUser(User *user)
* legit users - Rob
**/
if (this->users.size() >= Config->BSMinUsers && !this->FindUser(this->ci->bi))
- this->ci->bi->Join(this, false);
+ this->ci->bi->Join(this, &Config->BotModeList);
/* Only display the greet if the main uplink we're connected
* to has synced, or we'll get greet-floods when the net
* recovers from a netsplit. -GD
@@ -444,16 +444,17 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string &param, bo
if (cc)
cc->Status->UnsetFlag(cm->Name);
- /* Reset modes on bots if we're supposed to */
- if (bi)
+ if (EnforceMLock)
{
- if (std::find(Config->BotModeList.begin(), Config->BotModeList.end(), cm) != Config->BotModeList.end())
- this->SetMode(bi, cm, bi->nick);
- }
+ /* Reset modes on bots if we're supposed to */
+ if (bi)
+ {
+ if (Config->BotModeList.HasFlag(cm->Name))
+ this->SetMode(bi, cm, bi->nick);
+ }
- /* Enforce secureops, etc */
- if (EnforceMLock)
chan_set_correct_modes(u, this, 0);
+ }
return;
}
@@ -726,7 +727,10 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
continue;
cm = ModeManager::FindChannelModeByChar(m[i]);
if (!cm)
+ {
+ Log(LOG_DEBUG) << "Channel::SetModeInternal: Unknown mode char " << m[i];
continue;
+ }
modestring += cm->ModeChar;
}
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index 64cfeeef5..de43bb91c 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -109,6 +109,9 @@ int levelinfo_maxwidth = 0;
Anope::string get_mlock_modes(ChannelInfo *ci, int complete)
{
+ if (!ci)
+ return "";
+
Anope::string pos = "+", neg = "-", params;
for (std::multimap<ChannelModeName, ModeLock>::const_iterator it = ci->GetMLock().begin(), it_end = ci->GetMLock().end(); it != it_end; ++it)
diff --git a/src/commands.cpp b/src/commands.cpp
index 6944ac31e..b2e3b7192 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -141,6 +141,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
if (params.size() < c->MinParams)
{
c->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : "");
+ source.DoReply();
PopLanguage();
return;
}
@@ -149,6 +150,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, c, params));
if (MOD_RESULT == EVENT_STOP)
{
+ source.DoReply();
PopLanguage();
return;
}
@@ -158,16 +160,16 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
{
u->SendMessage(bi, LanguageString::ACCESS_DENIED);
Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command;
+ source.DoReply();
PopLanguage();
return;
}
CommandReturn ret = c->Execute(source, params);
+ if (ret == MOD_STOP)
+ return;
- if (ret == MOD_CONT)
- {
- FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params));
- }
+ FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params));
source.DoReply();
}
diff --git a/src/config.cpp b/src/config.cpp
index 6bf0a522f..cc0879936 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -317,6 +317,8 @@ ServerConfig::ServerConfig() : errstr(""), config_data(), NSDefFlags(NickCoreFla
}
SetDefaultMLock(this);
+ if (ircd)
+ InitLogChannels(this);
if (IsFile(this->NameServer))
{
@@ -950,9 +952,6 @@ bool DoLogs(ServerConfig *config, const Anope::string &, const Anope::string *,
bool DoneLogs(ServerConfig *config, const Anope::string &)
{
- if (ircd)
- InitLogChannels(config);
-
Log() << "Loaded " << config->LogInfos.size() << " log blocks";
return true;
diff --git a/src/init.cpp b/src/init.cpp
index 6ee84478a..fd2a1f3b1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -37,7 +37,7 @@ void introduce_user(const Anope::string &user)
ircdproto->SendSQLine(&x);
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
- ircdproto->SendJoin(bi, *cit);
+ ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
}
}
@@ -70,7 +70,7 @@ void introduce_user(const Anope::string &user)
ircdproto->SendSQLine(&x);
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
- ircdproto->SendJoin(bi, *cit);
+ ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
}
}
diff --git a/src/logger.cpp b/src/logger.cpp
index 42bac03cb..b40fdc11d 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -27,12 +27,8 @@ void InitLogChannels(ServerConfig *config)
if (target[0] == '#')
{
Channel *c = findchan(target);
- bool created = false;
if (!c)
- {
c = new Channel(target);
- created = true;
- }
c->SetFlag(CH_LOGCHAN);
c->SetFlag(CH_PERSIST);
@@ -41,9 +37,7 @@ void InitLogChannels(ServerConfig *config)
BotInfo *bi = *it;
if (bi->HasFlag(BI_CORE) && !c->FindUser(bi))
- {
- bi->Join(c, created);
- }
+ bi->Join(c, &config->BotModeList);
}
}
}
diff --git a/src/modes.cpp b/src/modes.cpp
index 3a79409a6..14b884896 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -68,36 +68,13 @@ void SetDefaultMLock(ServerConfig *config)
}
/* Set Bot Modes */
- config->BotModeList.clear();
+ config->BotModeList.ClearFlags();
for (unsigned i = 0; i < config->BotModes.length(); ++i)
{
ChannelMode *cm = ModeManager::FindChannelModeByChar(config->BotModes[i]);
- if (cm && cm->Type == MODE_STATUS && std::find(config->BotModeList.begin(), config->BotModeList.end(), cm) == config->BotModeList.end())
- config->BotModeList.push_back(debug_cast<ChannelModeStatus *>(cm));
- }
-
- /* Apply the new modes to channels */
- for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
- {
- BotInfo *bi = *it;
-
- for (UChannelList::const_iterator cit = bi->chans.begin(); cit != bi->chans.end(); ++cit)
- {
- ChannelContainer *cc = *cit;
-
- if (!cc || !cc->chan)
- continue;
-
- for (unsigned i = 0; i < config->BotModeList.size(); ++i)
- {
- if (cc->Status->HasFlag(config->BotModeList[i]->Name))
- continue;
-
- cc->Status->SetFlag(config->BotModeList[i]->Name);
- cc->chan->SetModeInternal(config->BotModeList[i], bi->nick, false);
- }
- }
+ if (cm && cm->Type == MODE_STATUS)
+ config->BotModeList.SetFlag(cm->Name);
}
}
diff --git a/src/protocol.cpp b/src/protocol.cpp
index a035d2f22..220b33622 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -212,11 +212,6 @@ void IRCDProto::SendPong(const Anope::string &servname, const Anope::string &who
send_cmd(ircd->ts6 ? Config->Numeric : Config->ServerName, "PONG %s %s", servname.c_str(), who.c_str());
}
-void IRCDProto::SendJoin(BotInfo *bi, const ChannelContainer *cc)
-{
- SendJoin(bi, cc->chan->name, cc->chan->creation_time);
-}
-
void IRCDProto::SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick)
{
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "INVITE %s %s", nick.c_str(), chan.c_str());
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 204745e0c..a04cb54df 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -568,8 +568,8 @@ void ChannelInfo::LoadMLock()
if (ModeManager::FindChannelModeByName(CMODE_PERM) != NULL)
{
/* At this point, CMODE_PERM *must* be locked on the channel, so this is fine */
- ircdproto->SendChannel(this->c, get_mlock_modes(this, true));
- this->c->SetModesInternal(NULL, get_mlock_modes(this, true));
+ ircdproto->SendChannel(this->c);
+ this->c->Reset();
}
else
{
@@ -577,10 +577,10 @@ void ChannelInfo::LoadMLock()
whosends(this)->Assign(NULL, this);
if (this->c->FindUser(this->bi) == NULL)
this->bi->Join(this->c);
- }
- check_modes(this->c);
- this->RestoreTopic();
+ check_modes(this->c);
+ this->RestoreTopic();
+ }
}
}
diff --git a/src/users.cpp b/src/users.cpp
index fa69b928a..fa486935f 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -823,7 +823,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
/*************************************************************************/
-void do_umode(const Anope::string &, const Anope::string &user, const Anope::string &modes)
+void do_umode(const Anope::string &user, const Anope::string &modes)
{
User *u = finduser(user);
if (!u)