summaryrefslogtreecommitdiff
path: root/console_cmds.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2005-01-15 16:38:10 +0000
committerdarkvater <darkvater@openttd.org>2005-01-15 16:38:10 +0000
commit732c362deaaa9b6a817a2e82c45d88e33f8f1e90 (patch)
tree07ffc7b8b01005a5dcc5636c3c4b6ce24aabf934 /console_cmds.c
parentef3b9161f8f106a7cf6b02766fac06d92523816a (diff)
downloadopenttd-732c362deaaa9b6a817a2e82c45d88e33f8f1e90.tar.xz
(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
Diffstat (limited to 'console_cmds.c')
-rw-r--r--console_cmds.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 73eaca08f..cf58e0b1b 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -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;
}