packet is being sent and received, bare-bones ping-pong is working

This commit is contained in:
Kayne Ruse
2013-05-20 01:02:15 +10:00
parent b587759203
commit 7866f46ed5
18 changed files with 342 additions and 63 deletions
+45
View File
@@ -1,2 +1,47 @@
#include "player_manager.hpp"
PlayerManager::PlayerManager(int max) {
maxPlayers = max;
}
PlayerManager::~PlayerManager() {
DeleteAll();
}
void PlayerManager::UpdateAll(int delta) {
for (auto it : playerList) {
it->Update(delta);
}
}
Player* PlayerManager::New(int playerID, int channel, std::string handle, std::string avatar) {
Player* p = new Player(playerID, channel, handle, avatar);
playerList.push_back(p);
return p;
}
Player* PlayerManager::Get(int playerID) {
for (auto it : playerList) {
if (it->GetPlayerID() == playerID) {
return it;
}
}
return nullptr;
}
void PlayerManager::Delete(int playerID) {
for (auto it : playerList) {
if (it->GetPlayerID() == playerID) {
delete it;
playerList.remove(it);
return;
}
}
}
void PlayerManager::DeleteAll() {
for (auto it : playerList) {
delete it;
}
playerList.clear();
}