diff --git a/Client.cpp b/Client.cpp index 34659e9c..0baebbe9 100644 --- a/Client.cpp +++ b/Client.cpp @@ -233,11 +233,11 @@ void CClient::ReadLine(const CString& sData) { sCTCP.LeftChomp(); sCTCP.RightChomp(); - USERMODULECALL(OnUserCTCPReply(sTarget, sCTCP), m_pUser, this, return); + NETWORKMODULECALL(OnUserCTCPReply(sTarget, sCTCP), m_pUser, m_pNetwork, this, return); sMsg = "\001" + sCTCP + "\001"; } else { - USERMODULECALL(OnUserNotice(sTarget, sMsg), m_pUser, this, return); + NETWORKMODULECALL(OnUserNotice(sTarget, sMsg), m_pUser, m_pNetwork, this, return); } if (!GetIRCSock()) { @@ -298,7 +298,7 @@ void CClient::ReadLine(const CString& sData) { if (sCTCP.Token(0).Equals("ACTION")) { CString sMessage = sCTCP.Token(1, true); - USERMODULECALL(OnUserAction(sTarget, sMessage), m_pUser, this, return); + NETWORKMODULECALL(OnUserAction(sTarget, sMessage), m_pUser, m_pNetwork, this, return); sCTCP = "ACTION " + sMessage; if (pChan && pChan->KeepBuffer()) { @@ -319,7 +319,7 @@ void CClient::ReadLine(const CString& sData) { } } } else { - USERMODULECALL(OnUserCTCP(sTarget, sCTCP), m_pUser, this, return); + NETWORKMODULECALL(OnUserCTCP(sTarget, sCTCP), m_pUser, m_pNetwork, this, return); } if (m_pNetwork) { @@ -338,7 +338,7 @@ void CClient::ReadLine(const CString& sData) { return; } - USERMODULECALL(OnUserMsg(sTarget, sMsg), m_pUser, this, return); + NETWORKMODULECALL(OnUserMsg(sTarget, sMsg), m_pUser, m_pNetwork, this, return); if (!GetIRCSock()) { // Some lagmeters do a PRIVMSG to their own nick, ignore those. @@ -410,7 +410,7 @@ void CClient::ReadLine(const CString& sData) { for (unsigned int a = 0; a < vChans.size(); a++) { CString sChannel = vChans[a]; - USERMODULECALL(OnUserJoin(sChannel, sKey), m_pUser, this, continue); + NETWORKMODULECALL(OnUserJoin(sChannel, sKey), m_pUser, m_pNetwork, this, continue); CChan* pChan = m_pNetwork->FindChan(sChannel); if (pChan) { @@ -444,7 +444,7 @@ void CClient::ReadLine(const CString& sData) { sMessage.LeftChomp(); } - USERMODULECALL(OnUserPart(sChan, sMessage), m_pUser, this, return); + NETWORKMODULECALL(OnUserPart(sChan, sMessage), m_pUser, m_pNetwork, this, return); CChan* pChan = m_pNetwork->FindChan(sChan); @@ -466,10 +466,10 @@ void CClient::ReadLine(const CString& sData) { if (!sTopic.empty()) { if (sTopic.Left(1) == ":") sTopic.LeftChomp(); - USERMODULECALL(OnUserTopic(sChan, sTopic), m_pUser, this, return); + NETWORKMODULECALL(OnUserTopic(sChan, sTopic), m_pUser, m_pNetwork, this, return); sLine = "TOPIC " + sChan + " :" + sTopic; } else { - USERMODULECALL(OnUserTopicRequest(sChan), m_pUser, this, return); + NETWORKMODULECALL(OnUserTopicRequest(sChan), m_pUser, m_pNetwork, this, return); } } else if (m_pNetwork && sCommand.Equals("MODE")) { CString sTarget = sLine.Token(1); @@ -670,7 +670,7 @@ void CClient::AcceptLogin(CUser& User) { SendMotd(); - USERMODULECALL(OnClientLogin(), m_pUser, this, NOTHING); + NETWORKMODULECALL(OnClientLogin(), m_pUser, m_pNetwork, this, NOTHING); } void CClient::Timeout() { @@ -690,7 +690,7 @@ void CClient::Disconnected() { SetNetwork(NULL, true, false); if (m_pUser) { - USERMODULECALL(OnClientDisconnect(), m_pUser, this, NOTHING); + NETWORKMODULECALL(OnClientDisconnect(), m_pUser, m_pNetwork, this, NOTHING); } } diff --git a/ClientCommand.cpp b/ClientCommand.cpp index 070bb6c2..41a9f917 100644 --- a/ClientCommand.cpp +++ b/ClientCommand.cpp @@ -25,7 +25,7 @@ void CClient::UserCommand(CString& sLine) { return; } - USERMODULECALL(OnStatusCommand(sLine), m_pUser, this, return); + NETWORKMODULECALL(OnStatusCommand(sLine), m_pUser, m_pNetwork, this, return); const CString sCommand = sLine.Token(0); diff --git a/main.h b/main.h index ab04d993..95ed8fb4 100644 --- a/main.h +++ b/main.h @@ -91,16 +91,17 @@ #define NETWORKMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \ do { \ assert(macUSER != NULL); \ - assert(macNETWORK != NULL); \ _USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER); \ - CModules& NMods = ((CIRCNetwork*)macNETWORK)->GetModules(); \ - CClient* pOldNClient = NMods.GetClient(); \ - NMods.SetClient(macCLIENT); \ - if (NMods.macFUNC) { \ - NMods.SetClient(pOldNClient); \ - macEXITER; \ - } \ - NMods.SetClient(pOldNClient); \ + if (macNETWORK != NULL) { \ + CModules& NMods = macNETWORK->GetModules(); \ + CClient* pOldNClient = NMods.GetClient(); \ + NMods.SetClient(macCLIENT); \ + if (NMods.macFUNC) { \ + NMods.SetClient(pOldNClient); \ + macEXITER; \ + } \ + NMods.SetClient(pOldNClient); \ + } \ } while (false) #define GLOBALMODULECALL(macFUNC, macEXITER) \