cls.demostarting = true;
// disconnect from server
- if(cls.state == ca_connected)
- CL_Disconnect();
- if(sv.active)
- SV_Shutdown();
+ CL_Disconnect();
// update networking ports (this is mainly just needed at startup)
NetConn_UpdateSockets();
return;
if (cls.demonum == -1)
cls.demonum = 1;
- CL_Disconnect_f (cmd);
- CL_NextDemo ();
+ CL_Disconnect();
+ CL_NextDemo();
}
/*
{
Con_Print("CL_SendMove: lost server connection\n");
CL_Disconnect();
- SV_LockThreadMutex();
- SV_Shutdown();
- SV_UnlockThreadMutex();
}
}
// If we're dropped mid-connection attempt, it won't clear otherwise.
SCR_ClearLoadingScreen(false);
+
+ if(host.hook.SV_Shutdown)
+ host.hook.SV_Shutdown();
}
/*
void CL_Disconnect_f(cmd_state_t *cmd)
{
- CL_Disconnect ();
- if (sv.active)
- SV_Shutdown ();
+ CL_Disconnect();
}
if (cls.demoplayback)
{
- CL_Disconnect_f(cmd_local);
+ CL_Disconnect();
cls.demonum = 0;
}
Cvar_SetValueQuick(&csqc_progcrc, -1);
Cvar_SetValueQuick(&csqc_progsize, -1);
- SV_LockThreadMutex();
- SV_Shutdown ();
- SV_UnlockThreadMutex();
+ if(host.hook.SV_Shutdown)
+ host.hook.SV_Shutdown();
if (cls.state == ca_dedicated)
Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit
host.hook.Disconnect = NULL;
host.hook.ToggleMenu = NULL;
host.hook.CL_Intermission = NULL;
- host.hook.SV_CanSave = NULL;
+ host.hook.SV_Shutdown = NULL;
host.state = host_init;
SV_StopThread();
// shut down local server if active
- SV_LockThreadMutex();
- SV_Shutdown ();
- SV_UnlockThreadMutex();
+ if(host.hook.SV_Shutdown)
+ host.hook.SV_Shutdown();
// AK shutdown PRVM
// AK hmm, no PRVM_Shutdown(); yet
qbool (*CL_Intermission)(void); // Quake compatibility
void (*CL_SendCvar)(struct cmd_state_s *);
void (*SV_SendCvar)(struct cmd_state_s *);
+ void (*SV_Shutdown)(void);
} hook;
} host_t;
#ifdef CONFIG_MENU
M_Update_Return_Reason("");
#endif
- // if we're connecting to a remote server, shut down any local server
- if (LHNETADDRESS_GetAddressType(peeraddress) != LHNETADDRESSTYPE_LOOP && sv.active)
- {
- SV_LockThreadMutex();
- SV_Shutdown ();
- SV_UnlockThreadMutex();
- }
+ // Disconnect from the current server or stop demo playback
if(cls.state == ca_connected || cls.demoplayback)
CL_Disconnect();
// allocate a net connection to keep track of things
{
Con_Print("Connection timed out\n");
CL_Disconnect();
- SV_LockThreadMutex();
- SV_Shutdown ();
- SV_UnlockThreadMutex();
}
}
Cvar_RegisterVariable (&sv_writepicture_quality);
SV_InitOperatorCommands();
+ host.hook.SV_Shutdown = SV_Shutdown;
sv_mempool = Mem_AllocPool("server", 0, NULL);
prvm_prog_t *prog = SVVM_prog;
int i;
- Con_DPrintf("SV_Shutdown\n");
+ SV_LockThreadMutex();
if (!sv.active)
- return;
+ goto end;
+
+ Con_DPrintf("SV_Shutdown\n");
NetConn_Heartbeat(2);
NetConn_Heartbeat(2);
//
memset(&sv, 0, sizeof(sv));
memset(svs.clients, 0, svs.maxclients*sizeof(client_t));
+end:
+ SV_UnlockThreadMutex();
}
/////////////////////////////////////////////////////