diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_joinflood.cpp | 23 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 51 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 17 |
3 files changed, 46 insertions, 45 deletions
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index cd233a01c..ac966cc39 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -101,6 +101,8 @@ class JoinFlood : public ModeHandler ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { + joinfloodsettings* dummy; + if (adding) { char ndata[MAXBUF]; @@ -132,11 +134,11 @@ class JoinFlood : public ModeHandler } else { - if (!channel->GetExt("joinflood")) + if (!channel->GetExt("joinflood", dummy)) { parameter = ConvToStr(njoins) + ":" +ConvToStr(nsecs); joinfloodsettings *f = new joinfloodsettings(nsecs,njoins); - channel->Extend("joinflood",(char*)f); + channel->Extend("joinflood", f); channel->SetMode('j', true); channel->SetModeParam('j', parameter.c_str(), true); return MODEACTION_ALLOW; @@ -151,9 +153,10 @@ class JoinFlood : public ModeHandler } else { - if (channel->GetExt("joinflood")) + if (channel->GetExt("joinflood", dummy)) { - joinfloodsettings *f = (joinfloodsettings*)channel->GetExt("joinflood"); + joinfloodsettings *f; + channel->GetExt("joinflood", f); DELETE(f); channel->Shrink("joinflood"); channel->SetMode('j', false); @@ -183,8 +186,8 @@ class ModuleJoinFlood : public Module { if (chan) { - joinfloodsettings *f = (joinfloodsettings*)chan->GetExt("joinflood"); - if (f) + joinfloodsettings *f; + if (chan->GetExt("joinflood", f)) { if (f->islocked()) { @@ -198,8 +201,8 @@ class ModuleJoinFlood : public Module virtual void OnUserJoin(userrec* user, chanrec* channel) { - joinfloodsettings *f = (joinfloodsettings*)channel->GetExt("joinflood"); - if (f) + joinfloodsettings *f; + if (channel->GetExt("joinflood",f)) { f->addjoin(); if (f->shouldlock()) @@ -213,9 +216,9 @@ class ModuleJoinFlood : public Module void OnChannelDelete(chanrec* chan) { - if (chan->GetExt("joinflood")) + joinfloodsettings *f; + if (chan->GetExt("joinflood",f)) { - joinfloodsettings *f = (joinfloodsettings*)chan->GetExt("joinflood"); DELETE(f); chan->Shrink("joinflood"); } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index e96e42185..80e1fb8d0 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -30,9 +30,9 @@ class KickRejoin : public ModeHandler if (!adding) { // Taking the mode off, we need to clean up. - delaylist* dl = (delaylist*)channel->GetExt("norejoinusers"); + delaylist* dl; - if (dl) + if (channel->GetExt("norejoinusers", dl)) { DELETE(dl); channel->Shrink("norejoinusers"); @@ -71,10 +71,8 @@ public: { if (chan) { - delaylist* dl = (delaylist*)chan->GetExt("norejoinusers"); - log(DEBUG, "m_kicknorejoin.so: tried to grab delay list"); - - if (dl) + delaylist* dl; + if (chan->GetExt("norejoinusers", dl)) { log(DEBUG, "m_kicknorejoin.so: got delay list, iterating over it"); std::vector<userrec*> itemstoremove; @@ -108,36 +106,35 @@ public: // Now it's empty.. DELETE(dl); chan->Shrink("norejoinusers"); - } } } - return 0; } + return 0; + } - virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) + virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) + { + if (chan->IsModeSet('J') && (source != user)) { - if (chan->IsModeSet('J') && (source != user)) + delaylist* dl; + if (!chan->GetExt("norejoinusers", dl)) { - delaylist* dl = (delaylist*)chan->GetExt("norejoinusers"); - - if (!dl) - { - dl = new delaylist; - chan->Extend("norejoinusers", (char*)dl); - } - - log(DEBUG, "m_kicknorejoin.so: setting record for %s, %d second delay", user->nick, strtoint(chan->GetModeParameter('J'))); - (*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J')); + dl = new delaylist; + chan->Extend("norejoinusers", dl); } + + log(DEBUG, "m_kicknorejoin.so: setting record for %s, %d second delay", user->nick, strtoint(chan->GetModeParameter('J'))); + (*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J')); } - - virtual void OnChannelDelete(chanrec* chan) - { - delaylist* dl = (delaylist*)chan->GetExt("norejoinusers"); + } + + virtual void OnChannelDelete(chanrec* chan) + { + delaylist* dl; - if (dl) - { - DELETE(dl); + if (chan->GetExt("norejoinusers", dl)) + { + DELETE(dl); chan->Shrink("norejoinusers"); } } diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 04f9766d5..b41c71da9 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -90,6 +90,8 @@ class MsgFlood : public ModeHandler ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { + floodsettings *f; + if (adding) { char ndata[MAXBUF]; @@ -131,11 +133,11 @@ class MsgFlood : public ModeHandler } else { - if (!channel->GetExt("flood")) + if (!channel->GetExt("flood", f)) { parameter = ConvToStr(nlines) + ":" +ConvToStr(nsecs); floodsettings *f = new floodsettings(ban,nsecs,nlines); - channel->Extend("flood",(char*)f); + channel->Extend("flood",f); channel->SetMode('f', true); channel->SetModeParam('f', parameter.c_str(), true); return MODEACTION_ALLOW; @@ -151,9 +153,8 @@ class MsgFlood : public ModeHandler } else { - if (channel->GetExt("flood")) + if (channel->GetExt("flood", f)) { - floodsettings *f = (floodsettings*)channel->GetExt("flood"); DELETE(f); channel->Shrink("flood"); channel->SetMode('f', false); @@ -184,8 +185,8 @@ class ModuleMsgFlood : public Module { if (IS_LOCAL(user)) { - floodsettings *f = (floodsettings*)dest->GetExt("flood"); - if (f) + floodsettings *f; + if (dest->GetExt("flood", f)) { f->addmessage(user); if (f->shouldkick(user)) @@ -236,9 +237,9 @@ class ModuleMsgFlood : public Module void OnChannelDelete(chanrec* chan) { - if (chan->GetExt("flood")) + floodsettings* f; + if (chan->GetExt("flood", f)) { - floodsettings *f = (floodsettings*)chan->GetExt("flood"); DELETE(f); chan->Shrink("flood"); } |