* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
+ * E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
*
{
if (!strcasecmp(i->data,dest))
{
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest));
- if (MOD_RESULT)
- return NULL;
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest));
+ if (MOD_RESULT)
+ return NULL;
chan->bans.erase(i);
return dest;
}
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'o', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'o', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeOps(user,parameters[param++],chan,status);
}
else param++;
r = NULL;
if (mdir == 1)
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
r = GiveHops(user,parameters[param++],chan,status);
}
else param++;
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeHops(user,parameters[param++],chan,status);
}
else param++;
r = NULL;
if (mdir == 1)
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
r = GiveVoice(user,parameters[param++],chan,status);
}
else param++;
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeVoice(user,parameters[param++],chan,status);
}
else param++;
r = NULL;
if (mdir == 1)
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
r = AddBan(user,parameters[param++],chan,status);
}
else param++;
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeBan(user,parameters[param++],chan,status);
}
else param++;
break;
previously_set_k = true;
- if (!*chan->key)
+ if (!chan->modes[CM_KEY])
{
MOD_RESULT = 0;
FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'k', parameters[param], true, 1));
strlcpy(key,parameters[param++],32);
outpars[pc++] = key;
strlcpy(chan->key,key,MAXBUF);
+ chan->modes[CM_KEY] = 1;
k_set = true;
}
else param++;
{
*outl++ = 'k';
*chan->key = 0;
+ chan->modes[CM_KEY] = 0;
outpars[pc++] = key;
}
}
if (previously_set_l)
break;
previously_unset_l = true;
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', "", false, 0));
- if (!MOD_RESULT)
- {
- if (chan->limit)
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', "", false, 0));
+ if (!MOD_RESULT)
+ {
+ if (chan->modes[CM_LIMIT])
{
*outl++ = 'l';
chan->limit = 0;
+ chan->modes[CM_LIMIT] = 0;
}
}
}
if (invalid)
break;
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
chan->limit = atoi(parameters[param]);
if (chan->limit)
{
*outl++ = 'l';
+ chan->modes[CM_LIMIT] = 1;
outpars[pc++] = parameters[param++];
l_set = true;
}
break;
case 'i':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'i', "", mdir, 0));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'i', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
if (mdir)
{
- if (!(chan->binarymodes & CM_INVITEONLY)) *outl++ = 'i';
- chan->binarymodes |= CM_INVITEONLY;
+ if (!(chan->modes[CM_INVITEONLY])) *outl++ = 'i';
+ chan->modes[CM_INVITEONLY] = 1;
}
else
{
- if (chan->binarymodes & CM_INVITEONLY) *outl++ = 'i';
- chan->binarymodes &= ~CM_INVITEONLY;
+ if (chan->modes[CM_INVITEONLY]) *outl++ = 'i';
+ chan->modes[CM_INVITEONLY] = 0;
}
}
break;
case 't':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 't', "", mdir, 0));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 't', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
if (mdir)
- {
- if (!(chan->binarymodes & CM_TOPICLOCK)) *outl++ = 't';
- chan->binarymodes |= CM_TOPICLOCK;
- }
- else
- {
- if (chan->binarymodes & CM_TOPICLOCK) *outl++ = 't';
- chan->binarymodes &= ~CM_TOPICLOCK;
- }
+ {
+ if (!(chan->modes[CM_TOPICLOCK])) *outl++ = 't';
+ chan->modes[CM_TOPICLOCK] = 1;
+ }
+ else
+ {
+ if (chan->modes[CM_TOPICLOCK]) *outl++ = 't';
+ chan->modes[CM_TOPICLOCK] = 0;
+ }
}
break;
case 'n':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'n', "", mdir, 0));
- if (!MOD_RESULT)
- {
- if (mdir)
- {
- if (!(chan->binarymodes & CM_NOEXTERNAL)) *outl++ = 'n';
- chan->binarymodes |= CM_NOEXTERNAL;
- }
- else
- {
- if (chan->binarymodes & CM_NOEXTERNAL) *outl++ = 'n';
- chan->binarymodes &= ~CM_NOEXTERNAL;
- }
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'n', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
+ if (mdir)
+ {
+ if (!(chan->modes[CM_NOEXTERNAL])) *outl++ = 'n';
+ chan->modes[CM_NOEXTERNAL] = 1;
+ }
+ else
+ {
+ if (chan->modes[CM_NOEXTERNAL]) *outl++ = 'n';
+ chan->modes[CM_NOEXTERNAL] = 0;
+ }
}
break;
case 'm':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'm', "", mdir, 0));
- if (!MOD_RESULT)
- {
- if (mdir)
- {
- if (!(chan->binarymodes & CM_MODERATED)) *outl++ = 'm';
- chan->binarymodes |= CM_MODERATED;
- }
- else
- {
- if (chan->binarymodes & CM_MODERATED) *outl++ = 'm';
- chan->binarymodes &= ~CM_MODERATED;
- }
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'm', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
+ if (mdir)
+ {
+ if (!(chan->modes[CM_MODERATED])) *outl++ = 'm';
+ chan->modes[CM_MODERATED] = 1;
+ }
+ else
+ {
+ if (chan->modes[CM_MODERATED]) *outl++ = 'm';
+ chan->modes[CM_MODERATED] = 0;
+ }
}
break;
case 's':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 's', "", mdir, 0));
- if (!MOD_RESULT)
- {
- if (mdir)
- {
- if (!(chan->binarymodes & CM_SECRET)) *outl++ = 's';
- chan->binarymodes |= CM_SECRET;
- if (chan->binarymodes & CM_PRIVATE)
- {
- chan->binarymodes &= ~CM_PRIVATE;
- if (mdir)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 's', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
+ if (mdir)
+ {
+ if (!(chan->modes[CM_SECRET])) *outl++ = 's';
+ chan->modes[CM_SECRET] = 1;
+ if (chan->modes[CM_PRIVATE])
+ {
+ chan->modes[CM_PRIVATE] = 0;
+ if (mdir)
+ {
*outl++ = '-'; *outl++ = 'p'; *outl++ = '+';
- }
- }
- }
- else
- {
- if (chan->binarymodes & CM_SECRET) *outl++ = 's';
- chan->binarymodes &= ~CM_SECRET;
- }
+ }
+ }
+ }
+ else
+ {
+ if (chan->modes[CM_SECRET]) *outl++ = 's';
+ chan->modes[CM_SECRET] = 0;
+ }
}
break;
{
if(mdir)
{
- if(!(chan->binarymodes & CM_PRIVATE))
+ if(!(chan->modes[CM_PRIVATE]))
*outl++ = 'p';
- chan->binarymodes |= CM_PRIVATE;
+ chan->modes[CM_PRIVATE] = 1;
- if(chan->binarymodes & CM_SECRET)
+ if(chan->modes[CM_SECRET])
{
- chan->binarymodes &= ~CM_SECRET;
+ chan->modes[CM_SECRET] = 0;
*outl++ = '-';
*outl++ = 's';
}
else
{
- if(chan->binarymodes & CM_PRIVATE)
+ if(chan->modes[CM_PRIVATE])
*outl++ = 'p';
- chan->binarymodes &= ~CM_PRIVATE;
+ chan->modes[CM_PRIVATE] = 0;
}
}
break;
default:
string_list p;
p.clear();
- bool x = chan->custom_modes[*modechar-65];
+ bool x = chan->modes[*modechar-65];
if ((!x && !mdir) || (x && mdir))
{
if (!ModeIsListMode(*modechar,MT_CHANNEL))
if ((dest) && (pcnt > 1))
{
- std::string tidied = ServerInstance->ModeGrok->CompressModes(parameters[1],false);
- parameters[1] = (char*)tidied.c_str();
+ std::string tidied = ServerInstance->ModeGrok->CompressModes(parameters[1],false);
+ parameters[1] = (char*)tidied.c_str();
char dmodes[MAXBUF];
strlcpy(dmodes,dest->modes,MAXBUF);
switch (*i)
{
- case ' ':
- continue;
+ case ' ':
+ continue;
case '+':
if ((direction != 1) && (next_ok))
{
charlcat(dmodes,*i,MAXBUF);
charlcat(outpars,*i,53);
+ switch (*i)
+ {
+ case 'i':
+ dest->modebits |= UM_INVISIBLE;
+ break;
+ case 's':
+ dest->modebits |= UM_SERVERNOTICE;
+ break;
+ case 'w':
+ dest->modebits |= UM_WALLOPS;
+ break;
+ default:
+ break;
+ }
}
}
}
{
charlcat(outpars,*i,MAXBUF);
charremove(dmodes,*i);
+ switch (*i)
+ {
+ case 'i':
+ dest->modebits &= ~UM_INVISIBLE;
+ break;
+ case 's':
+ dest->modebits &= ~UM_SERVERNOTICE;
+ break;
+ case 'w':
+ dest->modebits &= ~UM_WALLOPS;
+ break;
+ default:
+ break;
+ }
}
}
}
break;
}
}
- if (*outpars)
- {
- char b[MAXBUF];
- char* z = b;
-
- for (char* i = outpars; *i;)
- {
- *z++ = *i++;
- if (((*i == '-') || (*i == '+')) && ((*(i+1) == '-') || (*(i+1) == '+')))
- {
- // someones playing silly buggers and trying
- // to put a +- or -+ into the line...
- i++;
- }
- if (!*(i+1))
- {
- // Someone's trying to make the last character in
- // the line be a + or - symbol.
- if ((*i == '-') || (*i == '+'))
- {
- i++;
- }
- }
- }
- *z = 0;
-
- if ((*b) && (!IS_SINGLE(b,'+')) && (!IS_SINGLE(b,'-')))
- {
- WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
- FOREACH_MOD(I_OnMode,OnMode(user, dest, TYPE_USER, b));
- }
-
- log(DEBUG,"Stripped mode line");
- log(DEBUG,"Line dest is now %s",dmodes);
- strlcpy(dest->modes,dmodes,MAXMODES-1);
-
- }
+ if (*outpars)
+ {
+ char b[MAXBUF];
+ char* z = b;
+
+ for (char* i = outpars; *i;)
+ {
+ *z++ = *i++;
+ if (((*i == '-') || (*i == '+')) && ((*(i+1) == '-') || (*(i+1) == '+')))
+ {
+ // someones playing silly buggers and trying
+ // to put a +- or -+ into the line...
+ i++;
+ }
+ if (!*(i+1))
+ {
+ // Someone's trying to make the last character in
+ // the line be a + or - symbol.
+ if ((*i == '-') || (*i == '+'))
+ {
+ i++;
+ }
+ }
+ }
+ *z = 0;
+
+ if ((*b) && (!IS_SINGLE(b,'+')) && (!IS_SINGLE(b,'-')))
+ {
+ WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
+ FOREACH_MOD(I_OnMode,OnMode(user, dest, TYPE_USER, b));
+ }
+
+ log(DEBUG,"Stripped mode line");
+ log(DEBUG,"Line dest is now %s",dmodes);
+ strlcpy(dest->modes,dmodes,MAXMODES-1);
+
+ }
return;
}