console.c
changeset 247 1cbc32ff06eb
parent 229 b94bfdf02bae
child 248 bd894287e3f2
--- a/console.c	Tue Sep 14 15:46:21 2004 +0000
+++ b/console.c	Tue Sep 14 16:10:20 2004 +0000
@@ -27,6 +27,7 @@
 // ** stdlib ** //
 byte _stdlib_developer=1;
 bool _stdlib_con_developer=false;
+FILE * _iconsole_output_file;
 
 // ** main console cmd buffer ** // sign_de: especialy for Celestar :D
 static byte* _iconsole_cmdbuffer[20];
@@ -186,8 +187,9 @@
 	#if defined(WITH_REV)
 	extern char _openttd_revision[];
 	#endif
+	_iconsole_output_file = NULL;
 	_iconsole_color_default = 1;
-	_iconsole_color_error = 3;
+	_iconsole_color_error = 3;
 	_iconsole_color_warning = 13;
 	_iconsole_color_debug = 5;
 	_iconsole_color_commands = 2;
@@ -231,6 +233,7 @@
 {
 	_iconsole_inited=false;
 	IConsoleClear();
+	if (_iconsole_output_file!=NULL) fclose(_iconsole_output_file);
 }
 
 void IConsoleResize()
@@ -344,9 +347,19 @@
 {
 	va_list va;
 	char buf[1024];
+	int len;
+
 	va_start(va, s);
-	vsprintf(buf, s, va);
+	len = vsprintf(buf, s, va);
 	va_end(va);
+
+	if (_iconsole_output_file!=NULL) {
+		// if there is an console output file ... also print it there
+		fwrite((void *) &buf, len, 1, _iconsole_output_file);
+		buf[1023]='\n';
+		fwrite((void *)&buf[1023], 1, 1,_iconsole_output_file);
+		}
+
 	IConsolePrint(color_code, (byte *) &buf);
 }
 
@@ -359,11 +372,11 @@
 {
 	if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_error, "ERROR: %s", string);
 }
-
-void IConsoleWarning(const byte* string)
-{
-	if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_warning, "WARNING: %s", string);
-}
+
+void IConsoleWarning(const byte* string)
+{
+	if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_warning, "WARNING: %s", string);
+}
 
 void IConsoleCmdRegister(const byte * name, void * addr)
 {