- case '-':
- if ((direction != 0) && (next_ok))
- {
- next_ok = false;
- charlcat(outpars,'-',MAXBUF);
- }
- direction = 0;
- break;
-
- default:
- log(DEBUG,"begin mode processing entry");
- can_change = 1;
- if (can_change)
- {
- if (direction == 1)
- {
- log(DEBUG,"umode %c being added",*i);
- if ((!strchr(dmodes,*i)) && (ServerInstance->ModeGrok->AllowedUmode(*i,user->modes,true,true)))
- {
- log(DEBUG,"umode %c is an allowed umode",*i);
- if ((*i == 'i') || (*i == 's') || (*i == 'w') || (*i == 'o') || (ServerInstance->ModeGrok->ProcessModuleUmode(*i, user, dest, direction)))
- {
- 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;
- }
- }
- }
- }
- else
- {
- // can only remove a mode they already have
- log(DEBUG,"umode %c being removed",*i);
- if ((ServerInstance->ModeGrok->AllowedUmode(*i,user->modes,false,true)) && (strchr(dmodes,*i)))
- {
- log(DEBUG,"umode %c is an allowed umode",*i);
- if ((*i == 'i') || (*i == 's') || (*i == 'w') || (*i == 'o') || (ServerInstance->ModeGrok->ProcessModuleUmode(*i, user, dest, direction)))
- {
- 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);
-
- }