Adding backward compatibility for 0.6 clients. They cannot join games with > 7 players.
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
SessionData::SessionData(SOCKET sockfd, SessionId id, boost::shared_ptr<SenderInterface> 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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
#include <list>
|
||||
|
||||
#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
|
||||
|
||||
@@ -71,6 +71,9 @@ public:
|
||||
void MarkActivityNotice();
|
||||
unsigned GetAutoDisconnectTimerElapsedSec() const;
|
||||
|
||||
unsigned GetMaxNumPlayers() const;
|
||||
void SetMaxNumPlayers(unsigned numPlayers);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<boost::asio::ip::tcp::socket> m_socket;
|
||||
const SessionId m_id;
|
||||
@@ -84,6 +87,7 @@ private:
|
||||
boost::timers::portable::microsec_timer m_autoDisconnectTimer;
|
||||
boost::shared_ptr<SenderInterface> m_sender;
|
||||
SessionDataCallback &m_callback;
|
||||
unsigned m_maxNumPlayers;
|
||||
|
||||
mutable boost::mutex m_dataMutex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user