Offer post-crash safe settings on a per-mod basis
Offer to restore settings when loading a mod that crashed, not the first mod that gets loaded after a crash. Before the first mod loaded (usually baseq3) would get the option even if missionpack or some other mod crashed. - Make pid files separate for each fs_game. - Remove/write pid every time switching fs_game. - Create path before writing pid file otherwise it fails on first run. - Show mod description.txt or fs_game instead of engine name in abnormal exit message. - Check com_fullyInitialized in Com_Error before removing PID, otherwise "ioquake3 --version" segfaults when accessing fs_gamevar->string (plus not fully initialized isn't really a normal shutdown).
This commit is contained in:
parent
1246d16834
commit
755b2f38f0
4 changed files with 87 additions and 41 deletions
|
@ -2776,17 +2776,7 @@ void Com_Init( char *commandLine ) {
|
|||
|
||||
Sys_Init();
|
||||
|
||||
if( Sys_WritePIDFile( ) ) {
|
||||
#ifndef DEDICATED
|
||||
const char *message = "The last time " CLIENT_WINDOW_TITLE " ran, "
|
||||
"it didn't exit properly. This may be due to inappropriate video "
|
||||
"settings. Would you like to start with \"safe\" video settings?";
|
||||
|
||||
if( Sys_Dialog( DT_YES_NO, message, "Abnormal Exit" ) == DR_YES ) {
|
||||
Cvar_Set( "com_abnormalExit", "1" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Sys_InitPIDFile( FS_GetCurrentGameDir() );
|
||||
|
||||
// Pick a random port value
|
||||
Com_RandomBytes( (byte*)&qport, sizeof(int) );
|
||||
|
|
|
@ -2482,6 +2482,33 @@ static char** Sys_ConcatenateFileLists( char **list0, char **list1 )
|
|||
return cat;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
FS_GetModDescription
|
||||
================
|
||||
*/
|
||||
void FS_GetModDescription( const char *modDir, char *description, int descriptionLen ) {
|
||||
fileHandle_t descHandle;
|
||||
char descPath[MAX_QPATH];
|
||||
int nDescLen;
|
||||
FILE *file;
|
||||
|
||||
Com_sprintf( descPath, sizeof ( descPath ), "%s/description.txt", modDir );
|
||||
nDescLen = FS_SV_FOpenFileRead( descPath, &descHandle );
|
||||
|
||||
if ( nDescLen > 0 && descHandle ) {
|
||||
file = FS_FileForHandle(descHandle);
|
||||
Com_Memset( description, 0, descriptionLen );
|
||||
nDescLen = fread(description, 1, descriptionLen, file);
|
||||
if (nDescLen >= 0) {
|
||||
description[nDescLen] = '\0';
|
||||
}
|
||||
FS_FCloseFile(descHandle);
|
||||
} else {
|
||||
Q_strncpyz( description, modDir, descriptionLen );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
FS_GetModList
|
||||
|
@ -2496,8 +2523,7 @@ int FS_GetModList( char *listbuf, int bufsize ) {
|
|||
char **pFiles = NULL;
|
||||
char **pPaks = NULL;
|
||||
char *name, *path;
|
||||
char descPath[MAX_OSPATH];
|
||||
fileHandle_t descHandle;
|
||||
char description[MAX_OSPATH];
|
||||
|
||||
int dummy;
|
||||
char **pFiles0 = NULL;
|
||||
|
@ -2571,28 +2597,13 @@ int FS_GetModList( char *listbuf, int bufsize ) {
|
|||
nLen = strlen(name) + 1;
|
||||
// nLen is the length of the mod path
|
||||
// we need to see if there is a description available
|
||||
descPath[0] = '\0';
|
||||
strcpy(descPath, name);
|
||||
strcat(descPath, "/description.txt");
|
||||
nDescLen = FS_SV_FOpenFileRead( descPath, &descHandle );
|
||||
if ( nDescLen > 0 && descHandle) {
|
||||
FILE *file;
|
||||
file = FS_FileForHandle(descHandle);
|
||||
Com_Memset( descPath, 0, sizeof( descPath ) );
|
||||
nDescLen = fread(descPath, 1, 48, file);
|
||||
if (nDescLen >= 0) {
|
||||
descPath[nDescLen] = '\0';
|
||||
}
|
||||
FS_FCloseFile(descHandle);
|
||||
} else {
|
||||
strcpy(descPath, name);
|
||||
}
|
||||
nDescLen = strlen(descPath) + 1;
|
||||
FS_GetModDescription( name, description, sizeof( description ) );
|
||||
nDescLen = strlen(description) + 1;
|
||||
|
||||
if (nTotal + nLen + 1 + nDescLen + 1 < bufsize) {
|
||||
strcpy(listbuf, name);
|
||||
listbuf += nLen;
|
||||
strcpy(listbuf, descPath);
|
||||
strcpy(listbuf, description);
|
||||
listbuf += nDescLen;
|
||||
nTotal += nLen + nDescLen;
|
||||
nMods++;
|
||||
|
@ -3999,6 +4010,9 @@ void FS_Restart( int checksumFeed ) {
|
|||
}
|
||||
|
||||
if ( Q_stricmp(fs_gamedirvar->string, lastValidGame) ) {
|
||||
Sys_RemovePIDFile( lastValidGame );
|
||||
Sys_InitPIDFile( fs_gamedirvar->string );
|
||||
|
||||
// skip the q3config.cfg if "safe" is on the command line
|
||||
if ( !Com_SafeMode() ) {
|
||||
Cbuf_AddText ("exec " Q3CONFIG_CFG "\n");
|
||||
|
|
|
@ -637,6 +637,8 @@ int FS_LoadStack( void );
|
|||
int FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
|
||||
int FS_GetModList( char *listbuf, int bufsize );
|
||||
|
||||
void FS_GetModDescription( const char *modDir, char *description, int descriptionLen );
|
||||
|
||||
fileHandle_t FS_FOpenFileWrite( const char *qpath );
|
||||
fileHandle_t FS_FOpenFileAppend( const char *filename );
|
||||
fileHandle_t FS_FCreateOpenPipeFile( const char *filename );
|
||||
|
@ -1145,7 +1147,8 @@ typedef enum
|
|||
|
||||
dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title );
|
||||
|
||||
qboolean Sys_WritePIDFile( void );
|
||||
void Sys_RemovePIDFile( const char *gamedir );
|
||||
void Sys_InitPIDFile( const char *gamedir );
|
||||
|
||||
/* This is based on the Adaptive Huffman algorithm described in Sayood's Data
|
||||
* Compression book. The ranks are not actually stored, but implicitly defined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue