From fbfc886b229db2e52ff4a58cdd35b58a9308be2b Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Mon, 28 Aug 2006 00:44:59 +0000 Subject: [PATCH] Fix crash when recording to files and the map changes. Was caused by new, correct, behaviour of FS_Restart() which would close the files before they'd be closed by the client. --- code/client/cl_main.c | 3 +++ code/client/cl_parse.c | 9 ++++++++- code/client/client.h | 1 + code/qcommon/common.c | 7 ++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 2df8cb15..6fc4cabe 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -1199,6 +1199,9 @@ void CL_Vid_Restart_f( void ) { CL_CloseAVI( ); } + if(clc.demorecording) + CL_StopRecord_f(); + // don't let them loop during the restart S_StopAllSounds(); // shutdown the UI diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index d8ad6d73..e6b655a9 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -482,8 +482,15 @@ void CL_ParseGamestate( msg_t *msg ) { // parse serverId and other cvars CL_SystemInfoChanged(); + // stop recording before FS_Restart closes the demo file + if(clc.demorecording) + CL_StopRecord_f(); + // same fore AVI recording + if(CL_VideoRecording()) + CL_CloseAVI(); + // reinitialize the filesystem if the game directory has changed - FS_ConditionalRestart( clc.checksumFeed ); + FS_ConditionalRestart( clc.checksumFeed ); // This used to call CL_StartHunkUsers, but now we enter the download state before loading the // cgame diff --git a/code/client/client.h b/code/client/client.h index 9db786a8..89ea4c60 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -376,6 +376,7 @@ void CL_Snd_Restart_f (void); void CL_StartDemoLoop( void ); void CL_NextDemo( void ); void CL_ReadDemoMessage( void ); +void CL_StopRecord_f(void); void CL_InitDownloads(void); void CL_NextDownload(void); diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 438f049b..efb7851e 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -262,9 +262,6 @@ void QDECL Com_Error( int code, const char *fmt, ... ) { code = ERR_FATAL; } - // make sure we can get at our local stuff - FS_PureServerSetLoadedPaks( "", "" ); - // if we are getting a solid stream of ERR_DROP, do an ERR_FATAL currentTime = Sys_Milliseconds(); if ( currentTime - lastErrorTime < 100 ) { @@ -292,6 +289,8 @@ void QDECL Com_Error( int code, const char *fmt, ... ) { if ( code == ERR_SERVERDISCONNECT ) { CL_Disconnect( qtrue ); CL_FlushMemory( ); + // make sure we can get at our local stuff + FS_PureServerSetLoadedPaks("", ""); com_errorEntered = qfalse; longjmp (abortframe, -1); } else if ( code == ERR_DROP || code == ERR_DISCONNECT ) { @@ -299,6 +298,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) { SV_Shutdown (va("Server crashed: %s", com_errorMessage)); CL_Disconnect( qtrue ); CL_FlushMemory( ); + FS_PureServerSetLoadedPaks("", ""); com_errorEntered = qfalse; longjmp (abortframe, -1); } else if ( code == ERR_NEED_CD ) { @@ -311,6 +311,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) { } else { Com_Printf("Server didn't have CD\n" ); } + FS_PureServerSetLoadedPaks("", ""); longjmp (abortframe, -1); } else { CL_Shutdown ();