mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 05:43:12 +02:00
Clean up WHOX a bit and fix WHO hiding yourself if not in any channels,
reported by Koragg in https://bugs.unrealircd.org/view.php?id=5757. This changes the following in the code of who_global(): 1) We initialize all the 'marked' users to zero at the beginning, and remove the previously unmarking in the bottom loop that shouldn't have anything to do with it. Now there's "no way" to screw up initialization of marked users. 2) Check for marked users in the bottom loop. 3) Thanks to #1 and #2 we can now easily add simple logic like not skipping when client==acptr. 4) Similarly, we can remove checks for +i/-i in who_common_channel(), and as a bonus we will list common channel results altogether in the WHO result, rather than first +i on common and then at the very end the remaining -i (which may also be in common channels). All in all, the code is now more like how I would write it, rather than the original. It's now harder to screw things up if you change some visibility or searching logic here or there.
This commit is contained in:
+21
-21
@@ -497,8 +497,10 @@ static int do_match(Client *client, Client *acptr, char *mask, struct who_format
|
||||
* - pointer to int maxmatches
|
||||
* - format options
|
||||
* output - NONE
|
||||
* side effects - lists matching invisible clients on specified channel,
|
||||
* side effects - lists matching clients on specified channel,
|
||||
* marks matched clients.
|
||||
*
|
||||
* NOTE: only call this from who_global() due to client marking!
|
||||
*/
|
||||
|
||||
static void who_common_channel(Client *client, Channel *channel,
|
||||
@@ -513,10 +515,10 @@ static void who_common_channel(Client *client, Channel *channel,
|
||||
{
|
||||
acptr = cm->client;
|
||||
|
||||
if (!IsInvisible(acptr) || IsMarked(acptr))
|
||||
if (IsMarked(acptr))
|
||||
continue;
|
||||
|
||||
if(IsMatch(fmt, WMATCH_OPER) && !IsOper(acptr))
|
||||
if (IsMatch(fmt, WMATCH_OPER) && !IsOper(acptr))
|
||||
continue;
|
||||
|
||||
for (h = Hooks[HOOKTYPE_VISIBLE_IN_CHANNEL]; h; h = h->next)
|
||||
@@ -562,10 +564,12 @@ static void who_global(Client *client, char *mask, int operspy, struct who_forma
|
||||
Client *acptr;
|
||||
int maxmatches = IsOper(client) ? INT_MAX : WHOLIMIT;
|
||||
|
||||
/* first, list all matching INvisible clients on common channels
|
||||
* if this is not an operspy who
|
||||
*/
|
||||
if(!operspy)
|
||||
/* Initialize the markers to zero */
|
||||
list_for_each_entry(acptr, &client_list, client_node)
|
||||
ClearMark(acptr);
|
||||
|
||||
/* First, if not operspy, then list all matching clients on common channels */
|
||||
if (!operspy)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
@@ -573,26 +577,22 @@ static void who_global(Client *client, char *mask, int operspy, struct who_forma
|
||||
who_common_channel(client, lp->channel, mask, &maxmatches, fmt);
|
||||
}
|
||||
|
||||
/* second, list all matching visible clients and clear all marks
|
||||
* on invisible clients
|
||||
* if this is an operspy who, list all matching clients, no need
|
||||
* to clear marks
|
||||
*/
|
||||
/* Second, list all matching visible clients. */
|
||||
list_for_each_entry(acptr, &client_list, client_node)
|
||||
{
|
||||
if(!IsUser(acptr))
|
||||
if (!IsUser(acptr))
|
||||
continue;
|
||||
|
||||
if(IsInvisible(acptr) && !operspy)
|
||||
{
|
||||
ClearMark(acptr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(IsMatch(fmt, WMATCH_OPER) && !IsOper(acptr))
|
||||
if (IsInvisible(acptr) && !operspy && (client != acptr))
|
||||
continue;
|
||||
|
||||
if(maxmatches > 0)
|
||||
if (IsMarked(acptr))
|
||||
continue;
|
||||
|
||||
if (IsMatch(fmt, WMATCH_OPER) && !IsOper(acptr))
|
||||
continue;
|
||||
|
||||
if (maxmatches > 0)
|
||||
{
|
||||
if (do_match(client, acptr, mask, fmt))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user