From 83b9a28e4c04ea73209df6d0bfaca2aa4c1d4cdf Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Thu, 10 Oct 2013 17:22:16 +0200 Subject: [PATCH] Implemented a nick compare function As suggested by the todos in IRCSock, added IsNick(CString) method so the ugly Nick.GetNick().Equals(GetNick()) could be simplified. Signed-off-by: Toon Schoenmakers --- include/znc/Nick.h | 1 + src/IRCSock.cpp | 9 +++------ src/Nick.cpp | 4 ++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/znc/Nick.h b/include/znc/Nick.h index 97eb8482..00480ad8 100644 --- a/include/znc/Nick.h +++ b/include/znc/Nick.h @@ -37,6 +37,7 @@ public: void Parse(const CString& sNickMask); CString GetHostMask() const; size_t GetCommonChans(std::vector& vChans, CIRCNetwork* pNetwork) const; + bool IsNick(const CString& nickname) const; // Setters void SetNetwork(CIRCNetwork* pNetwork); diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index f9a394a1..2959f781 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -512,8 +512,7 @@ void CIRCSock::ReadLine(const CString& sData) { } } - // Todo: use nick compare function here - if (Nick.GetNick().Equals(GetNick())) { + if (Nick.IsNick(GetNick())) { // We are changing our own nick, the clients always must see this! bIsVisible = false; SetNick(sNewNick); @@ -563,8 +562,7 @@ void CIRCSock::ReadLine(const CString& sData) { CString sChan = sRest.Token(0).TrimPrefix_n(); CChan* pChan; - // Todo: use nick compare function - if (Nick.GetNick().Equals(GetNick())) { + if (Nick.IsNick(GetNick())) { m_pNetwork->AddChan(sChan, false); pChan = m_pNetwork->FindChan(sChan); if (pChan) { @@ -598,8 +596,7 @@ void CIRCSock::ReadLine(const CString& sData) { bDetached = true; } - // Todo: use nick compare function - if (Nick.GetNick().Equals(GetNick())) { + if (Nick.IsNick(GetNick())) { m_pNetwork->DelChan(sChan); } diff --git a/src/Nick.cpp b/src/Nick.cpp index 55ba4759..79de72f4 100644 --- a/src/Nick.cpp +++ b/src/Nick.cpp @@ -78,6 +78,10 @@ size_t CNick::GetCommonChans(vector& vRetChans, CIRCNetwork* pNetwork) c return vRetChans.size(); } +bool CNick::IsNick(const CString& nickname) const { + return m_sNick.Equals(nickname); +} + void CNick::SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; } void CNick::SetNick(const CString& s) { m_sNick = s; } void CNick::SetIdent(const CString& s) { m_sIdent = s; }