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

Replace various 90% identical functions with some macro's instead.

This commit is contained in:
Bram Matthys
2019-06-22 17:29:03 +02:00
parent 19af2c6b5c
commit cf29aa8feb
6 changed files with 19 additions and 107 deletions
-97
View File
@@ -639,103 +639,6 @@ long get_access(aClient *cptr, aChannel *chptr)
return 0;
}
int is_chan_op(aClient *cptr, aChannel *chptr)
{
Membership *lp;
/* chanop/halfop ? */
if (IsServer(cptr))
return 1;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
#ifdef PREFIX_AQ
return ((lp->flags & (CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER)));
#else
return ((lp->flags & CHFL_CHANOP));
#endif
return 0;
}
int has_voice(aClient *cptr, aChannel *chptr)
{
Membership *lp;
if (IsServer(cptr))
return 1;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
return (lp->flags & CHFL_VOICE);
return 0;
}
int is_halfop(aClient *cptr, aChannel *chptr)
{
Membership *lp;
if (IsServer(cptr))
return 1;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
if (!(lp->flags & CHFL_CHANOP))
return (lp->flags & CHFL_HALFOP);
return 0;
}
int is_chanowner(aClient *cptr, aChannel *chptr)
{
Membership *lp;
if (IsServer(cptr))
return 1;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
return (lp->flags & CHFL_CHANOWNER);
return 0;
}
int is_chanownprotop(aClient *cptr, aChannel *chptr)
{
Membership *lp;
if (IsServer(cptr))
return 1;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
if (lp->flags & (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP))
return 1;
return 0;
}
int is_skochanop(aClient *cptr, aChannel *chptr)
{
Membership *lp;
if (IsServer(cptr))
return 1;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
#ifdef PREFIX_AQ
if (lp->flags & (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP|CHFL_HALFOP))
#else
if (lp->flags & (CHFL_CHANOP|CHFL_HALFOP))
#endif
return 1;
return 0;
}
int is_chanprot(aClient *cptr, aChannel *chptr)
{
Membership *lp;
if (chptr)
if ((lp = find_membership_link(cptr->user->channel, chptr)))
return (lp->flags & CHFL_CHANPROT);
return 0;
}
/** Returns 1 if channel has this channel mode set and 0 if not */
int has_channel_mode(aChannel *chptr, char mode)
{
+3 -1
View File
@@ -71,8 +71,10 @@ int nonickchange_check (aClient *sptr, aChannel *chptr)
{
if (!IsOper(sptr) && !IsULine(sptr)
&& IsNoNickChange(chptr)
&& !is_chanownprotop(sptr, chptr))
&& !is_chan_op(sptr, chptr))
{
return HOOK_DENY;
}
return HOOK_ALLOW;
}
+1 -1
View File
@@ -132,7 +132,7 @@ CMD_FUNC(m_part)
continue;
}
if (!ValidatePermissionsForPath("channel:override:banpartmsg",sptr,NULL,chptr,NULL) && !is_chanownprotop(sptr, chptr)) {
if (!ValidatePermissionsForPath("channel:override:banpartmsg",sptr,NULL,chptr,NULL) && !is_chan_op(sptr, chptr)) {
/* Banned? No comment allowed ;) */
if (comment && is_banned(sptr, chptr, BANCHK_MSG, &comment, NULL))
comment = NULL;