1
0
mirror of https://github.com/anope/anope.git synced 2026-07-06 23:03:14 +02:00

regchannels: remove dependency on no-delete-null-pointer-checks

This commit is contained in:
Adam
2023-05-28 21:25:02 -04:00
parent 0646547c9e
commit 66f37139cb
12 changed files with 39 additions and 18 deletions
+5
View File
@@ -289,6 +289,11 @@ class CoreExport Channel : public Base, public Extensible
*/
bool CheckKick(User *user);
/** Find which bot should send mode/topic/etc changes for this channel
* @return The bot
*/
BotInfo *WhoSends() const;
/** Finds a channel
* @param name The channel to find
* @return The channel, if found
+1 -1
View File
@@ -284,7 +284,7 @@ class NSRecover : public Module
if (it != ei->end())
{
for (size_t i = 0; i < it->second.Modes().length(); ++i)
c->SetMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID());
c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID());
ei->erase(it);
if (ei->empty())
+2 -2
View File
@@ -37,7 +37,7 @@ class CommandOSMode : public Command
const Channel::ModeList chmodes = c->GetModes();
for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it)
c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false);
c->RemoveMode(c->WhoSends(), it->first, it->second, false);
if (!c)
{
@@ -55,7 +55,7 @@ class CommandOSMode : public Command
continue;
for (size_t i = uc->status.Modes().length(); i > 0; --i)
c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false);
c->RemoveMode(c->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false);
}
source.Reply(_("All modes cleared on %s."), c->name.c_str());
+1 -1
View File
@@ -144,7 +144,7 @@ class InspIRCd12Proto : public IRCDProto
{
if (Servers::Capab.count("SVSTOPIC"))
{
UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
}
else
{
+1 -1
View File
@@ -179,7 +179,7 @@ class InspIRCd3Proto : public IRCDProto
{
if (Servers::Capab.count("SVSTOPIC"))
{
UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
}
else
{
+1 -1
View File
@@ -362,7 +362,7 @@ class UnrealIRCdProto : public IRCDProto
/* Unreal does not support updating a channels TS without actually joining a user,
* so we will join and part us now
*/
BotInfo *bi = c->ci->WhoSends();
BotInfo *bi = c->WhoSends();
if (!bi)
;
else if (c->FindUser(bi) == NULL)
+2 -2
View File
@@ -288,7 +288,7 @@ class ChanServCore : public Module, public ChanServService
if (c->ci)
c->SetMode(c->ci->WhoSends(), "REGISTERED", "", false);
else
c->RemoveMode(c->ci->WhoSends(), "REGISTERED", "", false);
c->RemoveMode(c->WhoSends(), "REGISTERED", "", false);
const Anope::string &require = Config->GetModule(this)->Get<const Anope::string>("require");
if (!require.empty())
@@ -296,7 +296,7 @@ class ChanServCore : public Module, public ChanServService
if (c->ci)
c->SetModes(c->ci->WhoSends(), false, "+%s", require.c_str());
else
c->SetModes(c->ci->WhoSends(), false, "-%s", require.c_str());
c->SetModes(c->WhoSends(), false, "-%s", require.c_str());
}
}
+20 -3
View File
@@ -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);
+1 -1
View File
@@ -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());
}
+1 -1
View File
@@ -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();
+2 -3
View File
@@ -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();
+2 -2
View File
@@ -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;
}