Working on reimplementing the player characters
I've also added EraseIf() to the manager classes.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user