diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-12-30 18:58:31 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-12-30 18:58:31 +0100 |
commit | 0c061aff64625799160dadfb09ade008a38eb6c5 (patch) | |
tree | 261af81d4d5262009661d21e7956309bd3d2dea2 /src | |
parent | 03c5ffbdc3850fee20887885bcddd9d0738c8537 (diff) |
Clean up User::FormatModes(), rename to GetModeLetters()
Prefix the returned string with '+'
Diffstat (limited to 'src')
-rw-r--r-- | src/coremods/core_user/cmd_mode.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_whois.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 30 |
6 files changed, 21 insertions, 21 deletions
diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp index b1790bb89..65ab96112 100644 --- a/src/coremods/core_user/cmd_mode.cpp +++ b/src/coremods/core_user/cmd_mode.cpp @@ -145,7 +145,7 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar // Display user's current mode string // XXX: Use WriteServ() because WriteNumeric() assumes the target (i.e. next word after the number) // is 'user' and puts his nick there which is not what we want - user->WriteServ("%03d %s :+%s", RPL_UMODEIS, targetuser->nick.c_str(), targetuser->FormatModes()); + user->WriteServ("%03d %s :%s", RPL_UMODEIS, targetuser->nick.c_str(), targetuser->GetModeLetters().c_str()); if (targetuser->IsOper()) { ModeHandler* snomask = ServerInstance->Modes->FindMode('s', MODETYPE_USER); diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index ed5c1cda0..81e62c8e5 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -211,11 +211,11 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un { if (dest->IsModeSet(snomaskmode)) { - whois.SendLine(379, InspIRCd::Format("is using modes +%s %s", dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str())); + whois.SendLine(379, InspIRCd::Format("is using modes %s %s", dest->GetModeLetters().c_str(), snomaskmode->GetUserParameter(dest).c_str())); } else { - whois.SendLine(379, InspIRCd::Format("is using modes +%s", dest->FormatModes())); + whois.SendLine(379, InspIRCd::Format("is using modes %s", dest->GetModeLetters().c_str())); } } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index f4123466e..2cb45ad43 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -169,7 +169,7 @@ class CommandCheck : public Command context.Write("nuh", targuser->GetFullHost()); context.Write("realnuh", targuser->GetFullRealHost()); context.Write("realname", targuser->fullname); - context.Write("modes", std::string("+") + targuser->FormatModes()); + context.Write("modes", targuser->GetModeLetters()); context.Write("snomasks", GetSnomasks(targuser)); context.Write("server", targuser->server->GetName()); context.Write("uid", targuser->uuid); diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index eb8e856ac..11fad4b18 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -189,7 +189,7 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener data << "<away>" << Sanitize(u->awaymsg) << "</away><awaytime>" << u->awaytime << "</awaytime>"; if (u->IsOper()) data << "<opertype>" << Sanitize(u->oper->name) << "</opertype>"; - data << "<modes>" << u->FormatModes() << "</modes><ident>" << Sanitize(u->ident) << "</ident>"; + data << "<modes>" << u->GetModeLetters().substr(1) << "</modes><ident>" << Sanitize(u->ident) << "</ident>"; LocalUser* lu = IS_LOCAL(u); if (lu) data << "<port>" << lu->GetServerPort() << "</port><servaddr>" diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 6f59fcd50..91c9f3ca8 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -162,6 +162,6 @@ CommandUID::Builder::Builder(User* user) push(user->ident); push(user->GetIPString()); push_int(user->signon); - push('+').push_raw(user->FormatModes(true)); + push(user->GetModeLetters(true)); push_last(user->fullname); } diff --git a/src/users.cpp b/src/users.cpp index 90978a496..bdcc9edd0 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -39,28 +39,28 @@ bool User::IsModeSet(unsigned char m) const return (mh && modes[mh->GetId()]); } -const char* User::FormatModes(bool showparameters) +std::string User::GetModeLetters(bool includeparams) const { - static std::string data; + std::string ret(1, '+'); std::string params; - data.clear(); - for (unsigned char n = 0; n < 64; n++) + for (unsigned char i = 'A'; i < 'z'; i++) { - ModeHandler* mh = ServerInstance->Modes->FindMode(n + 65, MODETYPE_USER); - if (mh && IsModeSet(mh)) + const ModeHandler* const mh = ServerInstance->Modes.FindMode(i, MODETYPE_USER); + if ((!mh) || (!IsModeSet(mh))) + continue; + + ret.push_back(mh->GetModeChar()); + if ((includeparams) && (mh->NeedsParam(true))) { - data.push_back(n + 65); - if (showparameters && mh->NeedsParam(true)) - { - std::string p = mh->GetUserParameter(this); - if (p.length()) - params.append(" ").append(p); - } + const std::string val = mh->GetUserParameter(this); + if (!val.empty()) + params.append(1, ' ').append(val); } } - data += params; - return data.c_str(); + + ret += params; + return ret; } User::User(const std::string& uid, Server* srv, int type) |