Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetSession.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
bool CNetClientSession::Connect(const CStr& server, const u16 port, ENetHost* enetClient) | bool CNetClientSession::Connect(const CStr& server, const u16 port, ENetHost* enetClient) | ||||
{ | { | ||||
ENSURE(!m_LoopRunning); | ENSURE(!m_LoopRunning); | ||||
ENSURE(!m_Host); | ENSURE(!m_Host); | ||||
ENSURE(!m_Server); | ENSURE(!m_Server); | ||||
// Create ENet host | // Create ENet host | ||||
ENetHost* host; | ENetHost* host; | ||||
if (enetClient != nullptr) | if (enetClient != nullptr) | ||||
host = enetClient; | host = enetClient; | ||||
else | else | ||||
host = enet_host_create(NULL, 1, CHANNEL_COUNT, 0, 0); | host = ps_enet_host_create_with_mtu(NULL, 1, CHANNEL_COUNT, 0, 0, PS_ENET_HOST_DEFAULT_MTU); | ||||
vladislavbelov: Maybe?
```lang=cpp
ENetHost* host = enetClient != nullptr ? enetClient : PS::Enet::CreateHost… | |||||
Done Inline ActionsYeah, reasonable to clean up at the same time. sera: Yeah, reasonable to clean up at the same time. | |||||
if (!host) | if (!host) | ||||
return false; | return false; | ||||
// Bind to specified host | // Bind to specified host | ||||
ENetAddress addr; | ENetAddress addr; | ||||
addr.port = port; | addr.port = port; | ||||
if (enet_address_set_host(&addr, server.c_str()) < 0) | if (enet_address_set_host(&addr, server.c_str()) < 0) | ||||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Maybe?