summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-06-12 09:10:17 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-13 12:45:45 +0200
commit55a11710a6c0f7942f3947711f2050c34782c39d (patch)
tree491b3009324e623236977614e91371a0ea4abac7 /src/network/core
parenta99ac62c1ab816ee48cac85fdf834f9fdc599cb1 (diff)
downloadopenttd-55a11710a6c0f7942f3947711f2050c34782c39d.tar.xz
Codechange: convert printf DEBUG statements to fmt Debug statements
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/address.cpp26
-rw-r--r--src/network/core/core.cpp4
-rw-r--r--src/network/core/game_info.cpp4
-rw-r--r--src/network/core/host.cpp4
-rw-r--r--src/network/core/tcp.cpp6
-rw-r--r--src/network/core/tcp_admin.cpp6
-rw-r--r--src/network/core/tcp_connect.cpp30
-rw-r--r--src/network/core/tcp_content.cpp6
-rw-r--r--src/network/core/tcp_game.cpp6
-rw-r--r--src/network/core/tcp_http.cpp14
-rw-r--r--src/network/core/tcp_listen.h12
-rw-r--r--src/network/core/udp.cpp14
12 files changed, 66 insertions, 66 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp
index 044df0050..8f74ed754 100644
--- a/src/network/core/address.cpp
+++ b/src/network/core/address.cpp
@@ -247,9 +247,9 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
auto end = std::chrono::steady_clock::now();
std::chrono::seconds duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
if (!_resolve_timeout_error_message_shown && duration >= std::chrono::seconds(5)) {
- DEBUG(net, 0, "getaddrinfo for hostname \"%s\", port %s, address family %s and socket type %s took %i seconds",
- this->hostname.c_str(), port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), (int)duration.count());
- DEBUG(net, 0, " this is likely an issue in the DNS name resolver's configuration causing it to time out");
+ Debug(net, 0, "getaddrinfo for hostname \"{}\", port {}, address family {} and socket type {} took {} seconds",
+ this->hostname, port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), duration.count());
+ Debug(net, 0, " this is likely an issue in the DNS name resolver's configuration causing it to time out");
_resolve_timeout_error_message_shown = true;
}
@@ -258,8 +258,8 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
if (e != 0) {
if (func != ResolveLoopProc) {
- DEBUG(net, 0, "getaddrinfo for hostname \"%s\", port %s, address family %s and socket type %s failed: %s",
- this->hostname.c_str(), port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), FS2OTTD(gai_strerror(e)).c_str());
+ Debug(net, 0, "getaddrinfo for hostname \"{}\", port {}, address family {} and socket type {} failed: {}",
+ this->hostname, port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), FS2OTTD(gai_strerror(e)));
}
return INVALID_SOCKET;
}
@@ -317,35 +317,35 @@ static SOCKET ListenLoopProc(addrinfo *runp)
if (sock == INVALID_SOCKET) {
const char *type = NetworkAddress::SocketTypeAsString(runp->ai_socktype);
const char *family = NetworkAddress::AddressFamilyAsString(runp->ai_family);
- DEBUG(net, 0, "Could not create %s %s socket: %s", type, family, NetworkError::GetLast().AsString());
+ Debug(net, 0, "Could not create {} {} socket: {}", type, family, NetworkError::GetLast().AsString());
return INVALID_SOCKET;
}
if (runp->ai_socktype == SOCK_STREAM && !SetNoDelay(sock)) {
- DEBUG(net, 1, "Setting no-delay mode failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 1, "Setting no-delay mode failed: {}", NetworkError::GetLast().AsString());
}
int on = 1;
/* The (const char*) cast is needed for windows!! */
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)) == -1) {
- DEBUG(net, 0, "Setting reuse-address mode failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 0, "Setting reuse-address mode failed: {}", NetworkError::GetLast().AsString());
}
#ifndef __OS2__
if (runp->ai_family == AF_INET6 &&
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
- DEBUG(net, 3, "Could not disable IPv4 over IPv6: %s", NetworkError::GetLast().AsString());
+ Debug(net, 3, "Could not disable IPv4 over IPv6: {}", NetworkError::GetLast().AsString());
}
#endif
if (bind(sock, runp->ai_addr, (int)runp->ai_addrlen) != 0) {
- DEBUG(net, 0, "Could not bind socket on %s: %s", address.c_str(), NetworkError::GetLast().AsString());
+ Debug(net, 0, "Could not bind socket on {}: {}", address, NetworkError::GetLast().AsString());
closesocket(sock);
return INVALID_SOCKET;
}
if (runp->ai_socktype != SOCK_DGRAM && listen(sock, 1) != 0) {
- DEBUG(net, 0, "Could not listen on socket: %s", NetworkError::GetLast().AsString());
+ Debug(net, 0, "Could not listen on socket: {}", NetworkError::GetLast().AsString());
closesocket(sock);
return INVALID_SOCKET;
}
@@ -353,10 +353,10 @@ static SOCKET ListenLoopProc(addrinfo *runp)
/* Connection succeeded */
if (!SetNonBlocking(sock)) {
- DEBUG(net, 0, "Setting non-blocking mode failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 0, "Setting non-blocking mode failed: {}", NetworkError::GetLast().AsString());
}
- DEBUG(net, 3, "Listening on %s", address.c_str());
+ Debug(net, 3, "Listening on {}", address);
return sock;
}
diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp
index af35720db..91f159471 100644
--- a/src/network/core/core.cpp
+++ b/src/network/core/core.cpp
@@ -27,9 +27,9 @@ bool NetworkCoreInitialize()
#ifdef _WIN32
{
WSADATA wsa;
- DEBUG(net, 5, "Loading windows socket library");
+ Debug(net, 5, "Loading windows socket library");
if (WSAStartup(MAKEWORD(2, 0), &wsa) != 0) {
- DEBUG(net, 0, "WSAStartup failed, network unavailable");
+ Debug(net, 0, "WSAStartup failed, network unavailable");
return false;
}
}
diff --git a/src/network/core/game_info.cpp b/src/network/core/game_info.cpp
index dd58ae500..539b48af5 100644
--- a/src/network/core/game_info.cpp
+++ b/src/network/core/game_info.cpp
@@ -51,7 +51,7 @@ const char *GetNetworkRevisionString()
/* Tag names are not mangled further. */
if (_openttd_revision_tagged) {
- DEBUG(net, 3, "Network revision name: %s", network_revision);
+ Debug(net, 3, "Network revision name: {}", network_revision);
return network_revision;
}
@@ -71,7 +71,7 @@ const char *GetNetworkRevisionString()
/* Replace the git hash in revision string. */
strecpy(network_revision + hashofs, githash_suffix, network_revision + NETWORK_REVISION_LENGTH);
assert(strlen(network_revision) < NETWORK_REVISION_LENGTH); // strlen does not include terminator, constant does, hence strictly less than
- DEBUG(net, 3, "Network revision name: %s", network_revision);
+ Debug(net, 3, "Network revision name: {}", network_revision);
}
return network_revision;
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index 4ff77a141..b55f5f5ec 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -131,10 +131,10 @@ void NetworkFindBroadcastIPs(NetworkAddressList *broadcast)
NetworkFindBroadcastIPsInternal(broadcast);
/* Now display to the debug all the detected ips */
- DEBUG(net, 3, "Detected broadcast addresses:");
+ Debug(net, 3, "Detected broadcast addresses:");
int i = 0;
for (NetworkAddress &addr : *broadcast) {
addr.SetPort(NETWORK_DEFAULT_PORT);
- DEBUG(net, 3, " %d) %s", i++, addr.GetHostname());
+ Debug(net, 3, " {}) {}", i++, addr.GetHostname());
}
}
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index d5754f69a..a2e31b53d 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -112,7 +112,7 @@ SendPacketsState NetworkTCPSocketHandler::SendPackets(bool closing_down)
if (!err.WouldBlock()) {
/* Something went wrong.. close client! */
if (!closing_down) {
- DEBUG(net, 0, "Send failed: %s", err.AsString());
+ Debug(net, 0, "Send failed: {}", err.AsString());
this->CloseConnection();
}
return SPS_CLOSED;
@@ -161,7 +161,7 @@ Packet *NetworkTCPSocketHandler::ReceivePacket()
NetworkError err = NetworkError::GetLast();
if (!err.WouldBlock()) {
/* Something went wrong... */
- if (!err.IsConnectionReset()) DEBUG(net, 0, "Recv failed: %s", err.AsString());
+ if (!err.IsConnectionReset()) Debug(net, 0, "Recv failed: {}", err.AsString());
this->CloseConnection();
return nullptr;
}
@@ -189,7 +189,7 @@ Packet *NetworkTCPSocketHandler::ReceivePacket()
NetworkError err = NetworkError::GetLast();
if (!err.WouldBlock()) {
/* Something went wrong... */
- if (!err.IsConnectionReset()) DEBUG(net, 0, "Recv failed: %s", err.AsString());
+ if (!err.IsConnectionReset()) Debug(net, 0, "Recv failed: {}", err.AsString());
this->CloseConnection();
return nullptr;
}
diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp
index 234ab2e25..e1b18549c 100644
--- a/src/network/core/tcp_admin.cpp
+++ b/src/network/core/tcp_admin.cpp
@@ -87,9 +87,9 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p)
default:
if (this->HasClientQuit()) {
- DEBUG(net, 0, "[tcp/admin] Received invalid packet type %d from '%s' (%s)", type, this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 0, "[tcp/admin] Received invalid packet type {} from '{}' ({})", type, this->admin_name, this->admin_version);
} else {
- DEBUG(net, 0, "[tcp/admin] Received illegal packet from '%s' (%s)", this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 0, "[tcp/admin] Received illegal packet from '{}' ({})", this->admin_name, this->admin_version);
}
this->CloseConnection();
@@ -123,7 +123,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::ReceivePackets()
*/
NetworkRecvStatus NetworkAdminSocketHandler::ReceiveInvalidPacket(PacketAdminType type)
{
- DEBUG(net, 0, "[tcp/admin] Received illegal packet type %d from admin %s (%s)", type, this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 0, "[tcp/admin] Received illegal packet type {} from admin {} ({})", type, this->admin_name, this->admin_version);
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp
index 921a1e6c1..5538416f6 100644
--- a/src/network/core/tcp_connect.cpp
+++ b/src/network/core/tcp_connect.cpp
@@ -56,25 +56,25 @@ void TCPConnecter::Connect(addrinfo *address)
{
SOCKET sock = socket(address->ai_family, address->ai_socktype, address->ai_protocol);
if (sock == INVALID_SOCKET) {
- DEBUG(net, 0, "Could not create %s %s socket: %s", NetworkAddress::SocketTypeAsString(address->ai_socktype), NetworkAddress::AddressFamilyAsString(address->ai_family), NetworkError::GetLast().AsString());
+ Debug(net, 0, "Could not create {} {} socket: {}", NetworkAddress::SocketTypeAsString(address->ai_socktype), NetworkAddress::AddressFamilyAsString(address->ai_family), NetworkError::GetLast().AsString());
return;
}
if (!SetNoDelay(sock)) {
- DEBUG(net, 1, "Setting TCP_NODELAY failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 1, "Setting TCP_NODELAY failed: {}", NetworkError::GetLast().AsString());
}
if (!SetNonBlocking(sock)) {
- DEBUG(net, 0, "Setting non-blocking mode failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 0, "Setting non-blocking mode failed: {}", NetworkError::GetLast().AsString());
}
NetworkAddress network_address = NetworkAddress(address->ai_addr, (int)address->ai_addrlen);
- DEBUG(net, 5, "Attempting to connect to %s", network_address.GetAddressAsString().c_str());
+ Debug(net, 5, "Attempting to connect to {}", network_address.GetAddressAsString());
int err = connect(sock, address->ai_addr, (int)address->ai_addrlen);
if (err != 0 && !NetworkError::GetLast().IsConnectInProgress()) {
closesocket(sock);
- DEBUG(net, 1, "Could not connect to %s: %s", network_address.GetAddressAsString().c_str(), NetworkError::GetLast().AsString());
+ Debug(net, 1, "Could not connect to {}: {}", network_address.GetAddressAsString(), NetworkError::GetLast().AsString());
return;
}
@@ -150,9 +150,9 @@ void TCPConnecter::OnResolved(addrinfo *ai)
}
if (_debug_net_level >= 6) {
- DEBUG(net, 6, "%s resolved in:", this->connection_string.c_str());
+ Debug(net, 6, "{} resolved in:", this->connection_string);
for (const auto &address : this->addresses) {
- DEBUG(net, 6, "- %s", NetworkAddress(address->ai_addr, (int)address->ai_addrlen).GetAddressAsString().c_str());
+ Debug(net, 6, "- {}", NetworkAddress(address->ai_addr, (int)address->ai_addrlen).GetAddressAsString());
}
}
@@ -188,13 +188,13 @@ void TCPConnecter::Resolve()
auto end = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
if (!getaddrinfo_timeout_error_shown && duration >= std::chrono::seconds(5)) {
- DEBUG(net, 0, "getaddrinfo() for address \"%s\" took %i seconds", this->connection_string.c_str(), (int)duration.count());
- DEBUG(net, 0, " This is likely an issue in the DNS name resolver's configuration causing it to time out");
+ Debug(net, 0, "getaddrinfo() for address \"{}\" took {} seconds", this->connection_string, duration.count());
+ Debug(net, 0, " This is likely an issue in the DNS name resolver's configuration causing it to time out");
getaddrinfo_timeout_error_shown = true;
}
if (error != 0) {
- DEBUG(net, 0, "Failed to resolve DNS for %s", this->connection_string.c_str());
+ Debug(net, 0, "Failed to resolve DNS for {}", this->connection_string);
this->status = Status::FAILURE;
return;
}
@@ -272,7 +272,7 @@ bool TCPConnecter::CheckActivity()
/* select() failed; hopefully next try it doesn't. */
if (n < 0) {
/* select() normally never fails; so hopefully it works next try! */
- DEBUG(net, 1, "select() failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 1, "select() failed: {}", NetworkError::GetLast().AsString());
return false;
}
@@ -289,7 +289,7 @@ bool TCPConnecter::CheckActivity()
/* More than 3 seconds no socket reported activity, and there are no
* more address to try. Timeout the attempt. */
- DEBUG(net, 0, "Timeout while connecting to %s", this->connection_string.c_str());
+ Debug(net, 0, "Timeout while connecting to {}", this->connection_string);
for (const auto &socket : this->sockets) {
closesocket(socket);
@@ -305,7 +305,7 @@ bool TCPConnecter::CheckActivity()
for (auto it = this->sockets.begin(); it != this->sockets.end(); /* nothing */) {
NetworkError socket_error = GetSocketError(*it);
if (socket_error.HasError()) {
- DEBUG(net, 1, "Could not connect to %s: %s", this->sock_to_address[*it].GetAddressAsString().c_str(), socket_error.AsString());
+ Debug(net, 1, "Could not connect to {}: {}", this->sock_to_address[*it].GetAddressAsString(), socket_error.AsString());
closesocket(*it);
this->sock_to_address.erase(*it);
it = this->sockets.erase(it);
@@ -338,9 +338,9 @@ bool TCPConnecter::CheckActivity()
}
assert(connected_socket != INVALID_SOCKET);
- DEBUG(net, 3, "Connected to %s", this->connection_string.c_str());
+ Debug(net, 3, "Connected to {}", this->connection_string);
if (_debug_net_level >= 5) {
- DEBUG(net, 5, "- using %s", NetworkAddress::GetPeerName(connected_socket).c_str());
+ Debug(net, 5, "- using {}", NetworkAddress::GetPeerName(connected_socket));
}
this->OnConnect(connected_socket);
diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp
index 84c82ead1..84573d557 100644
--- a/src/network/core/tcp_content.cpp
+++ b/src/network/core/tcp_content.cpp
@@ -114,9 +114,9 @@ bool NetworkContentSocketHandler::HandlePacket(Packet *p)
default:
if (this->HasClientQuit()) {
- DEBUG(net, 0, "[tcp/content] Received invalid packet type %d", type);
+ Debug(net, 0, "[tcp/content] Received invalid packet type {}", type);
} else {
- DEBUG(net, 0, "[tcp/content] Received illegal packet");
+ Debug(net, 0, "[tcp/content] Received illegal packet");
}
return false;
}
@@ -167,7 +167,7 @@ bool NetworkContentSocketHandler::ReceivePackets()
*/
bool NetworkContentSocketHandler::ReceiveInvalidPacket(PacketContentType type)
{
- DEBUG(net, 0, "[tcp/content] Received illegal packet type %d", type);
+ Debug(net, 0, "[tcp/content] Received illegal packet type {}", type);
return false;
}
diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp
index 0e38133fb..84fb164de 100644
--- a/src/network/core/tcp_game.cpp
+++ b/src/network/core/tcp_game.cpp
@@ -117,9 +117,9 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet *p)
this->CloseConnection();
if (this->HasClientQuit()) {
- DEBUG(net, 0, "[tcp/game] Received invalid packet type %d from client %d", type, this->client_id);
+ Debug(net, 0, "[tcp/game] Received invalid packet type {} from client {}", type, this->client_id);
} else {
- DEBUG(net, 0, "[tcp/game] Received illegal packet from client %d", this->client_id);
+ Debug(net, 0, "[tcp/game] Received illegal packet from client {}", this->client_id);
}
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
@@ -151,7 +151,7 @@ NetworkRecvStatus NetworkGameSocketHandler::ReceivePackets()
*/
NetworkRecvStatus NetworkGameSocketHandler::ReceiveInvalidPacket(PacketGameType type)
{
- DEBUG(net, 0, "[tcp/game] Received illegal packet type %d from client %d", type, this->client_id);
+ Debug(net, 0, "[tcp/game] Received illegal packet type {} from client {}", type, this->client_id);
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp
index f11722ae3..abb240708 100644
--- a/src/network/core/tcp_http.cpp
+++ b/src/network/core/tcp_http.cpp
@@ -45,7 +45,7 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s,
size_t bufferSize = strlen(url) + strlen(host) + strlen(GetNetworkRevisionString()) + (data == nullptr ? 0 : strlen(data)) + 128;
char *buffer = AllocaM(char, bufferSize);
- DEBUG(net, 5, "[tcp/http] Requesting %s%s", host, url);
+ Debug(net, 5, "[tcp/http] Requesting {}{}", host, url);
if (data != nullptr) {
seprintf(buffer, buffer + bufferSize - 1, "POST %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: OpenTTD/%s\r\nContent-Type: text/plain\r\nContent-Length: %d\r\n\r\n%s\r\n", url, host, GetNetworkRevisionString(), (int)strlen(data), data);
} else {
@@ -86,7 +86,7 @@ void NetworkHTTPSocketHandler::CloseSocket()
* Helper to simplify the error handling.
* @param msg the error message to show.
*/
-#define return_error(msg) { DEBUG(net, 1, msg); return -1; }
+#define return_error(msg) { Debug(net, 1, msg); return -1; }
static const char * const NEWLINE = "\r\n"; ///< End of line marker
static const char * const END_OF_HEADER = "\r\n\r\n"; ///< End of header marker
@@ -142,7 +142,7 @@ int NetworkHTTPSocketHandler::HandleHeader()
* wrong. You can't have gzips of 0 bytes! */
if (len == 0) return_error("[tcp/http] Refusing to download 0 bytes");
- DEBUG(net, 7, "[tcp/http] Downloading %i bytes", len);
+ Debug(net, 7, "[tcp/http] Downloading {} bytes", len);
return len;
}
@@ -155,7 +155,7 @@ int NetworkHTTPSocketHandler::HandleHeader()
/* Search the end of the line. This is safe because the header will
* always end with two newlines. */
*strstr(status, NEWLINE) = '\0';
- DEBUG(net, 1, "[tcp/http] Unhandled status reply %s", status);
+ Debug(net, 1, "[tcp/http] Unhandled status reply {}", status);
return -1;
}
@@ -172,7 +172,7 @@ int NetworkHTTPSocketHandler::HandleHeader()
char *end_of_line = strstr(uri, NEWLINE);
*end_of_line = '\0';
- DEBUG(net, 7, "[tcp/http] Redirecting to %s", uri);
+ Debug(net, 7, "[tcp/http] Redirecting to {}", uri);
int ret = NetworkHTTPSocketHandler::Connect(uri, this->callback, this->data, this->redirect_depth + 1);
if (ret != 0) return ret;
@@ -229,7 +229,7 @@ int NetworkHTTPSocketHandler::Receive()
NetworkError err = NetworkError::GetLast();
if (!err.WouldBlock()) {
/* Something went wrong... */
- if (!err.IsConnectionReset()) DEBUG(net, 0, "Recv failed: %s", err.AsString());
+ if (!err.IsConnectionReset()) Debug(net, 0, "Recv failed: {}", err.AsString());
return -1;
}
/* Connection would block, so stop for now */
@@ -257,7 +257,7 @@ int NetworkHTTPSocketHandler::Receive()
if (end_of_header == nullptr) {
if (read == lengthof(this->recv_buffer)) {
- DEBUG(net, 1, "[tcp/http] Header too big");
+ Debug(net, 1, "[tcp/http] Header too big");
return -1;
}
this->recv_pos = read;
diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h
index 40fc84efe..1cde4a179 100644
--- a/src/network/core/tcp_listen.h
+++ b/src/network/core/tcp_listen.h
@@ -49,7 +49,7 @@ public:
SetNonBlocking(s); // XXX error handling?
NetworkAddress address(sin, sin_len);
- DEBUG(net, 3, "[%s] Client connected from %s on frame %d", Tsocket::GetName(), address.GetHostname(), _frame_counter);
+ Debug(net, 3, "[{}] Client connected from {} on frame {}", Tsocket::GetName(), address.GetHostname(), _frame_counter);
SetNoDelay(s); // XXX error handling?
@@ -61,10 +61,10 @@ public:
Packet p(Tban_packet);
p.PrepareToSend();
- DEBUG(net, 2, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), entry.c_str());
+ Debug(net, 2, "[{}] Banned ip tried to join ({}), refused", Tsocket::GetName(), entry);
if (p.TransferOut<int>(send, s, 0) < 0) {
- DEBUG(net, 0, "[%s] send failed: %s", Tsocket::GetName(), NetworkError::GetLast().AsString());
+ Debug(net, 0, "[{}] send failed: {}", Tsocket::GetName(), NetworkError::GetLast().AsString());
}
closesocket(s);
break;
@@ -81,7 +81,7 @@ public:
p.PrepareToSend();
if (p.TransferOut<int>(send, s, 0) < 0) {
- DEBUG(net, 0, "[%s] send failed: %s", Tsocket::GetName(), NetworkError::GetLast().AsString());
+ Debug(net, 0, "[{}] send failed: {}", Tsocket::GetName(), NetworkError::GetLast().AsString());
}
closesocket(s);
@@ -150,7 +150,7 @@ public:
}
if (sockets.size() == 0) {
- DEBUG(net, 0, "Could not start network: could not create listening socket");
+ Debug(net, 0, "Could not start network: could not create listening socket");
ShowNetworkError(STR_NETWORK_ERROR_SERVER_START);
return false;
}
@@ -165,7 +165,7 @@ public:
closesocket(s.second);
}
sockets.clear();
- DEBUG(net, 5, "[%s] Closed listeners", Tsocket::GetName());
+ Debug(net, 5, "[{}] Closed listeners", Tsocket::GetName());
}
};
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 312ac0f0a..7a3fc19f3 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -89,16 +89,16 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
/* Enable broadcast */
unsigned long val = 1;
if (setsockopt(s.second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) {
- DEBUG(net, 1, "Setting broadcast mode failed: %s", NetworkError::GetLast().AsString());
+ Debug(net, 1, "Setting broadcast mode failed: {}", NetworkError::GetLast().AsString());
}
}
/* Send the buffer */
ssize_t res = p->TransferOut<int>(sendto, s.second, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength());
- DEBUG(net, 7, "sendto(%s)", send.GetAddressAsString().c_str());
+ Debug(net, 7, "sendto({})", send.GetAddressAsString());
/* Check for any errors, but ignore it otherwise */
- if (res == -1) DEBUG(net, 1, "sendto(%s) failed: %s", send.GetAddressAsString().c_str(), NetworkError::GetLast().AsString());
+ if (res == -1) Debug(net, 1, "sendto({}) failed: {}", send.GetAddressAsString(), NetworkError::GetLast().AsString());
if (!all) break;
}
@@ -134,7 +134,7 @@ void NetworkUDPSocketHandler::ReceivePackets()
/* If the size does not match the packet must be corrupted.
* Otherwise it will be marked as corrupted later on. */
if (!p.ParsePacketSize() || (size_t)nbytes != p.Size()) {
- DEBUG(net, 1, "Received a packet with mismatching size from %s", address.GetAddressAsString().c_str());
+ Debug(net, 1, "Received a packet with mismatching size from {}", address.GetAddressAsString());
continue;
}
p.PrepareToRead();
@@ -175,9 +175,9 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_
default:
if (this->HasClientQuit()) {
- DEBUG(net, 0, "[udp] Received invalid packet type %d from %s", type, client_addr->GetAddressAsString().c_str());
+ Debug(net, 0, "[udp] Received invalid packet type {} from {}", type, client_addr->GetAddressAsString());
} else {
- DEBUG(net, 0, "[udp] Received illegal packet from %s", client_addr->GetAddressAsString().c_str());
+ Debug(net, 0, "[udp] Received illegal packet from {}", client_addr->GetAddressAsString());
}
break;
}
@@ -190,7 +190,7 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_
*/
void NetworkUDPSocketHandler::ReceiveInvalidPacket(PacketUDPType type, NetworkAddress *client_addr)
{
- DEBUG(net, 0, "[udp] Received packet type %d on wrong port from %s", type, client_addr->GetAddressAsString().c_str());
+ Debug(net, 0, "[udp] Received packet type {} on wrong port from {}", type, client_addr->GetAddressAsString());
}
void NetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_CLIENT_FIND_SERVER, client_addr); }