ref: df34acd44e62ce727cc85ee48b3c3bb7567e831d
parent: ab134749048360f18e829a34775716d713b7430b
author: Simon Howard <fraggle@soulsphere.org>
date: Fri Apr 20 18:43:22 EDT 2018
net: Move server reject message into error message. Since we surface error messages in dialog boxes, it's important that the full context of why a connection attempt was rejected is shown to the user, otherwise it just appears as "failed to connect" with no indication of why or how to fix the problem. Thanks to AgitationSkeleton and GuyNamedErick for help identifying this problem.
--- a/src/d_loop.c
+++ b/src/d_loop.c
@@ -512,8 +512,8 @@
if (!NET_CL_Connect(addr, connect_data))
{
- I_Error("D_InitNetGame: Failed to connect to %s\n",
- NET_AddrToString(addr));
+ I_Error("D_InitNetGame: Failed to connect to %s:\n%s\n",
+ NET_AddrToString(addr), net_client_reject_reason);
}
printf("D_InitNetGame: Connected to %s\n", NET_AddrToString(addr));
--- a/src/net_client.h
+++ b/src/net_client.h
@@ -37,6 +37,7 @@
extern boolean net_client_connected;
extern boolean net_client_received_wait_data;
extern net_waitdata_t net_client_wait_data;
+extern char *net_client_reject_reason;
extern boolean net_waiting_for_launch;
extern char *net_player_name;
--- a/src/net_common.c
+++ b/src/net_common.c
@@ -46,6 +46,9 @@
net_reliable_packet_t *next;
};
+// Why did the server reject us?
+char *net_client_reject_reason = NULL;
+
static void NET_Conn_Init(net_connection_t *conn, net_addr_t *addr,
net_protocol_t protocol)
{
@@ -139,7 +142,8 @@
conn->state = NET_CONN_STATE_DISCONNECTED;
conn->disconnect_reason = NET_DISCONNECT_REMOTE;
- printf("Rejected by server: %s\n", msg);
+ free(net_client_reject_reason);
+ net_client_reject_reason = strdup(msg);
}
}