Working on reimplementing the player characters

I've also added EraseIf() to the manager classes.
This commit is contained in:
Kayne Ruse
2014-03-07 22:09:50 +11:00
parent 006a72174f
commit 56d02ad8d4
6 changed files with 56 additions and 25 deletions
+12 -1
View File
@@ -38,12 +38,23 @@ int ClientManager::HandleDisconnection(int i) {
return -1;
}
void ClientManager::ForEach(Lambda fn) {
void ClientManager::ForEach(std::function<void(Iterator)> fn) {
for(Iterator it = clientMap.begin(); it != clientMap.end(); it++) {
fn(it);
}
}
void ClientManager::EraseIf(std::function<bool(Iterator)> fn) {
for(Iterator it = clientMap.begin(); it != clientMap.end(); /* empty */) {
if(fn(it)) {
it = clientMap.erase(it);
}
else {
++it;
}
}
}
ClientEntry* ClientManager::GetClient(int i) {
for (auto& it : clientMap) {
if (it.first == i) {