The console server can now be fully used for a single game. The first player to join the game is admin, he can start the game and kick players.

However, if the admin player leaves, a new game can only be started if all players have left before (this is a bug, admin status should be passed to another player).
This commit is contained in:
lotodore
2007-08-02 20:52:13 +00:00
parent f11998c28c
commit 0da29b3874
25 changed files with 481 additions and 262 deletions
+12 -21
View File
@@ -140,15 +140,10 @@ ServerRecvThread::NotificationLoop()
Notification notification = m_notificationQueue.front();
m_notificationQueue.pop_front();
switch(notification.message)
{
case NOTIFY_GAME_START:
InternalStartGame();
break;
case NOTIFY_KICK_PLAYER:
InternalKickPlayer(notification.param);
break;
}
// switch(notification.message)
// {
// break;
// }
}
}
@@ -249,8 +244,6 @@ ServerRecvThread::CleanupSessionMap()
void
ServerRecvThread::InternalStartGame()
{
SetState(SERVER_START_GAME_STATE::Instance());
// Kick all players which are not fully connected.
RemoveNotEstablishedSessions();
// Set order of players.
@@ -295,14 +288,10 @@ ServerRecvThread::InternalStartGame()
}
void
ServerRecvThread::InternalKickPlayer(const string playerName)
ServerRecvThread::InternalKickPlayer(unsigned uniqueId)
{
if (!playerName.empty())
{
SessionWrapper tmpSession = GetSessionByPlayerName(playerName);
SessionError(tmpSession, ERR_NET_PLAYER_KICKED);
}
SessionWrapper tmpSession = GetSessionByUniquePlayerId(uniqueId);
SessionError(tmpSession, ERR_NET_PLAYER_KICKED);
}
SessionWrapper
@@ -394,9 +383,11 @@ ServerRecvThread::AddSession(boost::shared_ptr<SessionData> sessionData)
void
ServerRecvThread::SessionError(SessionWrapper session, int errorCode)
{
assert(session.sessionData.get());
SendError(session.sessionData->GetSocket(), errorCode);
CloseSessionDelayed(session);
if (session.sessionData.get())
{
SendError(session.sessionData->GetSocket(), errorCode);
CloseSessionDelayed(session);
}
}
void