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
@@ -37,12 +37,23 @@ int PlayerManager::HandlePlayerUnload(int uniqueID) {
//
}
void PlayerManager::ForEach(Lambda fn) {
void PlayerManager::ForEach(std::function<void(Iterator)> fn) {
for(Iterator it = playerMap.begin(); it != playerMap.end(); it++) {
fn(it);
}
}
void PlayerManager::EraseIf(std::function<bool(Iterator)> fn) {
for(Iterator it = playerMap.begin(); it != playerMap.end(); /* empty */) {
if(fn(it)) {
it = playerMap.erase(it);
}
else {
++it;
}
}
}
PlayerEntry* PlayerManager::GetPlayer(int uniqueID) {
for (auto& it : playerMap) {
if (it.first == uniqueID) {