diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-01-05 14:23:03 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-01-05 14:23:03 +0100 |
commit | 8acee01804e96f80bb980137738764573780a642 (patch) | |
tree | 470c942cc41d930d718efd242dd1897e4e29ab69 /src/modules/m_spanningtree | |
parent | d736eba00b274c87662bd73a3acf8288135643d6 (diff) |
m_spanningtree Remove vector from TreeServer::QuitUsers()
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 2fce9a504..7d8abf4bf 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -140,23 +140,18 @@ void TreeServer::FinishBurst() int TreeServer::QuitUsers(const std::string &reason) { std::string publicreason = ServerInstance->Config->HideSplits ? "*.net *.split" : reason; - std::vector<User*> time_to_die; - for (user_hash::iterator n = ServerInstance->Users->clientlist->begin(); n != ServerInstance->Users->clientlist->end(); n++) - { - if (n->second->server == ServerName) - { - time_to_die.push_back(n->second); - } - } - for (std::vector<User*>::iterator n = time_to_die.begin(); n != time_to_die.end(); n++) + + const user_hash& users = *ServerInstance->Users->clientlist; + unsigned int original_size = users.size(); + for (user_hash::const_iterator i = users.begin(); i != users.end(); ) { - User* a = (User*)*n; - if (!IS_LOCAL(a)) - { - ServerInstance->Users->QuitUser(a, publicreason, &reason); - } + User* user = i->second; + // Increment the iterator now because QuitUser() removes the user from the container + ++i; + if (user->server == ServerName) + ServerInstance->Users->QuitUser(user, publicreason, &reason); } - return time_to_die.size(); + return original_size - users.size(); } /** This method is used to add the structure to the |