From 92ccf96768b5d76c073267762e0a8dec296d39bd Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 30 Aug 2002 01:06:23 +0000 Subject: [PATCH] Well, I've received complaints about my other errors, but nothing about the build rules, so I'm assuming they're at least not blowing up at anyone. Enabling the debug crash window. More details will go to sm-devs. --- stepmania/src/StepMania.cpp | 45 +++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 3a3d9ed005..53f26345f3 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -55,6 +55,8 @@ #include "NoteData.h" #include "Notes.h" +#include "tls.h" +#include "crash.h" #include "dxerr8.h" //#include @@ -133,12 +135,34 @@ void StructuredExceptionHandler(unsigned int uCode, } throw std::exception(msg); } +void SplitCommandLine(const char *lpCmdLine, CStringArray &aCmds) { + const char *s = lpCmdLine; + + /* Split a string on whitespace, but never between quotes. */ + while(*s) { + CString cmd; + + while( isspace(*s) ) s++; + + bool quoted = false; + while( *s && (quoted || !isspace(*s)) ) + { + cmd += *s; + if (*s == '"') + quoted = !quoted; + s++; + } + + if(cmd.GetLength()) + aCmds.Add(cmd); + } +} //----------------------------------------------------------------------------- // Name: WinMain() // Desc: Application entry point //----------------------------------------------------------------------------- -int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) +int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR CmdLine, int nCmdShow ) { _set_se_translator( StructuredExceptionHandler ); @@ -146,6 +170,17 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); #endif + + SetUnhandledExceptionFilter(CrashHandler); + InitThreadData("Main thread"); + VDCHECKPOINT; + + CStringArray Cmds; + SplitCommandLine(CmdLine, Cmds); + for(int i = 0; i < Cmds.GetSize(); ++i) + { + if(Cmds[i] == "--fsck") { crash(); exit( 0 ); } + } #ifndef _DEBUG try @@ -304,14 +339,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) { g_sErrorString = e.what(); } - catch( exception e ) - { - g_sErrorString = e.what(); - } - catch( ... ) - { - g_sErrorString = "Unknown exception"; - } if( g_sErrorString != "" ) {