Changeset - r1023:da927b91b653
[Not reviewed]
master
0 2 0
darkvater - 19 years ago 2005-01-15 16:38:10
darkvater@openttd.org
(svn r1524) -"Feature": when windows exception tracker is enabled (release builds) and the game crashes for any reason any active log file is closed first. This ensures the log file and ingame debug messages can be used to debug a problem. Any *nix versions are welcome
2 files changed with 21 insertions and 7 deletions:
0 comments (0 inline, 0 general)
console_cmds.c
Show inline comments
 
@@ -595,20 +595,28 @@ DEF_CONSOLE_CMD(ConReturn)
 
/* **************************** */
 
/*   default console commands   */
 
/* **************************** */
 

	
 
DEF_CONSOLE_CMD(ConScript)
 
bool CloseConsoleLogIfActive()
 
{
 
	extern FILE* _iconsole_output_file;
 
	if (_iconsole_output_file != NULL) {
 
		IConsolePrintF(_iconsole_color_default, "file output complete");
 
		fclose(_iconsole_output_file);
 
	} else {
 
		return true;
 
	}
 

	
 
	return false;
 
}
 

	
 
DEF_CONSOLE_CMD(ConScript)
 
{
 
	extern FILE* _iconsole_output_file;
 
	if (!CloseConsoleLogIfActive()) {
 
		if (argc < 2) return NULL;
 
		IConsolePrintF(_iconsole_color_default, "file output started to: %s",
 
			argv[1]);
 
		IConsolePrintF(_iconsole_color_default, "file output started to: %s",	argv[1]);
 
		_iconsole_output_file = fopen(argv[1], "ab");
 
		if (_iconsole_output_file == NULL) IConsoleError("could not open file");
 
	}
 

	
 
	return NULL;
 
}
 

	
win32.c
Show inline comments
 
@@ -1337,6 +1337,8 @@ static void Handler2()
 
	DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(100), NULL, CrashDialogFunc);
 
}
 

	
 
extern bool CloseConsoleLogIfActive();
 

	
 
static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
 
{
 
	char *output;
 
@@ -1442,13 +1444,17 @@ static LONG WINAPI ExceptionHandler(EXCE
 
		}
 
	}
 

	
 
	/* Close any possible log files */
 
	CloseConsoleLogIfActive();
 

	
 
	if (_safe_esp) {
 
		ep->ContextRecord->Eip = (DWORD)Handler2;
 
		ep->ContextRecord->Esp = (DWORD)_safe_esp;
 
		return EXCEPTION_CONTINUE_EXECUTION;
 
	} else {
 
		return EXCEPTION_EXECUTE_HANDLER;
 
	}
 

	
 

	
 
	return EXCEPTION_EXECUTE_HANDLER;
 
}
 

	
 
static void Win32InitializeExceptions()
0 comments (0 inline, 0 general)