Permalink
Browse files

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 <nighteyes1993@gmail.com>
  • Loading branch information...
1 parent b7ce935 commit 83b9a28e4c04ea73209df6d0bfaca2aa4c1d4cdf @schoentoon schoentoon committed Oct 10, 2013
Showing with 8 additions and 6 deletions.
  1. +1 −0 include/znc/Nick.h
  2. +3 −6 src/IRCSock.cpp
  3. +4 −0 src/Nick.cpp
View
@@ -37,6 +37,7 @@ class CNick
void Parse(const CString& sNickMask);
CString GetHostMask() const;
size_t GetCommonChans(std::vector<CChan*>& vChans, CIRCNetwork* pNetwork) const;
+ bool IsNick(const CString& nickname) const;
// Setters
void SetNetwork(CIRCNetwork* pNetwork);
View
@@ -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);
}
View
@@ -78,6 +78,10 @@ size_t CNick::GetCommonChans(vector<CChan*>& 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; }

0 comments on commit 83b9a28

Please sign in to comment.