1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 21:43:13 +02:00

Fix +s/+p during netmerge (was on todo)

This commit is contained in:
Bram Matthys
2021-12-04 10:17:34 +01:00
parent b25da63d27
commit adc8d5802f
3 changed files with 25 additions and 14 deletions
+1
View File
@@ -923,6 +923,7 @@ extern MODVAR int debugfd;
extern void convert_to_absolute_path(char **path, const char *reldir);
extern int has_user_mode(Client *acptr, char mode);
extern int has_channel_mode(Channel *channel, char mode);
extern int has_channel_mode_raw(Cmode_t m, char mode);
extern Cmode_t get_extmode_bitbychar(char m);
extern long find_user_mode(char mode);
extern void start_listeners(void);
+12
View File
@@ -581,6 +581,18 @@ int has_channel_mode(Channel *channel, char mode)
return 0; /* Not found */
}
/** Returns 1 if channel has this mode is set and 0 if not */
int has_channel_mode_raw(Cmode_t m, char mode)
{
Cmode *cm;
for (cm=channelmodes; cm; cm = cm->next)
if ((cm->letter == mode) && (m & cm->mode))
return 1;
return 0; /* Not found */
}
/** Get the extended channel mode 'bit' value (eg: 0x20) by character (eg: 'Z') */
Cmode_t get_extmode_bitbychar(char m)
{
+12 -14
View File
@@ -662,6 +662,18 @@ CMD_FUNC(cmd_sjoin)
parabuf[0] = '\0';
b = 1;
/* Check if we had +s and it became +p, then revert it silently (as it is no-change) */
if (has_channel_mode_raw(oldmode.mode, 's') && has_channel_mode(channel, 'p'))
{
/* stay +s ! */
long mode_p = get_extmode_bitbychar('p');
long mode_s = get_extmode_bitbychar('s');
channel->mode.mode &= ~mode_p;
channel->mode.mode |= mode_s;
/* TODO: all the code of above would ideally be in a module */
}
/* (And the other condition, +p to +s, is already handled below by the generic code) */
/* First, check if we had something that is now gone
* note that: oldmode.* = us, channel->mode.* = merged.
*/
@@ -683,20 +695,6 @@ CMD_FUNC(cmd_sjoin)
}
}
#if 0
// FIXME: fix this case of +p/+s merging... which should end up in +s:
// can use get_extmode_bitbychar() or shit but probably should call a hook (or sjoin thingy) instead?
/* Check if we had +s and it became +p, then revert it... */
if ((oldmode.mode & MODE_SECRET) && (channel->mode.mode & MODE_PRIVATE))
{
/* stay +s ! */
channel->mode.mode &= ~MODE_PRIVATE;
channel->mode.mode |= MODE_SECRET;
Addsingle('p'); /* - */
queue_s = 1;
}
#endif
if (b > 1)
{
Addsingle('+');