Allow using --connect-now with wan server with server-id
This commit is contained in:
parent
07e681e927
commit
2c35b0f03c
@ -22,6 +22,7 @@
|
|||||||
#include "guiengine/widgets/model_view_widget.hpp"
|
#include "guiengine/widgets/model_view_widget.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/render_target.hpp"
|
#include "graphics/render_target.hpp"
|
||||||
|
#include "modes/profile_world.hpp"
|
||||||
|
|
||||||
#include <IAnimatedMesh.h>
|
#include <IAnimatedMesh.h>
|
||||||
#include <IAnimatedMeshSceneNode.h>
|
#include <IAnimatedMeshSceneNode.h>
|
||||||
@ -55,7 +56,7 @@ m_rtt_size(rtt_size)
|
|||||||
// so that the base class doesn't complain there is no icon defined
|
// so that the base class doesn't complain there is no icon defined
|
||||||
m_properties[PROP_ICON]="gui/main_help.png";
|
m_properties[PROP_ICON]="gui/main_help.png";
|
||||||
|
|
||||||
m_rtt_unsupported = false;
|
m_rtt_unsupported = ProfileWorld::isNoGraphics();
|
||||||
} // ModelViewWidget
|
} // ModelViewWidget
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
53
src/main.cpp
53
src/main.cpp
@ -224,6 +224,7 @@
|
|||||||
#include "network/server_config.hpp"
|
#include "network/server_config.hpp"
|
||||||
#include "network/servers_manager.hpp"
|
#include "network/servers_manager.hpp"
|
||||||
#include "network/stk_host.hpp"
|
#include "network/stk_host.hpp"
|
||||||
|
#include "network/stk_peer.hpp"
|
||||||
#include "online/profile_manager.hpp"
|
#include "online/profile_manager.hpp"
|
||||||
#include "online/request_manager.hpp"
|
#include "online/request_manager.hpp"
|
||||||
#include "race/grand_prix_manager.hpp"
|
#include "race/grand_prix_manager.hpp"
|
||||||
@ -608,6 +609,7 @@ void cmdLineHelp()
|
|||||||
" --connect-now=ip Connect to a server with IP known now\n"
|
" --connect-now=ip Connect to a server with IP known now\n"
|
||||||
" (in format x.x.x.x:xxx(port)), the port should be its\n"
|
" (in format x.x.x.x:xxx(port)), the port should be its\n"
|
||||||
" public port.\n"
|
" public port.\n"
|
||||||
|
" --server-id=n Server id in stk addons for --connect-now.\n"
|
||||||
" --login=s Automatically log in (set the login).\n"
|
" --login=s Automatically log in (set the login).\n"
|
||||||
" --password=s Automatically log in (set the password).\n"
|
" --password=s Automatically log in (set the password).\n"
|
||||||
" --init-user Save the above login and password (if set) in config.\n"
|
" --init-user Save the above login and password (if set) in config.\n"
|
||||||
@ -1243,6 +1245,31 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
|
|||||||
{
|
{
|
||||||
NetworkConfig::get()->setIsPublicServer();
|
NetworkConfig::get()->setIsPublicServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned server_id = 0;
|
||||||
|
if ((NetworkConfig::get()->isServer() && ServerConfig::m_wan_server) ||
|
||||||
|
CommandLine::has("--server-id", &server_id))
|
||||||
|
{
|
||||||
|
PlayerProfile* player = PlayerManager::getCurrentPlayer();
|
||||||
|
// Try to use saved user token if exists
|
||||||
|
if (!can_wan && player && player->wasOnlineLastTime() &&
|
||||||
|
player->wasOnlineLastTime() && player->hasSavedSession())
|
||||||
|
{
|
||||||
|
while (PlayerManager::getCurrentOnlineState() !=
|
||||||
|
PlayerProfile::OS_SIGNED_IN)
|
||||||
|
{
|
||||||
|
Online::RequestManager::get()->update(0.0f);
|
||||||
|
StkTime::sleep(1);
|
||||||
|
}
|
||||||
|
can_wan = true;
|
||||||
|
}
|
||||||
|
else if (!can_wan)
|
||||||
|
{
|
||||||
|
Log::warn("main","No saved online player session to create "
|
||||||
|
"or connect to a wan server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (CommandLine::has("--connect-now", &s))
|
if (CommandLine::has("--connect-now", &s))
|
||||||
{
|
{
|
||||||
TransportAddress server_addr(s);
|
TransportAddress server_addr(s);
|
||||||
@ -1257,6 +1284,12 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
|
|||||||
STKHost::create();
|
STKHost::create();
|
||||||
auto cts = std::make_shared<ConnectToServer>(server);
|
auto cts = std::make_shared<ConnectToServer>(server);
|
||||||
cts->setup();
|
cts->setup();
|
||||||
|
if (server_id != 0)
|
||||||
|
{
|
||||||
|
server->setServerId(server_id);
|
||||||
|
server->setSupportsEncryption(true);
|
||||||
|
cts->registerWithSTKServer();
|
||||||
|
}
|
||||||
Log::info("main", "Trying to connect to server '%s'.",
|
Log::info("main", "Trying to connect to server '%s'.",
|
||||||
server_addr.toString().c_str());
|
server_addr.toString().c_str());
|
||||||
if (!cts->tryConnect(2000, 15))
|
if (!cts->tryConnect(2000, 15))
|
||||||
@ -1268,6 +1301,8 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
server_addr =
|
||||||
|
STKHost::get()->getServerPeerForClient()->getAddress();
|
||||||
auto cl = LobbyProtocol::create<ClientLobby>(server_addr, server);
|
auto cl = LobbyProtocol::create<ClientLobby>(server_addr, server);
|
||||||
cl->requestStart();
|
cl->requestStart();
|
||||||
}
|
}
|
||||||
@ -1278,24 +1313,6 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
|
|||||||
const std::string& server_name = ServerConfig::m_server_name;
|
const std::string& server_name = ServerConfig::m_server_name;
|
||||||
if (ServerConfig::m_wan_server)
|
if (ServerConfig::m_wan_server)
|
||||||
{
|
{
|
||||||
PlayerProfile* player = PlayerManager::getCurrentPlayer();
|
|
||||||
// Try to use saved user token if exists
|
|
||||||
if (!can_wan && player && player->wasOnlineLastTime() &&
|
|
||||||
player->wasOnlineLastTime() && player->hasSavedSession())
|
|
||||||
{
|
|
||||||
while (PlayerManager::getCurrentOnlineState() !=
|
|
||||||
PlayerProfile::OS_SIGNED_IN)
|
|
||||||
{
|
|
||||||
Online::RequestManager::get()->update(0.0f);
|
|
||||||
StkTime::sleep(1);
|
|
||||||
}
|
|
||||||
can_wan = true;
|
|
||||||
}
|
|
||||||
else if (!can_wan)
|
|
||||||
{
|
|
||||||
Log::warn("main",
|
|
||||||
"No saved online player session to create a wan server");
|
|
||||||
}
|
|
||||||
if (can_wan)
|
if (can_wan)
|
||||||
{
|
{
|
||||||
// Server owner online account will keep online as long as
|
// Server owner online account will keep online as long as
|
||||||
|
@ -44,7 +44,6 @@ private:
|
|||||||
std::atomic<ConnectState> m_state;
|
std::atomic<ConnectState> m_state;
|
||||||
|
|
||||||
void getClientServerInfo();
|
void getClientServerInfo();
|
||||||
void registerWithSTKServer();
|
|
||||||
static TransportAddress m_server_address;
|
static TransportAddress m_server_address;
|
||||||
static int interceptCallback(ENetHost* host, ENetEvent* event);
|
static int interceptCallback(ENetHost* host, ENetEvent* event);
|
||||||
static int m_retry_count;
|
static int m_retry_count;
|
||||||
@ -56,6 +55,7 @@ public:
|
|||||||
virtual void setup() OVERRIDE;
|
virtual void setup() OVERRIDE;
|
||||||
virtual void asynchronousUpdate() OVERRIDE;
|
virtual void asynchronousUpdate() OVERRIDE;
|
||||||
virtual void update(int ticks) OVERRIDE;
|
virtual void update(int ticks) OVERRIDE;
|
||||||
|
void registerWithSTKServer();
|
||||||
bool tryConnect(int timeout, int retry, bool another_port = false);
|
bool tryConnect(int timeout, int retry, bool another_port = false);
|
||||||
|
|
||||||
}; // class ConnectToServer
|
}; // class ConnectToServer
|
||||||
|
Loading…
Reference in New Issue
Block a user