]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_who.cpp
Merge pull request #1308 from SaberUK/insp20+warnings
[user/henk/code/inspircd.git] / src / commands / cmd_who.cpp
index c474abc3c8b2ea7c4662b3f24568181793553074..8438f8cdd0e07d222252eb96c76df49a0d5741f1 100644 (file)
@@ -58,13 +58,15 @@ class CommandWho : public Command
 };
 
 
-static Channel* get_first_visible_channel(User *u)
+static Channel* get_first_visible_channel(User *source, User *u)
 {
        UCListIter i = u->chans.begin();
        while (i != u->chans.end())
        {
                Channel* c = *i++;
-               if (!c->IsModeSet('s'))
+
+               /* XXX move the +I check into m_hidechans */
+               if (source == u || !(c->IsModeSet('s') || c->IsModeSet('p') || u->IsModeSet('I')) || c->HasUser(source))
                        return c;
        }
        return NULL;
@@ -141,7 +143,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext)
                        long seconds = ServerInstance->Duration(matchtext);
 
                        // Okay, so time matching, we want all users connected `seconds' ago
-                       if (user->age >= ServerInstance->Time() - seconds)
+                       if (user->signon >= ServerInstance->Time() - seconds)
                                match = true;
                }
 
@@ -189,7 +191,7 @@ bool CommandWho::CanView(Channel* chan, User* user)
 void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults)
 {
        if (!ch)
-               ch = get_first_visible_channel(u);
+               ch = get_first_visible_channel(user, u);
 
        std::string wholine = initial + (ch ? ch->name : "*") + " " + u->ident + " " +
                (opt_showrealhost ? u->host : u->dhost) + " ";
@@ -251,7 +253,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
 
        Channel *ch = NULL;
        std::vector<std::string> whoresults;
-       std::string initial = "352 " + std::string(user->nick) + " ";
+       std::string initial = "352 " + user->nick + " ";
 
        char matchtext[MAXBUF];
        bool usingwildcards = false;
@@ -264,7 +266,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
 
        for (const char* check = matchtext; *check; check++)
        {
-               if (*check == '*' || *check == '?')
+               if (*check == '*' || *check == '?' || *check == '.')
                {
                        usingwildcards = true;
                        break;
@@ -368,7 +370,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                                {
                                        if (!user->SharesChannelWith(oper))
                                        {
-                                               if (usingwildcards && (!oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex")))
+                                               if (usingwildcards && (oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex")))
                                                        continue;
                                        }