- if (!ServerInstance->IsChannel(i->second->name))
- chanvec.push_back(i->second);
- }
- std::vector<Channel*>::reverse_iterator c2 = chanvec.rbegin();
- while (c2 != chanvec.rend())
- {
- Channel* c = *c2++;
- if (c->IsModeSet('P') && c->GetUserCounter())
- {
- std::vector<std::string> modes;
- modes.push_back(c->name);
- modes.push_back("-P");
+ Channel* c = i->second;
+ // Move iterator before we begin kicking
+ ++i;
+ if (ServerInstance->IsChannel(c->name))
+ continue; // The name of this channel is still valid