summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-12 14:26:15 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-12 14:26:15 +0000
commit988568f3d1cc2247fa3adbadd8daa0ee175fcb1d (patch)
tree00623416ea844e1fce5343f1073bb6dbaa75511b /src
parentc73881748324fb454153c2d0fd85e8b80996b2b7 (diff)
*NEEDS TESTING* changed binarymodes to use the custom_modes entries
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3691 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp7
-rw-r--r--src/cmd_invite.cpp2
-rw-r--r--src/cmd_list.cpp2
-rw-r--r--src/cmd_names.cpp2
-rw-r--r--src/cmd_notice.cpp4
-rw-r--r--src/cmd_privmsg.cpp4
-rw-r--r--src/cmd_topic.cpp4
-rw-r--r--src/helperfuncs.cpp53
-rw-r--r--src/message.cpp2
-rw-r--r--src/mode.cpp64
-rw-r--r--src/modules/m_knock.cpp2
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_safelist.cpp2
-rw-r--r--src/modules/m_uninvite.cpp2
14 files changed, 74 insertions, 78 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 819195871..aabf9664c 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -71,7 +71,7 @@ chanrec* ForceChan(chanrec* Ptr,ucrec *a,userrec* user, int created);
chanrec::chanrec()
{
*name = *topic = *setby = *key = 0;
- created = topicset = limit = binarymodes = 0;
+ created = topicset = limit = 0;
internal_userlist.clear();
memset(&custom_modes,0,64);
}
@@ -254,7 +254,8 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
/* create a new one */
chanlist[cname] = new chanrec();
strlcpy(chanlist[cname]->name, cname,CHANMAX);
- chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL;
+ chanlist[cname]->custom_modes[CM_TOPICLOCK] = chanlist[cname]->custom_modes[CM_NOEXTERNAL] = 1;
+ //chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL;
chanlist[cname]->created = TIME;
*chanlist[cname]->topic = 0;
strlcpy(chanlist[cname]->setby, user->nick,NICKMAX-1);
@@ -311,7 +312,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
}
}
}
- if (Ptr->binarymodes & CM_INVITEONLY)
+ if (Ptr->custom_modes[CM_INVITEONLY])
{
MOD_RESULT = 0;
irc::string xname(Ptr->name);
diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp
index bd2123311..3dbabe859 100644
--- a/src/cmd_invite.cpp
+++ b/src/cmd_invite.cpp
@@ -64,7 +64,7 @@ void cmd_invite::Handle (char **parameters, int pcnt, userrec *user)
return;
}
- if ((c->binarymodes & CM_INVITEONLY) && (IS_LOCAL(user)))
+ if ((c->custom_modes[CM_INVITEONLY]) && (IS_LOCAL(user)))
{
if (cstatus(user,c) < STATUS_HOP)
{
diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp
index fd0e0c557..3b91d88e9 100644
--- a/src/cmd_list.cpp
+++ b/src/cmd_list.cpp
@@ -47,7 +47,7 @@ void cmd_list::Handle (char **parameters, int pcnt, userrec *user)
{
// if the channel is not private/secret, OR the user is on the channel anyway
bool n = i->second->HasUser(user);
- if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (n))
+ if (((!(i->second->custom_modes[CM_PRIVATE])) && (!(i->second->custom_modes[CM_SECRET]))) || (n))
{
long users = usercount_i(i->second);
if (users)
diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp
index 43797cbeb..2eb046eac 100644
--- a/src/cmd_names.cpp
+++ b/src/cmd_names.cpp
@@ -76,7 +76,7 @@ void cmd_names::Handle (char **parameters, int pcnt, userrec *user)
c = FindChan(parameters[0]);
if (c)
{
- if ((c->binarymodes & CM_SECRET) && (!c->HasUser(user)))
+ if ((c->custom_modes[CM_SECRET]) && (!c->HasUser(user)))
{
WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, c->name);
return;
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index 58800ccc0..6e894e6a4 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -94,12 +94,12 @@ void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
{
if (IS_LOCAL(user))
{
- if ((chan->binarymodes & CM_NOEXTERNAL) && (!chan->HasUser(user)))
+ if ((chan->custom_modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
{
WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
return;
}
- if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE))
+ if ((chan->custom_modes[CM_MODERATED]) && (cstatus(user,chan)<STATUS_VOICE))
{
WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
return;
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 2770be330..feed75293 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -94,12 +94,12 @@ void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
{
if (IS_LOCAL(user))
{
- if ((chan->binarymodes & CM_NOEXTERNAL) && (!chan->HasUser(user)))
+ if ((chan->custom_modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
{
WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
return;
}
- if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE))
+ if ((chan->custom_modes[CM_MODERATED]) && (cstatus(user,chan)<STATUS_VOICE))
{
WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
return;
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index 463184de7..37cfe035e 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -70,7 +70,7 @@ void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
Ptr = FindChan(parameters[0]);
if (Ptr)
{
- if ((Ptr->binarymodes & CM_SECRET) && (!Ptr->HasUser(user)))
+ if ((Ptr->custom_modes[CM_SECRET]) && (!Ptr->HasUser(user)))
{
WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
return;
@@ -103,7 +103,7 @@ void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
return;
}
- if ((Ptr->binarymodes & CM_TOPICLOCK) && (cstatus(user,Ptr)<STATUS_HOP))
+ if ((Ptr->custom_modes[CM_TOPICLOCK]) && (cstatus(user,Ptr)<STATUS_HOP))
{
WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
return;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 9157a7f62..31a87fd70 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -1260,6 +1260,7 @@ char* chanmodes(chanrec *chan, bool showkey)
static char scratch[MAXBUF];
static char sparam[MAXBUF];
char* offset = scratch;
+ std::string extparam = "";
if (!chan)
{
@@ -1271,43 +1272,33 @@ char* chanmodes(chanrec *chan, bool showkey)
*scratch = '\0';
*sparam = '\0';
- if (chan->binarymodes & CM_NOEXTERNAL)
- *offset++ = 'n';
- if (chan->binarymodes & CM_TOPICLOCK)
- *offset++ = 't';
- if (*chan->key)
- *offset++ = 'k';
- if (chan->limit)
- *offset++ = 'l';
- if (chan->binarymodes & CM_INVITEONLY)
- *offset++ = 'i';
- if (chan->binarymodes & CM_MODERATED)
- *offset++ = 'm';
- if (chan->binarymodes & CM_SECRET)
- *offset++ = 's';
- if (chan->binarymodes & CM_PRIVATE)
- *offset++ = 'p';
-
- if (*chan->key)
- {
- snprintf(sparam,MAXBUF," %s",showkey ? chan->key : "<key>");
- }
-
- if (chan->limit)
- {
- char foo[24];
- sprintf(foo," %lu",(unsigned long)chan->limit);
- strlcat(sparam,foo,MAXBUF);
- }
-
/* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
for(int n = 0; n < 64; n++)
{
if(chan->custom_modes[n])
{
*offset++ = n+65;
- std::string extparam = chan->GetModeParameter(n+65);
-
+ extparam = "";
+ switch (n)
+ {
+ case CM_KEY:
+ extparam = (showkey ? chan->key : "<key>");
+ break;
+ case CM_LIMIT:
+ extparam = ConvToStr(chan->limit);
+ break;
+ case CM_NOEXTERNAL:
+ case CM_TOPICLOCK:
+ case CM_INVITEONLY:
+ case CM_MODERATED:
+ case CM_SECRET:
+ case CM_PRIVATE:
+ /* We know these have no parameters */
+ break;
+ default:
+ extparam = chan->GetModeParameter(n+65);
+ break;
+ }
if (extparam != "")
{
charlcat(sparam,' ',MAXBUF);
diff --git a/src/message.cpp b/src/message.cpp
index 39c321f42..87e23e501 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -416,7 +416,7 @@ std::string chlist(userrec *user,userrec* source)
{
// if the channel is NOT private/secret, OR the source user is on the channel, AND the user is not invisible.
// if the user is the same as the source, shortcircuit the comparison.
- if ((source == user) || ((((!(((ucrec*)(*i))->channel->binarymodes & CM_PRIVATE)) && (!(((ucrec*)(*i))->channel->binarymodes & CM_SECRET)) && (!userinvisible)) || (((ucrec*)(*i))->channel->HasUser(source)))))
+ if ((source == user) || ((((!(((ucrec*)(*i))->channel->custom_modes[CM_PRIVATE])) && (!(((ucrec*)(*i))->channel->custom_modes[CM_SECRET])) && (!userinvisible)) || (((ucrec*)(*i))->channel->HasUser(source)))))
{
lst = lst + std::string(cmode(user,((ucrec*)(*i))->channel)) + std::string(((ucrec*)(*i))->channel->name) + " ";
}
diff --git a/src/mode.cpp b/src/mode.cpp
index 0436d04be..fa3ccd88d 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -653,7 +653,7 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
break;
previously_set_k = true;
- if (!*chan->key)
+ if (!chan->custom_modes[CM_KEY])
{
MOD_RESULT = 0;
FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'k', parameters[param], true, 1));
@@ -664,6 +664,7 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
strlcpy(key,parameters[param++],32);
outpars[pc++] = key;
strlcpy(chan->key,key,MAXBUF);
+ chan->custom_modes[CM_KEY] = 1;
k_set = true;
}
else param++;
@@ -688,6 +689,7 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
*outl++ = 'k';
*chan->key = 0;
+ chan->custom_modes[CM_KEY] = 0;
outpars[pc++] = key;
}
}
@@ -705,10 +707,11 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', "", false, 0));
if (!MOD_RESULT)
{
- if (chan->limit)
+ if (chan->custom_modes[CM_LIMIT])
{
*outl++ = 'l';
chan->limit = 0;
+ chan->custom_modes[CM_LIMIT] = 0;
}
}
}
@@ -753,6 +756,7 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
if (chan->limit)
{
*outl++ = 'l';
+ chan->custom_modes[CM_LIMIT] = 1;
outpars[pc++] = parameters[param++];
l_set = true;
}
@@ -766,13 +770,13 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
if (mdir)
{
- if (!(chan->binarymodes & CM_INVITEONLY)) *outl++ = 'i';
- chan->binarymodes |= CM_INVITEONLY;
+ if (!(chan->custom_modes[CM_INVITEONLY])) *outl++ = 'i';
+ chan->custom_modes[CM_INVITEONLY] = 1;
}
else
{
- if (chan->binarymodes & CM_INVITEONLY) *outl++ = 'i';
- chan->binarymodes &= ~CM_INVITEONLY;
+ if (chan->custom_modes[CM_INVITEONLY]) *outl++ = 'i';
+ chan->custom_modes[CM_INVITEONLY] = 0;
}
}
break;
@@ -784,13 +788,13 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
if (mdir)
{
- if (!(chan->binarymodes & CM_TOPICLOCK)) *outl++ = 't';
- chan->binarymodes |= CM_TOPICLOCK;
+ if (!(chan->custom_modes[CM_TOPICLOCK])) *outl++ = 't';
+ chan->custom_modes[CM_TOPICLOCK] = 1;
}
else
{
- if (chan->binarymodes & CM_TOPICLOCK) *outl++ = 't';
- chan->binarymodes &= ~CM_TOPICLOCK;
+ if (chan->custom_modes[CM_TOPICLOCK]) *outl++ = 't';
+ chan->custom_modes[CM_TOPICLOCK] = 0;
}
}
break;
@@ -802,13 +806,13 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
if (mdir)
{
- if (!(chan->binarymodes & CM_NOEXTERNAL)) *outl++ = 'n';
- chan->binarymodes |= CM_NOEXTERNAL;
+ if (!(chan->custom_modes[CM_NOEXTERNAL])) *outl++ = 'n';
+ chan->custom_modes[CM_NOEXTERNAL] = 1;
}
else
{
- if (chan->binarymodes & CM_NOEXTERNAL) *outl++ = 'n';
- chan->binarymodes &= ~CM_NOEXTERNAL;
+ if (chan->custom_modes[CM_NOEXTERNAL]) *outl++ = 'n';
+ chan->custom_modes[CM_NOEXTERNAL] = 0;
}
}
break;
@@ -820,13 +824,13 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
if (mdir)
{
- if (!(chan->binarymodes & CM_MODERATED)) *outl++ = 'm';
- chan->binarymodes |= CM_MODERATED;
+ if (!(chan->custom_modes[CM_MODERATED])) *outl++ = 'm';
+ chan->custom_modes[CM_MODERATED] = 1;
}
else
{
- if (chan->binarymodes & CM_MODERATED) *outl++ = 'm';
- chan->binarymodes &= ~CM_MODERATED;
+ if (chan->custom_modes[CM_MODERATED]) *outl++ = 'm';
+ chan->custom_modes[CM_MODERATED] = 0;
}
}
break;
@@ -838,11 +842,11 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
if (mdir)
{
- if (!(chan->binarymodes & CM_SECRET)) *outl++ = 's';
- chan->binarymodes |= CM_SECRET;
- if (chan->binarymodes & CM_PRIVATE)
+ if (!(chan->custom_modes[CM_SECRET])) *outl++ = 's';
+ chan->custom_modes[CM_SECRET] = 1;
+ if (chan->custom_modes[CM_PRIVATE])
{
- chan->binarymodes &= ~CM_PRIVATE;
+ chan->custom_modes[CM_PRIVATE] = 0;
if (mdir)
{
*outl++ = '-'; *outl++ = 'p'; *outl++ = '+';
@@ -851,8 +855,8 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
}
else
{
- if (chan->binarymodes & CM_SECRET) *outl++ = 's';
- chan->binarymodes &= ~CM_SECRET;
+ if (chan->custom_modes[CM_SECRET]) *outl++ = 's';
+ chan->custom_modes[CM_SECRET] = 0;
}
}
break;
@@ -864,14 +868,14 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
{
if(mdir)
{
- if(!(chan->binarymodes & CM_PRIVATE))
+ if(!(chan->custom_modes[CM_PRIVATE]))
*outl++ = 'p';
- chan->binarymodes |= CM_PRIVATE;
+ chan->custom_modes[CM_PRIVATE] = 1;
- if(chan->binarymodes & CM_SECRET)
+ if(chan->custom_modes[CM_SECRET])
{
- chan->binarymodes &= ~CM_SECRET;
+ chan->custom_modes[CM_SECRET] = 0;
*outl++ = '-';
*outl++ = 's';
@@ -880,10 +884,10 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
}
else
{
- if(chan->binarymodes & CM_PRIVATE)
+ if(chan->custom_modes[CM_PRIVATE])
*outl++ = 'p';
- chan->binarymodes &= ~CM_PRIVATE;
+ chan->custom_modes[CM_PRIVATE] = 0;
}
}
break;
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 2a9fd30fa..2e63e890b 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -52,7 +52,7 @@ class cmd_knock : public command_t
}
line = line + std::string(parameters[pcnt-1]);
- if (c->binarymodes & CM_INVITEONLY)
+ if (c->custom_modes[CM_INVITEONLY])
{
WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str());
WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name);
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 58fa0ac48..b048f7493 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -185,7 +185,7 @@ class ModuleOverride : public Module
{
if (chan)
{
- if ((chan->binarymodes & CM_INVITEONLY) && (CanOverride(user,"INVITE")))
+ if ((chan->custom_modes[CM_INVITEONLY]) && (CanOverride(user,"INVITE")))
{
if (NoisyOverride)
{
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index ca820e86e..90eb0d613 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -98,7 +98,7 @@ class ListTimer : public InspTimer
chan = Srv->GetChannelIndex(ld->list_position);
/* spool details */
bool has_user = (chan && chan->HasUser(u));
- if ((chan) && (((!(chan->binarymodes & CM_PRIVATE)) && (!(chan->binarymodes & CM_SECRET))) || (has_user)))
+ if ((chan) && (((!(chan->custom_modes[CM_PRIVATE])) && (!(chan->custom_modes[CM_SECRET]))) || (has_user)))
{
/* Increment total plus linefeed */
long users = usercount_i(chan);
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index dbd3af52f..07c01f058 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -54,7 +54,7 @@ class cmd_uninvite : public command_t
return;
}
- if (c->binarymodes & CM_INVITEONLY)
+ if (c->custom_modes[CM_INVITEONLY])
{
if (cstatus(user,c) < STATUS_HOP)
{