summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-09-14 16:10:20 +0000
committerdarkvater <darkvater@openttd.org>2004-09-14 16:10:20 +0000
commitd48ce392b2569c3d856caf4f069b9bffbf0de9cc (patch)
tree6a9cad412cda5d812b392d390d583b0f6bcf7e39 /console.c
parent6d55489368c8f2324d0ff43d4caad60478902b58 (diff)
downloadopenttd-d48ce392b2569c3d856caf4f069b9bffbf0de9cc.tar.xz
(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
Diffstat (limited to 'console.c')
-rw-r--r--console.c27
1 files changed, 20 insertions, 7 deletions
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)
{