]> jfr.im git - irc/rizon/znc.git/commitdiff
fixed a null reference to pClient in hooks 'OnChanBufferStarting,OnChanBufferStarting...
authorJim Hull <redacted>
Tue, 13 Sep 2011 06:03:03 +0000 (23:03 -0700)
committerUli Schlachter <redacted>
Tue, 13 Sep 2011 07:52:41 +0000 (09:52 +0200)
Conflicts:

Chan.cpp

Signed-off-by: Uli Schlachter <redacted>
Chan.cpp

index 287eecb32ead09b013d5f9f8358a3c7ca8b64945..b0b22079a602a71688fdd1ae1aeb4f11b4d326ea 100644 (file)
--- a/Chan.cpp
+++ b/Chan.cpp
@@ -547,28 +547,39 @@ void CChan::SendBuffer(CClient* pClient) {
                const vector<CString>& vsBuffer = GetBuffer();
 
                if (vsBuffer.size()) {
-                       bool bSkipStatusMsg = false;
-                       MODULECALL(OnChanBufferStarting(*this, *pClient), m_pUser, NULL, bSkipStatusMsg = true);
+                       const vector<CClient*> & vClients = m_pUser->GetClients();
+                       for( size_t uClient = 0; uClient < vClients.size(); ++uClient ) {
+                               // in the event that pClient is NULL, need to send this to all clients for the user
+                               // I'm presuming here that pClient is listed inside vClients so thus vClients at this
+                               // point can't be empty. Rework this if you like ...
+
+                               CClient * pUseClient = ( pClient ? pClient : vClients[uClient] );
+                               bool bSkipStatusMsg = false;
+                               MODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pUser, NULL, bSkipStatusMsg = true);
+
+                               if (!bSkipStatusMsg) {
+                                       m_pUser->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient);
+                               }
 
-                       if (!bSkipStatusMsg) {
-                               m_pUser->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pClient);
-                       }
+                               for (unsigned int a = 0; a < vsBuffer.size(); a++) {
+                                       CString sLine(vsBuffer[a]);
+                                       MODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pUser, NULL, continue);
+                                       m_pUser->PutUser(sLine, pUseClient);
+                               }
 
-                       for (unsigned int a = 0; a < vsBuffer.size(); a++) {
-                               CString sLine(vsBuffer[a]);
-                               MODULECALL(OnChanBufferPlayLine(*this, *pClient, sLine), m_pUser, NULL, continue);
-                               m_pUser->PutUser(sLine, pClient);
-                       }
+                               if (!KeepBuffer()) {
+                                       ClearBuffer();
+                               }
 
-                       if (!KeepBuffer()) {
-                               ClearBuffer();
-                       }
+                               bSkipStatusMsg = false;
+                               MODULECALL(OnChanBufferEnding(*this, *pUseClient), m_pUser, NULL, bSkipStatusMsg = true);
 
-                       bSkipStatusMsg = false;
-                       MODULECALL(OnChanBufferEnding(*this, *pClient), m_pUser, NULL, bSkipStatusMsg = true);
+                               if (!bSkipStatusMsg) {
+                                       m_pUser->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pUseClient);
+                               }
 
-                       if (!bSkipStatusMsg) {
-                               m_pUser->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pClient);
+                               if( pClient )
+                                       break;
                        }
                }
        }