aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2026-03-08 17:01:22 +0000
committerGravatar Sadie Powell2026-03-08 17:47:44 +0000
commitbb1e5a7b60ea200ddae99f263a38a219879f9617 (patch)
treea5cecddf75a3458447d09ca1fa2f859c4486ddec /src
parentRemove the unused remote user finding methods. (diff)
Replace IS_* with member functions.
- All user types get an Is* function. - Only local users are cast using the old function so only local users get an As* function.
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp6
-rw-r--r--src/commands.cpp4
-rw-r--r--src/listmode.cpp2
-rw-r--r--src/mode.cpp10
-rw-r--r--src/snomasks.cpp2
-rw-r--r--src/usermanager.cpp12
-rw-r--r--src/users.cpp30
-rw-r--r--src/xline.cpp4
8 files changed, 42 insertions, 28 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 62cf702df..d5d481f68 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -216,7 +216,7 @@ Membership* Channel::JoinUser(LocalUser* user, std::string cname, bool override,
Membership* Channel::ForceJoin(User* user, const std::string* privs, bool bursting, bool created_by_local)
{
- if (IS_SERVER(user))
+ if (user->IsServer())
{
ServerInstance->Logs.Debug("CHANNELS", "Attempted to join server user {} to channel {}",
user->uuid, this->name);
@@ -352,7 +352,7 @@ void Channel::Write(ClientProtocol::Event& protoev, char status, const CUList& e
for (const auto& [u, memb] : userlist)
{
- LocalUser* user = IS_LOCAL(u);
+ auto* user = u->AsLocal();
if ((user) && (!except_list.count(user)))
{
/* User doesn't have the status we're after */
@@ -471,7 +471,7 @@ bool Membership::SetPrefix(PrefixMode* delta_mh, bool adding)
void Membership::WriteNotice(const std::string& text) const
{
- LocalUser* const localuser = IS_LOCAL(user);
+ auto* const localuser = user->AsLocal();
if (!localuser)
return;
diff --git a/src/commands.cpp b/src/commands.cpp
index d84937d49..f2ec94ab6 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -63,7 +63,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const CommandBase::Pa
irc::commasepstream items2(extra != SIZE_MAX ? parameters[extra] : "", true);
std::string item;
size_t max = 0;
- LocalUser* localuser = IS_LOCAL(user);
+ auto* localuser = user->AsLocal();
/* Attempt to iterate these lists and call the command handler
* for every parameter or parameter pair until there are no more
@@ -123,7 +123,7 @@ CmdResult CommandParser::CallHandler(const std::string& commandname, const Comma
if (parameters.size() >= handler->min_params)
{
bool bOkay = true;
- if (IS_LOCAL(user))
+ if (user->IsLocal())
bOkay = handler->IsUsableBy(user);
if (bOkay)
diff --git a/src/listmode.cpp b/src/listmode.cpp
index 35843e385..446d523e4 100644
--- a/src/listmode.cpp
+++ b/src/listmode.cpp
@@ -153,7 +153,7 @@ size_t ListModeBase::GetLowerLimit()
bool ListModeBase::OnModeChange(User* source, User*, Channel* channel, Modes::Change& change)
{
- LocalUser* lsource = IS_LOCAL(source);
+ auto* lsource = source->AsLocal();
if (change.adding)
{
// Try to canonicalise the parameter locally.
diff --git a/src/mode.cpp b/src/mode.cpp
index 5496e6457..33bf6d0ff 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -203,7 +203,7 @@ ModResult PrefixMode::AccessCheck(User* src, Channel*, Modes::Change& change)
bool PrefixMode::OnModeChange(User* source, User*, Channel* chan, Modes::Change& change)
{
User* target;
- if (IS_LOCAL(source))
+ if (source->IsLocal())
target = ServerInstance->Users.FindNick(change.param);
else
target = ServerInstance->Users.Find(change.param);
@@ -273,7 +273,7 @@ bool ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Modes::Cha
ModResult modres;
FIRST_MOD_RESULT(OnRawMode, modres, (user, chan, mcitem));
- if (IS_LOCAL(user) && (modres == MOD_RES_DENY))
+ if (user->IsLocal() && (modres == MOD_RES_DENY))
return false;
const char modechar = mh->GetModeChar();
@@ -311,7 +311,7 @@ bool ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Modes::Cha
}
}
- if ((chan || (!chan && mcitem.adding)) && IS_LOCAL(user) && mh->NeedsOper() && !user->HasModePermission(mh))
+ if ((chan || (!chan && mcitem.adding)) && user->IsLocal() && mh->NeedsOper() && !user->HasModePermission(mh))
{
/* It's an oper only mode, and they don't have access to it. */
if (user->IsOper())
@@ -473,9 +473,9 @@ size_t ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* targe
{
targetchannel->Write(modeevent);
}
- else
+ else if (targetuser)
{
- LocalUser* localtarget = IS_LOCAL(targetuser);
+ auto* localtarget = targetuser->AsLocal();
if (localtarget)
localtarget->Send(modeevent);
}
diff --git a/src/snomasks.cpp b/src/snomasks.cpp
index a2e1587dc..37012aee1 100644
--- a/src/snomasks.cpp
+++ b/src/snomasks.cpp
@@ -119,7 +119,7 @@ void Snomask::Send(char letter, const std::string& desc, const std::string& msg)
for (auto* user : ServerInstance->Users.all_opers)
{
// IsNoticeMaskSet() returns false for opers who aren't +s, no need to check for it separately
- if (IS_LOCAL(user) && user->IsNoticeMaskSet(letter))
+ if (user->IsLocal() && user->IsNoticeMaskSet(letter))
user->WriteNotice(finalmsg);
}
}
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index e70e1c465..e58ffdf23 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -201,7 +201,7 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
return;
}
- if (IS_SERVER(user))
+ if (user->IsServer())
{
ServerInstance->Logs.Debug("USERS", "BUG: Tried to quit server user: {}", user->nick);
return;
@@ -212,7 +212,7 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
if (operquitmessage)
operquitmsg.assign(*operquitmessage);
- LocalUser* const localuser = IS_LOCAL(user);
+ auto* const localuser = user->AsLocal();
if (localuser)
{
ModResult modres;
@@ -247,9 +247,9 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
else
unknown_count--;
- if (IS_LOCAL(user))
+ if (user->IsLocal())
{
- LocalUser* lu = IS_LOCAL(user);
+ auto* lu = user->AsLocal();
FOREACH_MOD(OnUserDisconnect, (lu));
lu->io->Close();
@@ -275,7 +275,7 @@ void UserManager::AddClone(User* user)
{
CloneCounts& counts = clonemap[user->GetCIDRMask()];
counts.global++;
- if (IS_LOCAL(user))
+ if (user->IsLocal())
counts.local++;
}
@@ -293,7 +293,7 @@ void UserManager::RemoveCloneCounts(User* user)
return;
}
- if (IS_LOCAL(user))
+ if (user->IsLocal())
counts.local--;
}
}
diff --git a/src/users.cpp b/src/users.cpp
index e1e5024fd..e92beb4ba 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -239,7 +239,7 @@ Cullable::Result FakeUser::Cull()
bool User::OperLogin(const std::shared_ptr<OperAccount>& account, bool automatic, bool force)
{
- LocalUser* luser = IS_LOCAL(this);
+ auto* luser = this->AsLocal();
if (luser && !quitting && !force)
{
ModResult modres;
@@ -460,6 +460,20 @@ void LocalUser::OverruleNick()
this->ChangeNick(this->uuid);
}
+LocalUser* User::AsLocal()
+{
+ return this->IsLocal()
+ ? static_cast<LocalUser*>(this)
+ : nullptr;
+}
+
+const LocalUser* User::AsLocal() const
+{
+ return this->IsLocal()
+ ? static_cast<const LocalUser*>(this)
+ : nullptr;
+}
+
const std::string& User::GetBanUser(bool real) const
{
static const std::string wildcard = "*";
@@ -661,7 +675,7 @@ bool LocalUserIO::CheckMaxSendQ(size_t extra) const
void User::WriteNumeric(const Numeric::Numeric& numeric)
{
- LocalUser* const localuser = IS_LOCAL(this);
+ auto* const localuser = this->AsLocal();
if (!localuser)
return;
@@ -678,8 +692,8 @@ void User::WriteNumeric(const Numeric::Numeric& numeric)
void User::WriteReply(const Reply::Reply& reply)
{
- auto* lthis = IS_LOCAL(this);
- if (!IS_LOCAL(this))
+ auto* lthis = this->AsLocal();
+ if (!this->IsLocal())
return;
ClientProtocol::Messages::Reply replymsg(reply);
@@ -745,7 +759,7 @@ uint64_t User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_sel
// Handle exceptions first
for (NeighborExceptions::const_iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
- LocalUser* curr = IS_LOCAL(i->first);
+ auto* curr = i->first->AsLocal();
if (curr)
{
// Mark as visited to ensure we won't visit again if there is a common channel
@@ -761,7 +775,7 @@ uint64_t User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_sel
{
for (const auto& [user, _] : memb->chan->GetUsers())
{
- LocalUser* curr = IS_LOCAL(user);
+ auto* curr = user->AsLocal();
// User not yet visited?
if ((curr) && (curr->already_sent != newid))
{
@@ -830,7 +844,7 @@ void User::ChangeDisplayedHost(const std::string& newhost)
this->InvalidateCache();
- if (IS_LOCAL(this) && connected != User::CONN_NONE)
+ if (this->IsLocal() && connected != User::CONN_NONE)
this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->GetDisplayedHost(), "is now your displayed host");
}
@@ -945,7 +959,7 @@ void User::PurgeEmptyChannels()
void User::WriteNotice(const std::string& text)
{
- LocalUser* const localuser = IS_LOCAL(this);
+ auto* const localuser = this->AsLocal();
if (!localuser)
return;
diff --git a/src/xline.cpp b/src/xline.cpp
index 6f077ee5f..ec68b11ab 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -565,7 +565,7 @@ void XLine::DefaultApply(User* u, bool bancache)
bool GLine::Matches(User* u) const
{
- LocalUser* lu = IS_LOCAL(u);
+ auto* lu = u->AsLocal();
if (lu && lu->exempt)
return false;
@@ -602,7 +602,7 @@ bool ELine::Matches(User* u) const
bool ZLine::Matches(User* u) const
{
- LocalUser* lu = IS_LOCAL(u);
+ auto* lu = u->AsLocal();
if (lu && lu->exempt)
return false;