summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-04 18:50:09 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-04 18:50:09 +0000
commit369aef56c68aecccac7c3c30108fd958cfdc62f0 (patch)
tree8307db770ef949cf64d9f3c0886a1a52f6b4f37e
parentfc8fb6b916e4dbb155af3e54a3c1cd5308fdf5e6 (diff)
Allow for custom prefixes as status chars in /notice @#chan etc. Up until now theyve just used a hard coded check on @%+. This slows down writing to a channels users by a small amount, but only when writing to a prefix is happening.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9329 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/channels.cpp22
-rw-r--r--src/commands/cmd_notice.cpp2
-rw-r--r--src/commands/cmd_privmsg.cpp2
-rw-r--r--src/modules/m_deaf.cpp21
-rw-r--r--src/modules/m_spanningtree/privmsg.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp28
6 files changed, 22 insertions, 55 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 52e8faca9..c03a69ace 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -721,25 +721,9 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
{
- CUList *ulist;
+ CUList *ulist = this->GetUsers();
char tb[MAXBUF];
- switch (status)
- {
- case '@':
- ulist = this->GetOppedUsers();
- break;
- case '%':
- ulist = this->GetHalfoppedUsers();
- break;
- case '+':
- ulist = this->GetVoicedUsers();
- break;
- default:
- ulist = this->GetUsers();
- break;
- }
-
snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
std::string out = tb;
@@ -747,6 +731,10 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
{
if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
{
+ /* User doesnt have the status we're after */
+ if (status && !strchr(this->GetAllPrefixChars(i->first), status))
+ continue;
+
if (serversource)
i->first->WriteServ(text);
else
diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp
index ee9868fb3..1a47b56fb 100644
--- a/src/commands/cmd_notice.cpp
+++ b/src/commands/cmd_notice.cpp
@@ -51,7 +51,7 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
}
char status = 0;
const char* target = parameters[0];
- if ((*target == '@') || (*target == '%') || (*target == '+'))
+ if (ServerInstance->Modes->FindPrefix(*target))
{
status = *target;
target++;
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index c9100dcd9..9ce089dc0 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -50,7 +50,7 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
}
char status = 0;
const char* target = parameters[0];
- if ((*target == '@') || (*target == '%') || (*target == '+'))
+ if (ServerInstance->Modes->FindPrefix(*target))
{
status = *target;
target++;
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 6431462f3..179a443a7 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -109,7 +109,7 @@ class ModuleDeaf : public Module
virtual void BuildDeafList(MessageType message_type, Channel* chan, User* sender, char status, const std::string &text, CUList &exempt_list)
{
- CUList *ulist;
+ CUList *ulist = chan->GetUsers();
bool is_a_uline;
bool is_bypasschar, is_bypasschar_avail;
bool is_bypasschar_uline, is_bypasschar_uline_avail;
@@ -135,22 +135,6 @@ class ModuleDeaf : public Module
if (!is_bypasschar_uline_avail && is_bypasschar)
return;
- switch (status)
- {
- case '@':
- ulist = chan->GetOppedUsers();
- break;
- case '%':
- ulist = chan->GetHalfoppedUsers();
- break;
- case '+':
- ulist = chan->GetVoicedUsers();
- break;
- default:
- ulist = chan->GetUsers();
- break;
- }
-
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
/* not +d ? */
@@ -168,6 +152,9 @@ class ModuleDeaf : public Module
if (is_bypasschar && !is_a_uline)
continue; /* deliver message */
+ if (status && !strchr(chan->GetAllPrefixChars(i->first), status))
+ continue;
+
/* don't deliver message! */
exempt_list[i->first] = i->first->nick;
}
diff --git a/src/modules/m_spanningtree/privmsg.cpp b/src/modules/m_spanningtree/privmsg.cpp
index 4a266a465..316ad2e5c 100644
--- a/src/modules/m_spanningtree/privmsg.cpp
+++ b/src/modules/m_spanningtree/privmsg.cpp
@@ -32,7 +32,7 @@ bool TreeSocket::ServerMessage(const std::string &messagetype, const std::string
const char* target = params[0].c_str();
std::string text = params[1].c_str();
- if ((*target == '@') || (*target == '%') || (*target == '+'))
+ if (Instance->Modes->FindPrefix(*target))
{
status = *target;
target++;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 8181969ac..bc295766f 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -162,25 +162,17 @@ void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &li
/* returns a list of DIRECT servernames for a specific channel */
void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list)
{
- CUList *ulist;
- switch (status)
- {
- case '@':
- ulist = c->GetOppedUsers();
- break;
- case '%':
- ulist = c->GetHalfoppedUsers();
- break;
- case '+':
- ulist = c->GetVoicedUsers();
- break;
- default:
- ulist = c->GetUsers();
- break;
- }
+ CUList *ulist = c->GetUsers();
+
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- if ((i->first->GetFd() < 0) && (exempt_list.find(i->first) == exempt_list.end()))
+ if (IS_LOCAL(i->first))
+ continue;
+
+ if (status && !strchr(c->GetAllPrefixChars(i->first), status))
+ continue;
+
+ if (exempt_list.find(i->first) == exempt_list.end())
{
TreeServer* best = this->BestRouteTo(i->first->server);
if (best)
@@ -199,7 +191,7 @@ bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, cons
if (params.size() >= 2)
{
/* Prefixes */
- if ((*(params[0].c_str()) == '@') || (*(params[0].c_str()) == '%') || (*(params[0].c_str()) == '+'))
+ if (ServerInstance->Modes->FindPrefix(params[0][0]))
{
pfx = params[0][0];
params[0] = params[0].substr(1, params[0].length()-1);