console.c
author darkvater
Tue, 11 Jan 2005 23:39:21 +0000
changeset 986 239603c9dd34
parent 959 b031d88c76f3
child 1008 92f933a67f3b
permissions -rw-r--r--
(svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (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
{
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
    97
	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
    98
		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
    99
		{
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
   100
			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
   101
			int max = (w->height / ICON_LINE_HEIGHT) - 1;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   102
			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
   103
			GfxFillRect(w->left, w->top, w->width, w->height - 1, 0);
986
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   104
			while ((i > 0) && (i > _iconsole_scroll - max) && (_iconsole_buffer[i] != 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
   105
				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
   106
					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
   107
				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
   108
			}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   109
			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
   110
			if (delta > 0) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   111
				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
   112
				delta = 0;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   113
			}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   114
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   115
			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
   116
			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
   117
		}
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
   118
		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
   119
			_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
   120
			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
   121
				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
   122
				int posy;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   123
				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
   124
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
   125
				_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
   126
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
   127
				_cur_dpi = &_screen;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   128
				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
   129
				if (delta > 0)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   130
					delta = 0;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   131
				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
   132
				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
   133
				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
   134
				_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
   135
				_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
   136
			}
1e1102dd2a62 (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
			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
   138
		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
   139
			_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
   140
			_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
   141
			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
   142
		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
   143
		{
1e1102dd2a62 (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
			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
   145
			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
   146
				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
   147
					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
   148
					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
   149
					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
   150
				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
   151
					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
   152
					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
   153
					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
   154
				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
   155
					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
   156
					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
   157
					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
   158
				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
   159
					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
   160
						_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
   161
					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
   162
						_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
   163
					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
   164
					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
   165
				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
   166
					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
   167
						_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
   168
					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
   169
						_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
   170
					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
   171
					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
   172
				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
   173
					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
   174
						_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
   175
					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
   176
						--_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
   177
					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
   178
					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
   179
				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
   180
					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
   181
						_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
   182
					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
   183
						++_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
   184
					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
   185
					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
   186
				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
   187
					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
   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_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
   190
					IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   191
					_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
   192
					IConsoleCmdBufferAdd(_iconsole_cmdline);
672
d06d46264039 (svn r1110) -Fix: Empty console commands were executed and returned error message (sign_de for GeniusDex)
darkvater
parents: 659
diff changeset
   193
					if (strlen(_iconsole_cmdline) != 0) // only execute if there is something typed obviously
d06d46264039 (svn r1110) -Fix: Empty console commands were executed and returned error message (sign_de for GeniusDex)
darkvater
parents: 659
diff changeset
   194
						IConsoleCmdExec(_iconsole_cmdline);
d06d46264039 (svn r1110) -Fix: Empty console commands were executed and returned error message (sign_de for GeniusDex)
darkvater
parents: 659
diff changeset
   195
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
   196
					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
   197
					break;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   198
				case WKC_CTRL | WKC_RETURN:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   199
					if (_iconsole_mode == ICONSOLE_FULL) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   200
						_iconsole_mode = ICONSOLE_OPENED;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   201
					} else {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   202
						_iconsole_mode = ICONSOLE_FULL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   203
					}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   204
					IConsoleResize();
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   205
					MarkWholeScreenDirty();
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   206
					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
   207
				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
   208
					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
   209
					_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
   210
					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
   211
					_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
   212
					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
   213
				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
   214
					/* 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
   215
					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
   216
						_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
   217
						_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
   218
						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
   219
							_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
   220
						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
   221
						_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
   222
					}
1e1102dd2a62 (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
					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
   224
						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
   225
			}
1e1102dd2a62 (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
			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
   227
		}
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
   228
	}
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
659
a98c731921b4 (svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents: 656
diff changeset
   231
extern const char _openttd_revision[];
a98c731921b4 (svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents: 656
diff changeset
   232
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
   233
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
   234
{
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
   235
	uint i;
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   236
	_iconsole_output_file = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   237
	_iconsole_color_default = 1;
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   238
	_iconsole_color_error = 3;
229
b94bfdf02bae (svn r230) -Feature: IConsoleWarning for warning messages
signde
parents: 228
diff changeset
   239
	_iconsole_color_warning = 13;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   240
	_iconsole_color_debug = 5;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   241
	_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
   242
	_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
   243
	_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
   244
	_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
   245
	_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
   246
	_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
   247
	_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
   248
	_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
   249
	_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
   250
	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
   251
		_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
   252
	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
   253
		_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
   254
		_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
   255
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   256
	IConsoleStdLibRegister();
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   257
	IConsolePrintF(13, "OpenTTD Game Console Revision 6 - %s", _openttd_revision);
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
   258
	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
   259
	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
   260
	IConsolePrint(12, "");
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   261
	IConsoleClearCommand();
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   262
	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
   263
}
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
   264
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
   265
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
   266
{
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
   267
	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
   268
	for (i = 0; i <= ICON_BUFFER; i++)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   269
		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
   270
}
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
   271
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
   272
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
   273
{
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
   274
	_iconsole_inited = false;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   275
	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
   276
	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
   277
}
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
   278
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
   279
void IConsoleResize(void)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   280
{
986
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   281
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   282
	_iconsole_win = FindWindowById(WC_CONSOLE, 0);
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   283
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   284
	switch (_iconsole_mode) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   285
		case ICONSOLE_OPENED:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   286
			_iconsole_win->height = _screen.height / 3;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   287
			_iconsole_win->width = _screen.width;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   288
			break;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   289
		case ICONSOLE_FULL:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   290
			_iconsole_win->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   291
			_iconsole_win->width = _screen.width;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   292
			break;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   293
		default:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   294
			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
   295
	}
986
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   296
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   297
	MarkWholeScreenDirty();
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
   298
}
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
   299
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
   300
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
   301
{
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
   302
	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
   303
		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
   304
			_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
   305
			_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
   306
			_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
   307
			_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
   308
			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
   309
		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
   310
			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
   311
			_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
   312
			_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
   313
			break;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   314
		case ICONSOLE_FULL:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   315
			DeleteWindowById(WC_CONSOLE, 0);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   316
			_iconsole_win = NULL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   317
			_iconsole_mode = ICONSOLE_CLOSED;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   318
			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
   319
	}
986
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   320
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   321
	MarkWholeScreenDirty();
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
   322
}
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
   323
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
   324
void IConsoleClose(void)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   325
{
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
   326
	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
   327
}
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
   328
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
   329
void IConsoleOpen(void)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   330
{
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
   331
	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
   332
}
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
   333
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
   334
void IConsoleCmdBufferAdd(const char* cmd)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   335
{
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   336
	int i;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   337
	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
   338
	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
   339
	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
   340
	_iconsole_cmdbuffer[0] = strdup(cmd);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   341
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   342
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   343
void IConsoleCmdBufferNavigate(signed char direction)
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   344
{
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   345
	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
   346
	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
   347
	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
   348
	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
   349
	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
   350
		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
   351
			++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
   352
			if (i > 19) i = 0;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   353
		}
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
   354
	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
   355
		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
   356
			--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
   357
			if (i < 0) i = 19;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   358
		}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   359
	_iconsole_cmdbufferpos = i;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   360
	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
   361
	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
   362
		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
   363
	_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
   364
}
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
   365
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   366
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
   367
{
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
   368
	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
   369
	char* _new;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   370
	uint16 _exc;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   371
	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
   372
	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
   373
	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
   374
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   375
	if (_network_dedicated) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   376
		printf("%s\n", string);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   377
		return;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   378
	}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   379
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   380
	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
   381
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
   382
	_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
   383
	_new = strdup(string);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   384
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
   385
	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
   386
		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
   387
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
   388
	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
   389
		_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
   390
		_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
   391
		_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
   392
		_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
   393
		_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
   394
		_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
   395
	}
1e1102dd2a62 (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
	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
   397
650
e29098665100 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents: 644
diff changeset
   398
	if (_iconsole_output_file != NULL) {
e29098665100 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents: 644
diff changeset
   399
		// if there is an console output file ... also print it there
e29098665100 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents: 644
diff changeset
   400
		fwrite(string, strlen(string), 1, _iconsole_output_file);
e29098665100 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents: 644
diff changeset
   401
		fwrite("\n", 1, 1, _iconsole_output_file);
e29098665100 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents: 644
diff changeset
   402
	}
e29098665100 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents: 644
diff changeset
   403
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
   404
	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
   405
}
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
   406
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
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   408
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
   409
{
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
   410
	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
   411
	char buf[1024];
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   412
	int len;
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   413
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_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
   415
	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
   416
	va_end(va);
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   417
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
   418
	IConsolePrint(color_code, buf);
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
   419
}
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
   420
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
   421
void IConsoleDebug(const char* string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   422
{
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
   423
	if (_stdlib_developer > 1)
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   424
		IConsolePrintF(_iconsole_color_debug, "dbg: %s", string);
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   425
}
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
   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
void IConsoleError(const char* string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   428
{
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
   429
	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
   430
		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
   431
}
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
   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
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
   434
{
1e1102dd2a62 (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
	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
   436
		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
   437
}
1e1102dd2a62 (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
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
   440
{
1e1102dd2a62 (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
	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
   442
	_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
   443
	_iconsole_cmd* item_new;
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   444
	_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
   445
1e1102dd2a62 (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
	_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
   447
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   448
	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
   449
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   450
	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
   451
	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
   452
	item_new->name = _new;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   453
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   454
	item_new->hook_access = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   455
	item_new->hook_after_exec = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   456
	item_new->hook_before_exec = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   457
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   458
	item_before = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   459
	item = _iconsole_cmds;
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   460
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   461
	if (item == NULL) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   462
		_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
   463
	} else {
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   464
		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
   465
			item_before = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   466
			item = item->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   467
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   468
// insertion sort
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   469
		if (item_before==NULL) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   470
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   471
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   472
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   473
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   474
				// inserting as startitem
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   475
				_iconsole_cmds = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   476
				item_new ->_next = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   477
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   478
		} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   479
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   480
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   481
				item ->_next = item_new;
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
				// inserting
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   484
				item_new ->_next = item_before->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   485
				item_before ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   486
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   487
		}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   488
// 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
   489
	}
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   490
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   491
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   492
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
_iconsole_cmd* IConsoleCmdGet(const char* name)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   494
{
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
   495
	_iconsole_cmd* item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   496
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   497
	item = _iconsole_cmds;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   498
	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
   499
		if (strcmp(item->name, name) == 0) return item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   500
		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
   501
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   502
	return NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   503
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   504
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   505
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
   506
{
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   507
	char* _new;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   508
	char* _newcmd;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   509
	_iconsole_alias* item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   510
	_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
   511
	_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
   512
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   513
	_new = strdup(name);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   514
	_newcmd = strdup(cmdline);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   515
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   516
	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
   517
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   518
	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
   519
	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
   520
	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
   521
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   522
	item_before = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   523
	item = _iconsole_aliases;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   524
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   525
	if (item == NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   526
		_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
   527
	} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   528
		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
   529
			item_before = item;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   530
			item = item->_next;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   531
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   532
// insertion sort
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   533
		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
   534
			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
   535
				// appending
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   536
				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
   537
			} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   538
				// inserting as startitem
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   539
				_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
   540
				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
   541
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   542
		} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   543
			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
   544
				// appending
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   545
				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
   546
			} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   547
				// inserting
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   548
				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
   549
				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
   550
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   551
		}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   552
// insertion sort end
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   553
	}
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
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   557
_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
   558
{
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   559
	_iconsole_alias* item;
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
	item = _iconsole_aliases;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   562
	while (item != NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   563
		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
   564
		item = item->_next;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   565
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   566
	return NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   567
}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   568
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   569
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
   570
	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
   571
	char* linestream;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   572
	char* linestream_s;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   573
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   574
	int c;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   575
	int i;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   576
	int l;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   577
	int x;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   578
	byte t;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   579
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   580
	//** clearing buffer **//
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   581
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   582
	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
   583
		lines[0] = NULL;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   584
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   585
	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
   586
	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
   587
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   588
	//** parsing **//
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   589
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   590
	l = strlen(cmdline);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   591
	i = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   592
	c = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   593
	x = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   594
	t = 0;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   595
	lines[c] = linestream;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   596
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   597
	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
   598
		if (cmdline[i] == '%') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   599
			i++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   600
			if (cmdline[i] == '+') {
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   601
				// all params seperated: "[param 1]" "[param 2]"
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   602
				t=1;
656
01540e6c0fed (svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents: 650
diff changeset
   603
				while ((tokens[t]!=NULL) && (t<20) &&
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   604
						((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
   605
					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
   606
					*linestream = '"';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   607
					linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   608
					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
   609
					linestream += l2;
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
					linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   612
					*linestream = ' ';
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
					x += l2+3;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   615
					t++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   616
				}
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   617
			} else if (cmdline[i] == '!') {
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   618
				// merge the params to one: "[param 1] [param 2] [param 3...]"
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   619
				t=1;
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   620
				*linestream = '"';
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   621
				linestream++;
656
01540e6c0fed (svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents: 650
diff changeset
   622
				while ((tokens[t]!=NULL) && (t<20) &&
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   623
						((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   624
					int l2 = strlen(tokens[t]);
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   625
					memcpy(linestream,tokens[t],l2);
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   626
					linestream += l2;
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   627
					*linestream = ' ';
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   628
					linestream++;
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   629
					x += l2+1;
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   630
					t++;
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   631
				}
932
5fcff6cdc612 (svn r1420) -Fix: Console alias, load_game functionality and load fix (sign_de)
darkvater
parents: 672
diff changeset
   632
				linestream--;
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   633
				*linestream = '"';
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   634
				linestream++;
932
5fcff6cdc612 (svn r1420) -Fix: Console alias, load_game functionality and load fix (sign_de)
darkvater
parents: 672
diff changeset
   635
				x += 1;
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   636
			} else {
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   637
				// one specific parameter: %A = [param 1] %B = [param 2] ...
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   638
				int l2;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   639
				t = ((byte)cmdline[i]) - 64;
656
01540e6c0fed (svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents: 650
diff changeset
   640
				if ((t<20) && (tokens[t]!=NULL) &&
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   641
						((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
   642
					l2 = strlen(tokens[t]);
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   643
					*linestream = '"';
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   644
					linestream++;
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   645
					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
   646
					linestream += l2;
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   647
					*linestream = '"';
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   648
					linestream++;
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   649
					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
   650
				}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   651
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   652
		} else if (cmdline[i] == '\\') {
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   653
			// \\ = \       \' = '      \% = %
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   654
			i++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   655
			if (cmdline[i] == '\\') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   656
				*linestream = '\\';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   657
				linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   658
			} 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
   659
				*linestream = '\'';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   660
				linestream++;
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   661
			} else if (cmdline[i] == '%') {
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   662
				*linestream = '%';
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   663
				linestream++;
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   664
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   665
		} else if (cmdline[i] == '\'') {
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   666
			// ' = "
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   667
			*linestream = '"';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   668
			linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   669
		} else if (cmdline[i] == ';') {
644
e833509107ad (svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents: 640
diff changeset
   670
			// ; = start a new line
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   671
			c++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   672
			*linestream = '\0';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   673
			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
   674
			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
   675
			lines[c] = linestream;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   676
		} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   677
			*linestream = cmdline[i];
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   678
			linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   679
			x++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   680
		}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   681
		i++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   682
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   683
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   684
	linestream--;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   685
	if (*linestream != '\0') {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   686
		c++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   687
		linestream++;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   688
		*linestream = '\0';
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   689
	}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   690
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   691
	for (i=0; i<c; i++)	{
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   692
		IConsoleCmdExec(lines[i]);
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   693
	}
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   694
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   695
	free(linestream_s);
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   696
}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   697
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   698
void IConsoleVarInsert(_iconsole_var* item_new, const char* name)
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   699
{
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   700
	_iconsole_var* item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   701
	_iconsole_var* item_before;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   702
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   703
	item_new->_next = NULL;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   704
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   705
	item_new->name = malloc(strlen(name) + 2); /* XXX unchecked malloc */
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   706
	sprintf(item_new->name, "%s", name);
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   707
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   708
	item_before = NULL;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   709
	item = _iconsole_vars;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   710
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   711
	if (item == NULL) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   712
		_iconsole_vars = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   713
	} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   714
		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
   715
			item_before = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   716
			item = item->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   717
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   718
// insertion sort
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   719
		if (item_before==NULL) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   720
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   721
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   722
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   723
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   724
				// inserting as startitem
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   725
				_iconsole_vars = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   726
				item_new ->_next = item;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   727
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   728
		} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   729
			if (strcmp(item->name,item_new->name)<=0) {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   730
				// appending
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   731
				item ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   732
			} else {
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   733
				// inserting
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   734
				item_new ->_next = item_before->_next;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   735
				item_before ->_next = item_new;
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   736
			}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   737
		}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   738
// insertion sort end
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   739
	}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   740
}
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   741
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
   742
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
   743
{
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
   744
	_iconsole_var* item_new;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   745
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
   746
	item_new = malloc(sizeof(_iconsole_var)); /* XXX unchecked malloc */
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   747
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   748
	item_new->_next = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   749
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
   750
	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
   751
		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
   752
			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
   753
			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
   754
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   755
		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
   756
			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
   757
			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
   758
		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
   759
			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
   760
			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
   761
		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
   762
			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
   763
			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
   764
		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
   765
			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
   766
			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
   767
		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
   768
			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
   769
			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
   770
		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
   771
			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
   772
			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
   773
		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
   774
			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
   775
			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
   776
	}
554
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   777
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
diff changeset
   778
	IConsoleVarInsert(item_new, name);
670b089d7772 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight
parents: 543
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
	item_new->type = type;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   781
	item_new->_malloc = false;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   782
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   783
	item_new->hook_access = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   784
	item_new->hook_after_change = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   785
	item_new->hook_before_change = NULL;
618
b14421f6b2ee (svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents: 554
diff changeset
   786
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   787
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   788
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
   789
void IConsoleVarMemRegister(const char* name, _iconsole_var_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   790
{
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
   791
	_iconsole_var* item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   792
	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
   793
	IConsoleVarInsert(item, name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   794
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   795
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
   796
_iconsole_var* IConsoleVarGet(const char* name)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   797
{
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
   798
	_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
   799
	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
   800
		if (strcmp(item->name, name) == 0) return item;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   801
	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
   802
}
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
   803
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
   804
_iconsole_var* IConsoleVarAlloc(_iconsole_var_types type)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   805
{
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
   806
	_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
   807
	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
   808
	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
   809
	item->type = type;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   810
	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
   811
		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
   812
			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
   813
			*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
   814
			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
   815
			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
   816
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   817
		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
   818
			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
   819
			*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
   820
			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
   821
			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
   822
		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
   823
			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
   824
			*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
   825
			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
   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
		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
   828
			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
   829
			*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
   830
			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
   831
			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
   832
		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
   833
			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
   834
			*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
   835
			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
   836
			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
   837
		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
   838
			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
   839
			*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
   840
			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
   841
			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
   842
		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
   843
		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
   844
			// 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
   845
			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
   846
			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
   847
			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
   848
		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
   849
			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
   850
			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
   851
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   852
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   853
	item->hook_access = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   854
	item->hook_after_change = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   855
	item->hook_before_change = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   856
	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
   857
}
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
   858
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
   859
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
   860
void IConsoleVarFree(_iconsole_var* var)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   861
{
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
   862
	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
   863
		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
   864
	free(var->name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   865
	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
   866
}
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
   867
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
   868
void IConsoleVarSetString(_iconsole_var* var, const char* string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   869
{
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   870
	if (string == NULL) return;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   871
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
   872
	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
   873
		free(var->data.string_);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   874
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
   875
	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
   876
	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
   877
}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   878
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
   879
void IConsoleVarSetValue(_iconsole_var* var, int value) {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   880
	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
   881
		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
   882
			*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
   883
			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
   884
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   885
		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
   886
			*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
   887
			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
   888
		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
   889
			*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
   890
			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
   891
		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
   892
			*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
   893
			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
   894
		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
   895
			*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
   896
			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
   897
		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
   898
			*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
   899
			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
   900
		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
   901
			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
   902
			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
   903
	}
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
   904
}
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
   905
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
   906
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
   907
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   908
	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
   909
	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
   910
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
   911
	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
   912
		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
   913
			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
   914
				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
   915
			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
   916
		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
   917
		case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   918
		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
   919
			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
   920
				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
   921
			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
   922
		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
   923
			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
   924
				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
   925
			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
   926
		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
   927
			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
   928
				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
   929
			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
   930
		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
   931
			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
   932
				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
   933
			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
   934
		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
   935
			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
   936
				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
   937
			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
   938
		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
   939
			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
   940
				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
   941
			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
   942
		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
   943
			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
   944
				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
   945
		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
   946
		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
   947
			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
   948
				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
   949
			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
   950
		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
   951
			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
   952
				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
   953
			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
   954
	}
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
   955
}
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
   956
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   957
// * ************************* * //
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   958
// * hooking code              * //
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   959
// * ************************* * //
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
   960
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
   961
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
   962
{
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
   963
	_iconsole_var* hook_var = IConsoleVarGet(name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   964
	if (hook_var == NULL) return;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   965
	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
   966
		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
   967
			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
   968
			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
   969
		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
   970
			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
   971
			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
   972
		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
   973
			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
   974
			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
   975
		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
   976
		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
   977
			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
   978
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   979
	}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   980
}
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
   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
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
   983
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   984
	iconsole_var_hook proc;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   985
	if (hook_var == NULL) return false;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   986
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   987
	proc = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   988
	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
   989
		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
   990
			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
   991
			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
   992
		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
   993
			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
   994
			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
   995
		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
   996
			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
   997
			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
   998
		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
   999
		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
  1000
			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
  1001
			break;
220
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
	return proc == NULL ? true : proc(hook_var);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1004
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1005
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
  1006
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
  1007
{
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
  1008
	_iconsole_cmd* hook_cmd = IConsoleCmdGet(name);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1009
	if (hook_cmd == NULL) return;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1010
	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
  1011
		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
  1012
			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
  1013
			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
  1014
		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
  1015
			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
  1016
			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
  1017
		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
  1018
			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
  1019
			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
  1020
		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
  1021
		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
  1022
			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
  1023
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1024
	}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1025
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1026
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
  1027
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
  1028
{
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
  1029
	iconsole_cmd_hook proc = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1030
	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
  1031
		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
  1032
			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
  1033
			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
  1034
		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
  1035
			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
  1036
			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
  1037
		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
  1038
			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
  1039
			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
  1040
		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
  1041
		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
  1042
			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
  1043
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1044
	}
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
  1045
	return proc == NULL ? true : proc(hook_cmd);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1046
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1047
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
  1048
void IConsoleCmdExec(const char* cmdstr)
220
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
	_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
  1051
	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
  1052
	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
  1053
	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
  1054
	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
  1055
	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
  1056
	_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
  1057
	_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
  1058
	_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
  1059
	_iconsole_alias* alias = NULL;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1060
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1061
	bool longtoken;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1062
	bool valid_token;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1063
	bool skip_lt_change;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1064
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 932
diff changeset
  1065
	uint c;
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 932
diff changeset
  1066
	uint i;
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 932
diff changeset
  1067
	uint l;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1068
640
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
  1069
	if (_stdlib_con_developer)
b1f21d1ac4d3 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
  1070
		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
  1071
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1072
	//** clearing buffer **//
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1073
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
	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
  1075
		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
  1076
		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
  1077
	}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1078
	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
  1079
	memset(tokenstream, 0, 1024);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1080
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1081
	//** parsing **//
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1082
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
  1083
	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
  1084
	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
  1085
	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
  1086
	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
  1087
	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
  1088
	c = 0;
220
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;
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
  1091
	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
  1092
		if (cmdstr[i] == '"') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1093
			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
  1094
				if (cmdstr[i + 1] == '"') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1095
					i++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1096
					*tokenstream = '"';
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1097
					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
  1098
					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
  1099
				} 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
  1100
					longtoken = !longtoken;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1101
					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
  1102
				}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1103
			} 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
  1104
				longtoken = !longtoken;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1105
				tokentypes[c] = ICONSOLE_VAR_STRING;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1106
			}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1107
			if (!skip_lt_change) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1108
				if (!longtoken) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1109
					if (valid_token) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1110
						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
  1111
						*tokenstream = '\0';
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1112
						tokenstream++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1113
						tokens[c] = tokenstream;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1114
						tokentypes[c] = ICONSOLE_VAR_UNKNOWN;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1115
						valid_token = false;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1116
					}
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
				}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1118
				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
  1119
			}
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
  1120
		} else if (!longtoken && cmdstr[i] == ' ') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1121
			if (valid_token) {
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1122
				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
  1123
				*tokenstream = '\0';
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1124
				tokenstream++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1125
				tokens[c] = tokenstream;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1126
				tokentypes[c] = ICONSOLE_VAR_UNKNOWN;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1127
				valid_token = false;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1128
			}
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
  1129
		} 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
  1130
			valid_token = true;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1131
			*tokenstream = cmdstr[i];
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1132
			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
  1133
		}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1134
		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
  1135
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1136
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1137
	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
  1138
	if (*tokenstream != '\0') {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1139
		c++;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1140
		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
  1141
		*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
  1142
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1143
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1144
	//** interpreting **//
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1145
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
	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
  1147
		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
  1148
			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
  1149
				// 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
  1150
				// 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
  1151
				// 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
  1152
				// [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
  1153
				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
  1154
					(strcmp(tokens[1], "<<") == 0))) {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1155
					// 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
  1156
					var = NULL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1157
					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
  1158
					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
  1159
						// pointer to the data --> token
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1160
						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
  1161
						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
  1162
					}
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
  1163
				}
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
  1164
			}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1165
			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
  1166
				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
  1167
				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
  1168
					// pointer to the _iconsole_var struct --> token
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1169
					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
  1170
					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
  1171
				}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1172
			}
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
  1173
		}
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
  1174
	}
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
  1175
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1176
	execution_mode=0;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1177
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1178
	function = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1179
	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
  1180
	if (cmd != NULL) {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1181
		function = cmd->addr;
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1182
	} else {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1183
		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
  1184
		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
  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
	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
  1188
		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
  1189
	} else {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1190
		var = IConsoleVarGet(tokens[0]);
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1191
		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
  1192
			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
  1193
			if (c > 2 && strcmp(tokens[1], "<<") == 0) {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1194
				// 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
  1195
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1196
				function = NULL;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1197
				cmd = IConsoleCmdGet(tokens[2]);
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1198
				if (cmd != NULL) function = cmd->addr;
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1199
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1200
				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
  1201
					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
  1202
				} else {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1203
					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
  1204
					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
  1205
						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
  1206
				}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1207
			}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1208
		}
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
  1209
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1210
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1211
	//** 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
  1212
	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
  1213
		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
  1214
			execution_mode);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1215
	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
  1216
		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
  1217
			// 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
  1218
			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
  1219
			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
  1220
		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
  1221
			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
  1222
				// 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
  1223
				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
  1224
				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
  1225
				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
  1226
					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
  1227
					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
  1228
				}
1e1102dd2a62 (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
				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
  1230
				break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1231
			}
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
  1232
		case 2:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1233
		{
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
  1234
			// 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
  1235
			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
  1236
				// ** 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
  1237
				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
  1238
				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
  1239
					case ICONSOLE_VAR_BOOLEAN:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1240
					{
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
  1241
						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
  1242
							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
  1243
								*var->data.bool_ = (atoi(tokens[2]) != 0);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1244
							} 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
  1245
								*var->data.bool_ = false;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1246
							}
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
  1247
							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
  1248
						} 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
  1249
							*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
  1250
							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
  1251
						} 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
  1252
							*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
  1253
							IConsoleVarDump(var, NULL);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1254
						}
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
  1255
						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
  1256
							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
  1257
						break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1258
					}
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
  1259
					case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1260
					case ICONSOLE_VAR_UINT8:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1261
					{
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
  1262
						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
  1263
							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
  1264
								*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
  1265
							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
  1266
								*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
  1267
							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
  1268
						} 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
  1269
							++*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
  1270
							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
  1271
						} 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
  1272
							--*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
  1273
							IConsoleVarDump(var, NULL);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1274
						}
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
  1275
						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
  1276
							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
  1277
						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
  1278
					}
1e1102dd2a62 (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
					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
  1280
					{
1e1102dd2a62 (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
						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
  1282
							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
  1283
								*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
  1284
							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
  1285
								*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
  1286
							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
  1287
						} 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
  1288
							++*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
  1289
							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
  1290
						} 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
  1291
							--*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
  1292
							IConsoleVarDump(var, NULL);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1293
						}
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
  1294
						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
  1295
							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
  1296
						break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1297
					}
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
  1298
					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
  1299
					{
1e1102dd2a62 (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
						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
  1301
							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
  1302
								*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
  1303
							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
  1304
								*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
  1305
							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
  1306
						} 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
  1307
							++*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
  1308
							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
  1309
						} 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
  1310
							--*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
  1311
							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
  1312
						}
1e1102dd2a62 (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
						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
  1314
							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
  1315
						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
  1316
					}
1e1102dd2a62 (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
					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
  1318
					{
1e1102dd2a62 (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
						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
  1320
							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
  1321
								*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
  1322
							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
  1323
								*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
  1324
							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
  1325
						} 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
  1326
							++*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
  1327
							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
  1328
						} 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
  1329
							--*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
  1330
							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
  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
						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
  1333
							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
  1334
						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
  1335
					}
1e1102dd2a62 (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
					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
  1337
					{
1e1102dd2a62 (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
						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
  1339
							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
  1340
								*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
  1341
							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
  1342
								*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
  1343
							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
  1344
						} 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
  1345
							++*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
  1346
							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
  1347
						} 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
  1348
							--*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
  1349
							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
  1350
						}
1e1102dd2a62 (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 { 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
  1352
						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
  1353
					}
1e1102dd2a62 (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
					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
  1355
					{
1e1102dd2a62 (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
						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
  1357
							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
  1358
								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
  1359
							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
  1360
								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
  1361
							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
  1362
						}
1e1102dd2a62 (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
						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
  1364
							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
  1365
						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
  1366
					}
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
  1367
					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
  1368
					{
1e1102dd2a62 (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
						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
  1370
							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
  1371
								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
  1372
									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
  1373
								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
  1374
									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
  1375
							} 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
  1376
								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
  1377
							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
  1378
						} 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
  1379
							++*(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
  1380
							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
  1381
						} 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
  1382
							--*(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
  1383
							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
  1384
						}
1e1102dd2a62 (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
						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
  1386
							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
  1387
						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
  1388
					}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1389
					case ICONSOLE_VAR_NONE:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1390
					case ICONSOLE_VAR_REFERENCE:
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1391
					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
  1392
						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
  1393
						break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1394
				}
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
  1395
				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
  1396
			}
1e1102dd2a62 (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
			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
  1398
				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
  1399
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1400
		}
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
  1401
		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
  1402
		case 4:
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1403
		{
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
  1404
			// 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
  1405
			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
  1406
				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
  1407
					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
  1408
					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
  1409
					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
  1410
					byte temp2;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1411
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
  1412
					// 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
  1413
					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
  1414
						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
  1415
						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
  1416
						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
  1417
							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
  1418
							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
  1419
						}
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
  1420
						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
  1421
						tokentypes[19] = temp2;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1422
					}
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
  1423
					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
  1424
					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
  1425
					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
  1426
				} 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
  1427
					execution_mode = 255;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1428
			}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1429
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
  1430
			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
  1431
				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
  1432
					IConsoleError("variable type missmatch");
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1433
				} 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
  1434
					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
  1435
					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
  1436
						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
  1437
							*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
  1438
							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
  1439
							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
  1440
						case ICONSOLE_VAR_BYTE:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
  1441
						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
  1442
							*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
  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
						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
  1446
							*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
  1447
							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
  1448
							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
  1449
						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
  1450
							*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
  1451
							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
  1452
							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
  1453
						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
  1454
							*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
  1455
							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
  1456
							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
  1457
						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
  1458
							*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
  1459
							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
  1460
							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
  1461
						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
  1462
							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
  1463
							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
  1464
							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
  1465
						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
  1466
							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
  1467
							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
  1468
							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
  1469
						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
  1470
							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
  1471
							break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1472
					}
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
  1473
					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
  1474
				}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1475
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
  1476
				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
  1477
					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
  1478
				}
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
  1479
			}
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
  1480
			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
  1481
		}
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1482
		case 5: {
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1483
			// execute an alias
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1484
			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
  1485
			}
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
  1486
			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
  1487
		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
  1488
			// 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
  1489
			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
  1490
			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
  1491
	}
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
  1492
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
  1493
	//** freeing the tokenstream **//
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
  1494
	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
  1495
}