Skip to content
Snippets Groups Projects
Commit 2308441e authored by Yukita Mayako's avatar Yukita Mayako
Browse files

Fix client connection-failed crash.

parent 1ee2b465
No related branches found
No related tags found
No related merge requests found
......@@ -897,8 +897,7 @@ static void CL_ConnectToServer(boolean viams)
cl_mode = cl_askjoin; // don't break case continue to cljoin request now
case cl_askjoin:
if (!server) // the server already has their files loaded, duh!
CL_LoadServerFiles();
//CL_LoadServerFiles();
if (CL_SendJoin()) // Send join request, server instantly connects.
cl_mode = server ? cl_connected : cl_waitjoinresponse;
break;
......@@ -1070,10 +1069,15 @@ static void Command_connect(void)
}
else
{
boolean success = false;
if (COM_Argc() >= 3)
D_NetConnect(COM_Argv(1), COM_Argv(2));
success = D_NetConnect(COM_Argv(1), COM_Argv(2));
else
D_NetConnect(COM_Argv(1), NULL);
success = D_NetConnect(COM_Argv(1), NULL);
if (!success) {
M_StartMessage(M_GetText("Failed to connect to server.\n\nPress ESC\n"), NULL, MM_NOTHING);
return;
}
}
}
......
......@@ -225,7 +225,7 @@ void D_NetOpen(void)
net_playercount = 0;
}
void D_NetConnect(const char *hostname, const char *port)
boolean D_NetConnect(const char *hostname, const char *port)
{
ENetAddress address;
ENetEvent e;
......@@ -250,10 +250,12 @@ void D_NetConnect(const char *hostname, const char *port)
if (enet_host_service(ClientHost, &e, 5000) > 0
&& e.type == ENET_EVENT_TYPE_CONNECT)
{
CONS_Printf("Connection successful!");
return;
CONS_Printf("NETWORK: Connection successful!");
return true;
}
M_StartMessage(M_GetText("Failed to connect to server.\n\nPress ESC\n"), NULL, MM_NOTHING);
enet_host_destroy(ClientHost);
ClientHost = NULL;
return false;
}
// Initialize network.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment