summaryrefslogtreecommitdiff
path: root/src/qcommon
diff options
context:
space:
mode:
authorThilo Schulz <arny@ats.s.bawue.de>2011-06-21 11:18:35 +0000
committerTim Angus <tim@ngus.net>2013-01-10 21:47:33 +0000
commit555eaebb1b7cb7c4a5e1036892b0effbd62766ae (patch)
tree1038802c3629c85c47a62a5013f2a7271d485bec /src/qcommon
parente09392335162f87cd16257506e600268c2cd8ec9 (diff)
- Improve game_restart: * differing screen resolutions and network settings are now honoured when changing fs_game * Fix hunk memory leak on game_restart * Move cls.state and cls.servername to clc so connection state is fully preserved over game_restart * Revert back to previous fs_game after disconnecting from a server that triggered a game_restart * Fix error dialog popping up after every game_restart if an error happened previously (reported by Ensiform) - Fixed that not all commands added by CL_Init() would be removed by CL_Shutdown()
Diffstat (limited to 'src/qcommon')
-rw-r--r--src/qcommon/common.c39
-rw-r--r--src/qcommon/files.c7
-rw-r--r--src/qcommon/qcommon.h16
3 files changed, 38 insertions, 24 deletions
diff --git a/src/qcommon/common.c b/src/qcommon/common.c
index 9a9ca12d..160501b5 100644
--- a/src/qcommon/common.c
+++ b/src/qcommon/common.c
@@ -337,7 +337,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
longjmp (abortframe, -1);
} else {
VM_Forced_Unload_Start();
- CL_Shutdown (va("Client fatal crashed: %s", com_errorMessage));
+ CL_Shutdown (va("Client fatal crashed: %s", com_errorMessage), qtrue);
SV_Shutdown (va("Server fatal crashed: %s", com_errorMessage));
VM_Forced_Unload_Done();
}
@@ -362,7 +362,7 @@ void Com_Quit_f( void ) {
char *p = Cmd_Args( );
if ( !com_errorEntered ) {
SV_Shutdown (p[0] ? p : "Server quit");
- CL_Shutdown (p[0] ? p : "Client quit");
+ CL_Shutdown (p[0] ? p : "Client quit", qtrue);
Com_Shutdown ();
FS_Shutdown(qtrue);
}
@@ -2385,34 +2385,46 @@ Change to a new mod properly with cleaning up cvars before switching.
==================
*/
-void Com_GameRestart(int checksumFeed, qboolean clientRestart)
+void Com_GameRestart(int checksumFeed, qboolean disconnect)
{
// make sure no recursion can be triggered
if(!com_gameRestarting && com_fullyInitialized)
{
+ int clWasRunning = com_cl_running->integer;
+
com_gameRestarting = qtrue;
- if(clientRestart)
- {
- CL_Disconnect(qfalse);
- CL_ShutdownAll();
- }
-
// Kill server if we have one
if(com_sv_running->integer)
SV_Shutdown("Game directory changed");
+ if(clWasRunning)
+ {
+ if(disconnect)
+ CL_Disconnect(qfalse);
+
+ CL_Shutdown("Game directory changed", disconnect);
+ }
+
FS_Restart(checksumFeed);
// Clean out any user and VM created cvars
Cvar_Restart(qtrue);
Com_ExecuteCfg();
- // shut down sound system before restart
- CL_Snd_Shutdown();
-
- if(clientRestart)
+ if(disconnect)
+ {
+ // We don't want to change any network settings if gamedir
+ // change was triggered by a connect to server because the
+ // new network settings might make the connection fail.
+ NET_Restart_f();
+ }
+
+ if(clWasRunning)
+ {
+ CL_Init();
CL_StartHunkUsers(qfalse);
+ }
com_gameRestarting = qfalse;
}
@@ -2633,6 +2645,7 @@ void Com_Init( char *commandLine ) {
com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "0", CVAR_ARCHIVE );
com_abnormalExit = Cvar_Get( "com_abnormalExit", "0", CVAR_ROM );
com_busyWait = Cvar_Get("com_busyWait", "0", CVAR_ARCHIVE);
+ Cvar_Get("com_errorMessage", "", CVAR_ROM | CVAR_NORESTART);
s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ );
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
diff --git a/src/qcommon/files.c b/src/qcommon/files.c
index e2ca20d0..c11e9ba8 100644
--- a/src/qcommon/files.c
+++ b/src/qcommon/files.c
@@ -3587,19 +3587,16 @@ FS_ConditionalRestart
restart if necessary
=================
*/
-qboolean FS_ConditionalRestart(int checksumFeed)
+qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect)
{
if(fs_gamedirvar->modified)
{
- Com_GameRestart(checksumFeed, qfalse);
+ Com_GameRestart(checksumFeed, disconnect);
return qtrue;
}
else if(checksumFeed != fs_checksumFeed)
- {
FS_Restart(checksumFeed);
- return qtrue;
- }
return qfalse;
}
diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h
index 4b1d48c2..10f548e3 100644
--- a/src/qcommon/qcommon.h
+++ b/src/qcommon/qcommon.h
@@ -585,7 +585,7 @@ qboolean FS_Initialized( void );
void FS_InitFilesystem ( void );
void FS_Shutdown( qboolean closemfp );
-qboolean FS_ConditionalRestart( int checksumFeed );
+qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect);
void FS_Restart( int checksumFeed );
// shutdown and restart the filesystem so changes to fs_gamedir can take effect
@@ -796,7 +796,7 @@ void QDECL Com_Printf( const char *fmt, ... ) __attribute__ ((format (printf,
void QDECL Com_DPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
void Com_Quit_f( void );
-void Com_GameRestart(int checksumFeed, qboolean clientRestart);
+void Com_GameRestart(int checksumFeed, qboolean disconnect);
int Com_Milliseconds( void ); // will be journaled properly
unsigned Com_BlockChecksum( const void *buffer, int length );
@@ -847,6 +847,7 @@ extern int time_backend; // renderer backend time
extern int com_frameTime;
extern qboolean com_errorEntered;
+extern qboolean com_fullyInitialized;
extern fileHandle_t com_journalFile;
extern fileHandle_t com_journalDataFile;
@@ -936,7 +937,7 @@ void CL_InitKeyCommands( void );
void CL_Init( void );
void CL_Disconnect( qboolean showMainMenu );
-void CL_Shutdown( char *finalmsg );
+void CL_Shutdown(char *finalmsg, qboolean disconnect);
void CL_Frame( int msec );
qboolean CL_GameCommand( void );
void CL_KeyEvent (int key, qboolean down, unsigned time);
@@ -966,12 +967,15 @@ void CL_ForwardCommandToServer( const char *string );
void CL_CDDialog( void );
// bring up the "need a cd to play" dialog
-void CL_ShutdownAll( void );
-// shutdown all the client stuff
-
void CL_FlushMemory( void );
// dump all memory on an error
+void CL_ShutdownAll(qboolean shutdownRef);
+// shutdown client
+
+void CL_InitRef(void);
+// initialize renderer interface
+
void CL_StartHunkUsers( qboolean rendererOnly );
// start all the client stuff using the hunk