diff options
author | Adam <Adam@sigterm.info> | 2023-05-28 21:25:02 -0400 |
---|---|---|
committer | Adam <Adam@sigterm.info> | 2023-05-28 21:26:03 -0400 |
commit | 66f37139cba97f2bb2a490376ffc33f153900b6c (patch) | |
tree | 8e36db8bfb468bcac8663eb462145d6a06fece45 /src | |
parent | 0646547c9eecc464dfc3c6fb0c7dfa9a3298a268 (diff) |
regchannels: remove dependency on no-delete-null-pointer-checks
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 23 | ||||
-rw-r--r-- | src/logger.cpp | 2 | ||||
-rw-r--r-- | src/modes.cpp | 2 | ||||
-rw-r--r-- | src/regchannel.cpp | 5 | ||||
-rw-r--r-- | src/servers.cpp | 4 |
5 files changed, 26 insertions, 10 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 6fcd62b67..8a1f89081 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -783,7 +783,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) return false; if (bi == NULL) - bi = this->ci->WhoSends(); + bi = this->WhoSends(); EventReturn MOD_RESULT; FOREACH_RESULT(OnBotKick, MOD_RESULT, (bi, this, u, buf)); @@ -812,7 +812,7 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop this->topic_setter = user; this->topic_ts = ts; - IRCD->SendTopic(this->ci->WhoSends(), this); + IRCD->SendTopic(this->WhoSends(), this); /* Now that the topic is set update the time set. This is *after* we set it so the protocol modules are able to tell the old last set time */ this->topic_time = Anope::CurTime; @@ -911,8 +911,10 @@ bool Channel::CheckKick(User *user) if (MOD_RESULT != EVENT_STOP) return false; - if (mask.empty()) + if (mask.empty() && this->ci) mask = this->ci->GetIdealBan(user); + if (mask.empty()) + mask = "*!*@" + user->GetDisplayedHost(); if (reason.empty()) reason = Language::Translate(user->Account(), CHAN_NOT_ALLOWED_TO_JOIN); @@ -924,6 +926,21 @@ bool Channel::CheckKick(User *user) return true; } +BotInfo* Channel::WhoSends() const +{ + if (ci) + return ci->WhoSends(); + + BotInfo *ChanServ = Config->GetClient("ChanServ"); + if (ChanServ) + return ChanServ; + + if (!BotListByNick->empty()) + return BotListByNick->begin()->second; + + return NULL; +} + Channel* Channel::Find(const Anope::string &name) { channel_map::const_iterator it = ChannelList.find(name); diff --git a/src/logger.cpp b/src/logger.cpp index 244cacdba..acacda286 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -369,7 +369,7 @@ void LogInfo::ProcessMessage(const Log *l) if (!bi) bi = this->bot; if (!bi) - bi = c->ci->WhoSends(); + bi = c->WhoSends(); if (bi) IRCD->SendPrivmsg(bi, c->name, "%s", buffer.c_str()); } diff --git a/src/modes.cpp b/src/modes.cpp index c5675b119..5f950df57 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -617,7 +617,7 @@ void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, if (bi) s->bi = bi; else - s->bi = c->ci->WhoSends(); + s->bi = c->WhoSends(); if (!modePipe) modePipe = new ModePipe(); diff --git a/src/regchannel.cpp b/src/regchannel.cpp index d420ab0df..984da55ab 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -355,7 +355,7 @@ NickCore *ChannelInfo::GetSuccessor() const BotInfo *ChannelInfo::WhoSends() const { - if (this && this->bi) + if (this->bi) return this->bi; BotInfo *ChanServ = Config->GetClient("ChanServ"); @@ -629,8 +629,7 @@ void ChannelInfo::ClearLevels() Anope::string ChannelInfo::GetIdealBan(User *u) const { - int bt = this ? this->bantype : -1; - switch (bt) + switch (this->bantype) { case 0: return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); diff --git a/src/servers.cpp b/src/servers.cpp index 54dd853b5..23ea18139 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -121,11 +121,11 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano ChannelMode *cm = ModeManager::FindChannelModeByName(it2->first); if (!cm || cm->type != MODE_LIST) continue; - ModeManager::StackerAdd(c->ci->WhoSends(), c, cm, true, it2->second); + ModeManager::StackerAdd(c->WhoSends(), c, cm, true, it2->second); } if (!c->topic.empty() && !c->topic_setter.empty()) - IRCD->SendTopic(c->ci->WhoSends(), c); + IRCD->SendTopic(c->WhoSends(), c); c->syncing = true; } |