+ if (chan)
+ {
+ if (chan->IsModeSet(re) && chan->IsModeSet(limitmode))
+ {
+ if (chan->GetUserCounter() >= ConvToNum<size_t>(chan->GetModeParameter(limitmode)))
+ {
+ const std::string& channel = *re.ext.get(chan);
+
+ /* sometimes broken ulines can make circular or chained +L, avoid this */
+ Channel* destchan = ServerInstance->FindChan(channel);
+ if (destchan && destchan->IsModeSet(re))
+ {
+ user->WriteNumeric(470, cname, '*', "You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.");
+ return MOD_RES_DENY;
+ }
+
+ if (user->IsModeSet(antiredirectmode))
+ {
+ user->WriteNumeric(470, cname, channel, "Force redirection stopped.");
+ return MOD_RES_DENY;
+ }
+ else
+ {
+ user->WriteNumeric(470, cname, channel, "You may not join this channel, so you are automatically being transferred to the redirected channel.");
+ Channel::JoinUser(user, channel);
+ return MOD_RES_DENY;
+ }
+ }
+ }
+ }
+ return MOD_RES_PASSTHRU;