diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index eec896a7..fdfd2454 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -308,6 +308,11 @@ ServerGameStateInit::HandleNewSession(ServerGameThread &server, SessionWrapper s { server.MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL); } + // Check whether the client supports the current game. + else if (curNumPlayers >= session.sessionData->GetMaxNumPlayers()) + { + server.MoveSessionToLobby(session, NTF_NET_NEW_RELEASE_AVAILABLE); + } else { if (session.playerData->GetUniqueId() == server.GetAdminPlayerId()) diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index abae58c9..a185da1b 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -568,6 +568,10 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const NetPacketIn SessionError(session, ERR_NET_VERSION_NOT_SUPPORTED); return; } + if (initData.versionMajor == 5 && (initData.versionMinor == 0 || initData.versionMinor == 1)) + session.sessionData->SetMaxNumPlayers(7); + else + session.sessionData->SetMaxNumPlayers(MAX_NUMBER_OF_PLAYERS); // Check the server password. if (!CheckPassword(initData.password)) diff --git a/src/net/common/sessiondata.cpp b/src/net/common/sessiondata.cpp index 32de4cdf..934d4f02 100644 --- a/src/net/common/sessiondata.cpp +++ b/src/net/common/sessiondata.cpp @@ -22,7 +22,8 @@ SessionData::SessionData(SOCKET sockfd, SessionId id, boost::shared_ptr sender, SessionDataCallback &cb, boost::asio::io_service &ioService) : m_id(id), m_state(SessionData::Init), m_readyFlag(false), - m_wantsLobbyMsg(true), m_activityTimeoutNoticeSent(false), m_callback(cb) + m_wantsLobbyMsg(true), m_activityTimeoutNoticeSent(false), m_callback(cb), + m_maxNumPlayers(0) { m_socket.reset(new boost::asio::ip::tcp::socket( ioService, boost::asio::ip::tcp::v6(), sockfd)); @@ -173,3 +174,16 @@ SessionData::GetAutoDisconnectTimerElapsedSec() const return m_autoDisconnectTimer.elapsed().total_seconds(); } +unsigned +SessionData::GetMaxNumPlayers() const +{ + boost::mutex::scoped_lock lock(m_dataMutex); + return m_maxNumPlayers; +} + +void +SessionData::SetMaxNumPlayers(unsigned numPlayers) +{ + boost::mutex::scoped_lock lock(m_dataMutex); + m_maxNumPlayers = numPlayers; +} diff --git a/src/net/netpacket.h b/src/net/netpacket.h index 3c4e25c0..d8f4d9f8 100644 --- a/src/net/netpacket.h +++ b/src/net/netpacket.h @@ -31,7 +31,7 @@ #include #define NET_VERSION_MAJOR 5 -#define NET_VERSION_MINOR 1 +#define NET_VERSION_MINOR 2 #define MIN_PACKET_SIZE 4 #define MAX_PACKET_SIZE 268 diff --git a/src/net/sessiondata.h b/src/net/sessiondata.h index c4dba413..ee792ea8 100644 --- a/src/net/sessiondata.h +++ b/src/net/sessiondata.h @@ -71,6 +71,9 @@ public: void MarkActivityNotice(); unsigned GetAutoDisconnectTimerElapsedSec() const; + unsigned GetMaxNumPlayers() const; + void SetMaxNumPlayers(unsigned numPlayers); + private: boost::shared_ptr m_socket; const SessionId m_id; @@ -84,6 +87,7 @@ private: boost::timers::portable::microsec_timer m_autoDisconnectTimer; boost::shared_ptr m_sender; SessionDataCallback &m_callback; + unsigned m_maxNumPlayers; mutable boost::mutex m_dataMutex; };