From d48ce392b2569c3d856caf4f069b9bffbf0de9cc Mon Sep 17 00:00:00 2001 From: darkvater Date: Tue, 14 Sep 2004 16:10:20 +0000 Subject: (svn r248) -Feature: console script files "exec myscript.file" -Feature: console logging (of debug messages with *developer = 2 and debug_level #) to text-files "script test.txt" -Feature: server and client are auto-executing "on_server.scr" and "on_client.scr" scripts --- console.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'console.c') diff --git a/console.c b/console.c index f39ba552d..612c6dbf0 100644 --- a/console.c +++ b/console.c @@ -27,6 +27,7 @@ static byte _icursor_counter; // ** 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 @@ void IConsoleInit() #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 @@ void IConsoleFree() { _iconsole_inited=false; IConsoleClear(); + if (_iconsole_output_file!=NULL) fclose(_iconsole_output_file); } void IConsoleResize() @@ -344,9 +347,19 @@ void CDECL IConsolePrintF(byte color_code, const char *s, ...) { 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 @@ void IConsoleError(const byte* string) { 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) { -- cgit v1.2.3-54-g00ecf