Keep sockets opened after first disconnect
Fixes #376 (closed).
Symptoms: connecting to a server and trying to change server will timeout.
The underlying problem is that global variables clientport
and clientport2
of netconn.c
are not initialized. On disconnect they get updated with the Cvar_Callback(&cl_netport);
from here. Network logic will notice they changed, and therefore close/reopen the sockets.
Problem is that we are between two servers, and the disconnect happens after the connection to the second server. When closing socket we lose the server info sitting in socket's buffer. That's why we timeout.
The fix I applied is to properly initialize the variables in CL_Init
as its already done in SV_Init
.
This effectively fix the common use case: launch game -> connect -> change server. Note that you'll still probably get a timeout if you change cl_port
while connected to a server and then try to directly hop to another one, for the same reasons described above.