mirror of
https://github.com/pissnet/pissircd.git
synced 2025-08-17 23:51:53 +01:00
Cleanup old channel mode stuff, now that all non-list-modes are gone.
Eg no longer need to walk through the corechannelmodetable for single param channel modes... Also fix sjoin comments about "their" and "our" modes. In the merge case this was not correct, it was "our old" and "merged modes".
This commit is contained in:
parent
8a5a0723e9
commit
5c114d0069
3 changed files with 8 additions and 102 deletions
|
@ -634,7 +634,6 @@ long get_mode_bitbychar(char m)
|
|||
/* TODO: this function has many security issues and needs an audit, maybe even a recode */
|
||||
void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, size_t pbuf_size, Channel *channel, int hide_local_modes)
|
||||
{
|
||||
CoreChannelModeTable *tab = &corechannelmodetable[0];
|
||||
int ismember = 0;
|
||||
int i;
|
||||
|
||||
|
@ -649,17 +648,6 @@ void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, siz
|
|||
mbuf_size--;
|
||||
|
||||
/* Paramless first */
|
||||
while (mbuf_size && tab->mode != 0x0)
|
||||
{
|
||||
if ((channel->mode.mode & tab->mode))
|
||||
{
|
||||
if (!tab->parameters) {
|
||||
*mbuf++ = tab->flag;
|
||||
mbuf_size--;
|
||||
}
|
||||
}
|
||||
tab++;
|
||||
}
|
||||
for (i=0; i <= Channelmode_highest; i++)
|
||||
{
|
||||
if (!mbuf_size)
|
||||
|
@ -1161,10 +1149,7 @@ int parse_chanmode(ParseMode *pm, char *modebuf_in, char *parabuf_in)
|
|||
/* INTERNAL MODE */
|
||||
if (tab->parameters)
|
||||
{
|
||||
if ((pm->what == MODE_DEL) && (tab->flag == 'l'))
|
||||
eatparam = 0; /* -l is special: no parameter required */
|
||||
else
|
||||
eatparam = 1; /* all other internal parameter modes do require a parameter on unset */
|
||||
eatparam = 1;
|
||||
}
|
||||
} else {
|
||||
/* EXTENDED CHANNEL MODE */
|
||||
|
|
|
@ -503,7 +503,6 @@ void make_mode_str(Channel *channel, long oldm, Cmode_t oldem, int pcount,
|
|||
size_t mode_buf_size, size_t para_buf_size)
|
||||
{
|
||||
char tmpbuf[MODEBUFLEN+3], *tmpstr;
|
||||
CoreChannelModeTable *tab = &corechannelmodetable[0];
|
||||
char *x = mode_buf;
|
||||
int what, cnt, z;
|
||||
int i;
|
||||
|
@ -514,24 +513,6 @@ void make_mode_str(Channel *channel, long oldm, Cmode_t oldem, int pcount,
|
|||
*mode_buf = '\0';
|
||||
*para_buf = '\0';
|
||||
what = 0;
|
||||
/* + param-less modes */
|
||||
tab = &corechannelmodetable[0];
|
||||
while (tab->mode != 0x0)
|
||||
{
|
||||
if (channel->mode.mode & tab->mode)
|
||||
{
|
||||
if (!(oldm & tab->mode))
|
||||
{
|
||||
if (what != MODE_ADD)
|
||||
{
|
||||
*x++ = '+';
|
||||
what = MODE_ADD;
|
||||
}
|
||||
*x++ = tab->flag;
|
||||
}
|
||||
}
|
||||
tab++;
|
||||
}
|
||||
|
||||
/* + paramless extmodes... */
|
||||
for (i=0; i <= Channelmode_highest; i++)
|
||||
|
@ -552,24 +533,6 @@ void make_mode_str(Channel *channel, long oldm, Cmode_t oldem, int pcount,
|
|||
}
|
||||
|
||||
*x = '\0';
|
||||
/* - param-less modes */
|
||||
tab = &corechannelmodetable[0];
|
||||
while (tab->mode != 0x0)
|
||||
{
|
||||
if (!(channel->mode.mode & tab->mode))
|
||||
{
|
||||
if (oldm & tab->mode)
|
||||
{
|
||||
if (what != MODE_DEL)
|
||||
{
|
||||
*x++ = '-';
|
||||
what = MODE_DEL;
|
||||
}
|
||||
*x++ = tab->flag;
|
||||
}
|
||||
}
|
||||
tab++;
|
||||
}
|
||||
|
||||
/* - extmodes (both "param modes" and paramless don't have
|
||||
* any params when unsetting... well, except one special type, that is (we skip those here)
|
||||
|
@ -778,24 +741,6 @@ int do_mode_char(Channel *channel, long modetype, char modechar, char *param,
|
|||
}
|
||||
switch (modetype)
|
||||
{
|
||||
setmode:
|
||||
retval = 0;
|
||||
if (what == MODE_ADD)
|
||||
{
|
||||
// FIXME: previously there was anti duplicate +s/+p code here
|
||||
// we may still need something for that...
|
||||
// like calling HOOKTYPE_MODECHAR_ADD
|
||||
channel->mode.mode |= modetype;
|
||||
RunHook2(HOOKTYPE_MODECHAR_ADD, channel, (int)modechar);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel->mode.mode &= ~modetype;
|
||||
RunHook2(HOOKTYPE_MODECHAR_DEL, channel, (int)modechar);
|
||||
}
|
||||
break;
|
||||
|
||||
/* do pro-opping here (popping) */
|
||||
case MODE_CHANOWNER:
|
||||
REQUIRE_PARAMETER()
|
||||
if (!IsULine(client) && !IsServer(client) && !is_chanowner(client, channel) && !samode_in_progress)
|
||||
|
|
|
@ -162,7 +162,6 @@ CMD_FUNC(cmd_sjoin)
|
|||
unsigned short b=0;
|
||||
char *tp, *p, *saved = NULL;
|
||||
long modeflags;
|
||||
char queue_s=0, queue_c=0; /* oh this is soooooo ugly :p */
|
||||
|
||||
if (!IsServer(client) || parc < 4)
|
||||
return;
|
||||
|
@ -708,8 +707,8 @@ getnick:
|
|||
parabuf[0] = '\0';
|
||||
b = 1;
|
||||
|
||||
/* First, check if we have something they don't have..
|
||||
* note that: oldmode.* = us, channel->mode.* = them.
|
||||
/* First, check if we had something that is now gone
|
||||
* note that: oldmode.* = us, channel->mode.* = merged.
|
||||
*/
|
||||
for (i=0; i <= Channelmode_highest; i++)
|
||||
{
|
||||
|
@ -743,14 +742,6 @@ getnick:
|
|||
queue_s = 1;
|
||||
}
|
||||
#endif
|
||||
/* Add single char modes... */
|
||||
for (acp = corechannelmodetable; acp->mode; acp++)
|
||||
{
|
||||
if ((oldmode.mode & acp->mode) && !(channel->mode.mode & acp->mode) && !acp->parameters)
|
||||
{
|
||||
Addsingle(acp->flag);
|
||||
}
|
||||
}
|
||||
if (b > 1)
|
||||
{
|
||||
Addsingle('+');
|
||||
|
@ -761,22 +752,10 @@ getnick:
|
|||
b = 1;
|
||||
}
|
||||
|
||||
if (queue_s)
|
||||
Addsingle('s');
|
||||
|
||||
if (queue_c)
|
||||
Addsingle('c');
|
||||
|
||||
for (acp = corechannelmodetable; acp->mode; acp++)
|
||||
{
|
||||
if (!(oldmode.mode & acp->mode) && (channel->mode.mode & acp->mode) && !acp->parameters)
|
||||
{
|
||||
Addsingle(acp->flag);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now, check if they have something we don't have..
|
||||
* note that: oldmode.* = us, channel->mode.* = them.
|
||||
/* Now, check if merged modes contain something we didn't have before.
|
||||
* note that: oldmode.* = us before, channel->mode.* = merged.
|
||||
*
|
||||
* First the simple single letter modes...
|
||||
*/
|
||||
for (i=0; i <= Channelmode_highest; i++)
|
||||
{
|
||||
|
@ -800,7 +779,7 @@ getnick:
|
|||
/* now, if we had diffent para modes - this loop really could be done better, but */
|
||||
|
||||
/* Now, check for any param differences in extended channel modes..
|
||||
* note that: oldmode.* = us, channel->mode.* = them.
|
||||
* note that: oldmode.* = us before, channel->mode.* = merged.
|
||||
* if we win: copy oldmode to channel mode, if they win: send the mode
|
||||
*/
|
||||
for (i=0; i <= Channelmode_highest; i++)
|
||||
|
@ -814,8 +793,6 @@ getnick:
|
|||
char flag = Channelmode_Table[i].flag;
|
||||
void *ourm = GETPARASTRUCTEX(oldmode.extmodeparams, flag);
|
||||
void *theirm = GETPARASTRUCT(channel, flag);
|
||||
//CmodeParam *ourm = extcmode_get_struct(oldmode.extmodeparam,Channelmode_Table[i].flag);
|
||||
//CmodeParam *theirm = extcmode_get_struct(channel->mode.extmodeparam, Channelmode_Table[i].flag);
|
||||
|
||||
r = Channelmode_Table[i].sjoin_check(channel, ourm, theirm);
|
||||
switch (r)
|
||||
|
@ -855,7 +832,6 @@ getnick:
|
|||
|
||||
/* free the oldmode.* crap :( */
|
||||
extcmode_free_paramlist(oldmode.extmodeparams);
|
||||
/* memset(&oldmode.extmodeparams, 0, sizeof(oldmode.extmodeparams)); -- redundant? */
|
||||
}
|
||||
|
||||
for (h = Hooks[HOOKTYPE_CHANNEL_SYNCED]; h; h = h->next)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue