Add report_player network capabilities
This commit is contained in:
parent
bb3566ac81
commit
c38278fbc1
@ -581,4 +581,9 @@
|
|||||||
max-adjust-time="2.0"
|
max-adjust-time="2.0"
|
||||||
adjust-length-threshold="4.0"/>
|
adjust-length-threshold="4.0"/>
|
||||||
|
|
||||||
|
<!-- List of network capabilities to handle different servers with same version.
|
||||||
|
-->
|
||||||
|
<network-capabilities>
|
||||||
|
<capabilities name="report_player"/>
|
||||||
|
</network-capabilities>
|
||||||
</config>
|
</config>
|
||||||
|
@ -539,6 +539,18 @@ void STKConfig::getAllData(const XMLNode * root)
|
|||||||
ns->get("adjust-length-threshold", &m_snb_adjust_length_threshold);
|
ns->get("adjust-length-threshold", &m_snb_adjust_length_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (const XMLNode* nc = root->getNode("network-capabilities"))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < nc->getNumNodes(); i++)
|
||||||
|
{
|
||||||
|
const XMLNode* name = nc->getNode(i);
|
||||||
|
std::string cap;
|
||||||
|
name->get("name", &cap);
|
||||||
|
if (!cap.empty())
|
||||||
|
m_network_capabilities.insert(cap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the default KartProperties
|
// Get the default KartProperties
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
const XMLNode *node = root -> getNode("general-kart-defaults");
|
const XMLNode *node = root -> getNode("general-kart-defaults");
|
||||||
|
@ -31,9 +31,10 @@
|
|||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
|
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class KartProperties;
|
class KartProperties;
|
||||||
class MusicInformation;
|
class MusicInformation;
|
||||||
@ -229,6 +230,10 @@ public:
|
|||||||
/** If true we allow all the server urls to be redirected by the news.xml. */
|
/** If true we allow all the server urls to be redirected by the news.xml. */
|
||||||
bool m_allow_news_redirects = true;
|
bool m_allow_news_redirects = true;
|
||||||
|
|
||||||
|
/** List of network capabilities to handle different servers with same
|
||||||
|
* version. */
|
||||||
|
std::set<std::string> m_network_capabilities;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** True if stk_config has been loaded. This is necessary if the
|
/** True if stk_config has been loaded. This is necessary if the
|
||||||
* --stk-config command line parameter has been specified to avoid
|
* --stk-config command line parameter has been specified to avoid
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
|
|
||||||
#include "irrString.h"
|
#include "irrString.h"
|
||||||
|
#include <set>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ private:
|
|||||||
|
|
||||||
/** List of server capabilities set when joining it, to determine features
|
/** List of server capabilities set when joining it, to determine features
|
||||||
* available in same version. */
|
* available in same version. */
|
||||||
std::vector<std::string> m_server_capabilities;
|
std::set<std::string> m_server_capabilities;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Singleton get, which creates this object if necessary. */
|
/** Singleton get, which creates this object if necessary. */
|
||||||
@ -236,12 +237,12 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool roundValuesNow() const;
|
bool roundValuesNow() const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setServerCapabilities(std::vector<std::string>& caps)
|
void setServerCapabilities(std::set<std::string>& caps)
|
||||||
{ m_server_capabilities = std::move(caps); }
|
{ m_server_capabilities = std::move(caps); }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void clearServerCapabilities() { m_server_capabilities.clear(); }
|
void clearServerCapabilities() { m_server_capabilities.clear(); }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const std::vector<std::string>& getServerCapabilities() const
|
const std::set<std::string>& getServerCapabilities() const
|
||||||
{ return m_server_capabilities; }
|
{ return m_server_capabilities; }
|
||||||
|
|
||||||
}; // class NetworkConfig
|
}; // class NetworkConfig
|
||||||
|
@ -360,8 +360,9 @@ void ClientLobby::update(int ticks)
|
|||||||
ns->addUInt8(LE_CONNECTION_REQUESTED)
|
ns->addUInt8(LE_CONNECTION_REQUESTED)
|
||||||
.addUInt32(ServerConfig::m_server_version)
|
.addUInt32(ServerConfig::m_server_version)
|
||||||
.encodeString(StringUtils::getUserAgentString())
|
.encodeString(StringUtils::getUserAgentString())
|
||||||
// Reserved for future to supply list of network capabilities
|
.addUInt16((uint16_t)stk_config->m_network_capabilities.size());
|
||||||
.addUInt16(0);
|
for (const std::string& cap : stk_config->m_network_capabilities)
|
||||||
|
ns->encodeString(cap);
|
||||||
|
|
||||||
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();
|
||||||
@ -606,12 +607,12 @@ void ClientLobby::connectionAccepted(Event* event)
|
|||||||
m_state.store(CONNECTED);
|
m_state.store(CONNECTED);
|
||||||
|
|
||||||
unsigned list_caps = data.getUInt16();
|
unsigned list_caps = data.getUInt16();
|
||||||
std::vector<std::string> caps;
|
std::set<std::string> caps;
|
||||||
for (unsigned i = 0; i < list_caps; i++)
|
for (unsigned i = 0; i < list_caps; i++)
|
||||||
{
|
{
|
||||||
std::string cap;
|
std::string cap;
|
||||||
data.decodeString(&cap);
|
data.decodeString(&cap);
|
||||||
caps.push_back(cap);
|
caps.insert(cap);
|
||||||
}
|
}
|
||||||
NetworkConfig::get()->setServerCapabilities(caps);
|
NetworkConfig::get()->setServerCapabilities(caps);
|
||||||
|
|
||||||
|
@ -2590,12 +2590,12 @@ void ServerLobby::connectionRequested(Event* event)
|
|||||||
event->getPeer()->setUserVersion(user_version);
|
event->getPeer()->setUserVersion(user_version);
|
||||||
|
|
||||||
unsigned list_caps = data.getUInt16();
|
unsigned list_caps = data.getUInt16();
|
||||||
std::vector<std::string> caps;
|
std::set<std::string> caps;
|
||||||
for (unsigned i = 0; i < list_caps; i++)
|
for (unsigned i = 0; i < list_caps; i++)
|
||||||
{
|
{
|
||||||
std::string cap;
|
std::string cap;
|
||||||
data.decodeString(&cap);
|
data.decodeString(&cap);
|
||||||
caps.push_back(cap);
|
caps.insert(cap);
|
||||||
}
|
}
|
||||||
event->getPeer()->setClientCapabilities(caps);
|
event->getPeer()->setClientCapabilities(caps);
|
||||||
|
|
||||||
@ -2843,8 +2843,10 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
|||||||
message_ack->addUInt8(LE_CONNECTION_ACCEPTED).addUInt32(peer->getHostId())
|
message_ack->addUInt8(LE_CONNECTION_ACCEPTED).addUInt32(peer->getHostId())
|
||||||
.addUInt32(ServerConfig::m_server_version);
|
.addUInt32(ServerConfig::m_server_version);
|
||||||
|
|
||||||
// Reserved for future to supply list of network capabilities
|
message_ack->addUInt16(
|
||||||
message_ack->addUInt16(0);
|
(uint16_t)stk_config->m_network_capabilities.size());
|
||||||
|
for (const std::string& cap : stk_config->m_network_capabilities)
|
||||||
|
message_ack->encodeString(cap);
|
||||||
|
|
||||||
message_ack->addFloat(auto_start_timer)
|
message_ack->addFloat(auto_start_timer)
|
||||||
.addUInt32(ServerConfig::m_state_frequency)
|
.addUInt32(ServerConfig::m_state_frequency)
|
||||||
|
@ -102,7 +102,7 @@ protected:
|
|||||||
|
|
||||||
/** List of client capabilities set when connecting it, to determine
|
/** List of client capabilities set when connecting it, to determine
|
||||||
* features available in same version. */
|
* features available in same version. */
|
||||||
std::vector<std::string> m_client_capabilities;
|
std::set<std::string> m_client_capabilities;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STKPeer(ENetPeer *enet_peer, STKHost* host, uint32_t host_id);
|
STKPeer(ENetPeer *enet_peer, STKHost* host, uint32_t host_id);
|
||||||
@ -236,10 +236,10 @@ public:
|
|||||||
return (int)(diff / 1000);
|
return (int)(diff / 1000);
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setClientCapabilities(std::vector<std::string>& caps)
|
void setClientCapabilities(std::set<std::string>& caps)
|
||||||
{ m_client_capabilities = std::move(caps); }
|
{ m_client_capabilities = std::move(caps); }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const std::vector<std::string>& getClientCapabilities() const
|
const std::set<std::string>& getClientCapabilities() const
|
||||||
{ return m_client_capabilities; }
|
{ return m_client_capabilities; }
|
||||||
}; // STKPeer
|
}; // STKPeer
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user