Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nic11 committed Feb 24, 2025
1 parent ab1e888 commit 9094645
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions skymp5-server/cpp/addon/ScampServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ ScampServer::ScampServer(const Napi::CallbackInfo& info)
auto serverSettings = nlohmann::json::parse(serverSettingsJson);

// TODO: rework parsing with archives?
std::string listenHost = serverSettings.at("listenHost").get<std::string>();
std::string listenHost =
serverSettings.at("listenHost").get<std::string>();
uint32_t listenPort = serverSettings.at("port").get<uint32_t>();
uint32_t maxPlayers = serverSettings.at("maxPlayers").get<uint32_t>();

Expand Down Expand Up @@ -320,9 +321,8 @@ ScampServer::ScampServer(const Napi::CallbackInfo& info)
? std::string(kNetworkingPasswordPrefix) +
static_cast<std::string>(serverSettings["password"])
: std::string(kNetworkingPasswordPrefix);
auto realServer = Networking::CreateServer(
listenHost.c_str(), listenPort, maxPlayers,
password.data());
auto realServer = Networking::CreateServer(listenHost.c_str(), listenPort,
maxPlayers, password.data());

static_assert(kMockServerIdx == 1);
server = Networking::CreateCombinedServer({ realServer, serverMock });
Expand Down
10 changes: 6 additions & 4 deletions skymp5-server/cpp/mp_common/Networking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class Server : public Networking::IServer
public:
constexpr static int timeoutTimeMs = 60000;

Server(const char* listenAddress, unsigned short port_, unsigned short maxConnections,
const char* password_)
Server(const char* listenAddress, unsigned short port_,
unsigned short maxConnections, const char* password_)
: password(password_)
{
if (maxConnections > kMaxPlayers) {
Expand Down Expand Up @@ -218,9 +218,11 @@ std::shared_ptr<Networking::IClient> Networking::CreateClient(
}

std::shared_ptr<Networking::IServer> Networking::CreateServer(
const char* listenAddress, unsigned short port, unsigned short maxConnections, const char* password)
const char* listenAddress, unsigned short port,
unsigned short maxConnections, const char* password)
{
return std::make_shared<Server>(listenAddress, port, maxConnections, password);
return std::make_shared<Server>(listenAddress, port, maxConnections,
password);
}

void Networking::HandlePacketClientside(Networking::IClient::OnPacket onPacket,
Expand Down
3 changes: 2 additions & 1 deletion skymp5-server/cpp/mp_common/Networking.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ std::shared_ptr<IClient> CreateClient(const char* serverIp,
unsigned short serverPort, int timeoutMs,
const char* password);

std::shared_ptr<IServer> CreateServer(const char* listenAddress, unsigned short port,
std::shared_ptr<IServer> CreateServer(const char* listenAddress,
unsigned short port,
unsigned short maxConnections,
const char* password);

Expand Down
9 changes: 6 additions & 3 deletions unit/NetworkingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ using namespace std::chrono_literals;

TEST_CASE("Handler destroys the client", "[Networking]")
{
auto server = Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
auto server =
Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
static auto client =
Networking::CreateClient("127.0.0.1", 7778, 500, "password");

Expand All @@ -32,7 +33,8 @@ TEST_CASE("Handler destroys the client", "[Networking]")

TEST_CASE("Connect/disconnect", "[Networking]")
{
auto server = Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
auto server =
Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
auto client = Networking::CreateClient("127.0.0.1", 7778, 500, "password");

REQUIRE(!client->IsConnected());
Expand All @@ -52,7 +54,8 @@ TEST_CASE("Connect/disconnect", "[Networking]")

TEST_CASE("Ctors", "[Networking]")
{
auto server = Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
auto server =
Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
auto client = Networking::CreateClient("127.0.0.1", 7778, 4000, "password");

try {
Expand Down
3 changes: 2 additions & 1 deletion unit/Networking_DataTransferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ using namespace std::chrono_literals;

TEST_CASE("Data transfer", "[Networking]")
{
static auto server = Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
static auto server =
Networking::CreateServer("127.0.0.1", 7778, MAX_PLAYERS, "password");
static auto client =
Networking::CreateClient("127.0.0.1", 7778, 4000, "password");

Expand Down

0 comments on commit 9094645

Please sign in to comment.