+ /*
+ * We don't restrict the number of channels that remote users or users that are override-joining may be in.
+ * We restrict local users to MaxChans channels.
+ * We restrict local operators to OperMaxChans channels.
+ * This is a lot more logical than how it was formerly. -- w00t
+ */
+ if (IS_LOCAL(user) && !override)
+ {
+ // Checking MyClass exists because we *may* get here with NULL, not 100% sure.
+ if (user->MyClass && user->MyClass->GetMaxChans())
+ {
+ if (user->chans.size() >= user->MyClass->GetMaxChans())
+ {
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ return NULL;
+ }
+ }
+ else
+ {
+ if (IS_OPER(user))
+ {
+ if (user->chans.size() >= Instance->Config->OperMaxChans)
+ {
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ return NULL;
+ }
+ }
+ else
+ {
+ if (user->chans.size() >= Instance->Config->MaxChans)
+ {
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ return NULL;
+ }
+ }
+ }
+ }
+
+ strlcpy(cname, cn, Instance->Config->Limits.ChanMax);
+ Ptr = Instance->FindChan(cname);