Disconnect when we're connected before starting an new game.

The old code was working only when the client was connected to a local
server. The 'newgame' executed by the menu expands to a 'map', loading
a map ends in SV_InitGame() which calls CL_Drop() on the local client.
That calls CL_Disconnect() and everything is okay.
When the client is already connected to a remote server and no local
server is running the 'map' command spawns a new local server. This
new server thinks "Hey, I'm a new local server and no one is connected
to me. Let's pull the client in!". So it pull the already connected
client onto a new server without disconnecting, smashing it's state.
And everything goes down in flames.

The correct way would be to execute a 'disconnect' right before the
'newgame'. But the 'disconnect' cmd calls CL_Disconnect_f that throws
an ERR_DROP. ERR_DROP is implememted through a longjump(), jumping
around puts the process internal state in ashes... So bite the bullet
and add another hack: Call CL_Disconnect() before executing 'newgame'.
This commit is contained in:
Yamagi Burmeister 2018-03-07 21:49:58 +01:00
parent ed54fe2364
commit 808a208de4

View file

@ -2085,6 +2085,11 @@ static menuseparator_s s_blankline;
static void
StartGame(void)
{
if (cls.state != ca_disconnected && cls.state != ca_uninitialized)
{
CL_Disconnect();
}
/* disable updates and start the cinematic going */
cl.servercount = -1;
M_ForceMenuOff();