Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
@@ -578,6 +578,7 @@ void cmdLineHelp()
|
||||
" --password=s Automatically log in (set the password).\n"
|
||||
" --port=n Port number to use.\n"
|
||||
" --my-address=1.1.1.1:1 Own IP address (can replace stun protocol)\n"
|
||||
" --disable-lan Disable LAN detection (connect using WAN).\n"
|
||||
" --max-players=n Maximum number of clients (server only).\n"
|
||||
" --no-console Does not write messages in the console but to\n"
|
||||
" stdout.log.\n"
|
||||
@@ -1016,6 +1017,11 @@ int handleCmdLine()
|
||||
if (CommandLine::has("--my-address", &s))
|
||||
GetPublicAddress::setMyIPAddress(s);
|
||||
|
||||
/** Disable detection of LAN connection when connecting via WAN. This is
|
||||
* mostly a debugging feature to force using WAN connection. */
|
||||
if (CommandLine::has("--disable-lan"))
|
||||
NetworkConfig::m_disable_lan = true;
|
||||
|
||||
// Race parameters
|
||||
if(CommandLine::has("--kartsize-debug"))
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "network/network_config.hpp"
|
||||
|
||||
NetworkConfig *NetworkConfig::m_network_config = NULL;
|
||||
bool NetworkConfig::m_disable_lan = false;
|
||||
|
||||
/** \class NetworkConfig
|
||||
* This class is the interface between STK and the online code, particularly
|
||||
|
||||
@@ -72,6 +72,10 @@ private:
|
||||
NetworkConfig();
|
||||
|
||||
public:
|
||||
/** Stores the command line flag to disable lan detection (i.e. force
|
||||
* WAN code to be used when connection client and server). */
|
||||
static bool m_disable_lan;
|
||||
|
||||
/** Singleton get, which creates this object if necessary. */
|
||||
static NetworkConfig *get()
|
||||
{
|
||||
|
||||
@@ -125,9 +125,10 @@ void ConnectToPeer::asynchronousUpdate()
|
||||
// the Ping protocol to keep the port available. We can't rely on
|
||||
// STKHost::isLAN(), since we might get a LAN connection even if
|
||||
// the server itself accepts connections from anywhere.
|
||||
if (!m_is_lan &&
|
||||
m_peer_address.getIP() != NetworkConfig::get()
|
||||
->getMyAddress().getIP())
|
||||
if ( (!m_is_lan &&
|
||||
m_peer_address.getIP() !=
|
||||
NetworkConfig::get()->getMyAddress().getIP() ) ||
|
||||
NetworkConfig::m_disable_lan )
|
||||
{
|
||||
m_current_protocol = new PingProtocol(m_peer_address,
|
||||
/*time-between-ping*/2.0);
|
||||
|
||||
@@ -175,9 +175,10 @@ void ConnectToServer::asynchronousUpdate()
|
||||
m_current_protocol->requestStart();
|
||||
return;
|
||||
}
|
||||
if (m_server_address.getIP()
|
||||
== NetworkConfig::get()->getMyAddress().getIP() ||
|
||||
NetworkConfig::get()->isLAN())
|
||||
if( ( !NetworkConfig::m_disable_lan &&
|
||||
m_server_address.getIP()
|
||||
== NetworkConfig::get()->getMyAddress().getIP() ) ||
|
||||
NetworkConfig::get()->isLAN() )
|
||||
{
|
||||
// We're in the same lan (same public ip address).
|
||||
// The state will change to CONNECTING
|
||||
|
||||
@@ -66,7 +66,7 @@ void GetPeerAddress::asynchronousUpdate()
|
||||
|
||||
uint16_t port;
|
||||
uint32_t my_ip = NetworkConfig::get()->getMyAddress().getIP();
|
||||
if (m_address.getIP() == my_ip)
|
||||
if (m_address.getIP() == my_ip && !NetworkConfig::m_disable_lan)
|
||||
result->get("private_port", &port);
|
||||
else
|
||||
result->get("port", &port);
|
||||
|
||||
@@ -136,6 +136,12 @@ bool StartGameProtocol::notifyEventAsynchronous(Event* event)
|
||||
if (NetworkConfig::get()->isServer() && ready) // on server, player is ready
|
||||
{
|
||||
Log::info("StartGameProtocol", "One of the players is ready.");
|
||||
if (m_player_states[player_id] != LOADING)
|
||||
{
|
||||
Log::error("StartGameProtocol",
|
||||
"Player %d send more than one ready message.",
|
||||
player_id);
|
||||
}
|
||||
m_player_states[player_id] = READY;
|
||||
m_ready_count++;
|
||||
if (m_ready_count == m_game_setup->getPlayerCount())
|
||||
@@ -159,7 +165,7 @@ void StartGameProtocol::startRace()
|
||||
Protocol *p = ProtocolManager::getInstance()
|
||||
->getProtocol(PROTOCOL_SYNCHRONIZATION);
|
||||
SynchronizationProtocol* protocol =
|
||||
static_cast<SynchronizationProtocol*>(p);
|
||||
dynamic_cast<SynchronizationProtocol*>(p);
|
||||
if (protocol)
|
||||
{
|
||||
protocol->startCountdown(5.0f); // 5 seconds countdown
|
||||
@@ -185,7 +191,7 @@ void StartGameProtocol::update(float dt)
|
||||
Protocol *p = ProtocolManager::getInstance()
|
||||
->getProtocol(PROTOCOL_SYNCHRONIZATION);
|
||||
SynchronizationProtocol* protocol =
|
||||
static_cast<SynchronizationProtocol*>(p);
|
||||
dynamic_cast<SynchronizationProtocol*>(p);
|
||||
if (protocol)
|
||||
{
|
||||
// Now the synchronization protocol exists.
|
||||
|
||||
@@ -184,7 +184,7 @@ void STKHost::create()
|
||||
* This triggers the creation of the kart selection screen in
|
||||
* CLR::startSelection / CLR::update for all clients. The clients create
|
||||
* the ActivePlayer object (which stores which device is used by which
|
||||
* plauyer). The kart selection in a client calls
|
||||
* player). The kart selection in a client calls
|
||||
* (NetworkKartSelection::playerConfirm) which calls CLR::requestKartSelection.
|
||||
* This sends a message to SLR::kartSelectionRequested, which verifies the
|
||||
* selected kart and sends this information to all clients (including the
|
||||
@@ -219,7 +219,7 @@ void STKHost::create()
|
||||
* NULL ActivePlayer (the ActivePlayer is only used for assigning the input
|
||||
* device to each kart, achievements and highscores, so it's not needed for
|
||||
* remote players). It will also start the SynchronizationProtocol.
|
||||
* The StartGameProtocol has a callback ready which is called from world
|
||||
* The StartGameProtocol has a callback ready() which is called from world
|
||||
* when the world is loaded (i.e. track and all karts are ready). When
|
||||
* this callback is invoked, each client will send a 'ready' message to
|
||||
* the server's StartGameProtocol. Once the server has received all
|
||||
@@ -228,7 +228,7 @@ void STKHost::create()
|
||||
* sending regular (once per second) pings to the clients and measure
|
||||
* the averate latency. Upon starting the countdown this information
|
||||
* is included in the ping request, so the clients can start the countdown
|
||||
* at that stage as wellk.
|
||||
* at that stage as well.
|
||||
*
|
||||
* Once the countdown is 0 (or below), the Synchronization Protocol will
|
||||
* start the protocols: KartUpdateProtocol, ControllerEventsProtocol,
|
||||
|
||||
@@ -199,10 +199,11 @@ void NetworkingLobby::tearDown()
|
||||
bool NetworkingLobby::onEscapePressed()
|
||||
{
|
||||
// notify the server that we left
|
||||
ClientLobbyRoomProtocol* protocol = static_cast<ClientLobbyRoomProtocol*>(
|
||||
ClientLobbyRoomProtocol* protocol = dynamic_cast<ClientLobbyRoomProtocol*>(
|
||||
ProtocolManager::getInstance()->getProtocol(PROTOCOL_LOBBY_ROOM));
|
||||
if (protocol)
|
||||
protocol->leave();
|
||||
STKHost::get()->shutdown();
|
||||
return true; // close the screen
|
||||
} // onEscapePressed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user