* Sys_Dialog for more user friendly error reporting

* (bug #3932) Recovery from bad video settings
This commit is contained in:
Tim Angus 2010-02-15 16:20:33 +00:00
parent 4876413217
commit 005f870ebe
13 changed files with 564 additions and 120 deletions

View file

@ -82,6 +82,7 @@ cvar_t *com_unfocused;
cvar_t *com_maxfpsUnfocused;
cvar_t *com_minimized;
cvar_t *com_maxfpsMinimized;
cvar_t *com_abnormalExit;
cvar_t *com_standalone;
// com_speeds times
@ -237,7 +238,7 @@ void QDECL Com_DPrintf( const char *fmt, ...) {
Com_Error
Both client and server can use this, and it will
do the apropriate things.
do the appropriate thing.
=============
*/
void QDECL Com_Error( int code, const char *fmt, ... ) {
@ -322,7 +323,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
com_errorEntered = qfalse;
longjmp (abortframe, -1);
} else {
CL_Shutdown ();
CL_Shutdown (va("Client fatal crashed: %s", com_errorMessage));
SV_Shutdown (va("Server fatal crashed: %s", com_errorMessage));
}
@ -346,7 +347,7 @@ void Com_Quit_f( void ) {
char *p = Cmd_Args( );
if ( !com_errorEntered ) {
SV_Shutdown (p[0] ? p : "Server quit");
CL_Shutdown ();
CL_Shutdown (p[0] ? p : "Client quit");
Com_Shutdown ();
FS_Shutdown(qtrue);
}
@ -2737,6 +2738,7 @@ void Com_Init( char *commandLine ) {
com_maxfpsUnfocused = Cvar_Get( "com_maxfpsUnfocused", "0", CVAR_ARCHIVE );
com_minimized = Cvar_Get( "com_minimized", "0", CVAR_ROM );
com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "0", CVAR_ARCHIVE );
com_abnormalExit = Cvar_Get( "com_abnormalExit", "0", CVAR_ROM );
com_standalone = Cvar_Get( "com_standalone", "0", CVAR_INIT );
com_introPlayed = Cvar_Get( "com_introplayed", "0", CVAR_ARCHIVE);
@ -2746,6 +2748,18 @@ 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
}
// Pick a random port value
Com_RandomBytes( (byte*)&qport, sizeof(int) );
Netchan_Init( qport & 0xffff );

View file

@ -181,7 +181,7 @@ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask);
qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);
qboolean NET_IsLocalAddress (netadr_t adr);
const char *NET_AdrToString (netadr_t a);
const char *NET_AdrToStringwPort (netadr_t a);
const char *NET_AdrToStringwPort (netadr_t a);
int NET_StringToAdr ( const char *s, netadr_t *a, netadrtype_t family);
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message);
void NET_JoinMulticast6(void);
@ -937,7 +937,7 @@ void CL_InitKeyCommands( void );
void CL_Init( void );
void CL_Disconnect( qboolean showMainMenu );
void CL_Shutdown( void );
void CL_Shutdown( char *finalmsg );
void CL_Frame( int msec );
qboolean CL_GameCommand( void );
void CL_KeyEvent (int key, qboolean down, unsigned time);
@ -1087,6 +1087,7 @@ char *Sys_DefaultAppPath(void);
void Sys_SetDefaultHomePath(const char *path);
char *Sys_DefaultHomePath(void);
const char *Sys_TempPath(void);
const char *Sys_Dirname( char *path );
const char *Sys_Basename( char *path );
char *Sys_ConsoleInput(void);
@ -1099,6 +1100,27 @@ qboolean Sys_LowPhysicalMemory( void );
void Sys_SetEnv(const char *name, const char *value);
typedef enum
{
DR_YES = 0,
DR_NO = 1,
DR_OK = 0,
DR_CANCEL = 1
} dialogResult_t;
typedef enum
{
DT_INFO,
DT_WARNING,
DT_ERROR,
DT_YES_NO,
DT_OK_CANCEL
} dialogType_t;
dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title );
qboolean Sys_WritePIDFile( void );
/* This is based on the Adaptive Huffman algorithm described in Sayood's Data
* Compression book. The ranks are not actually stored, but implicitly defined
* by the location of a node within a doubly-linked list */