Handle ERR_DROP during Com_GameRestart
If ERR_DROP during Com_GameRestart after shutting down client, Com_Error needs to restart the client otherwise there is just a black window. Also, clear the game restarting flag in Com_Error otherwise it's not possible to run Com_GameRestart again later. I don't know of a way to trigger ERR_DROP, in FS_Restart for instance, without engine changes however.
This commit is contained in:
parent
978afd7590
commit
c80f341711
1 changed files with 21 additions and 6 deletions
|
@ -115,6 +115,7 @@ int com_frameNumber;
|
||||||
qboolean com_errorEntered = qfalse;
|
qboolean com_errorEntered = qfalse;
|
||||||
qboolean com_fullyInitialized = qfalse;
|
qboolean com_fullyInitialized = qfalse;
|
||||||
qboolean com_gameRestarting = qfalse;
|
qboolean com_gameRestarting = qfalse;
|
||||||
|
qboolean com_gameClientRestarting = qfalse;
|
||||||
|
|
||||||
char com_errorMessage[MAXPRINTMSG];
|
char com_errorMessage[MAXPRINTMSG];
|
||||||
|
|
||||||
|
@ -264,6 +265,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
|
||||||
static int lastErrorTime;
|
static int lastErrorTime;
|
||||||
static int errorCount;
|
static int errorCount;
|
||||||
int currentTime;
|
int currentTime;
|
||||||
|
qboolean restartClient;
|
||||||
|
|
||||||
if(com_errorEntered)
|
if(com_errorEntered)
|
||||||
Sys_Error("recursive error after: %s", com_errorMessage);
|
Sys_Error("recursive error after: %s", com_errorMessage);
|
||||||
|
@ -296,9 +298,17 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
|
||||||
if (code != ERR_DISCONNECT && code != ERR_NEED_CD)
|
if (code != ERR_DISCONNECT && code != ERR_NEED_CD)
|
||||||
Cvar_Set("com_errorMessage", com_errorMessage);
|
Cvar_Set("com_errorMessage", com_errorMessage);
|
||||||
|
|
||||||
|
restartClient = com_gameClientRestarting && !( com_cl_running && com_cl_running->integer );
|
||||||
|
|
||||||
|
com_gameRestarting = qfalse;
|
||||||
|
com_gameClientRestarting = qfalse;
|
||||||
|
|
||||||
if (code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT) {
|
if (code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT) {
|
||||||
VM_Forced_Unload_Start();
|
VM_Forced_Unload_Start();
|
||||||
SV_Shutdown( "Server disconnected" );
|
SV_Shutdown( "Server disconnected" );
|
||||||
|
if ( restartClient ) {
|
||||||
|
CL_Init();
|
||||||
|
}
|
||||||
CL_Disconnect( qtrue );
|
CL_Disconnect( qtrue );
|
||||||
CL_FlushMemory( );
|
CL_FlushMemory( );
|
||||||
VM_Forced_Unload_Done();
|
VM_Forced_Unload_Done();
|
||||||
|
@ -310,6 +320,9 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
|
||||||
Com_Printf ("********************\nERROR: %s\n********************\n", com_errorMessage);
|
Com_Printf ("********************\nERROR: %s\n********************\n", com_errorMessage);
|
||||||
VM_Forced_Unload_Start();
|
VM_Forced_Unload_Start();
|
||||||
SV_Shutdown (va("Server crashed: %s", com_errorMessage));
|
SV_Shutdown (va("Server crashed: %s", com_errorMessage));
|
||||||
|
if ( restartClient ) {
|
||||||
|
CL_Init();
|
||||||
|
}
|
||||||
CL_Disconnect( qtrue );
|
CL_Disconnect( qtrue );
|
||||||
CL_FlushMemory( );
|
CL_FlushMemory( );
|
||||||
VM_Forced_Unload_Done();
|
VM_Forced_Unload_Done();
|
||||||
|
@ -319,6 +332,9 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
|
||||||
} else if ( code == ERR_NEED_CD ) {
|
} else if ( code == ERR_NEED_CD ) {
|
||||||
VM_Forced_Unload_Start();
|
VM_Forced_Unload_Start();
|
||||||
SV_Shutdown( "Server didn't have CD" );
|
SV_Shutdown( "Server didn't have CD" );
|
||||||
|
if ( restartClient ) {
|
||||||
|
CL_Init();
|
||||||
|
}
|
||||||
if ( com_cl_running && com_cl_running->integer ) {
|
if ( com_cl_running && com_cl_running->integer ) {
|
||||||
CL_Disconnect( qtrue );
|
CL_Disconnect( qtrue );
|
||||||
CL_FlushMemory( );
|
CL_FlushMemory( );
|
||||||
|
@ -2362,16 +2378,14 @@ void Com_GameRestart(int checksumFeed, qboolean disconnect)
|
||||||
// make sure no recursion can be triggered
|
// make sure no recursion can be triggered
|
||||||
if(!com_gameRestarting && com_fullyInitialized)
|
if(!com_gameRestarting && com_fullyInitialized)
|
||||||
{
|
{
|
||||||
int clWasRunning;
|
|
||||||
|
|
||||||
com_gameRestarting = qtrue;
|
com_gameRestarting = qtrue;
|
||||||
clWasRunning = com_cl_running->integer;
|
com_gameClientRestarting = com_cl_running->integer;
|
||||||
|
|
||||||
// Kill server if we have one
|
// Kill server if we have one
|
||||||
if(com_sv_running->integer)
|
if(com_sv_running->integer)
|
||||||
SV_Shutdown("Game directory changed");
|
SV_Shutdown("Game directory changed");
|
||||||
|
|
||||||
if(clWasRunning)
|
if(com_gameClientRestarting)
|
||||||
{
|
{
|
||||||
if(disconnect)
|
if(disconnect)
|
||||||
CL_Disconnect(qfalse);
|
CL_Disconnect(qfalse);
|
||||||
|
@ -2393,13 +2407,14 @@ void Com_GameRestart(int checksumFeed, qboolean disconnect)
|
||||||
NET_Restart_f();
|
NET_Restart_f();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(clWasRunning)
|
if(com_gameClientRestarting)
|
||||||
{
|
{
|
||||||
CL_Init();
|
CL_Init();
|
||||||
CL_StartHunkUsers(qfalse);
|
CL_StartHunkUsers(qfalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
com_gameRestarting = qfalse;
|
com_gameRestarting = qfalse;
|
||||||
|
com_gameClientRestarting = qfalse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue