- ban = false;
- }
- while (*data)
- {
- if (*data == ':')
- {
- *data = 0;
- data++;
- secs = data;
- break;
- }
- else data++;
- }
- if (secs)
- {
- /* Set up the flood parameters for this channel */
- int nlines = atoi(lines);
- int nsecs = atoi(secs);
- if ((nlines<2) || (nsecs<1))
- {
- source->WriteNumeric(608, "%s %s :Invalid flood parameter",source->nick.c_str(),channel->name.c_str());
- parameter.clear();
- return MODEACTION_DENY;
- }
- else
- {
- if (!channel->GetExt("flood", f))
- {
- parameter = std::string(ban ? "*" : "") + ConvToStr(nlines) + ":" +ConvToStr(nsecs);
- floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines);
- channel->Extend("flood",fs);
- channel->SetMode('f', parameter);
- return MODEACTION_ALLOW;
- }
- else
- {
- std::string cur_param = channel->GetModeParameter('f');
- parameter = std::string(ban ? "*" : "") + ConvToStr(nlines) + ":" +ConvToStr(nsecs);
- if (cur_param == parameter)
- {
- // mode params match
- return MODEACTION_DENY;
- }
- else
- {
- if ((((nlines != f->lines) || (nsecs != f->secs) || (ban != f->ban))) && (((nsecs > 0) && (nlines > 0))))
- {
- delete f;
- floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines);
- channel->Shrink("flood");
- channel->Extend("flood",fs);
- channel->SetMode('f', parameter);
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
- }
- }
- }