console.c
author dominik
Mon, 13 Dec 2004 20:45:55 +0000
changeset 640 b1f21d1ac4d3
parent 634 88d9420048db
child 644 e833509107ad
permissions -rw-r--r--
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
- fixed handling of aliases with parameters (sign_de)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     1
#include "stdafx.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     2
#include "ttd.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 301
diff changeset
     3
#include "table/strings.h"
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     4
#include "window.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     5
#include "gui.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     6
#include "gfx.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     7
#include "player.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     8
#include "variables.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     9
#include "hal.h"
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    10
#include <stdarg.h>
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    11
#include <string.h>
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    12
#include "console.h"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    13
#include "network.h"
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    14
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    15
#ifdef WIN32
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    16
#include <windows.h>
273
e542881b8a3b (svn r279) -Feature: [WIN32] Console now allows to paste data from the clipboard [ctrl + v]
signde
parents: 248
diff changeset
    17
#endif
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    18
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    19
#define ICON_BUFFER 79
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    20
#define ICON_CMDBUF_SIZE 20
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    21
#define ICON_CMDLN_SIZE 255
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    22
#define ICON_LINE_HEIGHT 12
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    23
#define ICON_RIGHT_BORDERWIDTH 10
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    24
#define ICON_BOTTOM_BORDERWIDTH 12
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
    25
#define ICON_MAX_ALIAS_LINES 40
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    26
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    27
// ** main console ** //
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    28
static bool _iconsole_inited;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    29
static char* _iconsole_buffer[ICON_BUFFER + 1];
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    30
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    31
static char _iconsole_cmdline[ICON_CMDLN_SIZE];
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    32
static byte _iconsole_cmdpos;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    33
static Window* _iconsole_win = NULL;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    34
static byte _iconsole_scroll;
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    35
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    36
// ** console cursor ** //
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    37
static bool _icursor_state;
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    38
static byte _icursor_rate;
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    39
static byte _icursor_counter;
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    40
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    41
// ** stdlib ** //
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    42
byte _stdlib_developer = 1;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    43
bool _stdlib_con_developer = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    44
FILE* _iconsole_output_file;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    45
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    46
// ** main console cmd buffer
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    47
static char* _iconsole_cmdbuffer[ICON_CMDBUF_SIZE];
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    48
static byte _iconsole_cmdbufferpos;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    49
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    50
// ** console window ** //
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    51
static void IConsoleWndProc(Window* w, WindowEvent* e);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    52
static const Widget _iconsole_window_widgets[] = {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    53
	{WIDGETS_END}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    54
};
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    55
static const WindowDesc _iconsole_window_desc = {
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    56
	0, 0, 2, 2,
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    57
	WC_CONSOLE, 0,
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    58
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    59
	_iconsole_window_widgets,
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    60
	IConsoleWndProc,
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    61
};
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    62
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    63
/* *************** */
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    64
/*  end of header  */
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    65
/* *************** */
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    66
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    67
static void IConsoleAppendClipboard(void)
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    68
{
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    69
#ifdef WIN32
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    70
	if (IsClipboardFormatAvailable(CF_TEXT)) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    71
		const char* data;
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    72
		HGLOBAL cbuf;
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    73
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    74
		OpenClipboard(NULL);
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    75
		cbuf = GetClipboardData(CF_TEXT);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    76
		data = GlobalLock(cbuf);
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    77
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    78
		/* IS_INT_INSIDE = filter for ascii-function codes like BELL and so on [we need an special filter here later] */
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    79
		for (; (IS_INT_INSIDE(*data, ' ', 256)) && (_iconsole_cmdpos < lengthof(_iconsole_cmdline) - 1); ++data)
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    80
			_iconsole_cmdline[_iconsole_cmdpos++] = *data;
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    81
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    82
		GlobalUnlock(cbuf);
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    83
		CloseClipboard();
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    84
	}
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    85
#endif
273
e542881b8a3b (svn r279) -Feature: [WIN32] Console now allows to paste data from the clipboard [ctrl + v]
signde
parents: 248
diff changeset
    86
}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    87
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    88
static void IConsoleClearCommand(void)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    89
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    90
	memset(_iconsole_cmdline, 0, sizeof(_iconsole_cmdline));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    91
	_iconsole_cmdpos = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    92
	SetWindowDirty(_iconsole_win);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    93
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    94
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    95
static void IConsoleWndProc(Window* w, WindowEvent* e)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    96
{
209
fd1ec5041eeb (svn r210) -Fix: Console key closes window in front
signde
parents: 205
diff changeset
    97
	// only do window events with the console
fd1ec5041eeb (svn r210) -Fix: Console key closes window in front
signde
parents: 205
diff changeset
    98
	w = FindWindowById(WC_CONSOLE, 0);
fd1ec5041eeb (svn r210) -Fix: Console key closes window in front
signde
parents: 205
diff changeset
    99
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   100
	switch(e->event) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   101
		case WE_PAINT:
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   102
		{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   103
			int i = _iconsole_scroll;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   104
			int max = (w->height / ICON_LINE_HEIGHT) - 1;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   105
			int delta = 0;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   106
			GfxFillRect(w->left, w->top, w->width, w->height - 1, 0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   107
			while ((i > _iconsole_scroll - max) && (_iconsole_buffer[i] != NULL)) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   108
				DoDrawString(_iconsole_buffer[i], 5,
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   109
					w->height - (_iconsole_scroll + 2 - i) * ICON_LINE_HEIGHT, _iconsole_cbuffer[i]);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   110
				i--;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   111
			}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   112
			delta = w->width - 10 - GetStringWidth(_iconsole_cmdline) - ICON_RIGHT_BORDERWIDTH;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   113
			if (delta > 0) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   114
				DoDrawString("]", 5, w->height - ICON_LINE_HEIGHT, _iconsole_color_commands);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   115
				delta = 0;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   116
			}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   117
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   118
			DoDrawString(_iconsole_cmdline, 10 + delta, w->height - ICON_LINE_HEIGHT, _iconsole_color_commands);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   119
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   120
		}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   121
		case WE_TICK:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   122
			_icursor_counter++;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   123
			if (_icursor_counter > _icursor_rate) {
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   124
				int posx;
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   125
				int posy;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   126
				int delta;
169
4081f1d1f393 (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater
parents: 141
diff changeset
   127
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   128
				_icursor_state = !_icursor_state;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   129
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   130
				_cur_dpi = &_screen;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   131
				delta = w->width - 10 - GetStringWidth(_iconsole_cmdline) - ICON_RIGHT_BORDERWIDTH;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   132
				if (delta > 0)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   133
					delta = 0;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   134
				posx = 10 + GetStringWidth(_iconsole_cmdline) + delta;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   135
				posy = w->height - 3;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   136
				GfxFillRect(posx, posy, posx + 5, posy + 1, _icursor_state ? 14 : 0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   137
				_video_driver->make_dirty(posx, posy, 5, 1);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   138
				_icursor_counter = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   139
			}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   140
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   141
		case WE_DESTROY:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   142
			_iconsole_win = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   143
			_iconsole_mode = ICONSOLE_CLOSED;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   144
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   145
		case WE_KEYPRESS:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   146
		{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   147
			e->keypress.cont = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   148
			switch (e->keypress.keycode) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   149
				case WKC_CTRL | 'V':
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   150
					IConsoleAppendClipboard();
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   151
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   152
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   153
				case WKC_UP:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   154
					IConsoleCmdBufferNavigate(+1);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   155
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   156
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   157
				case WKC_DOWN:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   158
					IConsoleCmdBufferNavigate(-1);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   159
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   160
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   161
				case WKC_SHIFT | WKC_PAGEUP:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   162
					if (_iconsole_scroll - (w->height / ICON_LINE_HEIGHT) - 1 < 0)
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   163
						_iconsole_scroll = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   164
					else
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   165
						_iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   166
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   167
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   168
				case WKC_SHIFT | WKC_PAGEDOWN:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   169
					if (_iconsole_scroll + (w->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER)
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   170
						_iconsole_scroll = ICON_BUFFER;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   171
					else
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   172
						_iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   173
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   174
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   175
				case WKC_SHIFT | WKC_UP:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   176
					if (_iconsole_scroll <= 0)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   177
						_iconsole_scroll = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   178
					else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   179
						--_iconsole_scroll;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   180
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   181
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   182
				case WKC_SHIFT | WKC_DOWN:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   183
					if (_iconsole_scroll >= ICON_BUFFER)
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   184
						_iconsole_scroll = ICON_BUFFER;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   185
					else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   186
						++_iconsole_scroll;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   187
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   188
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   189
				case WKC_BACKQUOTE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   190
					IConsoleSwitch();
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   191
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   192
				case WKC_RETURN:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   193
					IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   194
					_iconsole_cmdbufferpos = 19;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   195
					IConsoleCmdBufferAdd(_iconsole_cmdline);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   196
					IConsoleCmdExec(_iconsole_cmdline);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   197
					IConsoleClearCommand();
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   198
					break;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   199
				case WKC_CTRL | WKC_RETURN:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   200
					if (_iconsole_mode == ICONSOLE_FULL) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   201
						_iconsole_mode = ICONSOLE_OPENED;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   202
					} else {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   203
						_iconsole_mode = ICONSOLE_FULL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   204
					}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   205
					IConsoleResize();
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   206
					MarkWholeScreenDirty();
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   207
					break;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   208
				case WKC_BACKSPACE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   209
					if (_iconsole_cmdpos != 0) _iconsole_cmdpos--;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   210
					_iconsole_cmdline[_iconsole_cmdpos] = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   211
					SetWindowDirty(w);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   212
					_iconsole_cmdbufferpos = 19;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   213
					break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   214
				default:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   215
					/* IS_INT_INSIDE = filter for ascii-function codes like BELL and so on [we need an special filter here later] */
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   216
					if (IS_INT_INSIDE(e->keypress.ascii, ' ', 256)) {
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   217
						_iconsole_scroll = ICON_BUFFER;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   218
						_iconsole_cmdline[_iconsole_cmdpos] = e->keypress.ascii;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   219
						if (_iconsole_cmdpos != lengthof(_iconsole_cmdline))
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   220
							_iconsole_cmdpos++;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   221
						SetWindowDirty(w);
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   222
						_iconsole_cmdbufferpos = ICON_CMDBUF_SIZE - 1;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   223
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   224
					else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   225
						e->keypress.cont = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   226
			}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   227
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   228
		}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   229
	}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   230
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   231
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   232
void IConsoleInit(void)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   233
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   234
	uint i;
618
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   235
#ifdef WITH_REV_HACK
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   236
	#define WITH_REV
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   237
	const char _openttd_revision[] = WITH_REV_HACK;
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   238
#else
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   239
	#if defined(WITH_REV)
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   240
	extern char _openttd_revision[];
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   241
	#endif
618
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   242
#endif
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   243
	_iconsole_output_file = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   244
	_iconsole_color_default = 1;
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   245
	_iconsole_color_error = 3;
229
b94bfdf02bae (svn r230) -Feature: IConsoleWarning for warning messages
signde
parents: 228
diff changeset
   246
	_iconsole_color_warning = 13;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   247
	_iconsole_color_debug = 5;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   248
	_iconsole_color_commands = 2;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   249
	_iconsole_scroll = ICON_BUFFER;
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   250
	_iconsole_cmdbufferpos = ICON_CMDBUF_SIZE - 1;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   251
	_iconsole_inited = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   252
	_iconsole_mode = ICONSOLE_CLOSED;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   253
	_iconsole_win = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   254
	_icursor_state = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   255
	_icursor_rate = 5;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   256
	_icursor_counter = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   257
	for (i = 0; i < lengthof(_iconsole_cmdbuffer); i++)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   258
		_iconsole_cmdbuffer[i] = NULL;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   259
	for (i = 0; i <= ICON_BUFFER; i++) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   260
		_iconsole_buffer[i] = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   261
		_iconsole_cbuffer[i] = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   262
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   263
	IConsoleStdLibRegister();
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   264
	#if defined(WITH_REV)
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   265
	IConsolePrintF(13, "OpenTTD Game Console Revision 6 - %s", _openttd_revision);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   266
	#else
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   267
	IConsolePrint(13, "OpenTTD Game Console Revision 6");
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   268
	#endif
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   269
	IConsolePrint(12, "---------------------------------");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   270
	IConsolePrint(12, "use \"help\" for more info");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   271
	IConsolePrint(12, "");
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   272
	IConsoleClearCommand();
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   273
	IConsoleCmdBufferAdd("");
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   274
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   275
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   276
void IConsoleClear(void)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   277
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   278
	uint i;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   279
	for (i = 0; i <= ICON_BUFFER; i++)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   280
		free(_iconsole_buffer[i]);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   281
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   282
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   283
void IConsoleFree(void)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   284
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   285
	_iconsole_inited = false;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   286
	IConsoleClear();
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   287
	if (_iconsole_output_file != NULL) fclose(_iconsole_output_file);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   288
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   289
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   290
void IConsoleResize(void)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   291
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   292
	switch (_iconsole_mode) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   293
		case ICONSOLE_OPENED:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   294
			_iconsole_win->height = _screen.height / 3;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   295
			_iconsole_win->width = _screen.width;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   296
			break;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   297
		case ICONSOLE_FULL:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   298
			_iconsole_win->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   299
			_iconsole_win->width = _screen.width;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   300
			break;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   301
		default:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   302
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   303
	}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   304
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   305
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   306
void IConsoleSwitch(void)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   307
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   308
	switch (_iconsole_mode) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   309
		case ICONSOLE_CLOSED:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   310
			_iconsole_win = AllocateWindowDesc(&_iconsole_window_desc);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   311
			_iconsole_win->height = _screen.height / 3;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   312
			_iconsole_win->width = _screen.width;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   313
			_iconsole_mode = ICONSOLE_OPENED;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   314
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   315
		case ICONSOLE_OPENED:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   316
			DeleteWindowById(WC_CONSOLE, 0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   317
			_iconsole_win = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   318
			_iconsole_mode = ICONSOLE_CLOSED;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   319
			break;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   320
		case ICONSOLE_FULL:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   321
			DeleteWindowById(WC_CONSOLE, 0);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   322
			_iconsole_win = NULL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   323
			_iconsole_mode = ICONSOLE_CLOSED;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   324
			break;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   325
	}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   326
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   327
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   328
void IConsoleClose(void)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   329
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   330
	if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   331
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   332
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   333
void IConsoleOpen(void)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   334
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   335
	if (_iconsole_mode == ICONSOLE_CLOSED) IConsoleSwitch();
141
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   336
}
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   337
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   338
void IConsoleCmdBufferAdd(const char* cmd)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   339
{
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   340
	int i;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   341
	if (_iconsole_cmdbufferpos != 19) return;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   342
	free(_iconsole_cmdbuffer[18]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   343
	for (i = 18; i > 0; i--) _iconsole_cmdbuffer[i] = _iconsole_cmdbuffer[i - 1];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   344
	_iconsole_cmdbuffer[0] = strdup(cmd);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   345
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   346
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   347
void IConsoleCmdBufferNavigate(signed char direction)
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   348
{
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   349
	int i;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   350
	i = _iconsole_cmdbufferpos + direction;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   351
	if (i < 0) i = 19;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   352
	if (i > 19) i = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   353
	if (direction > 0)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   354
		while (_iconsole_cmdbuffer[i] == NULL) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   355
			++i;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   356
			if (i > 19) i = 0;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   357
		}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   358
	if (direction < 0)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   359
		while (_iconsole_cmdbuffer[i] == NULL) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   360
			--i;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   361
			if (i < 0) i = 19;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   362
		}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   363
	_iconsole_cmdbufferpos = i;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   364
	IConsoleClearCommand();
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   365
	memcpy(_iconsole_cmdline, _iconsole_cmdbuffer[i],
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   366
		strlen(_iconsole_cmdbuffer[i]));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   367
	_iconsole_cmdpos = strlen(_iconsole_cmdbuffer[i]);
141
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   368
}
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   369
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   370
void IConsolePrint(uint16 color_code, const char* string)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   371
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   372
	char* _ex;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   373
	char* _new;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   374
	uint16 _exc;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   375
	uint16 _newc;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   376
	char* i;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   377
	int j;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   378
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   379
	if (_network_dedicated) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   380
		printf("%s\n", string);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   381
		return;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   382
	}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   383
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   384
	if (!_iconsole_inited) return;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   385
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   386
	_newc = color_code;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   387
	_new = strdup(string);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   388
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   389
	for (i = _new; *i != '\0'; ++i)
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   390
		if (*i < ' ') *i = ' '; /* filter for ascii-function codes like BELL and so on [we need an special filter here later] */
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   391
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   392
	for (j = ICON_BUFFER; j >= 0; --j) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   393
		_ex = _iconsole_buffer[j];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   394
		_exc = _iconsole_cbuffer[j];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   395
		_iconsole_buffer[j] = _new;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   396
		_iconsole_cbuffer[j] = _newc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   397
		_new = _ex;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   398
		_newc = _exc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   399
	}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   400
	free(_ex);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   401
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   402
	if (_iconsole_win != NULL) SetWindowDirty(_iconsole_win);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   403
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   404
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   405
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   406
void CDECL IConsolePrintF(uint16 color_code, const char* s, ...)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   407
{
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   408
	va_list va;
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   409
	char buf[1024];
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   410
	int len;
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   411
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   412
	va_start(va, s);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   413
	len = vsnprintf(buf, sizeof(buf), s, va);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   414
	va_end(va);
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   415
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   416
	IConsolePrint(color_code, buf);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   417
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   418
	if (_iconsole_output_file != NULL) {
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   419
		// if there is an console output file ... also print it there
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   420
		fwrite(buf, len, 1, _iconsole_output_file);
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   421
		fwrite("\n", 1, 1, _iconsole_output_file);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   422
	}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   423
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   424
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   425
void IConsoleDebug(const char* string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   426
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   427
	if (_stdlib_developer > 1)
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   428
		IConsolePrintF(_iconsole_color_debug, "dbg: %s", string);
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   429
}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   430
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   431
void IConsoleError(const char* string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   432
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   433
	if (_stdlib_developer > 0)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   434
		IConsolePrintF(_iconsole_color_error, "ERROR: %s", string);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   435
}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   436
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   437
void IConsoleWarning(const char* string)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   438
{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   439
	if (_stdlib_developer > 0)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   440
		IConsolePrintF(_iconsole_color_warning, "WARNING: %s", string);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   441
}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   442
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   443
void IConsoleCmdRegister(const char* name, _iconsole_cmd_addr addr)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   444
{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   445
	char* _new;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   446
	_iconsole_cmd* item;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   447
	_iconsole_cmd* item_new;
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   448
	_iconsole_cmd* item_before;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   449
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   450
	_new = strdup(name);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   451
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   452
	item_new = malloc(sizeof(_iconsole_cmd));
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   453
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   454
	item_new->_next = NULL;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   455
	item_new->addr = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   456
	item_new->name = _new;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   457
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   458
	item_new->hook_access = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   459
	item_new->hook_after_exec = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   460
	item_new->hook_before_exec = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   461
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   462
	item_before = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   463
	item = _iconsole_cmds;
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   464
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   465
	if (item == NULL) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   466
		_iconsole_cmds = item_new;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   467
	} else {
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   468
		while ((item->_next != NULL) && (strcmp(item->name,item_new->name)<=0)) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   469
			item_before = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   470
			item = item->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   471
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   472
// insertion sort
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   473
		if (item_before==NULL) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   474
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   475
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   476
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   477
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   478
				// inserting as startitem
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   479
				_iconsole_cmds = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   480
				item_new ->_next = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   481
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   482
		} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   483
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   484
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   485
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   486
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   487
				// inserting
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   488
				item_new ->_next = item_before->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   489
				item_before ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   490
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   491
		}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   492
// insertion sort end
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   493
	}
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   494
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   495
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   496
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   497
_iconsole_cmd* IConsoleCmdGet(const char* name)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   498
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   499
	_iconsole_cmd* item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   500
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   501
	item = _iconsole_cmds;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   502
	while (item != NULL) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   503
		if (strcmp(item->name, name) == 0) return item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   504
		item = item->_next;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   505
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   506
	return NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   507
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   508
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   509
void IConsoleAliasRegister(const char* name, const char* cmdline)
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   510
{
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   511
	char* _new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   512
	char* _newcmd;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   513
	_iconsole_alias* item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   514
	_iconsole_alias* item_new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   515
	_iconsole_alias* item_before;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   516
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   517
	_new = strdup(name);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   518
	_newcmd = strdup(cmdline);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   519
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   520
	item_new = malloc(sizeof(_iconsole_alias));
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   521
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   522
	item_new->_next = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   523
	item_new->cmdline = _newcmd;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   524
	item_new->name = _new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   525
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   526
	item_before = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   527
	item = _iconsole_aliases;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   528
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   529
	if (item == NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   530
		_iconsole_aliases = item_new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   531
	} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   532
		while ((item->_next != NULL) && (strcmp(item->name,item_new->name)<=0)) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   533
			item_before = item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   534
			item = item->_next;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   535
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   536
// insertion sort
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   537
		if (item_before==NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   538
			if (strcmp(item->name,item_new->name)<=0) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   539
				// appending
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   540
				item ->_next = item_new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   541
			} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   542
				// inserting as startitem
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   543
				_iconsole_aliases = item_new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   544
				item_new ->_next = item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   545
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   546
		} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   547
			if (strcmp(item->name,item_new->name)<=0) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   548
				// appending
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   549
				item ->_next = item_new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   550
			} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   551
				// inserting
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   552
				item_new ->_next = item_before->_next;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   553
				item_before ->_next = item_new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   554
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   555
		}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   556
// insertion sort end
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   557
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   558
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   559
}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   560
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   561
_iconsole_alias* IConsoleAliasGet(const char* name)
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   562
{
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   563
	_iconsole_alias* item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   564
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   565
	item = _iconsole_aliases;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   566
	while (item != NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   567
		if (strcmp(item->name, name) == 0) return item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   568
		item = item->_next;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   569
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   570
	return NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   571
}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   572
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   573
void IConsoleAliasExec(const char* cmdline, char* tokens[20], byte tokentypes[20]) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   574
	char* lines[ICON_MAX_ALIAS_LINES];
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   575
	char* linestream;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   576
	char* linestream_s;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   577
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   578
	int c;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   579
	int i;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   580
	int l;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   581
	int x;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   582
	byte t;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   583
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   584
	//** clearing buffer **//
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   585
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   586
	for (i = 0; i < 40; i++) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   587
		lines[0] = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   588
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   589
	linestream_s = linestream = malloc(1024*ICON_MAX_ALIAS_LINES);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   590
	memset(linestream, 0, 1024*ICON_MAX_ALIAS_LINES);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   591
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   592
	//** parsing **//
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   593
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   594
	l = strlen(cmdline);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   595
	i = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   596
	c = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   597
	x = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   598
	t = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   599
	lines[c] = linestream;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   600
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   601
	while (i < l && c < ICON_MAX_ALIAS_LINES - 1) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   602
		if (cmdline[i] == '%') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   603
			i++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   604
			if (cmdline[i] == '+') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   605
				t=1;
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   606
				while ((tokens[t]!=NULL) && (t<20) && 
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   607
						((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   608
					int l2 = strlen(tokens[t]);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   609
					*linestream = '"';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   610
					linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   611
					memcpy(linestream,tokens[t],l2);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   612
					linestream += l2;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   613
					*linestream = '"';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   614
					linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   615
					*linestream = ' ';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   616
					linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   617
					x += l2+3;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   618
					t++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   619
				}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   620
			} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   621
				int l2;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   622
				t = ((byte)cmdline[i]) - 64;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   623
				if ((t<20) && (tokens[t]!=NULL)) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   624
					l2 = strlen(tokens[t]);
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   625
					*linestream = '"';
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   626
					linestream++;
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   627
					memcpy(linestream,tokens[t],l2);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   628
					linestream += l2;
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   629
					*linestream = '"';
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   630
					linestream++;
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   631
					x += l2+2;
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   632
				}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   633
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   634
		} else if (cmdline[i] == '\\') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   635
			i++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   636
			if (cmdline[i] == '\\') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   637
				*linestream = '\\';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   638
				linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   639
			} else if (cmdline[i] == '\'') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   640
				*linestream = '\'';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   641
				linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   642
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   643
		} else if (cmdline[i] == '\'') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   644
			*linestream = '"';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   645
			linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   646
		} else if (cmdline[i] == ';') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   647
			c++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   648
			*linestream = '\0';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   649
			linestream += 1024 - (x % 1024);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   650
			x += 1024 - (x % 1024);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   651
			lines[c] = linestream;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   652
		} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   653
			*linestream = cmdline[i];
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   654
			linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   655
			x++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   656
		}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   657
		i++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   658
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   659
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   660
	linestream--;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   661
	if (*linestream != '\0') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   662
		c++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   663
		linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   664
		*linestream = '\0';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   665
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   666
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   667
	for (i=0; i<c; i++)	{
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   668
		IConsoleCmdExec(lines[i]);
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   669
	}
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   670
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   671
	free(linestream_s);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   672
}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   673
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   674
void IConsoleVarInsert(_iconsole_var* item_new, const char* name)
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   675
{
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   676
	_iconsole_var* item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   677
	_iconsole_var* item_before;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   678
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   679
	item_new->_next = NULL;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   680
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   681
	item_new->name = malloc(strlen(name) + 2); /* XXX unchecked malloc */
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   682
	sprintf(item_new->name, "%s", name);
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   683
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   684
	item_before = NULL;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   685
	item = _iconsole_vars;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   686
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   687
	if (item == NULL) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   688
		_iconsole_vars = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   689
	} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   690
		while ((item->_next != NULL) && (strcmp(item->name,item_new->name)<=0)) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   691
			item_before = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   692
			item = item->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   693
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   694
// insertion sort
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   695
		if (item_before==NULL) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   696
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   697
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   698
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   699
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   700
				// inserting as startitem
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   701
				_iconsole_vars = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   702
				item_new ->_next = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   703
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   704
		} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   705
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   706
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   707
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   708
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   709
				// inserting
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   710
				item_new ->_next = item_before->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   711
				item_before ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   712
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   713
		}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   714
// insertion sort end
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   715
	}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   716
}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   717
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   718
void IConsoleVarRegister(const char* name, void* addr, _iconsole_var_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   719
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   720
	_iconsole_var* item_new;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   721
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   722
	item_new = malloc(sizeof(_iconsole_var)); /* XXX unchecked malloc */
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   723
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   724
	item_new->_next = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   725
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   726
	switch (type) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   727
		case ICONSOLE_VAR_BOOLEAN:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   728
			item_new->data.bool_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   729
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   730
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   731
		case ICONSOLE_VAR_UINT8:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   732
			item_new->data.byte_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   733
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   734
		case ICONSOLE_VAR_UINT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   735
			item_new->data.uint16_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   736
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   737
		case ICONSOLE_VAR_UINT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   738
			item_new->data.uint32_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   739
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   740
		case ICONSOLE_VAR_INT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   741
			item_new->data.int16_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   742
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   743
		case ICONSOLE_VAR_INT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   744
			item_new->data.int32_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   745
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   746
		case ICONSOLE_VAR_STRING:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   747
			item_new->data.string_ = addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   748
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   749
		default:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   750
			error("unknown console variable type");
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   751
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   752
	}
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   753
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   754
	IConsoleVarInsert(item_new, name);
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   755
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   756
	item_new->type = type;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   757
	item_new->_malloc = false;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   758
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   759
	item_new->hook_access = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   760
	item_new->hook_after_change = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   761
	item_new->hook_before_change = NULL;
618
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   762
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   763
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   764
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   765
void IConsoleVarMemRegister(const char* name, _iconsole_var_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   766
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   767
	_iconsole_var* item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   768
	item = IConsoleVarAlloc(type);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   769
	IConsoleVarInsert(item, name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   770
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   771
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   772
_iconsole_var* IConsoleVarGet(const char* name)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   773
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   774
	_iconsole_var* item;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   775
	for (item = _iconsole_vars; item != NULL; item = item->_next)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   776
		if (strcmp(item->name, name) == 0) return item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   777
	return NULL;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   778
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   779
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   780
_iconsole_var* IConsoleVarAlloc(_iconsole_var_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   781
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   782
	_iconsole_var* item = malloc(sizeof(_iconsole_var)); /* XXX unchecked malloc */
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   783
	item->_next = NULL;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   784
	item->name = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   785
	item->type = type;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   786
	switch (item->type) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   787
		case ICONSOLE_VAR_BOOLEAN:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   788
			item->data.bool_ = malloc(sizeof(*item->data.bool_));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   789
			*item->data.bool_ = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   790
			item->_malloc = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   791
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   792
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   793
		case ICONSOLE_VAR_UINT8:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   794
			item->data.byte_ = malloc(sizeof(*item->data.byte_));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   795
			*item->data.byte_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   796
			item->_malloc = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   797
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   798
		case ICONSOLE_VAR_UINT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   799
			item->data.uint16_ = malloc(sizeof(*item->data.uint16_));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   800
			*item->data.uint16_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   801
			item->_malloc = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   802
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   803
		case ICONSOLE_VAR_UINT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   804
			item->data.uint32_ = malloc(sizeof(*item->data.uint32_));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   805
			*item->data.uint32_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   806
			item->_malloc = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   807
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   808
		case ICONSOLE_VAR_INT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   809
			item->data.int16_ = malloc(sizeof(*item->data.int16_));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   810
			*item->data.int16_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   811
			item->_malloc = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   812
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   813
		case ICONSOLE_VAR_INT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   814
			item->data.int32_ = malloc(sizeof(*item->data.int32_));
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   815
			*item->data.int32_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   816
			item->_malloc = true;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   817
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   818
		case ICONSOLE_VAR_POINTER:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   819
		case ICONSOLE_VAR_STRING:
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   820
			// needs no memory ... it gets memory when it is set to an value
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   821
			item->data.addr = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   822
			item->_malloc = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   823
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   824
		default:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   825
			error("unknown console variable type");
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   826
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   827
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   828
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   829
	item->hook_access = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   830
	item->hook_after_change = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   831
	item->hook_before_change = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   832
	return item;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   833
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   834
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   835
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   836
void IConsoleVarFree(_iconsole_var* var)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   837
{
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
   838
	if (var->_malloc)
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   839
		free(var->data.addr);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   840
	free(var->name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   841
	free(var);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   842
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   843
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   844
void IConsoleVarSetString(_iconsole_var* var, const char* string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   845
{
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   846
	if (string == NULL) return;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   847
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   848
	if (var->_malloc)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   849
		free(var->data.string_);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   850
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   851
	var->data.string_ = strdup(string);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   852
	var->_malloc = true;
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
   853
}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   854
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   855
void IConsoleVarSetValue(_iconsole_var* var, int value) {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   856
	switch (var->type) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   857
		case ICONSOLE_VAR_BOOLEAN:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   858
			*var->data.bool_ = (value != 0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   859
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   860
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   861
		case ICONSOLE_VAR_UINT8:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   862
			*var->data.byte_ = value;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   863
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   864
		case ICONSOLE_VAR_UINT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   865
			*var->data.uint16_ = value;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   866
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   867
		case ICONSOLE_VAR_UINT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   868
			*var->data.uint32_ = value;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   869
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   870
		case ICONSOLE_VAR_INT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   871
			*var->data.int16_ = value;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   872
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   873
		case ICONSOLE_VAR_INT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   874
			*var->data.int32_ = value;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   875
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   876
		default:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   877
			assert(0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   878
			break;
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
   879
	}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   880
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   881
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   882
void IConsoleVarDump(const _iconsole_var* var, const char* dump_desc)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   883
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   884
	if (var == NULL) return;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   885
	if (dump_desc == NULL) dump_desc = var->name;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   886
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   887
	switch (var->type) {
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   888
		case ICONSOLE_VAR_BOOLEAN:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   889
			IConsolePrintF(_iconsole_color_default, "%s = %s",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   890
				dump_desc, *var->data.bool_ ? "true" : "false");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   891
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   892
		break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   893
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   894
		case ICONSOLE_VAR_UINT8:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   895
			IConsolePrintF(_iconsole_color_default, "%s = %u",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   896
				dump_desc, *var->data.byte_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   897
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   898
		case ICONSOLE_VAR_UINT16:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   899
			IConsolePrintF(_iconsole_color_default, "%s = %u",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   900
				dump_desc, *var->data.uint16_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   901
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   902
		case ICONSOLE_VAR_UINT32:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   903
			IConsolePrintF(_iconsole_color_default, "%s = %u",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   904
				dump_desc, *var->data.uint32_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   905
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   906
		case ICONSOLE_VAR_INT16:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   907
			IConsolePrintF(_iconsole_color_default, "%s = %i",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   908
				dump_desc, *var->data.int16_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   909
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   910
		case ICONSOLE_VAR_INT32:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   911
			IConsolePrintF(_iconsole_color_default, "%s = %i",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   912
				dump_desc, *var->data.int32_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   913
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   914
		case ICONSOLE_VAR_STRING:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   915
			IConsolePrintF(_iconsole_color_default, "%s = %s",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   916
				dump_desc, var->data.string_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   917
			break;
141
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   918
		case ICONSOLE_VAR_REFERENCE:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   919
			IConsolePrintF(_iconsole_color_default, "%s = @%s",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   920
				dump_desc, var->data.reference_);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   921
		case ICONSOLE_VAR_UNKNOWN:
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   922
		case ICONSOLE_VAR_POINTER:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   923
			IConsolePrintF(_iconsole_color_default, "%s = @%p",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   924
				dump_desc, var->data.addr);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   925
			break;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   926
		case ICONSOLE_VAR_NONE:
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   927
			IConsolePrintF(_iconsole_color_default, "%s = [nothing]",
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
   928
				dump_desc);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   929
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   930
	}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   931
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   932
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   933
// * ************************* * //
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   934
// * hooking code              * //
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   935
// * ************************* * //
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   936
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   937
void IConsoleVarHook(const char* name, _iconsole_hook_types type, iconsole_var_hook proc)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   938
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   939
	_iconsole_var* hook_var = IConsoleVarGet(name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   940
	if (hook_var == NULL) return;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   941
	switch (type) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   942
		case ICONSOLE_HOOK_BEFORE_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   943
			hook_var->hook_before_change = proc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   944
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   945
		case ICONSOLE_HOOK_AFTER_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   946
			hook_var->hook_after_change = proc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   947
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   948
		case ICONSOLE_HOOK_ACCESS:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   949
			hook_var->hook_access = proc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   950
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   951
		case ICONSOLE_HOOK_BEFORE_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   952
		case ICONSOLE_HOOK_AFTER_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   953
			assert(0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   954
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   955
	}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   956
}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   957
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   958
bool IConsoleVarHookHandle(_iconsole_var* hook_var, _iconsole_hook_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   959
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   960
	iconsole_var_hook proc;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   961
	if (hook_var == NULL) return false;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   962
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   963
	proc = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   964
	switch (type) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   965
		case ICONSOLE_HOOK_BEFORE_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   966
			proc = hook_var->hook_before_change;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   967
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   968
		case ICONSOLE_HOOK_AFTER_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   969
			proc = hook_var->hook_after_change;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   970
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   971
		case ICONSOLE_HOOK_ACCESS:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   972
			proc = hook_var->hook_access;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   973
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   974
		case ICONSOLE_HOOK_BEFORE_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   975
		case ICONSOLE_HOOK_AFTER_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   976
			assert(0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   977
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   978
	}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   979
	return proc == NULL ? true : proc(hook_var);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   980
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   981
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   982
void IConsoleCmdHook(const char* name, _iconsole_hook_types type, iconsole_cmd_hook proc)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   983
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   984
	_iconsole_cmd* hook_cmd = IConsoleCmdGet(name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   985
	if (hook_cmd == NULL) return;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   986
	switch (type) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   987
		case ICONSOLE_HOOK_AFTER_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   988
			hook_cmd->hook_after_exec = proc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   989
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   990
		case ICONSOLE_HOOK_BEFORE_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   991
			hook_cmd->hook_before_exec = proc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   992
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   993
		case ICONSOLE_HOOK_ACCESS:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   994
			hook_cmd->hook_access = proc;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   995
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   996
		case ICONSOLE_HOOK_BEFORE_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   997
		case ICONSOLE_HOOK_AFTER_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   998
			assert(0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   999
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1000
	}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1001
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1002
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1003
bool IConsoleCmdHookHandle(_iconsole_cmd* hook_cmd, _iconsole_hook_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1004
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1005
	iconsole_cmd_hook proc = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1006
	switch (type) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1007
		case ICONSOLE_HOOK_AFTER_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1008
			proc = hook_cmd->hook_after_exec;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1009
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1010
		case ICONSOLE_HOOK_BEFORE_EXEC:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1011
			proc = hook_cmd->hook_before_exec;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1012
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1013
		case ICONSOLE_HOOK_ACCESS:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1014
			proc = hook_cmd->hook_access;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1015
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1016
		case ICONSOLE_HOOK_BEFORE_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1017
		case ICONSOLE_HOOK_AFTER_CHANGE:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1018
			assert(0);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1019
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1020
	}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1021
	return proc == NULL ? true : proc(hook_cmd);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1022
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1023
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1024
void IConsoleCmdExec(const char* cmdstr)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1025
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1026
	_iconsole_cmd_addr function;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1027
	char* tokens[20];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1028
	byte  tokentypes[20];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1029
	char* tokenstream;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1030
	char* tokenstream_s;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1031
	byte  execution_mode;
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1032
	_iconsole_var* var     = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1033
	_iconsole_var* result  = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1034
	_iconsole_cmd* cmd     = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1035
	_iconsole_alias* alias = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1036
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1037
	bool longtoken;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1038
	bool valid_token;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1039
	bool skip_lt_change;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1040
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1041
	int c;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1042
	int i;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1043
	int l;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1044
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
  1045
	if (_stdlib_con_developer)
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
  1046
		IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr);
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
  1047
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1048
	//** clearing buffer **//
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1049
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1050
	for (i = 0; i < 20; i++) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1051
		tokens[i] = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1052
		tokentypes[i] = ICONSOLE_VAR_NONE;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1053
	}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1054
	tokenstream_s = tokenstream = malloc(1024);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1055
	memset(tokenstream, 0, 1024);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1056
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1057
	//** parsing **//
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1058
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1059
	longtoken = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1060
	valid_token = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1061
	skip_lt_change = false;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1062
	l = strlen(cmdstr);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1063
	i = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1064
	c = 0;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1065
	tokens[c] = tokenstream;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1066
	tokentypes[c] = ICONSOLE_VAR_UNKNOWN;
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1067
	while (i < l && c < lengthof(tokens) - 1) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1068
		if (cmdstr[i] == '"') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1069
			if (longtoken) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1070
				if (cmdstr[i + 1] == '"') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1071
					i++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1072
					*tokenstream = '"';
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1073
					tokenstream++;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1074
					skip_lt_change = true;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1075
				} else {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1076
					longtoken = !longtoken;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1077
					tokentypes[c] = ICONSOLE_VAR_STRING;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1078
				}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1079
			} else {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1080
				longtoken = !longtoken;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1081
				tokentypes[c] = ICONSOLE_VAR_STRING;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1082
			}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1083
			if (!skip_lt_change) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1084
				if (!longtoken) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1085
					if (valid_token) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1086
						c++;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1087
						*tokenstream = '\0';
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1088
						tokenstream++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1089
						tokens[c] = tokenstream;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1090
						tokentypes[c] = ICONSOLE_VAR_UNKNOWN;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1091
						valid_token = false;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1092
					}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1093
				}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1094
				skip_lt_change=false;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1095
			}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1096
		} else if (!longtoken && cmdstr[i] == ' ') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1097
			if (valid_token) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1098
				c++;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1099
				*tokenstream = '\0';
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1100
				tokenstream++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1101
				tokens[c] = tokenstream;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1102
				tokentypes[c] = ICONSOLE_VAR_UNKNOWN;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1103
				valid_token = false;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1104
			}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1105
		} else {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1106
			valid_token = true;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1107
			*tokenstream = cmdstr[i];
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1108
			tokenstream++;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1109
		}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1110
		i++;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1111
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1112
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1113
	tokenstream--;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1114
	if (*tokenstream != '\0') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1115
		c++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1116
		tokenstream++;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1117
		*tokenstream = '\0';
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1118
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1119
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1120
	//** interpreting **//
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1121
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1122
	for (i = 0; i < c; i++) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1123
		if (tokens[i] != NULL && i > 0 && strlen(tokens[i]) > 0) {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1124
			if (IConsoleVarGet((char *)tokens[i]) != NULL) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1125
				// change the variable to an pointer if execution_mode != 4 is
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1126
				// being prepared. execution_mode 4 is used to assign
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1127
				// one variables data to another one
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1128
				// [token 0 and 2]
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1129
				if (!((i == 2) && (tokentypes[1] == ICONSOLE_VAR_UNKNOWN) &&
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1130
					(strcmp(tokens[1], "<<") == 0))) {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1131
					// only look for another variable if it isnt an longtoken == string with ""
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1132
					var = NULL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1133
					if (tokentypes[i]!=ICONSOLE_VAR_STRING) var = IConsoleVarGet(tokens[i]);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1134
					if (var != NULL) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1135
						// pointer to the data --> token
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1136
						tokens[i] = (char *) var->data.addr; /* XXX: maybe someone finds an cleaner way to do this */
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1137
						tokentypes[i] = var->type;
141
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
  1138
					}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1139
				}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1140
			}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1141
			if (tokens[i] != NULL && tokens[i][0] == '@' && (IConsoleVarGet(tokens[i]+1) != NULL)) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1142
				var = IConsoleVarGet(tokens[i]+1);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1143
				if (var != NULL) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1144
					// pointer to the _iconsole_var struct --> token
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1145
					tokens[i] = (char *) var; /* XXX: maybe someone finds an cleaner way to do this */
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1146
					tokentypes[i] = ICONSOLE_VAR_REFERENCE;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1147
				}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1148
			}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1149
		}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1150
	}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1151
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1152
	execution_mode=0;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1153
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1154
	function = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1155
	cmd = IConsoleCmdGet(tokens[0]);
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1156
	if (cmd != NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1157
		function = cmd->addr;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1158
	} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1159
		alias = IConsoleAliasGet(tokens[0]);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1160
		if (alias != NULL) execution_mode = 5; // alias handling
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1161
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1162
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1163
	if (function != NULL) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1164
		execution_mode = 1; // this is a command
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1165
	} else {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1166
		var = IConsoleVarGet(tokens[0]);
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1167
		if (var != NULL) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1168
			execution_mode = 2; // this is a variable
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1169
			if (c > 2 && strcmp(tokens[1], "<<") == 0) {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1170
				// this is command to variable mode [normal]
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1171
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1172
				function = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1173
				cmd = IConsoleCmdGet(tokens[2]);
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1174
				if (cmd != NULL) function = cmd->addr;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1175
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1176
				if (function != NULL) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1177
					execution_mode = 3;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1178
				} else {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1179
					result = IConsoleVarGet(tokens[2]);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1180
					if (result != NULL)
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1181
						execution_mode = 4;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1182
				}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1183
			}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1184
		}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1185
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1186
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1187
	//** executing **//
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1188
	if (_stdlib_con_developer)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1189
		IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_mode: %i",
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1190
			execution_mode);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1191
	switch (execution_mode) {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1192
		case 0:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1193
			// not found
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1194
			IConsoleError("command or variable not found");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1195
			break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1196
		case 1:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1197
			if (IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_ACCESS)) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1198
				// execution with command syntax
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1199
				IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_BEFORE_EXEC);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1200
				result = function(c, tokens, tokentypes);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1201
				if (result != NULL) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1202
					IConsoleVarDump(result, "result");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1203
					IConsoleVarFree(result);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1204
				}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1205
				IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_AFTER_EXEC);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1206
				break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1207
			}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1208
		case 2:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1209
		{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1210
			// execution with variable syntax
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1211
			if (IConsoleVarHookHandle(var, ICONSOLE_HOOK_ACCESS) && (c == 2 || c == 3)) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1212
				// ** variable modifications ** //
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1213
				IConsoleVarHookHandle(var, ICONSOLE_HOOK_BEFORE_CHANGE);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1214
				switch (var->type) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1215
					case ICONSOLE_VAR_BOOLEAN:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1216
					{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1217
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1218
							if (c == 3) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1219
								*var->data.bool_ = (atoi(tokens[2]) != 0);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1220
							} else {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1221
								*var->data.bool_ = false;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1222
							}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1223
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1224
						} else if (strcmp(tokens[1], "++") == 0) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1225
							*var->data.bool_ = true;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1226
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1227
						} else if (strcmp(tokens[1], "--") == 0) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1228
							*var->data.bool_ = false;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1229
							IConsoleVarDump(var, NULL);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1230
						}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1231
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1232
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1233
						break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1234
					}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1235
					case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1236
					case ICONSOLE_VAR_UINT8:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1237
					{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1238
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1239
							if (c == 3)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1240
								*var->data.byte_ = atoi(tokens[2]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1241
							else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1242
								*var->data.byte_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1243
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1244
						} else if (strcmp(tokens[1], "++") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1245
							++*var->data.byte_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1246
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1247
						} else if (strcmp(tokens[1], "--")==0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1248
							--*var->data.byte_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1249
							IConsoleVarDump(var, NULL);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1250
						}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1251
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1252
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1253
						break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1254
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1255
					case ICONSOLE_VAR_UINT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1256
					{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1257
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1258
							if (c == 3)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1259
								*var->data.uint16_ = atoi(tokens[2]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1260
							else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1261
								*var->data.uint16_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1262
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1263
						} else if (strcmp(tokens[1], "++") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1264
							++*var->data.uint16_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1265
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1266
						} else if (strcmp(tokens[1], "--") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1267
							--*var->data.uint16_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1268
							IConsoleVarDump(var, NULL);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1269
						}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1270
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1271
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1272
						break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1273
					}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1274
					case ICONSOLE_VAR_UINT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1275
					{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1276
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1277
							if (c == 3)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1278
								*var->data.uint32_ = atoi(tokens[2]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1279
							else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1280
								*var->data.uint32_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1281
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1282
						} else if (strcmp(tokens[1], "++") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1283
							++*var->data.uint32_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1284
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1285
						} else if (strcmp(tokens[1], "--") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1286
							--*var->data.uint32_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1287
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1288
						}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1289
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1290
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1291
						break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1292
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1293
					case ICONSOLE_VAR_INT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1294
					{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1295
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1296
							if (c == 3)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1297
								*var->data.int16_ = atoi(tokens[2]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1298
							else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1299
								*var->data.int16_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1300
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1301
						} else if (strcmp(tokens[1], "++") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1302
							++*var->data.int16_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1303
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1304
						} else if (strcmp(tokens[1], "--") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1305
							--*var->data.int16_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1306
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1307
						}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1308
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1309
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1310
						break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1311
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1312
					case ICONSOLE_VAR_INT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1313
					{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1314
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1315
							if (c == 3)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1316
								*var->data.int32_ = atoi(tokens[2]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1317
							else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1318
								*var->data.int32_ = 0;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1319
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1320
						} else if (strcmp(tokens[1], "++") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1321
							++*var->data.int32_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1322
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1323
						} else if (strcmp(tokens[1], "--") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1324
							--*var->data.int32_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1325
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1326
						}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1327
						else { IConsoleError("operation not supported"); }
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1328
						break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1329
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1330
					case ICONSOLE_VAR_STRING:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1331
					{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1332
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1333
							if (c == 3)
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1334
								IConsoleVarSetString(var, tokens[2]);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1335
							else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1336
								IConsoleVarSetString(var, "");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1337
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1338
						}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1339
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1340
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1341
						break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1342
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1343
					case ICONSOLE_VAR_POINTER:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1344
					{
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1345
						if (strcmp(tokens[1], "=") == 0) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1346
							if (c == 3) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1347
								if (tokentypes[2] == ICONSOLE_VAR_UNKNOWN)
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1348
									var->data.addr = (void*)atoi(tokens[2]); /* direct access on memory [by address] */
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1349
								else
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1350
									var->data.addr = (void*)tokens[2]; /* direct acces on memory [by variable] */
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1351
							} else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1352
								var->data.addr = NULL;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1353
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1354
						} else if (strcmp(tokens[1], "++") == 0) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1355
							++*(char*)&var->data.addr; /* change the address + 1 */
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1356
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1357
						} else if (strcmp(tokens[1], "--") == 0) {
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1358
							--*(char*)&var->data.addr; /* change the address - 1 */
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1359
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1360
						}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1361
						else
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1362
							IConsoleError("operation not supported");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1363
						break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1364
					}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1365
					case ICONSOLE_VAR_NONE:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1366
					case ICONSOLE_VAR_REFERENCE:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1367
					case ICONSOLE_VAR_UNKNOWN:
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1368
						IConsoleError("operation not supported");
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1369
						break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1370
				}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1371
				IConsoleVarHookHandle(var, ICONSOLE_HOOK_AFTER_CHANGE);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1372
			}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1373
			if (c == 1) // ** variable output ** //
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1374
				IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1375
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1376
		}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1377
		case 3:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1378
		case 4:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1379
		{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1380
			// execute command with result or assign a variable
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1381
			if (execution_mode == 3) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1382
				if (IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_ACCESS)) {
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1383
					int i;
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1384
					int diff;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1385
					void* temp;
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1386
					byte temp2;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1387
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1388
					// tokenshifting
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1389
					for (diff = 0; diff < 2; diff++) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1390
						temp = tokens[0];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1391
						temp2 = tokentypes[0];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1392
						for (i = 0; i < 19; i++) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1393
							tokens[i] = tokens[i + 1];
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1394
							tokentypes[i] = tokentypes[i + 1];
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1395
						}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1396
						tokens[19] = temp;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1397
						tokentypes[19] = temp2;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1398
					}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1399
					IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_BEFORE_EXEC);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1400
					result = function(c, tokens, tokentypes);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1401
					IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_AFTER_EXEC);
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
  1402
				} else
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1403
					execution_mode = 255;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1404
			}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1405
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1406
			if (IConsoleVarHookHandle(var, ICONSOLE_HOOK_ACCESS) && result != NULL) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1407
				if (result->type != var->type) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1408
					IConsoleError("variable type missmatch");
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1409
				} else {
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1410
					IConsoleVarHookHandle(var, ICONSOLE_HOOK_BEFORE_CHANGE);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1411
					switch (result->type) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1412
						case ICONSOLE_VAR_BOOLEAN:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1413
							*var->data.bool_ = *result->data.bool_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1414
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1415
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1416
						case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1417
						case ICONSOLE_VAR_UINT8:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1418
							*var->data.byte_ = *result->data.byte_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1419
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1420
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1421
						case ICONSOLE_VAR_UINT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1422
							*var->data.uint16_ = *result->data.uint16_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1423
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1424
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1425
						case ICONSOLE_VAR_UINT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1426
							*var->data.uint32_ = *result->data.uint32_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1427
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1428
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1429
						case ICONSOLE_VAR_INT16:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1430
							*var->data.int16_ = *result->data.int16_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1431
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1432
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1433
						case ICONSOLE_VAR_INT32:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1434
							*var->data.int32_ = *result->data.int32_;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1435
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1436
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1437
						case ICONSOLE_VAR_POINTER:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1438
							var->data.addr = result->data.addr;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1439
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1440
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1441
						case ICONSOLE_VAR_STRING:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1442
							IConsoleVarSetString(var, result->data.string_);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1443
							IConsoleVarDump(var, NULL);
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1444
							break;
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1445
						default:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1446
							IConsoleError("variable type missmatch");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1447
							break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1448
					}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1449
					IConsoleVarHookHandle(var, ICONSOLE_HOOK_AFTER_CHANGE);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1450
				}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1451
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1452
				if (execution_mode == 3) {
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1453
					IConsoleVarFree(result);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1454
				}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1455
			}
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1456
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1457
		}
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1458
		case 5: {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1459
			// execute an alias
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1460
			IConsoleAliasExec(alias->cmdline, tokens,tokentypes);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1461
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1462
			break;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1463
		default:
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1464
			// execution mode invalid
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1465
			IConsoleError("invalid execution mode");
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1466
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1467
	}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1468
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
  1469
	//** freeing the tokenstream **//
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1470
	free(tokenstream_s);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
  1471
}