- if (adding)
- {
- /* Setting a new limit, sanity check */
- long limit = atoi(parameter.c_str());
-
- /* Wrap low values at 32768 */
- if (limit < 0)
- limit = 0x7FFF;
-
- /* If the new limit is the same as the old limit,
- * and the old limit isnt 0, disallow */
- std::string oldlimit = channel->GetModeParameter('l');
- if (limit == atoi(oldlimit.c_str()) && oldlimit != "0")
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- /* They must have specified an invalid number.
- * Dont allow +l 0.
- */
- if (!limit)
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- parameter = ConvToStr(limit);
-
- /* Set new limit */
- channel->SetModeParam('l', parameter.c_str(), true);
- channel->modes[CM_LIMIT] = 1;
-
- return MODEACTION_ALLOW;
- }
- else
- {
- /* Check if theres a limit here to remove.
- * If there isnt, dont allow the -l
- */
- if (channel->GetModeParameter('l').empty())
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- /* Removing old limit, no checks here */
- channel->SetModeParam('l', "", false);
- channel->modes[CM_LIMIT] = 0;