networking addPlayer

This commit is contained in:
j3d1 2016-09-28 01:48:34 +02:00
parent 0e8e41e4fb
commit ef38da703e
8 changed files with 50 additions and 37 deletions

View file

@ -62,10 +62,12 @@ namespace game {
return true;
}
void State::addPlayer(int playerId)
int State::addPlayer()
{
int playerId = m_nextId++;
Player *player = new Player(playerId);
players.push_back(player);
return playerId;
}
void State::playerLeft(int playerId)

View file

@ -36,7 +36,7 @@ namespace game {
// The upper layer (network/renderer) calling these three functions
// should keep id's unique and give one (network) input an id.
void addPlayer(int playerId);
int addPlayer();
void playerLeft(int playerId);
void commandForPlayer(int playerId, Command *cmd);
@ -89,5 +89,6 @@ namespace game {
float m_playerRespawnTime;
float m_shipRadius;
float m_defaultEnergy;
int m_nextId=0;
};
};