mirror of
https://github.com/anope/anope.git
synced 2026-07-07 16:03:15 +02:00
Simplify several boolean expressions.
This commit is contained in:
@@ -26,9 +26,7 @@ public:
|
||||
bool HasPriv(const Anope::string &priv) const override
|
||||
{
|
||||
std::map<Anope::string, char>::iterator it = defaultFlags.find(priv);
|
||||
if (it != defaultFlags.end() && this->flags.count(it->second) > 0)
|
||||
return true;
|
||||
return false;
|
||||
return it != defaultFlags.end() && this->flags.count(it->second) > 0;
|
||||
}
|
||||
|
||||
Anope::string AccessSerialize() const override
|
||||
@@ -324,7 +322,7 @@ class CommandCSFlags final
|
||||
for (size_t j = 1; j < arg.length(); ++j)
|
||||
if (flags.find(arg[j]) == Anope::string::npos)
|
||||
pass = false;
|
||||
if (pass == false)
|
||||
if (!pass)
|
||||
continue;
|
||||
}
|
||||
else if (!Anope::Match(access->Mask(), arg))
|
||||
|
||||
@@ -262,7 +262,7 @@ public:
|
||||
|
||||
ModeLocks *ml = ci->GetExt<ModeLocks>("modelocks");
|
||||
const ModeLock *secret = ml ? ml->GetMLock("SECRET") : NULL;
|
||||
if (!ci->last_topic.empty() && (show_all || ((!secret || secret->set == false) && (!ci->c || !ci->c->HasMode("SECRET")))))
|
||||
if (!ci->last_topic.empty() && (show_all || ((!secret || !secret->set) && (!ci->c || !ci->c->HasMode("SECRET")))))
|
||||
{
|
||||
info[_("Last topic")] = ci->last_topic;
|
||||
info[_("Topic set by")] = ci->last_topic_setter;
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
if (!source.AccessFor(ci).HasPriv("UNBAN") &&
|
||||
!(u2 == source.GetUser() && source.AccessFor(ci).HasPriv("UNBANME")) &&
|
||||
(u2 != source.GetUser() || !source.AccessFor(ci).HasPriv("UNBANME")) &&
|
||||
!source.HasPriv("chanserv/kick"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ class Packet final
|
||||
throw SocketException("Unable to unpack name - bogus compression header");
|
||||
|
||||
/* Place pos at the second byte of the first (farthest) compression pointer */
|
||||
if (compressed == false)
|
||||
if (!compressed)
|
||||
{
|
||||
++pos;
|
||||
compressed = true;
|
||||
@@ -95,7 +95,7 @@ class Packet final
|
||||
name += input[pos_ptr + i];
|
||||
|
||||
pos_ptr += offset + 1;
|
||||
if (compressed == false)
|
||||
if (!compressed)
|
||||
/* Move up pos */
|
||||
pos = pos_ptr;
|
||||
}
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
if (helped == false)
|
||||
if (!helped)
|
||||
source.Reply(_("No help available for \002%s\002."), params[0].c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,7 @@ class CommandHSRequest final
|
||||
{
|
||||
bool isvalidchar(char c)
|
||||
{
|
||||
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-')
|
||||
return true;
|
||||
return false;
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-';
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public:
|
||||
/* Close connection once all data is written */
|
||||
bool ProcessWrite() override
|
||||
{
|
||||
return !BinarySocket::ProcessWrite() || this->write_buffer.empty() ? false : true;
|
||||
return !(!BinarySocket::ProcessWrite() || this->write_buffer.empty());
|
||||
}
|
||||
|
||||
const Anope::string GetIP() override
|
||||
|
||||
@@ -146,7 +146,7 @@ class CommandNSAJoin final
|
||||
}
|
||||
else if (i != (*channels)->size())
|
||||
alreadyadded += chan + ", ";
|
||||
else if (IRCD->IsChannelValid(chan) == false)
|
||||
else if (!IRCD->IsChannelValid(chan))
|
||||
source.Reply(CHAN_X_INVALID, chan.c_str());
|
||||
else
|
||||
{
|
||||
@@ -361,9 +361,9 @@ public:
|
||||
continue;
|
||||
else if (c->HasMode("SSL") && !u->IsSecurelyConnected())
|
||||
continue;
|
||||
else if (c->MatchesList(u, "BAN") == true && c->MatchesList(u, "EXCEPT") == false)
|
||||
else if (c->MatchesList(u, "BAN") && !c->MatchesList(u, "EXCEPT"))
|
||||
need_invite = true;
|
||||
else if (c->HasMode("INVITE") && c->MatchesList(u, "INVITEOVERRIDE") == false)
|
||||
else if (c->HasMode("INVITE") && !c->MatchesList(u, "INVITEOVERRIDE"))
|
||||
need_invite = true;
|
||||
|
||||
if (c->HasMode("KEY"))
|
||||
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
if (user != NULL && !user->fingerprint.empty() && cl && cl->FindCert(user->fingerprint))
|
||||
ok = true;
|
||||
|
||||
if (ok == false && !pass.empty())
|
||||
if (!ok && !pass.empty())
|
||||
{
|
||||
auto *req = new NSGroupRequest(owner, source, this, source.GetNick(), target, pass);
|
||||
FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req));
|
||||
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
if (source.HasPriv("nickserv/recover"))
|
||||
ok = true;
|
||||
|
||||
if (ok == false && !pass.empty())
|
||||
if (!ok && !pass.empty())
|
||||
{
|
||||
auto *req = new NSRecoverRequest(owner, source, this, na->nick, pass);
|
||||
FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req));
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
NickAlias *na = NickAlias::Find(nick);
|
||||
if (na == NULL)
|
||||
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
|
||||
else if (na->nc->HasExt("UNCONFIRMED") == false)
|
||||
else if (!na->nc->HasExt("UNCONFIRMED"))
|
||||
source.Reply(_("Nick \002%s\002 is already confirmed."), na->nick.c_str());
|
||||
else
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
Log(LOG_ADMIN, source, this) << "for " << search_string;
|
||||
|
||||
bool wildcard = search_string.find_first_of("?*") != Anope::string::npos;
|
||||
bool regex = search_string.empty() == false && search_string[0] == '/' && search_string[search_string.length() - 1] == '/';
|
||||
bool regex = !search_string.empty() && search_string[0] == '/' && search_string[search_string.length() - 1] == '/';
|
||||
|
||||
const Anope::string &logfile_name = Config->GetModule(this->owner)->Get<const Anope::string>("logname");
|
||||
std::vector<Anope::string> matches;
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
|
||||
void SendLogin(User *u, NickAlias *na) override
|
||||
{
|
||||
if (UseSVSAccount == false)
|
||||
if (!UseSVSAccount)
|
||||
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d", na->nc->display);
|
||||
else
|
||||
Uplink::Send("SVSACCOUNT", u->GetUID(), u->timestamp, na->nc->display);
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
|
||||
void SendLogout(User *u) override
|
||||
{
|
||||
if (UseSVSAccount == false)
|
||||
if (!UseSVSAccount)
|
||||
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d", '*');
|
||||
else
|
||||
Uplink::Send("SVSACCOUNT", u->GetUID(), u->timestamp, '*');
|
||||
|
||||
@@ -687,7 +687,7 @@ public:
|
||||
size_t p = 0;
|
||||
while (p < arg.length() && isdigit(arg[p]))
|
||||
++p;
|
||||
if (p == arg.length() || !(arg[p] == 'c' || arg[p] == 'j' || arg[p] == 'k' || arg[p] == 'm' || arg[p] == 'n' || arg[p] == 't'))
|
||||
if (p == arg.length() || (arg[p] != 'c' && arg[p] != 'j' && arg[p] != 'k' && arg[p] != 'm' && arg[p] != 'n' && arg[p] != 't'))
|
||||
continue; /* continue instead of break for forward compatibility. */
|
||||
try
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ class ProxyCallbackListener final
|
||||
|
||||
bool ProcessWrite() override
|
||||
{
|
||||
return !BufferedSocket::ProcessWrite() || this->write_buffer.empty() ? false : true;
|
||||
return !(!BufferedSocket::ProcessWrite() || this->write_buffer.empty());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
|
||||
|
||||
if (u_access.HasPriv("ACCESS_CHANGE") || has_priv)
|
||||
{
|
||||
if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
|
||||
if (!message.get_data["del"].empty() && !message.get_data["mask"].empty())
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(ci->name);
|
||||
@@ -57,7 +57,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
|
||||
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/access", params, replacements);
|
||||
}
|
||||
else if (message.post_data["mask"].empty() == false && message.post_data["access"].empty() == false && message.post_data["provider"].empty() == false)
|
||||
else if (!message.post_data["mask"].empty() && !message.post_data["access"].empty() && !message.post_data["provider"].empty())
|
||||
{
|
||||
const Anope::string &provider = message.post_data["provider"];
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st
|
||||
|
||||
replacements["AKICK"] = "YES";
|
||||
|
||||
if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
|
||||
if (!message.get_data["del"].empty() && !message.get_data["mask"].empty())
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(ci->name);
|
||||
@@ -55,13 +55,13 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st
|
||||
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
|
||||
}
|
||||
else if (message.post_data["mask"].empty() == false)
|
||||
else if (!message.post_data["mask"].empty())
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(ci->name);
|
||||
params.emplace_back("ADD");
|
||||
params.push_back(message.post_data["mask"]);
|
||||
if (message.post_data["reason"].empty() == false)
|
||||
if (!message.post_data["reason"].empty())
|
||||
params.push_back(message.post_data["reason"]);
|
||||
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
|
||||
|
||||
@@ -73,7 +73,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByChar(mode[0]);
|
||||
if (cm)
|
||||
{
|
||||
if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
|
||||
if (!message.get_data["del"].empty() && !message.get_data["mask"].empty())
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(ci->name);
|
||||
@@ -82,7 +82,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
|
||||
params.push_back(message.get_data["mask"]);
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements);
|
||||
}
|
||||
else if (message.post_data["mask"].empty() == false)
|
||||
else if (!message.post_data["mask"].empty())
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(ci->name);
|
||||
|
||||
@@ -42,7 +42,7 @@ bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::stri
|
||||
can_set = true;
|
||||
}
|
||||
|
||||
if (can_set && message.post_data.empty() == false)
|
||||
if (can_set && !message.post_data.empty())
|
||||
{
|
||||
if (ci->HasExt("KEEPTOPIC") != message.post_data.count("keeptopic"))
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::
|
||||
|
||||
if (na->HasVhost())
|
||||
{
|
||||
if (na->GetVhostIdent().empty() == false)
|
||||
if (!na->GetVhostIdent().empty())
|
||||
replacements["VHOST"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
|
||||
else
|
||||
replacements["VHOST"] = na->GetVhostHost();
|
||||
|
||||
@@ -13,7 +13,7 @@ WebCPanel::NickServ::Info::Info(const Anope::string &cat, const Anope::string &u
|
||||
|
||||
bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
if (message.post_data.empty() == false)
|
||||
if (!message.post_data.empty())
|
||||
{
|
||||
if (message.post_data.count("email") > 0)
|
||||
{
|
||||
@@ -85,12 +85,12 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str
|
||||
}
|
||||
|
||||
replacements["DISPLAY"] = na->nc->display;
|
||||
if (na->nc->email.empty() == false)
|
||||
if (!na->nc->email.empty())
|
||||
replacements["EMAIL"] = na->nc->email;
|
||||
replacements["TIME_REGISTERED"] = Anope::strftime(na->time_registered, na->nc);
|
||||
if (na->HasVhost())
|
||||
{
|
||||
if (na->GetVhostIdent().empty() == false)
|
||||
if (!na->GetVhostIdent().empty())
|
||||
replacements["VHOST"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
|
||||
else
|
||||
replacements["VHOST"] = na->GetVhostHost();
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ public:
|
||||
Anope::string Sanitize(const Anope::string &string) override
|
||||
{
|
||||
Anope::string ret = string;
|
||||
for (int i = 0; special[i].character.empty() == false; ++i)
|
||||
for (int i = 0; !special[i].character.empty(); ++i)
|
||||
ret = ret.replace_all_cs(special[i].character, special[i].replace);
|
||||
return ret;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
static Anope::string Unescape(const Anope::string &string)
|
||||
{
|
||||
Anope::string ret = string;
|
||||
for (int i = 0; special[i].character.empty() == false; ++i)
|
||||
for (int i = 0; !special[i].character.empty(); ++i)
|
||||
if (!special[i].replace.empty())
|
||||
ret = ret.replace_all_cs(special[i].replace, special[i].character);
|
||||
|
||||
|
||||
+1
-4
@@ -260,10 +260,7 @@ void InfoFormatter::AddOption(const Anope::string &opt)
|
||||
bool Anope::IsFile(const Anope::string &filename)
|
||||
{
|
||||
struct stat fileinfo;
|
||||
if (!stat(filename.c_str(), &fileinfo))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return stat(filename.c_str(), &fileinfo) == 0;
|
||||
}
|
||||
|
||||
time_t Anope::DoTime(const Anope::string &s)
|
||||
|
||||
+1
-4
@@ -233,10 +233,7 @@ bool UserModeNoone::CanSet(User *u) const
|
||||
|
||||
bool ChannelModeKey::IsValid(Anope::string &value) const
|
||||
{
|
||||
if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return !value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos;
|
||||
}
|
||||
|
||||
bool ChannelModeOperOnly::CanSet(User *u) const
|
||||
|
||||
+2
-2
@@ -271,10 +271,10 @@ bool IRCDProto::IsNickValid(const Anope::string &nick)
|
||||
Anope::string special = "[]\\`_^{|}";
|
||||
|
||||
for (unsigned i = 0; i < nick.length(); ++i)
|
||||
if (!(nick[i] >= 'A' && nick[i] <= 'Z') && !(nick[i] >= 'a' && nick[i] <= 'z')
|
||||
if ((nick[i] < 'A' || nick[i] > 'Z') && (nick[i] < 'a' || nick[i] > 'z')
|
||||
&& special.find(nick[i]) == Anope::string::npos
|
||||
&& (Config && Config->NickChars.find(nick[i]) == Anope::string::npos)
|
||||
&& (!i || (!(nick[i] >= '0' && nick[i] <= '9') && nick[i] != '-')))
|
||||
&& (!i || ((nick[i] < '0' || nick[i] > '9') && nick[i] != '-')))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ UplinkSocket::~UplinkSocket()
|
||||
bool UplinkSocket::ProcessRead()
|
||||
{
|
||||
bool b = BufferedSocket::ProcessRead();
|
||||
for (Anope::string buf; (buf = this->GetLine()).empty() == false;)
|
||||
for (Anope::string buf; !(buf = this->GetLine()).empty();)
|
||||
{
|
||||
Anope::Process(buf);
|
||||
User::QuitUsers();
|
||||
|
||||
+1
-1
@@ -443,7 +443,7 @@ bool User::IsIdentified(bool check_nick) const
|
||||
return na && *na->nc == *this->nc;
|
||||
}
|
||||
|
||||
return this->nc ? true : false;
|
||||
return this->nc;
|
||||
}
|
||||
|
||||
bool User::IsRecognized(bool check_secure) const
|
||||
|
||||
Reference in New Issue
Block a user