Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetClient.cpp
/* Copyright (C) 2022 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 232 Lines • ▼ Show 20 Lines | if (m_ServerAddress.empty()) | ||||
PushGuiMessage( | PushGuiMessage( | ||||
"type", "netstatus", | "type", "netstatus", | ||||
"status", "disconnected", | "status", "disconnected", | ||||
"reason", static_cast<i32>(NDR_SERVER_REFUSED)); | "reason", static_cast<i32>(NDR_SERVER_REFUSED)); | ||||
return false; | return false; | ||||
} | } | ||||
ENetAddress hostAddr{ ENET_HOST_ANY, ENET_PORT_ANY }; | ENetAddress hostAddr{ ENET_HOST_ANY, ENET_PORT_ANY }; | ||||
ENetHost* enetClient = enet_host_create(&hostAddr, 1, 1, 0, 0); | ENetHost* enetClient = ps_enet_host_create_with_mtu(&hostAddr, 1, 1, 0, 0, PS_ENET_HOST_DEFAULT_MTU); | ||||
if (!enetClient) | if (!enetClient) | ||||
{ | { | ||||
PushGuiMessage( | PushGuiMessage( | ||||
"type", "netstatus", | "type", "netstatus", | ||||
"status", "disconnected", | "status", "disconnected", | ||||
"reason", static_cast<i32>(NDR_STUN_PORT_FAILED)); | "reason", static_cast<i32>(NDR_STUN_PORT_FAILED)); | ||||
return false; | return false; | ||||
} | } | ||||
CStr ip; | CStr ip; | ||||
u16 port = 0; | u16 port = 0; | ||||
if (g_XmppClient && m_UseSTUN) | if (g_XmppClient && m_UseSTUN) | ||||
{ | { | ||||
if (!StunClient::FindPublicIP(*enetClient, ip, port)) | if (!StunClient::FindPublicIP(*enetClient, ip, port)) | ||||
{ | { | ||||
PushGuiMessage( | PushGuiMessage( | ||||
phosit: Use a range based for with a temporary PS::span.
Remove the curly brackets as there is only one… | |||||
"type", "netstatus", | "type", "netstatus", | ||||
"status", "disconnected", | "status", "disconnected", | ||||
"reason", static_cast<i32>(NDR_STUN_ENDPOINT_FAILED)); | "reason", static_cast<i32>(NDR_STUN_ENDPOINT_FAILED)); | ||||
return false; | return false; | ||||
} | } | ||||
// If the host is on the same network, we risk failing to connect | // If the host is on the same network, we risk failing to connect | ||||
// on routers that don't support NAT hairpinning/NAT loopback. | // on routers that don't support NAT hairpinning/NAT loopback. | ||||
▲ Show 20 Lines • Show All 736 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Use a range based for with a temporary PS::span.
Remove the curly brackets as there is only one statement inside.