mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-08 22:26:51 +02:00
Remove unused parameters
This commit is contained in:
@@ -186,9 +186,9 @@ void CServerHandler::startLocalServerAndConnect(bool connectToLobby)
|
||||
si->difficulty = lastDifficulty.Integer();
|
||||
|
||||
logNetwork->trace("\tStarting local server");
|
||||
uint16_t srvport = serverRunner->start(getLocalPort(), loadMode == ELoadMode::MULTI, connectToLobby, si);
|
||||
serverRunner->start(loadMode == ELoadMode::MULTI, connectToLobby, si);
|
||||
logNetwork->trace("\tConnecting to local server");
|
||||
connectToServer(getLocalHostname(), srvport);
|
||||
connectToServer(getLocalHostname(), getLocalPort());
|
||||
logNetwork->trace("\tWaiting for connection");
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ void CServerHandler::connectToServer(const std::string & addr, const ui16 port)
|
||||
}
|
||||
else
|
||||
{
|
||||
serverRunner->connect(*networkHandler, *this, addr, port);
|
||||
serverRunner->connect(*networkHandler, *this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ void CServerHandler::onTimer()
|
||||
}
|
||||
|
||||
assert(isServerLocal());
|
||||
serverRunner->connect(*networkHandler, *this, getLocalHostname(), getLocalPort());
|
||||
serverRunner->connect(*networkHandler, *this);
|
||||
}
|
||||
|
||||
void CServerHandler::onConnectionEstablished(const NetworkConnectionPtr & netConnection)
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "../lib/VCMIDirs.h"
|
||||
#include "../lib/CThreadHelper.h"
|
||||
#include "../lib/network/NetworkInterface.h"
|
||||
#include "../lib/CConfigHandler.h"
|
||||
#include "../server/CVCMIServer.h"
|
||||
|
||||
#ifdef ENABLE_SERVER_PROCESS
|
||||
@@ -34,10 +35,11 @@
|
||||
ServerThreadRunner::ServerThreadRunner() = default;
|
||||
ServerThreadRunner::~ServerThreadRunner() = default;
|
||||
|
||||
uint16_t ServerThreadRunner::start(uint16_t cfgport, bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo)
|
||||
void ServerThreadRunner::start(bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo)
|
||||
{
|
||||
// cfgport may be 0 -- the real port is returned after calling prepare()
|
||||
server = std::make_unique<CVCMIServer>(cfgport, true);
|
||||
uint16_t port = settings["server"]["localPort"].Integer();
|
||||
server = std::make_unique<CVCMIServer>(port, true);
|
||||
|
||||
if (startingInfo)
|
||||
{
|
||||
@@ -54,10 +56,8 @@ uint16_t ServerThreadRunner::start(uint16_t cfgport, bool listenForConnections,
|
||||
});
|
||||
|
||||
logNetwork->trace("Waiting for server port...");
|
||||
auto srvport = promise.get_future().get();
|
||||
logNetwork->debug("Server port: %d", srvport);
|
||||
|
||||
return srvport;
|
||||
serverPort = promise.get_future().get();
|
||||
logNetwork->debug("Server port: %d", serverPort);
|
||||
}
|
||||
|
||||
void ServerThreadRunner::shutdown()
|
||||
@@ -75,7 +75,7 @@ int ServerThreadRunner::exitCode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ServerThreadRunner::connect(INetworkHandler & network, INetworkClientListener & listener, const std::string & host, uint16_t port)
|
||||
void ServerThreadRunner::connect(INetworkHandler & network, INetworkClientListener & listener)
|
||||
{
|
||||
network.createInternalConnection(listener, server->getNetworkServer());
|
||||
}
|
||||
@@ -100,8 +100,9 @@ int ServerProcessRunner::exitCode()
|
||||
return child->exit_code();
|
||||
}
|
||||
|
||||
uint16_t ServerProcessRunner::start(uint16_t port, bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo)
|
||||
void ServerProcessRunner::start(bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo)
|
||||
{
|
||||
uint16_t port = settings["server"]["localPort"].Integer();
|
||||
boost::filesystem::path serverPath = VCMIDirs::get().serverPath();
|
||||
boost::filesystem::path logPath = VCMIDirs::get().userLogsPath() / "server_log.txt";
|
||||
std::vector<std::string> args;
|
||||
@@ -115,12 +116,13 @@ uint16_t ServerProcessRunner::start(uint16_t port, bool listenForConnections, bo
|
||||
|
||||
if (ec)
|
||||
throw std::runtime_error("Failed to start server! Reason: " + ec.message());
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
void ServerProcessRunner::connect(INetworkHandler & network, INetworkClientListener & listener, const std::string & host, uint16_t port)
|
||||
void ServerProcessRunner::connect(INetworkHandler & network, INetworkClientListener & listener)
|
||||
{
|
||||
std::string host = settings["server"]["localHostname"].String();
|
||||
uint16_t port = settings["server"]["localPort"].Integer();
|
||||
|
||||
network.connectToRemote(listener, host, port);
|
||||
}
|
||||
|
||||
|
@@ -22,12 +22,12 @@ class CVCMIServer;
|
||||
class IServerRunner
|
||||
{
|
||||
public:
|
||||
virtual uint16_t start(uint16_t port, bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo) = 0;
|
||||
virtual void start(bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo) = 0;
|
||||
virtual void shutdown() = 0;
|
||||
virtual void wait() = 0;
|
||||
virtual int exitCode() = 0;
|
||||
|
||||
virtual void connect(INetworkHandler & network, INetworkClientListener & listener, const std::string & host, uint16_t port) = 0;
|
||||
virtual void connect(INetworkHandler & network, INetworkClientListener & listener) = 0;
|
||||
|
||||
virtual ~IServerRunner() = default;
|
||||
};
|
||||
@@ -37,13 +37,15 @@ class ServerThreadRunner final : public IServerRunner, boost::noncopyable
|
||||
{
|
||||
std::unique_ptr<CVCMIServer> server;
|
||||
boost::thread threadRunLocalServer;
|
||||
uint16_t serverPort = 0;
|
||||
|
||||
public:
|
||||
uint16_t start(uint16_t port, bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo) override;
|
||||
void start(bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo) override;
|
||||
void shutdown() override;
|
||||
void wait() override;
|
||||
int exitCode() override;
|
||||
|
||||
void connect(INetworkHandler & network, INetworkClientListener & listener, const std::string & host, uint16_t port) override;
|
||||
void connect(INetworkHandler & network, INetworkClientListener & listener) override;
|
||||
|
||||
ServerThreadRunner();
|
||||
~ServerThreadRunner();
|
||||
@@ -75,12 +77,12 @@ class ServerProcessRunner final : public IServerRunner, boost::noncopyable
|
||||
std::unique_ptr<boost::process::child> child;
|
||||
|
||||
public:
|
||||
uint16_t start(uint16_t port, bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo) override;
|
||||
void start(bool listenForConnections, bool connectToLobby, std::shared_ptr<StartInfo> startingInfo) override;
|
||||
void shutdown() override;
|
||||
void wait() override;
|
||||
int exitCode() override;
|
||||
|
||||
void connect(INetworkHandler & network, INetworkClientListener & listener, const std::string & host, uint16_t port) override;
|
||||
void connect(INetworkHandler & network, INetworkClientListener & listener) override;
|
||||
|
||||
ServerProcessRunner();
|
||||
~ServerProcessRunner();
|
||||
|
Reference in New Issue
Block a user