diff --git a/Buffer.cpp b/Buffer.cpp index 7b164687..a3ffbf84 100644 --- a/Buffer.cpp +++ b/Buffer.cpp @@ -54,6 +54,15 @@ int CBuffer::UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick return AddLine(sPre, sPost, bIncNick); } +int CBuffer::UpdateExactLine(const CString& sPre, const CString& sPost, bool bIncNick) { + for (iterator it = begin(); it != end(); it++) { + if (it->GetPre() == sPre && it->GetPost() == sPost) + return size(); + } + + return AddLine(sPre, sPost, bIncNick); +} + bool CBuffer::GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const { if (uIdx >= size()) { return false; diff --git a/Buffer.h b/Buffer.h index 5d236746..be93c3f8 100644 --- a/Buffer.h +++ b/Buffer.h @@ -43,6 +43,8 @@ public: int AddLine(const CString& sPre, const CString& sPost, bool bIncNick = true); /// Same as AddLine, but if there is already a line with sPre it is replaced. int UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick = true); + /// Same as UpdateLine, but does nothing if this exact line already exists + int UpdateExactLine(const CString& sPre, const CString& sPost, bool bIncNick = true); bool GetNextLine(const CString& sTarget, CString& sRet); bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const; bool IsEmpty() const { return empty(); } diff --git a/IRCSock.cpp b/IRCSock.cpp index 263632d9..eb210328 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -139,7 +139,7 @@ void CIRCSock::ReadLine(const CString& sData) { } case 5: ParseISupport(sRest); - m_pUser->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); + m_pUser->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 2: case 3: diff --git a/User.h b/User.h index ab8ae0a7..3ad6cc29 100644 --- a/User.h +++ b/User.h @@ -73,13 +73,16 @@ public: // Buffers void AddRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.AddLine(sPre, sPost, bIncNick); } - void AddMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.AddLine(sPre, sPost, bIncNick); } - void AddQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.AddLine(sPre, sPost, bIncNick); } void UpdateRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateLine(sPre, sPost, bIncNick); } - void UpdateMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.UpdateLine(sPre, sPost, bIncNick); } - void UpdateQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.UpdateLine(sPre, sPost, bIncNick); } + void UpdateExactRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateExactLine(sPre, sPost, bIncNick); } void ClearRawBuffer() { m_RawBuffer.Clear(); } + + void AddMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.AddLine(sPre, sPost, bIncNick); } + void UpdateMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.UpdateLine(sPre, sPost, bIncNick); } void ClearMotdBuffer() { m_MotdBuffer.Clear(); } + + void AddQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.AddLine(sPre, sPost, bIncNick); } + void UpdateQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.UpdateLine(sPre, sPost, bIncNick); } void ClearQueryBuffer() { m_QueryBuffer.Clear(); } // !Buffers