diff --git a/pokerth.proto b/pokerth.proto index 9724b6d0..169ca5da 100644 --- a/pokerth.proto +++ b/pokerth.proto @@ -371,6 +371,7 @@ message RemovedFromGameMessage { gameIsRunning = 3; gameTimeout = 4; removedStartFailed = 5; + gameClosed = 6; } required RemovedFromGameReason removedFromGameReason = 2; } diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index a22620ce..f1bf33a0 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -589,6 +589,9 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien case RemovedFromGameMessage::removedStartFailed : removeReason = NTF_NET_REMOVED_START_FAILED; break; + case RemovedFromGameMessage::gameClosed : + removeReason = NTF_NET_REMOVED_GAME_CLOSED; + break; default : removeReason = NTF_NET_REMOVED_ON_REQUEST; break; diff --git a/src/net/common/servergame.cpp b/src/net/common/servergame.cpp index 91d25ed0..592b5c35 100644 --- a/src/net/common/servergame.cpp +++ b/src/net/common/servergame.cpp @@ -198,6 +198,21 @@ ServerGame::RemoveAllSessions() SetState(ServerGameStateFinal::Instance()); } +void +ServerGame::MoveSpectatorsToLobby() +{ + PlayerIdList spectatorList = GetSpectatorIdList(); + PlayerIdList::const_iterator i = spectatorList.begin(); + PlayerIdList::const_iterator end = spectatorList.end(); + while (i != end) { + boost::shared_ptr tmpSession = GetSessionManager().GetSessionByUniquePlayerId(*i); + // Only remove if the spectator was found. + if (tmpSession) + MoveSessionToLobby(tmpSession, NTF_NET_REMOVED_GAME_CLOSED); + ++i; + } +} + void ServerGame::TimerVoteKick(const boost::system::error_code &ec) { diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 9a2a8861..aa7dc50a 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1835,6 +1835,7 @@ ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec) ++next; boost::shared_ptr tmpGame = i->second; if (!tmpGame->GetSessionManager().HasSessionWithState(SessionData::Game)) + tmpGame->MoveSpectatorsToLobby(); InternalRemoveGame(tmpGame); // This will delete the game. i = next; } diff --git a/src/net/servergame.h b/src/net/servergame.h index 43dfab0b..560c54aa 100644 --- a/src/net/servergame.h +++ b/src/net/servergame.h @@ -80,6 +80,7 @@ public: void SendToAllPlayers(boost::shared_ptr packet, int state); void SendToAllButOnePlayers(boost::shared_ptr packet, SessionId except, int state); void RemoveAllSessions(); + void MoveSpectatorsToLobby(); bool IsPasswordProtected() const; bool CheckPassword(const std::string &password) const; diff --git a/src/net/socket_msg.h b/src/net/socket_msg.h index 7242a992..416f731d 100644 --- a/src/net/socket_msg.h +++ b/src/net/socket_msg.h @@ -116,6 +116,7 @@ #define NTF_NET_REMOVED_KICKED 205 #define NTF_NET_REMOVED_TIMEOUT 206 #define NTF_NET_REMOVED_START_FAILED 207 +#define NTF_NET_REMOVED_GAME_CLOSED 208 // Notifications - join failed #define NTF_NET_JOIN_GAME_INVALID 210 diff --git a/src/third_party/protobuf/pokerth.pb.cc b/src/third_party/protobuf/pokerth.pb.cc index 83b7ccc3..02fd38af 100644 --- a/src/third_party/protobuf/pokerth.pb.cc +++ b/src/third_party/protobuf/pokerth.pb.cc @@ -9732,6 +9732,7 @@ bool RemovedFromGameMessage_RemovedFromGameReason_IsValid(int value) { case 3: case 4: case 5: + case 6: return true; default: return false; @@ -9745,6 +9746,7 @@ const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::gameI const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::gameIsRunning; const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::gameTimeout; const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::removedStartFailed; +const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::gameClosed; const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::RemovedFromGameReason_MIN; const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage::RemovedFromGameReason_MAX; const int RemovedFromGameMessage::RemovedFromGameReason_ARRAYSIZE; diff --git a/src/third_party/protobuf/pokerth.pb.h b/src/third_party/protobuf/pokerth.pb.h index 53ca9f8e..7c8f0293 100644 --- a/src/third_party/protobuf/pokerth.pb.h +++ b/src/third_party/protobuf/pokerth.pb.h @@ -224,11 +224,12 @@ enum RemovedFromGameMessage_RemovedFromGameReason { RemovedFromGameMessage_RemovedFromGameReason_gameIsFull = 2, RemovedFromGameMessage_RemovedFromGameReason_gameIsRunning = 3, RemovedFromGameMessage_RemovedFromGameReason_gameTimeout = 4, - RemovedFromGameMessage_RemovedFromGameReason_removedStartFailed = 5 + RemovedFromGameMessage_RemovedFromGameReason_removedStartFailed = 5, + RemovedFromGameMessage_RemovedFromGameReason_gameClosed = 6 }; bool RemovedFromGameMessage_RemovedFromGameReason_IsValid(int value); const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage_RemovedFromGameReason_RemovedFromGameReason_MIN = RemovedFromGameMessage_RemovedFromGameReason_removedOnRequest; -const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage_RemovedFromGameReason_RemovedFromGameReason_MAX = RemovedFromGameMessage_RemovedFromGameReason_removedStartFailed; +const RemovedFromGameMessage_RemovedFromGameReason RemovedFromGameMessage_RemovedFromGameReason_RemovedFromGameReason_MAX = RemovedFromGameMessage_RemovedFromGameReason_gameClosed; const int RemovedFromGameMessage_RemovedFromGameReason_RemovedFromGameReason_ARRAYSIZE = RemovedFromGameMessage_RemovedFromGameReason_RemovedFromGameReason_MAX + 1; enum RejectGameInvitationMessage_RejectGameInvReason { @@ -4685,6 +4686,7 @@ class RemovedFromGameMessage : public ::google::protobuf::MessageLite { static const RemovedFromGameReason gameIsRunning = RemovedFromGameMessage_RemovedFromGameReason_gameIsRunning; static const RemovedFromGameReason gameTimeout = RemovedFromGameMessage_RemovedFromGameReason_gameTimeout; static const RemovedFromGameReason removedStartFailed = RemovedFromGameMessage_RemovedFromGameReason_removedStartFailed; + static const RemovedFromGameReason gameClosed = RemovedFromGameMessage_RemovedFromGameReason_gameClosed; static inline bool RemovedFromGameReason_IsValid(int value) { return RemovedFromGameMessage_RemovedFromGameReason_IsValid(value); } diff --git a/tests/src/de/pokerth/protocol/ProtoBuf.java b/tests/src/de/pokerth/protocol/ProtoBuf.java index f741871a..57e1a4ae 100644 --- a/tests/src/de/pokerth/protocol/ProtoBuf.java +++ b/tests/src/de/pokerth/protocol/ProtoBuf.java @@ -21967,6 +21967,10 @@ public final class ProtoBuf { * removedStartFailed = 5; */ removedStartFailed(5, 5), + /** + * gameClosed = 6; + */ + gameClosed(6, 6), ; /** @@ -21997,6 +22001,10 @@ public final class ProtoBuf { * removedStartFailed = 5; */ public static final int removedStartFailed_VALUE = 5; + /** + * gameClosed = 6; + */ + public static final int gameClosed_VALUE = 6; public final int getNumber() { return value; } @@ -22009,6 +22017,7 @@ public final class ProtoBuf { case 3: return gameIsRunning; case 4: return gameTimeout; case 5: return removedStartFailed; + case 6: return gameClosed; default: return null; } }