author | bjarni |
Sat, 22 Jan 2005 23:55:45 +0000 | |
changeset 1099 | ad7522bd5c1c |
parent 1095 | b59632d9df1b |
child 1109 | ecb98f43ba2c |
permissions | -rw-r--r-- |
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
04b5403aaf6b
(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
6dd77b0ac456
(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 | 12 |
#include "console.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
13 |
#include "network.h" |
1026
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
14 |
#include "network_data.h" |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
15 |
#include "network_server.h" |
274 | 16 |
|
17 |
#ifdef WIN32 |
|
18 |
#include <windows.h> |
|
273
17a10e5f9ea0
(svn r279) -Feature: [WIN32] Console now allows to paste data from the clipboard [ctrl + v]
signde
parents:
248
diff
changeset
|
19 |
#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
|
20 |
|
301
3b69e7025af9
(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_BUFFER 79 |
3b69e7025af9
(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_CMDBUF_SIZE 20 |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
23 |
#define ICON_CMDLN_SIZE 255 |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
24 |
#define ICON_LINE_HEIGHT 12 |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
25 |
#define ICON_RIGHT_BORDERWIDTH 10 |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
26 |
#define ICON_BOTTOM_BORDERWIDTH 12 |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
27 |
#define ICON_MAX_ALIAS_LINES 40 |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
28 |
|
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
|
29 |
// ** 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
|
30 |
static bool _iconsole_inited; |
301
3b69e7025af9
(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_buffer[ICON_BUFFER + 1]; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
32 |
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1]; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
33 |
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
|
34 |
static byte _iconsole_cmdpos; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
35 |
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
|
36 |
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
|
37 |
|
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 |
// ** 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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
43 |
// ** stdlib ** // |
289
6dd77b0ac456
(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 |
byte _stdlib_developer = 1; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
45 |
bool _stdlib_con_developer = false; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
46 |
FILE* _iconsole_output_file; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
47 |
|
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
48 |
// ** main console cmd buffer |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
49 |
static char* _iconsole_cmdbuffer[ICON_CMDBUF_SIZE]; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
50 |
static byte _iconsole_cmdbufferpos; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
51 |
|
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
|
52 |
// ** console window ** // |
289
6dd77b0ac456
(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 |
static void IConsoleWndProc(Window* w, WindowEvent* e); |
6dd77b0ac456
(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 |
static const Widget _iconsole_window_widgets[] = { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
55 |
{WIDGETS_END} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
56 |
}; |
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
|
57 |
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
|
58 |
0, 0, 2, 2, |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
_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
|
62 |
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
|
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 |
|
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
|
65 |
/* *************** */ |
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
|
66 |
/* end of header */ |
274 | 67 |
/* *************** */ |
68 |
||
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
69 |
static void IConsoleAppendClipboard(void) |
274 | 70 |
{ |
71 |
#ifdef WIN32 |
|
72 |
if (IsClipboardFormatAvailable(CF_TEXT)) { |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
73 |
const char* data; |
274 | 74 |
HGLOBAL cbuf; |
75 |
||
76 |
OpenClipboard(NULL); |
|
77 |
cbuf = GetClipboardData(CF_TEXT); |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
78 |
data = GlobalLock(cbuf); |
274 | 79 |
|
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
80 |
/* IS_INT_INSIDE = filter for ascii-function codes like BELL and so on [we need an special filter here later] */ |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
81 |
for (; (IS_INT_INSIDE(*data, ' ', 256)) && (_iconsole_cmdpos < lengthof(_iconsole_cmdline) - 1); ++data) |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
82 |
_iconsole_cmdline[_iconsole_cmdpos++] = *data; |
274 | 83 |
|
84 |
GlobalUnlock(cbuf); |
|
85 |
CloseClipboard(); |
|
86 |
} |
|
87 |
#endif |
|
273
17a10e5f9ea0
(svn r279) -Feature: [WIN32] Console now allows to paste data from the clipboard [ctrl + v]
signde
parents:
248
diff
changeset
|
88 |
} |
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
6dd77b0ac456
(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 |
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
|
91 |
{ |
289
6dd77b0ac456
(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 |
memset(_iconsole_cmdline, 0, sizeof(_iconsole_cmdline)); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
93 |
_iconsole_cmdpos = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
94 |
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
|
95 |
} |
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 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
97 |
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
|
98 |
{ |
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 |
switch(e->event) { |
289
6dd77b0ac456
(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 |
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
|
101 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
102 |
int i = _iconsole_scroll; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
103 |
int max = (w->height / ICON_LINE_HEIGHT) - 1; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
104 |
int delta = 0; |
289
6dd77b0ac456
(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 |
GfxFillRect(w->left, w->top, w->width, w->height - 1, 0); |
986
023cc6cf2bd9
(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
|
106 |
while ((i > 0) && (i > _iconsole_scroll - max) && (_iconsole_buffer[i] != NULL)) { |
289
6dd77b0ac456
(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 |
DoDrawString(_iconsole_buffer[i], 5, |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
108 |
w->height - (_iconsole_scroll + 2 - i) * ICON_LINE_HEIGHT, _iconsole_cbuffer[i]); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
109 |
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
|
110 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
111 |
delta = w->width - 10 - GetStringWidth(_iconsole_cmdline) - ICON_RIGHT_BORDERWIDTH; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
112 |
if (delta > 0) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
113 |
DoDrawString("]", 5, w->height - ICON_LINE_HEIGHT, _iconsole_color_commands); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
114 |
delta = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
115 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
116 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
117 |
DoDrawString(_iconsole_cmdline, 10 + delta, w->height - ICON_LINE_HEIGHT, _iconsole_color_commands); |
289
6dd77b0ac456
(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 |
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
|
119 |
} |
289
6dd77b0ac456
(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 |
case WE_TICK: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
121 |
_icursor_counter++; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
int posy; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
125 |
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
|
126 |
|
289
6dd77b0ac456
(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 |
_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
|
128 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
129 |
_cur_dpi = &_screen; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
130 |
delta = w->width - 10 - GetStringWidth(_iconsole_cmdline) - ICON_RIGHT_BORDERWIDTH; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
131 |
if (delta > 0) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
132 |
delta = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
133 |
posx = 10 + GetStringWidth(_iconsole_cmdline) + delta; |
289
6dd77b0ac456
(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 |
posy = w->height - 3; |
6dd77b0ac456
(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 |
GfxFillRect(posx, posy, posx + 5, posy + 1, _icursor_state ? 14 : 0); |
6dd77b0ac456
(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 |
_video_driver->make_dirty(posx, posy, 5, 1); |
6dd77b0ac456
(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 |
_icursor_counter = 0; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case WE_DESTROY: |
6dd77b0ac456
(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 |
_iconsole_win = NULL; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
142 |
_iconsole_mode = ICONSOLE_CLOSED; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case WE_KEYPRESS: |
6dd77b0ac456
(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 |
{ |
6dd77b0ac456
(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 |
e->keypress.cont = false; |
6dd77b0ac456
(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 |
switch (e->keypress.keycode) { |
6dd77b0ac456
(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 |
case WKC_CTRL | 'V': |
6dd77b0ac456
(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 |
IConsoleAppendClipboard(); |
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case WKC_UP: |
6dd77b0ac456
(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 |
IConsoleCmdBufferNavigate(+1); |
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case WKC_DOWN: |
6dd77b0ac456
(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 |
IConsoleCmdBufferNavigate(-1); |
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
159 |
break; |
6dd77b0ac456
(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 |
case WKC_SHIFT | WKC_PAGEUP: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
161 |
if (_iconsole_scroll - (w->height / ICON_LINE_HEIGHT) - 1 < 0) |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
162 |
_iconsole_scroll = 0; |
6dd77b0ac456
(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 |
else |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
164 |
_iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1; |
289
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
166 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
167 |
case WKC_SHIFT | WKC_PAGEDOWN: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
168 |
if (_iconsole_scroll + (w->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER) |
3b69e7025af9
(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 = ICON_BUFFER; |
289
6dd77b0ac456
(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 |
else |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
171 |
_iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1; |
289
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case WKC_SHIFT | WKC_UP: |
6dd77b0ac456
(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 |
if (_iconsole_scroll <= 0) |
6dd77b0ac456
(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 = 0; |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
--_iconsole_scroll; |
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
180 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
181 |
case WKC_SHIFT | WKC_DOWN: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
182 |
if (_iconsole_scroll >= ICON_BUFFER) |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
183 |
_iconsole_scroll = ICON_BUFFER; |
289
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
++_iconsole_scroll; |
6dd77b0ac456
(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 |
SetWindowDirty(w); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case WKC_BACKQUOTE: |
6dd77b0ac456
(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 |
IConsoleSwitch(); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
191 |
case WKC_RETURN: |
6dd77b0ac456
(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 |
IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
193 |
_iconsole_cmdbufferpos = 19; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
194 |
IConsoleCmdBufferAdd(_iconsole_cmdline); |
672
9089c74ba6c9
(svn r1110) -Fix: Empty console commands were executed and returned error message (sign_de for GeniusDex)
darkvater
parents:
659
diff
changeset
|
195 |
|
1046
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
196 |
IConsoleCmdExec(_iconsole_cmdline); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
197 |
IConsoleClearCommand(); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
198 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
199 |
case WKC_CTRL | WKC_RETURN: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
200 |
if (_iconsole_mode == ICONSOLE_FULL) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
201 |
_iconsole_mode = ICONSOLE_OPENED; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
202 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
203 |
_iconsole_mode = ICONSOLE_FULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
204 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
205 |
IConsoleResize(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
206 |
MarkWholeScreenDirty(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
207 |
break; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
208 |
case WKC_BACKSPACE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
209 |
if (_iconsole_cmdpos != 0) _iconsole_cmdpos--; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
210 |
_iconsole_cmdline[_iconsole_cmdpos] = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
211 |
SetWindowDirty(w); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
212 |
_iconsole_cmdbufferpos = 19; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
213 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
214 |
default: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
215 |
/* IS_INT_INSIDE = filter for ascii-function codes like BELL and so on [we need an special filter here later] */ |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
216 |
if (IS_INT_INSIDE(e->keypress.ascii, ' ', 256)) { |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
217 |
_iconsole_scroll = ICON_BUFFER; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
218 |
_iconsole_cmdline[_iconsole_cmdpos] = e->keypress.ascii; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
219 |
if (_iconsole_cmdpos != lengthof(_iconsole_cmdline)) |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
220 |
_iconsole_cmdpos++; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
221 |
SetWindowDirty(w); |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
222 |
_iconsole_cmdbufferpos = ICON_CMDBUF_SIZE - 1; |
289
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
224 |
else |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
225 |
e->keypress.cont = true; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
227 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
228 |
} |
135
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
129
diff
changeset
|
229 |
} |
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
129
diff
changeset
|
230 |
} |
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
129
diff
changeset
|
231 |
|
659
a9733f856cd0
(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 |
extern const char _openttd_revision[]; |
a9733f856cd0
(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
|
233 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
234 |
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
|
235 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
236 |
uint i; |
247
1cbc32ff06eb
(svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents:
229
diff
changeset
|
237 |
_iconsole_output_file = NULL; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
238 |
_iconsole_color_default = 1; |
247
1cbc32ff06eb
(svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents:
229
diff
changeset
|
239 |
_iconsole_color_error = 3; |
229
b94bfdf02bae
(svn r230) -Feature: IConsoleWarning for warning messages
signde
parents:
228
diff
changeset
|
240 |
_iconsole_color_warning = 13; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
241 |
_iconsole_color_debug = 5; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
242 |
_iconsole_color_commands = 2; |
301
3b69e7025af9
(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_scroll = ICON_BUFFER; |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
244 |
_iconsole_cmdbufferpos = ICON_CMDBUF_SIZE - 1; |
289
6dd77b0ac456
(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_inited = true; |
6dd77b0ac456
(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_mode = ICONSOLE_CLOSED; |
6dd77b0ac456
(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 |
_iconsole_win = NULL; |
6dd77b0ac456
(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_state = false; |
6dd77b0ac456
(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_rate = 5; |
6dd77b0ac456
(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 |
_icursor_counter = 0; |
6dd77b0ac456
(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 |
for (i = 0; i < lengthof(_iconsole_cmdbuffer); i++) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
252 |
_iconsole_cmdbuffer[i] = NULL; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
253 |
for (i = 0; i <= ICON_BUFFER; i++) { |
289
6dd77b0ac456
(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_buffer[i] = NULL; |
6dd77b0ac456
(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 |
_iconsole_cbuffer[i] = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
256 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
257 |
IConsoleStdLibRegister(); |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
258 |
IConsolePrintF(13, "OpenTTD Game Console Revision 6 - %s", _openttd_revision); |
289
6dd77b0ac456
(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, "---------------------------------"); |
6dd77b0ac456
(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, "use \"help\" for more info"); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
261 |
IConsolePrint(12, ""); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
262 |
IConsoleClearCommand(); |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
263 |
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
|
264 |
} |
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
|
265 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
266 |
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
|
267 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
268 |
uint i; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
269 |
for (i = 0; i <= ICON_BUFFER; i++) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
270 |
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
|
271 |
} |
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
|
272 |
|
1046
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
273 |
static void IConsoleWriteToLogFile(const char* string) |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
274 |
{ |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
275 |
if (_iconsole_output_file != NULL) { |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
276 |
// if there is an console output file ... also print it there |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
277 |
fwrite(string, strlen(string), 1, _iconsole_output_file); |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
278 |
fwrite("\n", 1, 1, _iconsole_output_file); |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
279 |
} |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
280 |
} |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
281 |
|
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
282 |
bool CloseConsoleLogIfActive(void) |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
283 |
{ |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
284 |
if (_iconsole_output_file != NULL) { |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
285 |
IConsolePrintF(_iconsole_color_default, "file output complete"); |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
286 |
fclose(_iconsole_output_file); |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
287 |
return true; |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
288 |
} |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
289 |
|
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
290 |
return false; |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
291 |
} |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
292 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
293 |
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
|
294 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
295 |
_iconsole_inited = false; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
296 |
IConsoleClear(); |
1046
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
297 |
CloseConsoleLogIfActive(); |
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
6dd77b0ac456
(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 IConsoleResize(void) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
301 |
{ |
986
023cc6cf2bd9
(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
|
302 |
|
023cc6cf2bd9
(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
|
303 |
_iconsole_win = FindWindowById(WC_CONSOLE, 0); |
023cc6cf2bd9
(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
|
304 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
305 |
switch (_iconsole_mode) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
306 |
case ICONSOLE_OPENED: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
307 |
_iconsole_win->height = _screen.height / 3; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
308 |
_iconsole_win->width = _screen.width; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
309 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
310 |
case ICONSOLE_FULL: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
311 |
_iconsole_win->height = _screen.height - ICON_BOTTOM_BORDERWIDTH; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
312 |
_iconsole_win->width = _screen.width; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
313 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
314 |
default: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
315 |
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
|
316 |
} |
986
023cc6cf2bd9
(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
|
317 |
|
023cc6cf2bd9
(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
|
318 |
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
|
319 |
} |
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
|
320 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
321 |
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
|
322 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
323 |
switch (_iconsole_mode) { |
6dd77b0ac456
(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 |
case ICONSOLE_CLOSED: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
325 |
_iconsole_win = AllocateWindowDesc(&_iconsole_window_desc); |
6dd77b0ac456
(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 |
_iconsole_win->height = _screen.height / 3; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
327 |
_iconsole_win->width = _screen.width; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
328 |
_iconsole_mode = ICONSOLE_OPENED; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
330 |
case ICONSOLE_OPENED: |
6dd77b0ac456
(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 |
DeleteWindowById(WC_CONSOLE, 0); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
332 |
_iconsole_win = NULL; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
333 |
_iconsole_mode = ICONSOLE_CLOSED; |
6dd77b0ac456
(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 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
335 |
case ICONSOLE_FULL: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
336 |
DeleteWindowById(WC_CONSOLE, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
337 |
_iconsole_win = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
338 |
_iconsole_mode = ICONSOLE_CLOSED; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
339 |
break; |
289
6dd77b0ac456
(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 |
} |
986
023cc6cf2bd9
(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
|
341 |
|
023cc6cf2bd9
(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
|
342 |
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
|
343 |
} |
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
|
344 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
345 |
void IConsoleClose(void) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
346 |
{ |
289
6dd77b0ac456
(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 (_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
|
348 |
} |
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
|
349 |
|
289
6dd77b0ac456
(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 |
void IConsoleOpen(void) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
351 |
{ |
289
6dd77b0ac456
(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 (_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
|
353 |
} |
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
|
354 |
|
289
6dd77b0ac456
(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 |
void IConsoleCmdBufferAdd(const char* cmd) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
356 |
{ |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
357 |
int i; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
358 |
if (_iconsole_cmdbufferpos != 19) return; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
359 |
free(_iconsole_cmdbuffer[18]); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
360 |
for (i = 18; i > 0; i--) _iconsole_cmdbuffer[i] = _iconsole_cmdbuffer[i - 1]; |
6dd77b0ac456
(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 |
_iconsole_cmdbuffer[0] = strdup(cmd); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
362 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
363 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
364 |
void IConsoleCmdBufferNavigate(signed char direction) |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
365 |
{ |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
366 |
int i; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
367 |
i = _iconsole_cmdbufferpos + direction; |
6dd77b0ac456
(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 |
if (i < 0) i = 19; |
6dd77b0ac456
(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 |
if (i > 19) i = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
370 |
if (direction > 0) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
371 |
while (_iconsole_cmdbuffer[i] == NULL) { |
6dd77b0ac456
(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 |
++i; |
6dd77b0ac456
(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 |
if (i > 19) i = 0; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
374 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
375 |
if (direction < 0) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
376 |
while (_iconsole_cmdbuffer[i] == NULL) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
377 |
--i; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
378 |
if (i < 0) i = 19; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
379 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
380 |
_iconsole_cmdbufferpos = i; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
381 |
IConsoleClearCommand(); |
289
6dd77b0ac456
(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 |
memcpy(_iconsole_cmdline, _iconsole_cmdbuffer[i], |
6dd77b0ac456
(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 |
strlen(_iconsole_cmdbuffer[i])); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
384 |
_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
|
385 |
} |
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
|
386 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
387 |
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
|
388 |
{ |
289
6dd77b0ac456
(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 |
char* _ex; |
6dd77b0ac456
(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 |
char* _new; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
391 |
uint16 _exc; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
392 |
uint16 _newc; |
289
6dd77b0ac456
(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 |
char* i; |
6dd77b0ac456
(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 |
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
|
395 |
|
1026
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
396 |
if (_redirect_console_to_client != 0) { |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
397 |
/* Redirect the string to the client */ |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
398 |
SEND_COMMAND(PACKET_SERVER_RCON)(NetworkFindClientStateFromIndex(_redirect_console_to_client), color_code, string); |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
399 |
return; |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
400 |
} |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1008
diff
changeset
|
401 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
402 |
if (_network_dedicated) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
403 |
printf("%s\n", string); |
1046
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
404 |
IConsoleWriteToLogFile(string); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
405 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
406 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
407 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
408 |
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
|
409 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
410 |
_newc = color_code; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
411 |
_new = strdup(string); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
412 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
413 |
for (i = _new; *i != '\0'; ++i) |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
414 |
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
|
415 |
|
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
416 |
for (j = ICON_BUFFER; j >= 0; --j) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
417 |
_ex = _iconsole_buffer[j]; |
6dd77b0ac456
(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 |
_exc = _iconsole_cbuffer[j]; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
419 |
_iconsole_buffer[j] = _new; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
420 |
_iconsole_cbuffer[j] = _newc; |
6dd77b0ac456
(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 |
_new = _ex; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
422 |
_newc = _exc; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
424 |
free(_ex); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
425 |
|
1046
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
426 |
IConsoleWriteToLogFile(string); |
650
d0148e8dd551
(svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik
parents:
644
diff
changeset
|
427 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
428 |
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
|
429 |
} |
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
129
diff
changeset
|
430 |
|
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
|
431 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
432 |
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
|
433 |
{ |
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
|
434 |
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
|
435 |
char buf[1024]; |
247
1cbc32ff06eb
(svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents:
229
diff
changeset
|
436 |
int len; |
1cbc32ff06eb
(svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents:
229
diff
changeset
|
437 |
|
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
|
438 |
va_start(va, s); |
289
6dd77b0ac456
(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 |
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
|
440 |
va_end(va); |
247
1cbc32ff06eb
(svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents:
229
diff
changeset
|
441 |
|
289
6dd77b0ac456
(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 |
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
|
443 |
} |
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
|
444 |
|
289
6dd77b0ac456
(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 |
void IConsoleDebug(const char* string) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
446 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
447 |
if (_stdlib_developer > 1) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
448 |
IConsolePrintF(_iconsole_color_debug, "dbg: %s", string); |
247
1cbc32ff06eb
(svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents:
229
diff
changeset
|
449 |
} |
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
|
450 |
|
289
6dd77b0ac456
(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 |
void IConsoleError(const char* string) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
452 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
453 |
if (_stdlib_developer > 0) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
454 |
IConsolePrintF(_iconsole_color_error, "ERROR: %s", string); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
455 |
} |
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
|
456 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
457 |
void IConsoleWarning(const char* string) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
458 |
{ |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
459 |
if (_stdlib_developer > 0) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
460 |
IConsolePrintF(_iconsole_color_warning, "WARNING: %s", string); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
461 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
462 |
|
6dd77b0ac456
(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 |
void IConsoleCmdRegister(const char* name, _iconsole_cmd_addr addr) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
464 |
{ |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
465 |
char* _new; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
466 |
_iconsole_cmd* item; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
467 |
_iconsole_cmd* item_new; |
554 | 468 |
_iconsole_cmd* item_before; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
469 |
|
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
470 |
_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
|
471 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
472 |
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
|
473 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
474 |
item_new->_next = NULL; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
475 |
item_new->addr = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
476 |
item_new->name = _new; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
477 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
478 |
item_new->hook_access = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
479 |
item_new->hook_after_exec = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
480 |
item_new->hook_before_exec = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
481 |
|
554 | 482 |
item_before = NULL; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
483 |
item = _iconsole_cmds; |
554 | 484 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
485 |
if (item == NULL) { |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
486 |
_iconsole_cmds = item_new; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
487 |
} else { |
554 | 488 |
while ((item->_next != NULL) && (strcmp(item->name,item_new->name)<=0)) { |
489 |
item_before = item; |
|
490 |
item = item->_next; |
|
491 |
} |
|
492 |
// insertion sort |
|
493 |
if (item_before==NULL) { |
|
494 |
if (strcmp(item->name,item_new->name)<=0) { |
|
495 |
// appending |
|
496 |
item ->_next = item_new; |
|
497 |
} else { |
|
498 |
// inserting as startitem |
|
499 |
_iconsole_cmds = item_new; |
|
500 |
item_new ->_next = item; |
|
501 |
} |
|
502 |
} else { |
|
503 |
if (strcmp(item->name,item_new->name)<=0) { |
|
504 |
// appending |
|
505 |
item ->_next = item_new; |
|
506 |
} else { |
|
507 |
// inserting |
|
508 |
item_new ->_next = item_before->_next; |
|
509 |
item_before ->_next = item_new; |
|
510 |
} |
|
511 |
} |
|
512 |
// insertion sort end |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
513 |
} |
554 | 514 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
515 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
516 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
517 |
_iconsole_cmd* IConsoleCmdGet(const char* name) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
518 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
519 |
_iconsole_cmd* item; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
520 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
521 |
item = _iconsole_cmds; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
522 |
while (item != NULL) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
523 |
if (strcmp(item->name, name) == 0) return item; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
524 |
item = item->_next; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
525 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
526 |
return NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
527 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
528 |
|
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
529 |
void IConsoleAliasRegister(const char* name, const char* cmdline) |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
530 |
{ |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
531 |
char* _new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
532 |
char* _newcmd; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
533 |
_iconsole_alias* item; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
534 |
_iconsole_alias* item_new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
535 |
_iconsole_alias* item_before; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
536 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
537 |
_new = strdup(name); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
538 |
_newcmd = strdup(cmdline); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
539 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
540 |
item_new = malloc(sizeof(_iconsole_alias)); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
541 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
542 |
item_new->_next = NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
543 |
item_new->cmdline = _newcmd; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
544 |
item_new->name = _new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
545 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
546 |
item_before = NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
547 |
item = _iconsole_aliases; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
548 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
549 |
if (item == NULL) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
550 |
_iconsole_aliases = item_new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
551 |
} else { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
552 |
while ((item->_next != NULL) && (strcmp(item->name,item_new->name)<=0)) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
553 |
item_before = item; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
554 |
item = item->_next; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
555 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
556 |
// insertion sort |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
557 |
if (item_before==NULL) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
558 |
if (strcmp(item->name,item_new->name)<=0) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
559 |
// appending |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
560 |
item ->_next = item_new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
561 |
} else { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
562 |
// inserting as startitem |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
563 |
_iconsole_aliases = item_new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
564 |
item_new ->_next = item; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
565 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
566 |
} else { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
567 |
if (strcmp(item->name,item_new->name)<=0) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
568 |
// appending |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
569 |
item ->_next = item_new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
570 |
} else { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
571 |
// inserting |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
572 |
item_new ->_next = item_before->_next; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
573 |
item_before ->_next = item_new; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
574 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
575 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
576 |
// insertion sort end |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
577 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
578 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
579 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
580 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
581 |
_iconsole_alias* IConsoleAliasGet(const char* name) |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
582 |
{ |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
583 |
_iconsole_alias* item; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
584 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
585 |
item = _iconsole_aliases; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
586 |
while (item != NULL) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
587 |
if (strcmp(item->name, name) == 0) return item; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
588 |
item = item->_next; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
589 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
590 |
return NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
591 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
592 |
|
1095 | 593 |
static void IConsoleAliasExec(const char* cmdline, char* tokens[20], byte tokentypes[20]) |
594 |
{ |
|
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
595 |
char* lines[ICON_MAX_ALIAS_LINES]; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
596 |
char* linestream; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
597 |
char* linestream_s; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
598 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
599 |
int c; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
600 |
int i; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
601 |
int l; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
602 |
int x; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
603 |
byte t; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
604 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
605 |
//** clearing buffer **// |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
606 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
607 |
for (i = 0; i < 40; i++) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
608 |
lines[0] = NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
609 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
610 |
linestream_s = linestream = malloc(1024*ICON_MAX_ALIAS_LINES); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
611 |
memset(linestream, 0, 1024*ICON_MAX_ALIAS_LINES); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
612 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
613 |
//** parsing **// |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
614 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
615 |
l = strlen(cmdline); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
616 |
i = 0; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
617 |
c = 0; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
618 |
x = 0; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
619 |
t = 0; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
620 |
lines[c] = linestream; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
621 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
622 |
while (i < l && c < ICON_MAX_ALIAS_LINES - 1) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
623 |
if (cmdline[i] == '%') { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
624 |
i++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
625 |
if (cmdline[i] == '+') { |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
626 |
// all params seperated: "[param 1]" "[param 2]" |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
627 |
t=1; |
656
e3e435079efa
(svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents:
650
diff
changeset
|
628 |
while ((tokens[t]!=NULL) && (t<20) && |
640
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
629 |
((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) { |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
630 |
int l2 = strlen(tokens[t]); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
631 |
*linestream = '"'; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
632 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
633 |
memcpy(linestream,tokens[t],l2); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
634 |
linestream += l2; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
635 |
*linestream = '"'; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
636 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
637 |
*linestream = ' '; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
638 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
639 |
x += l2+3; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
640 |
t++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
641 |
} |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
642 |
} else if (cmdline[i] == '!') { |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
643 |
// merge the params to one: "[param 1] [param 2] [param 3...]" |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
644 |
t=1; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
645 |
*linestream = '"'; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
646 |
linestream++; |
656
e3e435079efa
(svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents:
650
diff
changeset
|
647 |
while ((tokens[t]!=NULL) && (t<20) && |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
648 |
((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) { |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
649 |
int l2 = strlen(tokens[t]); |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
650 |
memcpy(linestream,tokens[t],l2); |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
651 |
linestream += l2; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
652 |
*linestream = ' '; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
653 |
linestream++; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
654 |
x += l2+1; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
655 |
t++; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
656 |
} |
932
a274119d6ec7
(svn r1420) -Fix: Console alias, load_game functionality and load fix (sign_de)
darkvater
parents:
672
diff
changeset
|
657 |
linestream--; |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
658 |
*linestream = '"'; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
659 |
linestream++; |
932
a274119d6ec7
(svn r1420) -Fix: Console alias, load_game functionality and load fix (sign_de)
darkvater
parents:
672
diff
changeset
|
660 |
x += 1; |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
661 |
} else { |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
662 |
// one specific parameter: %A = [param 1] %B = [param 2] ... |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
663 |
int l2; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
664 |
t = ((byte)cmdline[i]) - 64; |
656
e3e435079efa
(svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents:
650
diff
changeset
|
665 |
if ((t<20) && (tokens[t]!=NULL) && |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
666 |
((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) { |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
667 |
l2 = strlen(tokens[t]); |
640
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
668 |
*linestream = '"'; |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
669 |
linestream++; |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
670 |
memcpy(linestream,tokens[t],l2); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
671 |
linestream += l2; |
640
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
672 |
*linestream = '"'; |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
673 |
linestream++; |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
674 |
x += l2+2; |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
675 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
676 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
677 |
} else if (cmdline[i] == '\\') { |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
678 |
// \\ = \ \' = ' \% = % |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
679 |
i++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
680 |
if (cmdline[i] == '\\') { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
681 |
*linestream = '\\'; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
682 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
683 |
} else if (cmdline[i] == '\'') { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
684 |
*linestream = '\''; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
685 |
linestream++; |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
686 |
} else if (cmdline[i] == '%') { |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
687 |
*linestream = '%'; |
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
688 |
linestream++; |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
689 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
690 |
} else if (cmdline[i] == '\'') { |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
691 |
// ' = " |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
692 |
*linestream = '"'; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
693 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
694 |
} else if (cmdline[i] == ';') { |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
640
diff
changeset
|
695 |
// ; = start a new line |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
696 |
c++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
697 |
*linestream = '\0'; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
698 |
linestream += 1024 - (x % 1024); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
699 |
x += 1024 - (x % 1024); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
700 |
lines[c] = linestream; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
701 |
} else { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
702 |
*linestream = cmdline[i]; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
703 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
704 |
x++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
705 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
706 |
i++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
707 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
708 |
|
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
709 |
linestream--; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
710 |
if (*linestream != '\0') { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
711 |
c++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
712 |
linestream++; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
713 |
*linestream = '\0'; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
714 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
715 |
|
640
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
716 |
for (i=0; i<c; i++) { |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
717 |
IConsoleCmdExec(lines[i]); |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
718 |
} |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
719 |
|
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
720 |
free(linestream_s); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
721 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
722 |
|
554 | 723 |
void IConsoleVarInsert(_iconsole_var* item_new, const char* name) |
724 |
{ |
|
725 |
_iconsole_var* item; |
|
726 |
_iconsole_var* item_before; |
|
727 |
||
728 |
item_new->_next = NULL; |
|
729 |
||
730 |
item_new->name = malloc(strlen(name) + 2); /* XXX unchecked malloc */ |
|
731 |
sprintf(item_new->name, "%s", name); |
|
732 |
||
733 |
item_before = NULL; |
|
734 |
item = _iconsole_vars; |
|
735 |
||
736 |
if (item == NULL) { |
|
737 |
_iconsole_vars = item_new; |
|
738 |
} else { |
|
739 |
while ((item->_next != NULL) && (strcmp(item->name,item_new->name)<=0)) { |
|
740 |
item_before = item; |
|
741 |
item = item->_next; |
|
742 |
} |
|
743 |
// insertion sort |
|
744 |
if (item_before==NULL) { |
|
745 |
if (strcmp(item->name,item_new->name)<=0) { |
|
746 |
// appending |
|
747 |
item ->_next = item_new; |
|
748 |
} else { |
|
749 |
// inserting as startitem |
|
750 |
_iconsole_vars = item_new; |
|
751 |
item_new ->_next = item; |
|
752 |
} |
|
753 |
} else { |
|
754 |
if (strcmp(item->name,item_new->name)<=0) { |
|
755 |
// appending |
|
756 |
item ->_next = item_new; |
|
757 |
} else { |
|
758 |
// inserting |
|
759 |
item_new ->_next = item_before->_next; |
|
760 |
item_before ->_next = item_new; |
|
761 |
} |
|
762 |
} |
|
763 |
// insertion sort end |
|
764 |
} |
|
765 |
} |
|
766 |
||
289
6dd77b0ac456
(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 |
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
|
768 |
{ |
289
6dd77b0ac456
(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 |
_iconsole_var* item_new; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
770 |
|
289
6dd77b0ac456
(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 = malloc(sizeof(_iconsole_var)); /* XXX unchecked malloc */ |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
772 |
|
554 | 773 |
item_new->_next = NULL; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
774 |
|
289
6dd77b0ac456
(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 |
switch (type) { |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BOOLEAN: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
777 |
item_new->data.bool_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
778 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
779 |
case ICONSOLE_VAR_BYTE: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
780 |
case ICONSOLE_VAR_UINT8: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
781 |
item_new->data.byte_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
782 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
783 |
case ICONSOLE_VAR_UINT16: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
784 |
item_new->data.uint16_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
785 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
786 |
case ICONSOLE_VAR_UINT32: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
787 |
item_new->data.uint32_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
788 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_INT16: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
790 |
item_new->data.int16_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
791 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
792 |
case ICONSOLE_VAR_INT32: |
6dd77b0ac456
(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 |
item_new->data.int32_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
794 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
795 |
case ICONSOLE_VAR_STRING: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
796 |
item_new->data.string_ = addr; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
797 |
break; |
6dd77b0ac456
(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 |
default: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
799 |
error("unknown console variable type"); |
289
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
801 |
} |
554 | 802 |
|
803 |
IConsoleVarInsert(item_new, name); |
|
804 |
||
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
805 |
item_new->type = type; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
806 |
item_new->_malloc = false; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
807 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
808 |
item_new->hook_access = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
809 |
item_new->hook_after_change = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
810 |
item_new->hook_before_change = NULL; |
618
c434c460c064
(svn r1042) -Fix: [Network] Hopefully enabled revision-check for windows (somehow
truelight
parents:
554
diff
changeset
|
811 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
812 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
813 |
|
289
6dd77b0ac456
(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 |
void IConsoleVarMemRegister(const char* name, _iconsole_var_types type) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
815 |
{ |
289
6dd77b0ac456
(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 |
_iconsole_var* item; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
817 |
item = IConsoleVarAlloc(type); |
289
6dd77b0ac456
(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 |
IConsoleVarInsert(item, name); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
819 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
820 |
|
289
6dd77b0ac456
(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 |
_iconsole_var* IConsoleVarGet(const char* name) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
822 |
{ |
289
6dd77b0ac456
(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 |
_iconsole_var* item; |
6dd77b0ac456
(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 |
for (item = _iconsole_vars; item != NULL; item = item->_next) |
6dd77b0ac456
(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 |
if (strcmp(item->name, name) == 0) return item; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
826 |
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
|
827 |
} |
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
|
828 |
|
289
6dd77b0ac456
(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 |
_iconsole_var* IConsoleVarAlloc(_iconsole_var_types type) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
830 |
{ |
289
6dd77b0ac456
(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 |
_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
|
832 |
item->_next = NULL; |
289
6dd77b0ac456
(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->name = NULL; |
6dd77b0ac456
(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->type = type; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
835 |
switch (item->type) { |
289
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BOOLEAN: |
6dd77b0ac456
(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 |
item->data.bool_ = malloc(sizeof(*item->data.bool_)); |
6dd77b0ac456
(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.bool_ = false; |
6dd77b0ac456
(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->_malloc = true; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BYTE: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
842 |
case ICONSOLE_VAR_UINT8: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
843 |
item->data.byte_ = malloc(sizeof(*item->data.byte_)); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
844 |
*item->data.byte_ = 0; |
6dd77b0ac456
(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->_malloc = true; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_UINT16: |
6dd77b0ac456
(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 |
item->data.uint16_ = malloc(sizeof(*item->data.uint16_)); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
849 |
*item->data.uint16_ = 0; |
6dd77b0ac456
(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 |
item->_malloc = true; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
852 |
case ICONSOLE_VAR_UINT32: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
853 |
item->data.uint32_ = malloc(sizeof(*item->data.uint32_)); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
854 |
*item->data.uint32_ = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
855 |
item->_malloc = true; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
856 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
857 |
case ICONSOLE_VAR_INT16: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
858 |
item->data.int16_ = malloc(sizeof(*item->data.int16_)); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
859 |
*item->data.int16_ = 0; |
6dd77b0ac456
(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 |
item->_malloc = true; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
861 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
862 |
case ICONSOLE_VAR_INT32: |
6dd77b0ac456
(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 |
item->data.int32_ = malloc(sizeof(*item->data.int32_)); |
6dd77b0ac456
(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 |
*item->data.int32_ = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
865 |
item->_malloc = true; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
866 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
867 |
case ICONSOLE_VAR_POINTER: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
868 |
case ICONSOLE_VAR_STRING: |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
869 |
// needs no memory ... it gets memory when it is set to an value |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
870 |
item->data.addr = NULL; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
871 |
item->_malloc = false; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
872 |
break; |
6dd77b0ac456
(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 |
default: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
874 |
error("unknown console variable type"); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
875 |
break; |
6dd77b0ac456
(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 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
877 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
878 |
item->hook_access = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
879 |
item->hook_after_change = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
880 |
item->hook_before_change = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
881 |
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
|
882 |
} |
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
|
883 |
|
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
|
884 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
885 |
void IConsoleVarFree(_iconsole_var* var) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
886 |
{ |
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
|
887 |
if (var->_malloc) |
289
6dd77b0ac456
(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 |
free(var->data.addr); |
6dd77b0ac456
(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 |
free(var->name); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
890 |
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
|
891 |
} |
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
|
892 |
|
289
6dd77b0ac456
(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 |
void IConsoleVarSetString(_iconsole_var* var, const char* string) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
894 |
{ |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
895 |
if (string == NULL) return; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
896 |
|
289
6dd77b0ac456
(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 |
if (var->_malloc) |
6dd77b0ac456
(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 |
free(var->data.string_); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
899 |
|
289
6dd77b0ac456
(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 |
var->data.string_ = strdup(string); |
6dd77b0ac456
(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 |
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
|
902 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
903 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
904 |
void IConsoleVarSetValue(_iconsole_var* var, int value) { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
905 |
switch (var->type) { |
289
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BOOLEAN: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
907 |
*var->data.bool_ = (value != 0); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
908 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BYTE: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
910 |
case ICONSOLE_VAR_UINT8: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
911 |
*var->data.byte_ = value; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
912 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_UINT16: |
6dd77b0ac456
(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 |
*var->data.uint16_ = value; |
6dd77b0ac456
(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; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_UINT32: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
917 |
*var->data.uint32_ = value; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
918 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_INT16: |
6dd77b0ac456
(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 |
*var->data.int16_ = value; |
6dd77b0ac456
(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; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
922 |
case ICONSOLE_VAR_INT32: |
6dd77b0ac456
(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 |
*var->data.int32_ = value; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
default: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
926 |
assert(0); |
6dd77b0ac456
(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 |
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
|
928 |
} |
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
|
929 |
} |
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 |
|
289
6dd77b0ac456
(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 |
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
|
932 |
{ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
933 |
if (var == NULL) return; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
934 |
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
|
935 |
|
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
129
diff
changeset
|
936 |
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
|
937 |
case ICONSOLE_VAR_BOOLEAN: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
938 |
IConsolePrintF(_iconsole_color_default, "%s = %s", |
6dd77b0ac456
(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 |
dump_desc, *var->data.bool_ ? "true" : "false"); |
6dd77b0ac456
(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 |
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
|
941 |
case ICONSOLE_VAR_BYTE: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
942 |
case ICONSOLE_VAR_UINT8: |
289
6dd77b0ac456
(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 = %u", |
6dd77b0ac456
(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.byte_); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
945 |
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
|
946 |
case ICONSOLE_VAR_UINT16: |
289
6dd77b0ac456
(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 = %u", |
6dd77b0ac456
(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.uint16_); |
6dd77b0ac456
(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; |
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
|
950 |
case ICONSOLE_VAR_UINT32: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
951 |
IConsolePrintF(_iconsole_color_default, "%s = %u", |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
952 |
dump_desc, *var->data.uint32_); |
6dd77b0ac456
(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; |
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
|
954 |
case ICONSOLE_VAR_INT16: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
955 |
IConsolePrintF(_iconsole_color_default, "%s = %i", |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
956 |
dump_desc, *var->data.int16_); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
957 |
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
|
958 |
case ICONSOLE_VAR_INT32: |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
959 |
IConsolePrintF(_iconsole_color_default, "%s = %i", |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
960 |
dump_desc, *var->data.int32_); |
6dd77b0ac456
(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 |
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
|
962 |
case ICONSOLE_VAR_STRING: |
289
6dd77b0ac456
(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 |
IConsolePrintF(_iconsole_color_default, "%s = %s", |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
964 |
dump_desc, var->data.string_); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
965 |
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
|
966 |
case ICONSOLE_VAR_REFERENCE: |
289
6dd77b0ac456
(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 |
IConsolePrintF(_iconsole_color_default, "%s = @%s", |
6dd77b0ac456
(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 |
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
|
969 |
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
|
970 |
case ICONSOLE_VAR_POINTER: |
289
6dd77b0ac456
(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 |
IConsolePrintF(_iconsole_color_default, "%s = @%p", |
6dd77b0ac456
(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 |
dump_desc, var->data.addr); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
973 |
break; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
974 |
case ICONSOLE_VAR_NONE: |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
975 |
IConsolePrintF(_iconsole_color_default, "%s = [nothing]", |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
976 |
dump_desc); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
977 |
break; |
6dd77b0ac456
(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 |
} |
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
|
979 |
} |
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
|
980 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
981 |
// * ************************* * // |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
982 |
// * hooking code * // |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
983 |
// * ************************* * // |
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
|
984 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
985 |
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
|
986 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
987 |
_iconsole_var* hook_var = IConsoleVarGet(name); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
988 |
if (hook_var == NULL) return; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
989 |
switch (type) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
990 |
case ICONSOLE_HOOK_BEFORE_CHANGE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
991 |
hook_var->hook_before_change = proc; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
992 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
993 |
case ICONSOLE_HOOK_AFTER_CHANGE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
994 |
hook_var->hook_after_change = proc; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
995 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
996 |
case ICONSOLE_HOOK_ACCESS: |
6dd77b0ac456
(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 |
hook_var->hook_access = proc; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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_BEFORE_EXEC: |
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_AFTER_EXEC: |
6dd77b0ac456
(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 |
assert(0); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1002 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1003 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1004 |
} |
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
|
1005 |
|
289
6dd77b0ac456
(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 |
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
|
1007 |
{ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1008 |
iconsole_var_hook proc; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1009 |
if (hook_var == NULL) return false; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1010 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1011 |
proc = NULL; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1012 |
switch (type) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1013 |
case ICONSOLE_HOOK_BEFORE_CHANGE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1014 |
proc = hook_var->hook_before_change; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1015 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1016 |
case ICONSOLE_HOOK_AFTER_CHANGE: |
6dd77b0ac456
(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 |
proc = hook_var->hook_after_change; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_ACCESS: |
6dd77b0ac456
(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 |
proc = hook_var->hook_access; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_BEFORE_EXEC: |
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_AFTER_EXEC: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1024 |
assert(0); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1025 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1026 |
} |
289
6dd77b0ac456
(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 |
return proc == NULL ? true : proc(hook_var); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1028 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1029 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1030 |
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
|
1031 |
{ |
289
6dd77b0ac456
(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 |
_iconsole_cmd* hook_cmd = IConsoleCmdGet(name); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1033 |
if (hook_cmd == NULL) return; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1034 |
switch (type) { |
289
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_AFTER_EXEC: |
6dd77b0ac456
(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 |
hook_cmd->hook_after_exec = proc; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_BEFORE_EXEC: |
6dd77b0ac456
(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 |
hook_cmd->hook_before_exec = proc; |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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_ACCESS: |
6dd77b0ac456
(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 |
hook_cmd->hook_access = proc; |
6dd77b0ac456
(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; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1044 |
case ICONSOLE_HOOK_BEFORE_CHANGE: |
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_AFTER_CHANGE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1046 |
assert(0); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1047 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1048 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1049 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1050 |
|
289
6dd77b0ac456
(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 |
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
|
1052 |
{ |
289
6dd77b0ac456
(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 |
iconsole_cmd_hook proc = NULL; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1054 |
switch (type) { |
289
6dd77b0ac456
(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 |
case ICONSOLE_HOOK_AFTER_EXEC: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1056 |
proc = hook_cmd->hook_after_exec; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1057 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1058 |
case ICONSOLE_HOOK_BEFORE_EXEC: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1059 |
proc = hook_cmd->hook_before_exec; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1060 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1061 |
case ICONSOLE_HOOK_ACCESS: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1062 |
proc = hook_cmd->hook_access; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1063 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1064 |
case ICONSOLE_HOOK_BEFORE_CHANGE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1065 |
case ICONSOLE_HOOK_AFTER_CHANGE: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1066 |
assert(0); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1067 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1068 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1069 |
return proc == NULL ? true : proc(hook_cmd); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1070 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1071 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1072 |
void IConsoleCmdExec(const char* cmdstr) |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1073 |
{ |
289
6dd77b0ac456
(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 |
_iconsole_cmd_addr function; |
6dd77b0ac456
(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 |
char* tokens[20]; |
6dd77b0ac456
(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 |
byte tokentypes[20]; |
6dd77b0ac456
(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 |
char* tokenstream; |
6dd77b0ac456
(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 |
char* tokenstream_s; |
6dd77b0ac456
(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 |
byte execution_mode; |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1080 |
_iconsole_var* var = NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1081 |
_iconsole_var* result = NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1082 |
_iconsole_cmd* cmd = NULL; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1083 |
_iconsole_alias* alias = NULL; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1084 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1085 |
bool longtoken; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1086 |
bool valid_token; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1087 |
bool skip_lt_change; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1088 |
|
959
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
932
diff
changeset
|
1089 |
uint c; |
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
932
diff
changeset
|
1090 |
uint i; |
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
932
diff
changeset
|
1091 |
uint l; |
1046
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
1092 |
|
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
1093 |
if (strlen(cmdstr) == 0) // only execute if there is something typed obviously |
f1d46abf7d35
(svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents:
1026
diff
changeset
|
1094 |
return; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1095 |
|
640
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
1096 |
if (_stdlib_con_developer) |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
1097 |
IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr); |
7f08d269c3f4
(svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents:
634
diff
changeset
|
1098 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1099 |
//** clearing buffer **// |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1100 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1101 |
for (i = 0; i < 20; i++) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1102 |
tokens[i] = NULL; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1103 |
tokentypes[i] = ICONSOLE_VAR_NONE; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1105 |
tokenstream_s = tokenstream = malloc(1024); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1106 |
memset(tokenstream, 0, 1024); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1107 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1108 |
//** parsing **// |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1109 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1110 |
longtoken = false; |
6dd77b0ac456
(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 |
valid_token = false; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1112 |
skip_lt_change = false; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1113 |
l = strlen(cmdstr); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1114 |
i = 0; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1115 |
c = 0; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1116 |
tokens[c] = tokenstream; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1117 |
tokentypes[c] = ICONSOLE_VAR_UNKNOWN; |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1118 |
while (i < l && c < lengthof(tokens) - 1) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1119 |
if (cmdstr[i] == '"') { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1120 |
if (longtoken) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1121 |
if (cmdstr[i + 1] == '"') { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1122 |
i++; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1123 |
*tokenstream = '"'; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1124 |
tokenstream++; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1125 |
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
|
1126 |
} else { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1127 |
longtoken = !longtoken; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1128 |
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
|
1129 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1130 |
} else { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1131 |
longtoken = !longtoken; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1132 |
tokentypes[c] = ICONSOLE_VAR_STRING; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1133 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1134 |
if (!skip_lt_change) { |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1135 |
if (!longtoken) { |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1136 |
if (valid_token) { |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1137 |
c++; |
289
6dd77b0ac456
(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 |
*tokenstream = '\0'; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1139 |
tokenstream++; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1140 |
tokens[c] = tokenstream; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1141 |
tokentypes[c] = ICONSOLE_VAR_UNKNOWN; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1142 |
valid_token = false; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1143 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1144 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1145 |
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
|
1146 |
} |
289
6dd77b0ac456
(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 |
} else if (!longtoken && cmdstr[i] == ' ') { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1148 |
if (valid_token) { |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1149 |
c++; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1150 |
*tokenstream = '\0'; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1151 |
tokenstream++; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1152 |
tokens[c] = tokenstream; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1153 |
tokentypes[c] = ICONSOLE_VAR_UNKNOWN; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1154 |
valid_token = false; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1155 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1156 |
} else { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1157 |
valid_token = true; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1158 |
*tokenstream = cmdstr[i]; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1159 |
tokenstream++; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1160 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1161 |
i++; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1162 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1163 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1164 |
tokenstream--; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1165 |
if (*tokenstream != '\0') { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1166 |
c++; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1167 |
tokenstream++; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1168 |
*tokenstream = '\0'; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1169 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1170 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1171 |
//** interpreting **// |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1172 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1173 |
for (i = 0; i < c; i++) { |
6dd77b0ac456
(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 |
if (tokens[i] != NULL && i > 0 && strlen(tokens[i]) > 0) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1175 |
if (IConsoleVarGet((char *)tokens[i]) != NULL) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1176 |
// change the variable to an pointer if execution_mode != 4 is |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1177 |
// being prepared. execution_mode 4 is used to assign |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1178 |
// one variables data to another one |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1179 |
// [token 0 and 2] |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1180 |
if (!((i == 2) && (tokentypes[1] == ICONSOLE_VAR_UNKNOWN) && |
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1181 |
(strcmp(tokens[1], "<<") == 0))) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1182 |
// only look for another variable if it isnt an longtoken == string with "" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1183 |
var = NULL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1184 |
if (tokentypes[i]!=ICONSOLE_VAR_STRING) var = IConsoleVarGet(tokens[i]); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1185 |
if (var != NULL) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1186 |
// pointer to the data --> token |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1187 |
tokens[i] = (char *) var->data.addr; /* XXX: maybe someone finds an cleaner way to do this */ |
289
6dd77b0ac456
(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 |
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
|
1189 |
} |
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
|
1190 |
} |
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
|
1191 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1192 |
if (tokens[i] != NULL && tokens[i][0] == '@' && (IConsoleVarGet(tokens[i]+1) != NULL)) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1193 |
var = IConsoleVarGet(tokens[i]+1); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1194 |
if (var != NULL) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1195 |
// pointer to the _iconsole_var struct --> token |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1196 |
tokens[i] = (char *) var; /* XXX: maybe someone finds an cleaner way to do this */ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1197 |
tokentypes[i] = ICONSOLE_VAR_REFERENCE; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1198 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1199 |
} |
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
|
1200 |
} |
289
6dd77b0ac456
(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 |
} |
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
|
1202 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1203 |
execution_mode=0; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1204 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1205 |
function = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1206 |
cmd = IConsoleCmdGet(tokens[0]); |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1207 |
if (cmd != NULL) { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1208 |
function = cmd->addr; |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1209 |
} else { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1210 |
alias = IConsoleAliasGet(tokens[0]); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1211 |
if (alias != NULL) execution_mode = 5; // alias handling |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1212 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1213 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1214 |
if (function != NULL) { |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1215 |
execution_mode = 1; // this is a command |
6dd77b0ac456
(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 |
} else { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1217 |
var = IConsoleVarGet(tokens[0]); |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1218 |
if (var != NULL) { |
289
6dd77b0ac456
(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 |
execution_mode = 2; // this is a variable |
6dd77b0ac456
(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 |
if (c > 2 && strcmp(tokens[1], "<<") == 0) { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1221 |
// 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
|
1222 |
|
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1223 |
function = NULL; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1224 |
cmd = IConsoleCmdGet(tokens[2]); |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1225 |
if (cmd != NULL) function = cmd->addr; |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1226 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1227 |
if (function != NULL) { |
289
6dd77b0ac456
(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 |
execution_mode = 3; |
6dd77b0ac456
(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 |
} else { |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1230 |
result = IConsoleVarGet(tokens[2]); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1231 |
if (result != NULL) |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1232 |
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
|
1233 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1234 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1235 |
} |
289
6dd77b0ac456
(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 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1237 |
|
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1238 |
//** executing **// |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1239 |
if (_stdlib_con_developer) |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1240 |
IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_mode: %i", |
6dd77b0ac456
(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 |
execution_mode); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1242 |
switch (execution_mode) { |
289
6dd77b0ac456
(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 |
case 0: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1244 |
// not found |
6dd77b0ac456
(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 |
IConsoleError("command or variable not found"); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1246 |
break; |
6dd77b0ac456
(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 |
case 1: |
6dd77b0ac456
(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 |
if (IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_ACCESS)) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1249 |
// execution with command syntax |
6dd77b0ac456
(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 |
IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_BEFORE_EXEC); |
6dd77b0ac456
(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 |
result = function(c, tokens, tokentypes); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1252 |
if (result != NULL) { |
6dd77b0ac456
(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(result, "result"); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1254 |
IConsoleVarFree(result); |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_AFTER_EXEC); |
6dd77b0ac456
(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
6dd77b0ac456
(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 2: |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1260 |
{ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1261 |
// execution with variable syntax |
6dd77b0ac456
(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 (IConsoleVarHookHandle(var, ICONSOLE_HOOK_ACCESS) && (c == 2 || c == 3)) { |
6dd77b0ac456
(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 |
// ** variable modifications ** // |
6dd77b0ac456
(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 |
IConsoleVarHookHandle(var, ICONSOLE_HOOK_BEFORE_CHANGE); |
6dd77b0ac456
(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 |
switch (var->type) { |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BOOLEAN: |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1267 |
{ |
289
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 |
if (c == 3) { |
6dd77b0ac456
(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 |
*var->data.bool_ = (atoi(tokens[2]) != 0); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1271 |
} else { |
289
6dd77b0ac456
(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.bool_ = false; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1273 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1274 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 if (strcmp(tokens[1], "++") == 0) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1276 |
*var->data.bool_ = true; |
289
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "--") == 0) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1279 |
*var->data.bool_ = false; |
289
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1281 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1282 |
else |
6dd77b0ac456
(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 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(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 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1285 |
} |
289
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BYTE: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1287 |
case ICONSOLE_VAR_UINT8: |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1288 |
{ |
289
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 |
if (c == 3) |
6dd77b0ac456
(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.byte_ = atoi(tokens[2]); |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1293 |
*var->data.byte_ = 0; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "++") == 0) { |
6dd77b0ac456
(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 |
++*var->data.byte_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1297 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1298 |
} else if (strcmp(tokens[1], "--")==0) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1299 |
--*var->data.byte_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1300 |
IConsoleVarDump(var, NULL); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1301 |
} |
289
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_UINT16: |
6dd77b0ac456
(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 |
{ |
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 |
if (c == 3) |
6dd77b0ac456
(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.uint16_ = atoi(tokens[2]); |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
*var->data.uint16_ = 0; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "++") == 0) { |
6dd77b0ac456
(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 |
++*var->data.uint16_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1317 |
} else if (strcmp(tokens[1], "--") == 0) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1318 |
--*var->data.uint16_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1319 |
IConsoleVarDump(var, NULL); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1320 |
} |
289
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(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 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1324 |
} |
289
6dd77b0ac456
(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 |
case ICONSOLE_VAR_UINT32: |
6dd77b0ac456
(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 |
{ |
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 |
if (c == 3) |
6dd77b0ac456
(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.uint32_ = atoi(tokens[2]); |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
*var->data.uint32_ = 0; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "++") == 0) { |
6dd77b0ac456
(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 |
++*var->data.uint32_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "--") == 0) { |
6dd77b0ac456
(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 |
--*var->data.uint32_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_INT16: |
6dd77b0ac456
(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 |
{ |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1346 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1347 |
if (c == 3) |
6dd77b0ac456
(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.int16_ = atoi(tokens[2]); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1349 |
else |
6dd77b0ac456
(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 |
*var->data.int16_ = 0; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "++") == 0) { |
6dd77b0ac456
(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 |
++*var->data.int16_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "--") == 0) { |
6dd77b0ac456
(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 |
--*var->data.int16_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
6dd77b0ac456
(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 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_INT32: |
6dd77b0ac456
(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 |
{ |
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 |
if (c == 3) |
6dd77b0ac456
(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 |
*var->data.int32_ = atoi(tokens[2]); |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
*var->data.int32_ = 0; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "++") == 0) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1372 |
++*var->data.int32_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1374 |
} else if (strcmp(tokens[1], "--") == 0) { |
6dd77b0ac456
(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 |
--*var->data.int32_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 { IConsoleError("operation not supported"); } |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1379 |
break; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_STRING: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1382 |
{ |
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 |
if (c == 3) |
6dd77b0ac456
(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 |
IConsoleVarSetString(var, tokens[2]); |
6dd77b0ac456
(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 |
else |
6dd77b0ac456
(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 |
IConsoleVarSetString(var, ""); |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1389 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1390 |
else |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1391 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1392 |
break; |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1394 |
case ICONSOLE_VAR_POINTER: |
6dd77b0ac456
(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 |
{ |
6dd77b0ac456
(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 |
if (strcmp(tokens[1], "=") == 0) { |
6dd77b0ac456
(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 == 3) { |
6dd77b0ac456
(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 |
if (tokentypes[2] == ICONSOLE_VAR_UNKNOWN) |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1399 |
var->data.addr = (void*)atoi(tokens[2]); /* direct access on memory [by address] */ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1400 |
else |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1401 |
var->data.addr = (void*)tokens[2]; /* direct acces on memory [by variable] */ |
289
6dd77b0ac456
(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 |
} else |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1403 |
var->data.addr = NULL; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
} else if (strcmp(tokens[1], "++") == 0) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1406 |
++*(char*)&var->data.addr; /* change the address + 1 */ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1407 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1408 |
} else if (strcmp(tokens[1], "--") == 0) { |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1409 |
--*(char*)&var->data.addr; /* change the address - 1 */ |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1410 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1411 |
} |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1412 |
else |
6dd77b0ac456
(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 |
IConsoleError("operation not supported"); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1416 |
case ICONSOLE_VAR_NONE: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1417 |
case ICONSOLE_VAR_REFERENCE: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1418 |
case ICONSOLE_VAR_UNKNOWN: |
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1419 |
IConsoleError("operation not supported"); |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1420 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1421 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1422 |
IConsoleVarHookHandle(var, ICONSOLE_HOOK_AFTER_CHANGE); |
6dd77b0ac456
(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 |
} |
6dd77b0ac456
(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 |
if (c == 1) // ** variable output ** // |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1426 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1427 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1428 |
case 3: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1429 |
case 4: |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1430 |
{ |
289
6dd77b0ac456
(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 |
// execute command with result or assign a variable |
6dd77b0ac456
(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 |
if (execution_mode == 3) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1433 |
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
|
1434 |
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
|
1435 |
int diff; |
289
6dd77b0ac456
(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 |
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
|
1437 |
byte temp2; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1438 |
|
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
|
1439 |
// tokenshifting |
289
6dd77b0ac456
(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 |
for (diff = 0; diff < 2; diff++) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1441 |
temp = tokens[0]; |
6dd77b0ac456
(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 |
temp2 = tokentypes[0]; |
6dd77b0ac456
(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 |
for (i = 0; i < 19; i++) { |
6dd77b0ac456
(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 |
tokens[i] = tokens[i + 1]; |
6dd77b0ac456
(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 |
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
|
1446 |
} |
289
6dd77b0ac456
(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 |
tokens[19] = temp; |
6dd77b0ac456
(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 |
tokentypes[19] = temp2; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1449 |
} |
289
6dd77b0ac456
(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 |
IConsoleCmdHookHandle(cmd, ICONSOLE_HOOK_BEFORE_EXEC); |
6dd77b0ac456
(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 |
result = function(c, tokens, tokentypes); |
6dd77b0ac456
(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 |
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
|
1453 |
} else |
289
6dd77b0ac456
(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 |
execution_mode = 255; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1455 |
} |
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1456 |
|
289
6dd77b0ac456
(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 |
if (IConsoleVarHookHandle(var, ICONSOLE_HOOK_ACCESS) && result != NULL) { |
6dd77b0ac456
(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 |
if (result->type != var->type) { |
6dd77b0ac456
(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 |
IConsoleError("variable type missmatch"); |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1460 |
} else { |
289
6dd77b0ac456
(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 |
IConsoleVarHookHandle(var, ICONSOLE_HOOK_BEFORE_CHANGE); |
6dd77b0ac456
(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 |
switch (result->type) { |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BOOLEAN: |
6dd77b0ac456
(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 |
*var->data.bool_ = *result->data.bool_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1466 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_BYTE: |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
518
diff
changeset
|
1468 |
case ICONSOLE_VAR_UINT8: |
289
6dd77b0ac456
(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 |
*var->data.byte_ = *result->data.byte_; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1472 |
case ICONSOLE_VAR_UINT16: |
6dd77b0ac456
(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 |
*var->data.uint16_ = *result->data.uint16_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1474 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1475 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_UINT32: |
6dd77b0ac456
(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 |
*var->data.uint32_ = *result->data.uint32_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1478 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1479 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_INT16: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1481 |
*var->data.int16_ = *result->data.int16_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1482 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1483 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1484 |
case ICONSOLE_VAR_INT32: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1485 |
*var->data.int32_ = *result->data.int32_; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1486 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(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 |
break; |
6dd77b0ac456
(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 |
case ICONSOLE_VAR_POINTER: |
6dd77b0ac456
(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 |
var->data.addr = result->data.addr; |
6dd77b0ac456
(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 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1491 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1492 |
case ICONSOLE_VAR_STRING: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1493 |
IConsoleVarSetString(var, result->data.string_); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1494 |
IConsoleVarDump(var, NULL); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1495 |
break; |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1496 |
default: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1497 |
IConsoleError("variable type missmatch"); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1498 |
break; |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1499 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1500 |
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
|
1501 |
} |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1502 |
|
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1503 |
if (execution_mode == 3) { |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1504 |
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
|
1505 |
} |
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
|
1506 |
} |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1507 |
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
|
1508 |
} |
634
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1509 |
case 5: { |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1510 |
// execute an alias |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1511 |
IConsoleAliasExec(alias->cmdline, tokens,tokentypes); |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1512 |
} |
754b2df37bfa
(svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents:
618
diff
changeset
|
1513 |
break; |
289
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1514 |
default: |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1515 |
// execution mode invalid |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1516 |
IConsoleError("invalid execution mode"); |
6dd77b0ac456
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents:
274
diff
changeset
|
1517 |
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
|
1518 |
} |
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
|
1519 |
|
301
3b69e7025af9
(svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents:
289
diff
changeset
|
1520 |
//** freeing the tokenstream **// |
220
dc1710f96b39
(svn r221) -Feature: console command and variable hooking
signde
parents:
209
diff
changeset
|
1521 |
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
|
1522 |
} |