summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-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
-rw-r--r--src/network/network.cpp40
-rw-r--r--src/network/network_admin.cpp22
-rw-r--r--src/network/network_client.cpp20
-rw-r--r--src/network/network_command.cpp2
-rw-r--r--src/network/network_server.cpp22
-rw-r--r--src/network/network_udp.cpp46
18 files changed, 142 insertions, 142 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); }
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 862169c1d..2a094190e 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -264,7 +264,7 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send,
char *msg_ptr = message + Utf8Encode(message, _current_text_dir == TD_LTR ? CHAR_TD_LRM : CHAR_TD_RLM);
GetString(msg_ptr, strid, lastof(message));
- DEBUG(desync, 1, "msg: %08x; %02x; %s", _date, _date_fract, message);
+ Debug(desync, 1, "msg: {:08x}; {:02x}; {}", _date, _date_fract, message);
IConsolePrintF(colour, "%s", message);
NetworkAddChatMessage((TextColour)colour, _settings_client.gui.network_chat_timeout, message);
}
@@ -877,14 +877,14 @@ static void CheckClientAndServerName()
static const std::string fallback_client_name = "Unnamed Client";
StrTrimInPlace(_settings_client.network.client_name);
if (_settings_client.network.client_name.empty() || _settings_client.network.client_name.compare(fallback_client_name) == 0) {
- DEBUG(net, 1, "No \"client_name\" has been set, using \"%s\" instead. Please set this now using the \"name <new name>\" command", fallback_client_name.c_str());
+ Debug(net, 1, "No \"client_name\" has been set, using \"{}\" instead. Please set this now using the \"name <new name>\" command", fallback_client_name);
_settings_client.network.client_name = fallback_client_name;
}
static const std::string fallback_server_name = "Unnamed Server";
StrTrimInPlace(_settings_client.network.server_name);
if (_settings_client.network.server_name.empty() || _settings_client.network.server_name.compare(fallback_server_name) == 0) {
- DEBUG(net, 1, "No \"server_name\" has been set, using \"%s\" instead. Please set this now using the \"server_name <new name>\" command", fallback_server_name.c_str());
+ Debug(net, 1, "No \"server_name\" has been set, using \"{}\" instead. Please set this now using the \"server_name <new name>\" command", fallback_server_name);
_settings_client.network.server_name = fallback_server_name;
}
}
@@ -902,17 +902,17 @@ bool NetworkServerStart()
NetworkDisconnect(false, false);
NetworkInitialize(false);
- DEBUG(net, 5, "Starting listeners for clients");
+ Debug(net, 5, "Starting listeners for clients");
if (!ServerNetworkGameSocketHandler::Listen(_settings_client.network.server_port)) return false;
/* Only listen for admins when the password isn't empty. */
if (!_settings_client.network.admin_password.empty()) {
- DEBUG(net, 5, "Starting listeners for admins");
+ Debug(net, 5, "Starting listeners for admins");
if (!ServerNetworkAdminSocketHandler::Listen(_settings_client.network.server_admin_port)) return false;
}
/* Try to start UDP-server */
- DEBUG(net, 5, "Starting listeners for incoming server queries");
+ Debug(net, 5, "Starting listeners for incoming server queries");
NetworkUDPServerListen();
_network_company_states = new NetworkCompanyState[MAX_COMPANIES];
@@ -1049,7 +1049,7 @@ void NetworkGameLoop()
/* We don't want to log multiple times if paused. */
static Date last_log;
if (last_log != _date) {
- DEBUG(desync, 1, "sync: %08x; %02x; %08x; %08x", _date, _date_fract, _random.state[0], _random.state[1]);
+ Debug(desync, 1, "sync: {:08x}; {:02x}; {:08x}; {:08x}", _date, _date_fract, _random.state[0], _random.state[1]);
last_log = _date;
}
}
@@ -1063,7 +1063,7 @@ void NetworkGameLoop()
static bool check_sync_state = false;
static uint32 sync_state[2];
if (f == nullptr && next_date == 0) {
- DEBUG(desync, 0, "Cannot open commands.log");
+ Debug(desync, 0, "Cannot open commands.log");
next_date = 1;
}
@@ -1071,15 +1071,15 @@ void NetworkGameLoop()
if (_date == next_date && _date_fract == next_date_fract) {
if (cp != nullptr) {
NetworkSendCommand(cp->tile, cp->p1, cp->p2, cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->text, cp->company);
- DEBUG(desync, 0, "Injecting: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text.c_str(), GetCommandName(cp->cmd));
+ Debug(desync, 0, "Injecting: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, GetCommandName(cp->cmd));
delete cp;
cp = nullptr;
}
if (check_sync_state) {
if (sync_state[0] == _random.state[0] && sync_state[1] == _random.state[1]) {
- DEBUG(desync, 0, "Sync check: %08x; %02x; match", _date, _date_fract);
+ Debug(desync, 0, "Sync check: {:08x}; {:02x}; match", _date, _date_fract);
} else {
- DEBUG(desync, 0, "Sync check: %08x; %02x; mismatch expected {%08x, %08x}, got {%08x, %08x}",
+ Debug(desync, 0, "Sync check: {:08x}; {:02x}; mismatch expected {{:08x}, {:08x}}, got {{:08x}, {:08x}}",
_date, _date_fract, sync_state[0], sync_state[1], _random.state[0], _random.state[1]);
NOT_REACHED();
}
@@ -1121,7 +1121,7 @@ void NetworkGameLoop()
/* Manually insert a pause when joining; this way the client can join at the exact right time. */
int ret = sscanf(p + 6, "%x; %x", &next_date, &next_date_fract);
assert(ret == 2);
- DEBUG(desync, 0, "Injecting pause for join at %08x:%02x; please join when paused", next_date, next_date_fract);
+ Debug(desync, 0, "Injecting pause for join at {:08x}:{:02x}; please join when paused", next_date, next_date_fract);
cp = new CommandPacket();
cp->company = COMPANY_SPECTATOR;
cp->cmd = CMD_PAUSE;
@@ -1137,16 +1137,16 @@ void NetworkGameLoop()
/* A message that is not very important to the log playback, but part of the log. */
#ifndef DEBUG_FAILED_DUMP_COMMANDS
} else if (strncmp(p, "cmdf: ", 6) == 0) {
- DEBUG(desync, 0, "Skipping replay of failed command: %s", p + 6);
+ Debug(desync, 0, "Skipping replay of failed command: {}", p + 6);
#endif
} else {
/* Can't parse a line; what's wrong here? */
- DEBUG(desync, 0, "Trying to parse: %s", p);
+ Debug(desync, 0, "Trying to parse: {}", p);
NOT_REACHED();
}
}
if (f != nullptr && feof(f)) {
- DEBUG(desync, 0, "End of commands.log");
+ Debug(desync, 0, "End of commands.log");
fclose(f);
f = nullptr;
}
@@ -1233,12 +1233,12 @@ public:
void OnFailure() override
{
- DEBUG(net, 0, "Failed to open connection to %s for redirecting DEBUG()", this->connection_string.c_str());
+ Debug(net, 0, "Failed to open connection to {} for redirecting Debug()", this->connection_string);
}
void OnConnect(SOCKET s) override
{
- DEBUG(net, 3, "Redirecting DEBUG() to %s", this->connection_string.c_str());
+ Debug(net, 3, "Redirecting Debug() to {}", this->connection_string);
extern SOCKET _debug_socket;
_debug_socket = s;
@@ -1253,7 +1253,7 @@ void NetworkStartDebugLog(const std::string &connection_string)
/** This tries to launch the network for a given OS */
void NetworkStartUp()
{
- DEBUG(net, 3, "Starting network");
+ Debug(net, 3, "Starting network");
/* Network is available */
_network_available = NetworkCoreInitialize();
@@ -1266,7 +1266,7 @@ void NetworkStartUp()
_network_game_info = {};
NetworkInitialize();
- DEBUG(net, 3, "Network online, multiplayer available");
+ Debug(net, 3, "Network online, multiplayer available");
NetworkFindBroadcastIPs(&_broadcast_list);
}
@@ -1276,7 +1276,7 @@ void NetworkShutDown()
NetworkDisconnect(true);
NetworkUDPClose();
- DEBUG(net, 3, "Shutting down network");
+ Debug(net, 3, "Shutting down network");
_network_available = false;
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index 8aa32d21e..b8801b215 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -74,7 +74,7 @@ ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler(SOCKET s) : Net
ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
{
_network_admins_connected--;
- DEBUG(net, 3, "[admin] '%s' (%s) has disconnected", this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 3, "[admin] '{}' ({}) has disconnected", this->admin_name, this->admin_version);
if (_redirect_console_to_admin == this->index) _redirect_console_to_admin = INVALID_ADMIN_ID;
}
@@ -97,7 +97,7 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
{
for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) {
if (as->status == ADMIN_STATUS_INACTIVE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) {
- DEBUG(net, 2, "[admin] Admin did not send its authorisation within %d seconds", (uint32)std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
+ Debug(net, 2, "[admin] Admin did not send its authorisation within {} seconds", std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
as->CloseConnection(true);
continue;
}
@@ -135,7 +135,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendError(NetworkErrorCode er
std::string error_message = GetString(GetNetworkErrorMsg(error));
- DEBUG(net, 1, "[admin] The admin '%s' (%s) made an error and has been disconnected: '%s'", this->admin_name.c_str(), this->admin_version.c_str(), error_message.c_str());
+ Debug(net, 1, "[admin] The admin '{}' ({}) made an error and has been disconnected: '{}'", this->admin_name, this->admin_version, error_message);
return this->CloseConnection(true);
}
@@ -500,7 +500,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet *p)
std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
- DEBUG(net, 3, "[admin] Rcon command from '%s' (%s): %s", this->admin_name.c_str(), this->admin_version.c_str(), command.c_str());
+ Debug(net, 3, "[admin] Rcon command from '{}' ({}): {}", this->admin_name, this->admin_version, command);
_redirect_console_to_admin = this->index;
IConsoleCmdExec(command.c_str());
@@ -514,7 +514,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Pack
std::string json = p->Recv_string(NETWORK_GAMESCRIPT_JSON_LENGTH);
- DEBUG(net, 6, "[admin] GameScript JSON from '%s' (%s): %s", this->admin_name.c_str(), this->admin_version.c_str(), json.c_str());
+ Debug(net, 6, "[admin] GameScript JSON from '{}' ({}): {}", this->admin_name, this->admin_version, json);
Game::NewEvent(new ScriptEventAdminPort(json));
return NETWORK_RECV_STATUS_OKAY;
@@ -526,7 +526,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(Packet *p)
uint32 d1 = p->Recv_uint32();
- DEBUG(net, 6, "[admin] Ping from '%s' (%s): %d", this->admin_name.c_str(), this->admin_version.c_str(), d1);
+ Debug(net, 6, "[admin] Ping from '{}' ({}): {}", this->admin_name, this->admin_version, d1);
return this->SendPong(d1);
}
@@ -662,7 +662,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(Packet *p)
this->status = ADMIN_STATUS_ACTIVE;
- DEBUG(net, 3, "[admin] '%s' (%s) has connected", this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
return this->SendProtocol();
}
@@ -682,7 +682,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENC
if (type >= ADMIN_UPDATE_END || (_admin_update_type_frequencies[type] & freq) != freq) {
/* The server does not know of this UpdateType. */
- DEBUG(net, 1, "[admin] Not supported update frequency %d (%d) from '%s' (%s)", type, freq, this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 1, "[admin] Not supported update frequency {} ({}) from '{}' ({})", type, freq, this->admin_name, this->admin_version);
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}
@@ -750,7 +750,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p)
default:
/* An unsupported "poll" update type. */
- DEBUG(net, 1, "[admin] Not supported poll %d (%d) from '%s' (%s).", type, d1, this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 1, "[admin] Not supported poll {} ({}) from '{}' ({}).", type, d1, this->admin_name, this->admin_version);
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}
@@ -776,7 +776,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet *p)
break;
default:
- DEBUG(net, 1, "[admin] Invalid chat action %d from admin '%s' (%s).", action, this->admin_name.c_str(), this->admin_version.c_str());
+ Debug(net, 1, "[admin] Invalid chat action {} from admin '{}' ({}).", action, this->admin_name, this->admin_version);
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}
@@ -852,7 +852,7 @@ void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code)
void NetworkAdminCompanyInfo(const Company *company, bool new_company)
{
if (company == nullptr) {
- DEBUG(net, 1, "[admin] Empty company given for update");
+ Debug(net, 1, "[admin] Empty company given for update");
return;
}
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 34129ad76..74d0bfc70 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -136,7 +136,7 @@ void ClientNetworkEmergencySave()
if (!_networking) return;
const char *filename = "netsave.sav";
- DEBUG(net, 3, "Performing emergency save: %s", filename);
+ Debug(net, 3, "Performing emergency save: {}", filename);
SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false);
}
@@ -173,7 +173,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
*/
if (this->sock == INVALID_SOCKET) return status;
- DEBUG(net, 3, "Closed client connection %d", this->client_id);
+ Debug(net, 3, "Closed client connection {}", this->client_id);
this->SendPackets(true);
@@ -285,8 +285,8 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
if (_sync_seed_1 != _random.state[0]) {
#endif
ShowNetworkError(STR_NETWORK_ERROR_DESYNC);
- DEBUG(desync, 1, "sync_err: %08x; %02x", _date, _date_fract);
- DEBUG(net, 0, "Sync error detected");
+ Debug(desync, 1, "sync_err: {:08x}; {:02x}", _date, _date_fract);
+ Debug(net, 0, "Sync error detected");
my_client->ClientError(NETWORK_RECV_STATUS_DESYNC);
return false;
}
@@ -301,7 +301,7 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
_sync_frame = 0;
} else if (_sync_frame < _frame_counter) {
- DEBUG(net, 1, "Missed frame for sync-test: %d / %d", _sync_frame, _frame_counter);
+ Debug(net, 1, "Missed frame for sync-test: {} / {}", _sync_frame, _frame_counter);
_sync_frame = 0;
}
}
@@ -777,7 +777,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(P
/* We do not know this GRF, bail out of initialization */
char buf[sizeof(c.md5sum) * 2 + 1];
md5sumToString(buf, lastof(buf), c.md5sum);
- DEBUG(grf, 0, "NewGRF %08X not found; checksum %s", BSWAP32(c.grfid), buf);
+ Debug(grf, 0, "NewGRF {:08X} not found; checksum {}", BSWAP32(c.grfid), buf);
ret = NETWORK_RECV_STATUS_NEWGRF_MISMATCH;
}
}
@@ -974,13 +974,13 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p
/* Receive the token. */
if (p->CanReadFromPacket(sizeof(uint8))) this->token = p->Recv_uint8();
- DEBUG(net, 7, "Received FRAME %d", _frame_counter_server);
+ Debug(net, 7, "Received FRAME {}", _frame_counter_server);
/* Let the server know that we received this frame correctly
* We do this only once per day, to save some bandwidth ;) */
if (!_network_first_time && last_ack_frame < _frame_counter) {
last_ack_frame = _frame_counter + DAY_TICKS;
- DEBUG(net, 7, "Sent ACK at %d", _frame_counter);
+ Debug(net, 7, "Sent ACK at {}", _frame_counter);
SendAck();
}
@@ -1096,7 +1096,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p)
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "", STR_NETWORK_MESSAGE_CLIENT_LEAVING);
delete ci;
} else {
- DEBUG(net, 1, "Unknown client (%d) is leaving the game", client_id);
+ Debug(net, 1, "Unknown client ({}) is leaving the game", client_id);
}
InvalidateWindowData(WC_CLIENT_LIST, 0);
@@ -1175,7 +1175,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p)
if (client_id == 0) {
/* definitely an invalid client id, debug message and do nothing. */
- DEBUG(net, 1, "Received invalid client index = 0");
+ Debug(net, 1, "Received invalid client index = 0");
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp
index d43e971ff..1a9849a34 100644
--- a/src/network/network_command.cpp
+++ b/src/network/network_command.cpp
@@ -332,7 +332,7 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp)
}
if (callback == lengthof(_callback_table)) {
- DEBUG(net, 0, "Unknown callback for command; no callback sent (command: %d)", cp->cmd);
+ Debug(net, 0, "Unknown callback for command; no callback sent (command: {})", cp->cmd);
callback = 0; // _callback_table[0] == nullptr
}
p->Send_uint8 (callback);
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 9b9dc6fc9..c97bab935 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -283,7 +283,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
}
NetworkAdminClientError(this->client_id, NETWORK_ERROR_CONNECTION_LOST);
- DEBUG(net, 3, "Closed client connection %d", this->client_id);
+ Debug(net, 3, "Closed client connection {}", this->client_id);
/* We just lost one client :( */
if (this->status >= STATUS_AUTHORIZED) _network_game_info.clients_on--;
@@ -445,7 +445,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
this->GetClientName(client_name, lastof(client_name));
- DEBUG(net, 1, "'%s' made an error and has been disconnected: %s", client_name, GetString(strid).c_str());
+ Debug(net, 1, "'{}' made an error and has been disconnected: {}", client_name, GetString(strid));
if (error == NETWORK_ERROR_KICKED && !reason.empty()) {
NetworkTextMessage(NETWORK_ACTION_KICKED, CC_DEFAULT, false, client_name, reason, strid);
@@ -466,7 +466,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
NetworkAdminClientError(this->client_id, error);
} else {
- DEBUG(net, 1, "Client %d made an error and has been disconnected: %s", this->client_id, GetString(strid).c_str());
+ Debug(net, 1, "Client {} made an error and has been disconnected: {}", this->client_id, GetString(strid));
}
/* The client made a mistake, so drop the connection now! */
@@ -925,7 +925,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
ci->join_date = _date;
ci->client_name = client_name;
ci->client_playas = playas;
- DEBUG(desync, 1, "client: %08x; %02x; %02x; %02x", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
+ Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
/* Make sure companies to which people try to join are not autocleaned */
if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0;
@@ -1133,7 +1133,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
StringID strid = GetNetworkErrorMsg(errorno);
- DEBUG(net, 1, "'%s' reported an error and is closing its connection: %s", client_name, GetString(strid).c_str());
+ Debug(net, 1, "'{}' reported an error and is closing its connection: {}", client_name, GetString(strid));
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid);
@@ -1323,7 +1323,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
break;
}
default:
- DEBUG(net, 1, "Received unknown chat destination type %d; doing broadcast instead", desttype);
+ Debug(net, 1, "Received unknown chat destination type {}; doing broadcast instead", desttype);
FALLTHROUGH;
case DESTTYPE_BROADCAST:
@@ -1425,11 +1425,11 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(Packet *p)
std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
if (_settings_client.network.rcon_password.compare(password) != 0) {
- DEBUG(net, 1, "[rcon] Wrong password from client-id %d", this->client_id);
+ Debug(net, 1, "[rcon] Wrong password from client-id {}", this->client_id);
return NETWORK_RECV_STATUS_OKAY;
}
- DEBUG(net, 3, "[rcon] Client-id %d executed: %s", this->client_id, command.c_str());
+ Debug(net, 3, "[rcon] Client-id {} executed: {}", this->client_id, command);
_redirect_console_to_client = this->client_id;
IConsoleCmdExec(command.c_str());
@@ -1453,7 +1453,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet *p)
/* Incorrect password sent, return! */
if (_network_company_states[company_id].password.compare(password) != 0) {
- DEBUG(net, 2, "Wrong password from client-id #%d for company #%d", this->client_id, company_id + 1);
+ Debug(net, 2, "Wrong password from client-id #{} for company #{}", this->client_id, company_id + 1);
return NETWORK_RECV_STATUS_OKAY;
}
}
@@ -1561,7 +1561,7 @@ void NetworkUpdateClientInfo(ClientID client_id)
if (ci == nullptr) return;
- DEBUG(desync, 1, "client: %08x; %02x; %02x; %04x", _date, _date_fract, (int)ci->client_playas, client_id);
+ Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", _date, _date_fract, (int)ci->client_playas, client_id);
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
@@ -1576,7 +1576,7 @@ void NetworkUpdateClientInfo(ClientID client_id)
static void NetworkCheckRestartMap()
{
if (_settings_client.network.restart_game_year != 0 && _cur_year >= _settings_client.network.restart_game_year) {
- DEBUG(net, 3, "Auto-restarting map: year %d reached", _cur_year);
+ Debug(net, 3, "Auto-restarting map: year {} reached", _cur_year);
_settings_newgame.game_creation.generation_seed = GENERATE_NEW_SEED;
switch(_file_to_saveload.abstract_ftype) {
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index a0d9ae136..6ad84aa2e 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -67,7 +67,7 @@ struct UDPSocket {
std::unique_lock<std::mutex> lock(mutex, std::defer_lock);
if (!lock.try_lock()) {
if (++receive_iterations_locked % 32 == 0) {
- DEBUG(net, 0, "%s background UDP loop processing appears to be blocked. Your OS may be low on UDP send buffers.", name.c_str());
+ Debug(net, 0, "{} background UDP loop processing appears to be blocked. Your OS may be low on UDP send buffers.", name);
}
return;
}
@@ -133,7 +133,7 @@ public:
void MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr)
{
_network_advertise_retries = 0;
- DEBUG(net, 3, "Advertising on master server successful (%s)", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
+ Debug(net, 3, "Advertising on master server successful ({})", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
/* We are advertised, but we don't want to! */
if (!_settings_client.network.server_advertise) NetworkUDPRemoveAdvertise(false);
@@ -142,7 +142,7 @@ void MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER(Packet *p, Netwo
void MasterNetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr)
{
_session_key = p->Recv_uint64();
- DEBUG(net, 6, "Received new session key from master server (%s)", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
+ Debug(net, 6, "Received new session key from master server ({})", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
}
///*** Communication with clients (we are server) ***/
@@ -175,7 +175,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, Networ
/* Let the client know that we are here */
this->SendPacket(&packet, client_addr);
- DEBUG(net, 7, "Queried from %s", client_addr->GetHostname());
+ Debug(net, 7, "Queried from {}", client_addr->GetHostname());
}
void ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr)
@@ -252,7 +252,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, Networ
uint8 in_reply_count = 0;
size_t packet_len = 0;
- DEBUG(net, 7, "NewGRF data request from %s", client_addr->GetAddressAsString().c_str());
+ Debug(net, 7, "NewGRF data request from {}", client_addr->GetAddressAsString());
num_grfs = p->Recv_uint8 ();
if (num_grfs > NETWORK_MAX_GRF_COUNT) return;
@@ -314,7 +314,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(Packet *p, NetworkAd
/* Just a fail-safe.. should never happen */
if (_network_udp_server) return;
- DEBUG(net, 3, "Server response from %s", client_addr->GetAddressAsString().c_str());
+ Debug(net, 3, "Server response from {}", client_addr->GetAddressAsString());
/* Find next item */
item = NetworkGameListAddItem(client_addr->GetAddressAsString(false));
@@ -409,7 +409,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAdd
uint8 num_grfs;
uint i;
- DEBUG(net, 7, "NewGRF data reply from %s", client_addr->GetAddressAsString().c_str());
+ Debug(net, 7, "NewGRF data reply from {}", client_addr->GetAddressAsString());
num_grfs = p->Recv_uint8 ();
if (num_grfs > NETWORK_MAX_GRF_COUNT) return;
@@ -440,7 +440,7 @@ static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket)
for (NetworkAddress &addr : _broadcast_list) {
Packet p(PACKET_UDP_CLIENT_FIND_SERVER);
- DEBUG(net, 5, "Broadcasting to %s", addr.GetHostname());
+ Debug(net, 5, "Broadcasting to {}", addr.GetHostname());
socket->SendPacket(&p, &addr, true, true);
}
@@ -460,7 +460,7 @@ void NetworkUDPQueryMasterServer()
std::lock_guard<std::mutex> lock(_udp_client.mutex);
_udp_client.socket->SendPacket(&p, &out_addr, true);
- DEBUG(net, 6, "Master server queried at %s", out_addr.GetAddressAsString().c_str());
+ Debug(net, 6, "Master server queried at {}", out_addr.GetAddressAsString());
}
/** Find all servers */
@@ -469,7 +469,7 @@ void NetworkUDPSearchGame()
/* We are still searching.. */
if (_network_udp_broadcast > 0) return;
- DEBUG(net, 3, "Searching server");
+ Debug(net, 3, "Searching server");
NetworkUDPBroadCast(_udp_client.socket);
_network_udp_broadcast = 300; // Stay searching for 300 ticks
@@ -480,7 +480,7 @@ void NetworkUDPSearchGame()
*/
static void NetworkUDPRemoveAdvertiseThread()
{
- DEBUG(net, 3, "Removing advertise from master server");
+ Debug(net, 3, "Removing advertise from master server");
/* Find somewhere to send */
NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);
@@ -517,22 +517,22 @@ static void NetworkUDPAdvertiseThread()
/* Find somewhere to send */
NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);
- DEBUG(net, 3, "Advertising to master server");
+ Debug(net, 3, "Advertising to master server");
/* Add a bit more messaging when we cannot get a session key */
static byte session_key_retries = 0;
if (_session_key == 0 && session_key_retries++ == 2) {
- DEBUG(net, 0, "Advertising to the master server is failing");
- DEBUG(net, 0, " we are not receiving the session key from the server");
- DEBUG(net, 0, " please allow udp packets from %s to you to be delivered", out_addr.GetAddressAsString(false).c_str());
- DEBUG(net, 0, " please allow udp packets from you to %s to be delivered", out_addr.GetAddressAsString(false).c_str());
+ Debug(net, 0, "Advertising to the master server is failing");
+ Debug(net, 0, " we are not receiving the session key from the server");
+ Debug(net, 0, " please allow udp packets from {} to you to be delivered", out_addr.GetAddressAsString(false));
+ Debug(net, 0, " please allow udp packets from you to {} to be delivered", out_addr.GetAddressAsString(false));
}
if (_session_key != 0 && _network_advertise_retries == 0) {
- DEBUG(net, 0, "Advertising to the master server is failing");
- DEBUG(net, 0, " we are not receiving the acknowledgement from the server");
- DEBUG(net, 0, " this usually means that the master server cannot reach us");
- DEBUG(net, 0, " please allow udp and tcp packets to port %u to be delivered", _settings_client.network.server_port);
- DEBUG(net, 0, " please allow udp and tcp packets from port %u to be delivered", _settings_client.network.server_port);
+ Debug(net, 0, "Advertising to the master server is failing");
+ Debug(net, 0, " we are not receiving the acknowledgement from the server");
+ Debug(net, 0, " this usually means that the master server cannot reach us");
+ Debug(net, 0, " please allow udp and tcp packets to port {} to be delivered", _settings_client.network.server_port);
+ Debug(net, 0, " please allow udp and tcp packets from port {} to be delivered", _settings_client.network.server_port);
}
/* Send the packet */
@@ -588,7 +588,7 @@ void NetworkUDPInitialize()
/* If not closed, then do it. */
if (_udp_server.socket != nullptr) NetworkUDPClose();
- DEBUG(net, 3, "Initializing UDP listeners");
+ Debug(net, 3, "Initializing UDP listeners");
assert(_udp_client.socket == nullptr && _udp_server.socket == nullptr && _udp_master.socket == nullptr);
std::scoped_lock lock(_udp_client.mutex, _udp_server.mutex, _udp_master.mutex);
@@ -624,7 +624,7 @@ void NetworkUDPClose()
_network_udp_server = false;
_network_udp_broadcast = 0;
- DEBUG(net, 5, "Closed UDP listeners");
+ Debug(net, 5, "Closed UDP listeners");
}
/** Receive the UDP packets. */