Commit 4b84168b authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

client/server version bump; eventConnectionStateChanged

parent d892d320
......@@ -341,6 +341,13 @@ void Server_Game::nextTurn()
setActivePlayer(keys[listPos]);
}
void Server_Game::postConnectionStatusUpdate(Server_Player *player, bool connectionStatus)
{
QMutexLocker locker(&gameMutex);
sendGameEvent(new Event_ConnectionStateChanged(player->getPlayerId(), connectionStatus));
}
QList<ServerInfo_Player *> Server_Game::getGameState(Server_Player *playerWhosAsking) const
{
QMutexLocker locker(&gameMutex);
......
......@@ -88,6 +88,7 @@ public:
void setActivePlayer(int _activePlayer);
void setActivePhase(int _activePhase);
void nextTurn();
void postConnectionStatusUpdate(Server_Player *player, bool connectionStatus);
QList<ServerInfo_Player *> getGameState(Server_Player *playerWhosAsking) const;
void sendGameEvent(GameEvent *event, GameEventContext *context = 0, Server_Player *exclude = 0);
......
......@@ -46,8 +46,10 @@ void Server_ProtocolHandler::prepareDestroy()
if ((authState == UnknownUser) || p->getSpectator())
g->removePlayer(p);
else
else {
p->setProtocolHandler(0);
g->postConnectionStatusUpdate(p, false);
}
}
gameListMutex.unlock();
......@@ -392,6 +394,7 @@ ResponseCode Server_ProtocolHandler::cmdJoinRoom(Command_JoinRoom *cmd, CommandC
for (int j = 0; j < gamePlayers.size(); ++j)
if (gamePlayers[j]->getUserInfo()->getName() == userInfo->getName()) {
gamePlayers[j]->setProtocolHandler(this);
game->postConnectionStatusUpdate(gamePlayers[j], true);
games.insert(game->getGameId(), QPair<Server_Game *, Server_Player *>(game, gamePlayers[j]));
enqueueProtocolItem(new Event_GameJoined(game->getGameId(), game->getDescription(), gamePlayers[j]->getPlayerId(), gamePlayers[j]->getSpectator(), game->getSpectatorsCanTalk(), game->getSpectatorsSeeEverything(), true));
......
......@@ -423,4 +423,4 @@ void Servatrice::shutdownTimeout()
deleteLater();
}
const QString Servatrice::versionString = "Servatrice 0.20110527";
const QString Servatrice::versionString = "Servatrice 0.20110625";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment