Use 32bit for server version
This commit is contained in:
parent
90073bc954
commit
9d78173ec6
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
NetworkConfig *NetworkConfig::m_network_config = NULL;
|
NetworkConfig *NetworkConfig::m_network_config = NULL;
|
||||||
bool NetworkConfig::m_disable_lan = false;
|
bool NetworkConfig::m_disable_lan = false;
|
||||||
const uint8_t NetworkConfig::m_server_version = 1;
|
const uint32_t NetworkConfig::m_server_version = 1;
|
||||||
|
|
||||||
/** \class NetworkConfig
|
/** \class NetworkConfig
|
||||||
* This class is the interface between STK and the online code, particularly
|
* This class is the interface between STK and the online code, particularly
|
||||||
@ -65,6 +65,7 @@ NetworkConfig::NetworkConfig()
|
|||||||
m_server_port = UserConfigParams::m_random_server_port ?
|
m_server_port = UserConfigParams::m_random_server_port ?
|
||||||
0 : stk_config->m_server_port;
|
0 : stk_config->m_server_port;
|
||||||
m_team_choosing = false;
|
m_team_choosing = false;
|
||||||
|
m_joined_server_version = 0;
|
||||||
} // NetworkConfig
|
} // NetworkConfig
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -121,13 +121,15 @@ private:
|
|||||||
|
|
||||||
NetworkConfig();
|
NetworkConfig();
|
||||||
|
|
||||||
|
uint32_t m_joined_server_version;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Stores the command line flag to disable lan detection (i.e. force
|
/** Stores the command line flag to disable lan detection (i.e. force
|
||||||
* WAN code to be used when connection client and server). */
|
* WAN code to be used when connection client and server). */
|
||||||
static bool m_disable_lan;
|
static bool m_disable_lan;
|
||||||
|
|
||||||
/** Server version, will be advanced if there are protocol changes. */
|
/** Server version, will be advanced if there are protocol changes. */
|
||||||
static const uint8_t m_server_version;
|
static const uint32_t m_server_version;
|
||||||
|
|
||||||
/** Singleton get, which creates this object if necessary. */
|
/** Singleton get, which creates this object if necessary. */
|
||||||
static NetworkConfig *get()
|
static NetworkConfig *get()
|
||||||
@ -330,7 +332,10 @@ public:
|
|||||||
void setTeamChoosing(bool val) { m_team_choosing = val; }
|
void setTeamChoosing(bool val) { m_team_choosing = val; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool hasTeamChoosing() const { return m_team_choosing; }
|
bool hasTeamChoosing() const { return m_team_choosing; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void setJoinedServerVersion(uint32_t v) { m_joined_server_version = v; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
uint32_t getJoinedServerVersion() const { return m_joined_server_version; }
|
||||||
}; // class NetworkConfig
|
}; // class NetworkConfig
|
||||||
|
|
||||||
#endif // HEADER_NETWORK_CONFIG
|
#endif // HEADER_NETWORK_CONFIG
|
||||||
|
@ -267,7 +267,7 @@ void ClientLobby::update(int ticks)
|
|||||||
{
|
{
|
||||||
NetworkString* ns = getNetworkString();
|
NetworkString* ns = getNetworkString();
|
||||||
ns->addUInt8(LE_CONNECTION_REQUESTED)
|
ns->addUInt8(LE_CONNECTION_REQUESTED)
|
||||||
.addUInt8(NetworkConfig::m_server_version);
|
.addUInt32(NetworkConfig::m_server_version);
|
||||||
|
|
||||||
auto all_k = kart_properties_manager->getAllAvailableKarts();
|
auto all_k = kart_properties_manager->getAllAvailableKarts();
|
||||||
auto all_t = track_manager->getAllTrackIdentifiers();
|
auto all_t = track_manager->getAllTrackIdentifiers();
|
||||||
@ -491,6 +491,9 @@ void ClientLobby::connectionAccepted(Event* event)
|
|||||||
Log::info("ClientLobby", "The server accepted the connection.");
|
Log::info("ClientLobby", "The server accepted the connection.");
|
||||||
STKHost::get()->setMyHostId(data.getUInt32());
|
STKHost::get()->setMyHostId(data.getUInt32());
|
||||||
assert(!NetworkConfig::get()->isAddingNetworkPlayers());
|
assert(!NetworkConfig::get()->isAddingNetworkPlayers());
|
||||||
|
uint32_t server_version = data.getUInt32();
|
||||||
|
NetworkConfig::get()->setJoinedServerVersion(server_version);
|
||||||
|
assert(server_version != 0);
|
||||||
m_state.store(CONNECTED);
|
m_state.store(CONNECTED);
|
||||||
float auto_start_timer = data.getFloat();
|
float auto_start_timer = data.getFloat();
|
||||||
if (auto_start_timer != std::numeric_limits<float>::max())
|
if (auto_start_timer != std::numeric_limits<float>::max())
|
||||||
|
@ -1273,7 +1273,7 @@ void ServerLobby::connectionRequested(Event* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check server version
|
// Check server version
|
||||||
int version = data.getUInt8();
|
int version = data.getUInt32();
|
||||||
if (version < stk_config->m_min_server_version ||
|
if (version < stk_config->m_min_server_version ||
|
||||||
version > stk_config->m_max_server_version)
|
version > stk_config->m_max_server_version)
|
||||||
{
|
{
|
||||||
@ -1481,6 +1481,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
|||||||
// connection success -- return the host id of peer
|
// connection success -- return the host id of peer
|
||||||
float auto_start_timer = m_timeout.load();
|
float auto_start_timer = m_timeout.load();
|
||||||
message_ack->addUInt8(LE_CONNECTION_ACCEPTED).addUInt32(peer->getHostId())
|
message_ack->addUInt8(LE_CONNECTION_ACCEPTED).addUInt32(peer->getHostId())
|
||||||
|
.addUInt32(NetworkConfig::m_server_version)
|
||||||
.addFloat(auto_start_timer == std::numeric_limits<float>::max() ?
|
.addFloat(auto_start_timer == std::numeric_limits<float>::max() ?
|
||||||
auto_start_timer : auto_start_timer - (float)StkTime::getRealTime());
|
auto_start_timer : auto_start_timer - (float)StkTime::getRealTime());
|
||||||
peer->sendPacket(message_ack);
|
peer->sendPacket(message_ack);
|
||||||
|
@ -176,7 +176,7 @@ Online::XMLRequest* ServersManager::getLANRefreshRequest() const
|
|||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
BareNetworkString s(buffer, len);
|
BareNetworkString s(buffer, len);
|
||||||
int version = s.getUInt8();
|
int version = s.getUInt32();
|
||||||
if (version < stk_config->m_max_server_version ||
|
if (version < stk_config->m_max_server_version ||
|
||||||
version > stk_config->m_max_server_version)
|
version > stk_config->m_max_server_version)
|
||||||
{
|
{
|
||||||
|
@ -993,7 +993,7 @@ void STKHost::handleDirectSocketRequest(Network* direct_socket,
|
|||||||
// Send the answer, consisting of server name, max players,
|
// Send the answer, consisting of server name, max players,
|
||||||
// current players
|
// current players
|
||||||
BareNetworkString s((int)name.size()+1+11);
|
BareNetworkString s((int)name.size()+1+11);
|
||||||
s.addUInt8(NetworkConfig::m_server_version);
|
s.addUInt32(NetworkConfig::m_server_version);
|
||||||
s.encodeString(name);
|
s.encodeString(name);
|
||||||
s.addUInt8(NetworkConfig::get()->getMaxPlayers());
|
s.addUInt8(NetworkConfig::get()->getMaxPlayers());
|
||||||
s.addUInt8((uint8_t)sl->getGameSetup()->getPlayerCount());
|
s.addUInt8((uint8_t)sl->getGameSetup()->getPlayerCount());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user