-/** This function forces this server to quit, removing this server
- * and any users on it (and servers and users below that, etc etc).
- * It's very slow and pretty clunky, but luckily unless your network
- * is having a REAL bad hair day, this function shouldnt be called
- * too many times a month ;-)
- */
-void TreeSocket::SquitServer(std::string &from, TreeServer* Current, int& num_lost_servers, int& num_lost_users)
-{
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "SquitServer for %s from %s", Current->GetName().c_str(), from.c_str());
- /* recursively squit the servers attached to 'Current'.
- * We're going backwards so we don't remove users
- * while we still need them ;)
- */
- for (unsigned int q = 0; q < Current->ChildCount(); q++)
- {
- TreeServer* recursive_server = Current->GetChild(q);
- this->SquitServer(from,recursive_server, num_lost_servers, num_lost_users);
- }
- /* Now we've whacked the kids, whack self */
- num_lost_servers++;
- num_lost_users += Current->QuitUsers(from);
-}
-
-/** This is a wrapper function for SquitServer above, which
- * does some validation first and passes on the SQUIT to all
- * other remaining servers.
- */
-void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
-{
- bool LocalSquit = false;
-
- if (!Current->IsRoot())
- {
- DelServerEvent(Utils->Creator, Current->GetName());
-
- if (Current->IsLocal())
- {
- ServerInstance->SNO->WriteGlobalSno('l', "Server \002"+Current->GetName()+"\002 split: "+reason);
- LocalSquit = true;
- if (Current->GetSocket()->Introduced())
- {
- parameterlist params;
- params.push_back(Current->GetID());
- params.push_back(":"+reason);
- Utils->DoOneToMany(Utils->TreeRoot->GetID(), "SQUIT", params);
- }
- }
- else
- {
- ServerInstance->SNO->WriteGlobalSno('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
- }
- int num_lost_servers = 0;
- int num_lost_users = 0;
- std::string from = Current->GetParent()->GetName()+" "+Current->GetName();
- SquitServer(from, Current, num_lost_servers, num_lost_users);
- ServerInstance->SNO->WriteToSnoMask(LocalSquit ? 'l' : 'L', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.",
- num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
- Current->Tidy();
- Current->GetParent()->DelChild(Current);
- Current->cull();
- delete Current;
- if (Current == MyRoot)
- {
- MyRoot = NULL;
- Close();
- }
- }
-}
-
-CmdResult CommandSQuit::Handle(User* user, std::vector<std::string>& params)