annotate console.c @ 1828:b15c8dfef71a draft

(svn r2333) - CodeChange: also don't execute command if user has typed all spaces (eg nothing worthwhile). Suggested and implemented by Tron.
author Darkvater <Darkvater@openttd.org>
date Mon, 16 May 2005 15:05:49 +0000
parents 77c5a8039e65
children 49b91393f676
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1 #include "stdafx.h"
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
2 #include "ttd.h"
507
9dcc34b8887e (svn r815) Include strings.h only in the files which need it.
tron <tron@openttd.org>
parents: 301
diff changeset
3 #include "table/strings.h"
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
4 #include "window.h"
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
5 #include "gui.h"
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
6 #include "gfx.h"
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
7 #include "player.h"
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
8 #include "variables.h"
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
9 #include "string.h"
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
10 #include "hal.h"
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
11 #include <stdarg.h>
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
12 #include <string.h>
274
ea766af32749 (svn r280) -Fix: ^M removement in console.c
signde <signde@openttd.org>
parents: 273
diff changeset
13 #include "console.h"
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
14 #include "network.h"
1026
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
15 #include "network_data.h"
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
16 #include "network_server.h"
274
ea766af32749 (svn r280) -Fix: ^M removement in console.c
signde <signde@openttd.org>
parents: 273
diff changeset
17
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
18 #define ICON_BUFFER 79
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
19 #define ICON_HISTORY_SIZE 20
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
20 #define ICON_LINE_HEIGHT 12
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
21 #define ICON_RIGHT_BORDERWIDTH 10
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
22 #define ICON_BOTTOM_BORDERWIDTH 12
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
23 #define ICON_MAX_ALIAS_LINES 40
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
24 #define ICON_TOKEN_COUNT 20
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
25
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
26 // ** main console ** //
1397
7e8611386aea (svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater <Darkvater@openttd.org>
parents: 1390
diff changeset
27 static Window *_iconsole_win; // Pointer to console window
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
28 static bool _iconsole_inited;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
29 static char *_iconsole_buffer[ICON_BUFFER + 1];
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
30 static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
31 static Textbuf _iconsole_cmdline;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
32 static byte _iconsole_scroll;
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
33
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
34 // ** stdlib ** //
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
35 byte _stdlib_developer = 1;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
36 bool _stdlib_con_developer = false;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
37 FILE *_iconsole_output_file;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
38
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
39 // ** main console cmd buffer
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
40 static char *_iconsole_history[ICON_HISTORY_SIZE];
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
41 static byte _iconsole_historypos;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
42
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
43 /* *************** */
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
44 /* end of header */
274
ea766af32749 (svn r280) -Fix: ^M removement in console.c
signde <signde@openttd.org>
parents: 273
diff changeset
45 /* *************** */
ea766af32749 (svn r280) -Fix: ^M removement in console.c
signde <signde@openttd.org>
parents: 273
diff changeset
46
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
47 static void IConsoleClearCommand(void)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
48 {
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
49 memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
50 _iconsole_cmdline.length = 0;
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
51 _iconsole_cmdline.width = 0;
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
52 _iconsole_cmdline.caretpos = 0;
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
53 _iconsole_cmdline.caretxoffs = 0;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
54 SetWindowDirty(_iconsole_win);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
55 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
56
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
57 static inline void IConsoleResetHistoryPos(void) {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
58
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
59 // ** console window ** //
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
60 static void IConsoleWndProc(Window* w, WindowEvent* e)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
61 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
62 switch (e->event) {
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
63 case WE_PAINT: {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
64 int i = _iconsole_scroll;
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
65 int max = (w->height / ICON_LINE_HEIGHT) - 1;
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
66 int delta = 0;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
67 GfxFillRect(w->left, w->top, w->width, w->height - 1, 0);
986
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
68 while ((i > 0) && (i > _iconsole_scroll - max) && (_iconsole_buffer[i] != NULL)) {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
69 DoDrawString(_iconsole_buffer[i], 5,
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
70 w->height - (_iconsole_scroll + 2 - i) * ICON_LINE_HEIGHT, _iconsole_cbuffer[i]);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
71 i--;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
72 }
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
73 /* If the text is longer than the window, don't show the starting ']' */
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
74 delta = w->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
75 if (delta > 0) {
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
76 DoDrawString("]", 5, w->height - ICON_LINE_HEIGHT, _icolour_cmd);
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
77 delta = 0;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
78 }
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
79
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
80 DoDrawString(_iconsole_cmdline.buf, 10 + delta, w->height - ICON_LINE_HEIGHT, _icolour_cmd);
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
81
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
82 if (_iconsole_cmdline.caret)
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
83 DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, w->height - ICON_LINE_HEIGHT, 12);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
84 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
85 }
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
86 case WE_MOUSELOOP:
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
87 if (HandleCaret(&_iconsole_cmdline))
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
88 SetWindowDirty(w);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
89 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
90 case WE_DESTROY:
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
91 _iconsole_win = NULL;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
92 _iconsole_mode = ICONSOLE_CLOSED;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
93 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
94 case WE_KEYPRESS:
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
95 e->keypress.cont = false;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
96 switch (e->keypress.keycode) {
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
97 case WKC_UP:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
98 IConsoleHistoryNavigate(+1);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
99 SetWindowDirty(w);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
100 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
101 case WKC_DOWN:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
102 IConsoleHistoryNavigate(-1);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
103 SetWindowDirty(w);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
104 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
105 case WKC_SHIFT | WKC_PAGEUP:
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
106 if (_iconsole_scroll - (w->height / ICON_LINE_HEIGHT) - 1 < 0)
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
107 _iconsole_scroll = 0;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
108 else
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
109 _iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
110 SetWindowDirty(w);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
111 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
112 case WKC_SHIFT | WKC_PAGEDOWN:
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
113 if (_iconsole_scroll + (w->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER)
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
114 _iconsole_scroll = ICON_BUFFER;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
115 else
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
116 _iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
117 SetWindowDirty(w);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
118 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
119 case WKC_SHIFT | WKC_UP:
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
120 if (_iconsole_scroll <= 0)
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
121 _iconsole_scroll = 0;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
122 else
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
123 --_iconsole_scroll;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
124 SetWindowDirty(w);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
125 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
126 case WKC_SHIFT | WKC_DOWN:
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
127 if (_iconsole_scroll >= ICON_BUFFER)
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
128 _iconsole_scroll = ICON_BUFFER;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
129 else
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
130 ++_iconsole_scroll;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
131 SetWindowDirty(w);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
132 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
133 case WKC_BACKQUOTE:
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
134 IConsoleSwitch();
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
135 break;
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
136 case WKC_RETURN: case WKC_NUM_ENTER:
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
137 IConsolePrintF(_icolour_cmd, "] %s", _iconsole_cmdline.buf);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
138 IConsoleHistoryAdd(_iconsole_cmdline.buf);
672
238376664628 (svn r1110) -Fix: Empty console commands were executed and returned error message (sign_de for GeniusDex)
darkvater <darkvater@openttd.org>
parents: 659
diff changeset
139
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
140 IConsoleCmdExec(_iconsole_cmdline.buf);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
141 IConsoleClearCommand();
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
142 break;
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
143 case WKC_CTRL | WKC_RETURN:
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
144 _iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
145 IConsoleResize();
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
146 MarkWholeScreenDirty();
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
147 break;
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
148 case (WKC_CTRL | 'V'):
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
149 if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
150 IConsoleResetHistoryPos();
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
151 SetWindowDirty(w);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
152 }
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
153 break;
1827
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
154 case (WKC_CTRL | 'L'):
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
155 IConsoleCmdExec("clear");
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
156 break;
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
157 case WKC_BACKSPACE: case WKC_DELETE:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
158 if (DeleteTextBufferChar(&_iconsole_cmdline, e->keypress.keycode)) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
159 IConsoleResetHistoryPos();
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
160 SetWindowDirty(w);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
161 }
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
162 break;
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
163 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
164 if (MoveTextBufferPos(&_iconsole_cmdline, e->keypress.keycode)) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
165 IConsoleResetHistoryPos();
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
166 SetWindowDirty(w);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
167 }
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
168 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
169 default:
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
170 if (IsValidAsciiChar(e->keypress.ascii)) {
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
171 _iconsole_scroll = ICON_BUFFER;
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
172 InsertTextBufferChar(&_iconsole_cmdline, e->keypress.ascii);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
173 IConsoleResetHistoryPos();
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
174 SetWindowDirty(w);
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
175 } else
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
176 e->keypress.cont = true;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
177 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
178 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
179 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
180 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
181
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
182 static const Widget _iconsole_window_widgets[] = {
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
183 {WIDGETS_END}
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
184 };
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
185
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
186 static const WindowDesc _iconsole_window_desc = {
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
187 0, 0, 2, 2,
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
188 WC_CONSOLE, 0,
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
189 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
190 _iconsole_window_widgets,
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
191 IConsoleWndProc,
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
192 };
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
193
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
194 void IConsoleInit(void)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
195 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
196 extern const char _openttd_revision[];
247
fca3d55c0984 (svn r248) -Feature: console script files "exec myscript.file"
darkvater <darkvater@openttd.org>
parents: 229
diff changeset
197 _iconsole_output_file = NULL;
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
198 _icolour_def = 1;
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
199 _icolour_err = 3;
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
200 _icolour_warn = 13;
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
201 _icolour_dbg = 5;
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
202 _icolour_cmd = 2;
301
a44c6d12ae01 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater <darkvater@openttd.org>
parents: 289
diff changeset
203 _iconsole_scroll = ICON_BUFFER;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
204 _iconsole_historypos = ICON_HISTORY_SIZE - 1;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
205 _iconsole_inited = true;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
206 _iconsole_mode = ICONSOLE_CLOSED;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
207 _iconsole_win = NULL;
1243
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
208
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
209 #ifdef ENABLE_NETWORK /* Initialize network only variables */
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
210 _redirect_console_to_client = 0;
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
211 #endif
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
212
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
213 memset(_iconsole_history, 0, sizeof(_iconsole_history));
1243
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
214 memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
215 memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
216 _iconsole_cmdline.buf = calloc(ICON_CMDLN_SIZE, sizeof(*_iconsole_cmdline.buf)); // create buffer and zero it
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
217 _iconsole_cmdline.maxlength = ICON_CMDLN_SIZE - 1;
1243
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
218
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
219 IConsolePrintF(13, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
220 IConsolePrint(12, "------------------------------------");
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
221 IConsolePrint(12, "use \"help\" for more information");
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
222 IConsolePrint(12, "");
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
223 IConsoleStdLibRegister();
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
224 IConsoleClearCommand();
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
225 IConsoleHistoryAdd("");
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
226 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
227
1827
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
228 void IConsoleClearBuffer(void)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
229 {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
230 uint i;
1827
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
231 for (i = 0; i <= ICON_BUFFER; i++) {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
232 free(_iconsole_buffer[i]);
1827
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
233 _iconsole_buffer[i] = NULL;
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
234 }
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
235 }
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
236
1827
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
237 static void IConsoleClear(void)
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
238 {
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
239 free(_iconsole_cmdline.buf);
1827
77c5a8039e65 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater <Darkvater@openttd.org>
parents: 1819
diff changeset
240 IConsoleClearBuffer();
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
241 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
242
1046
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
243 static void IConsoleWriteToLogFile(const char* string)
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
244 {
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
245 if (_iconsole_output_file != NULL) {
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
246 // if there is an console output file ... also print it there
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
247 fwrite(string, strlen(string), 1, _iconsole_output_file);
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
248 fwrite("\n", 1, 1, _iconsole_output_file);
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
249 }
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
250 }
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
251
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
252 bool CloseConsoleLogIfActive(void)
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
253 {
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
254 if (_iconsole_output_file != NULL) {
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
255 IConsolePrintF(_icolour_def, "file output complete");
1046
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
256 fclose(_iconsole_output_file);
1127
5c6ec2f4d519 (svn r1628) -Fix: [1107893] script command; log file pointer was not reset to NULL after logging was closed
darkvater <darkvater@openttd.org>
parents: 1109
diff changeset
257 _iconsole_output_file = NULL;
1046
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
258 return true;
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
259 }
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
260
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
261 return false;
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
262 }
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
263
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
264 void IConsoleFree(void)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
265 {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
266 _iconsole_inited = false;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
267 IConsoleClear();
1046
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
268 CloseConsoleLogIfActive();
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
269 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
270
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
271 void IConsoleResize(void)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
272 {
986
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
273 _iconsole_win = FindWindowById(WC_CONSOLE, 0);
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
274
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
275 switch (_iconsole_mode) {
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
276 case ICONSOLE_OPENED:
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
277 _iconsole_win->height = _screen.height / 3;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
278 _iconsole_win->width = _screen.width;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
279 break;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
280 case ICONSOLE_FULL:
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
281 _iconsole_win->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
282 _iconsole_win->width = _screen.width;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
283 break;
1755
c1d6dd3d87d3 (svn r2259) - Fix (regression): remove a warning and make the help for variables behave the same as for commands
Darkvater <Darkvater@openttd.org>
parents: 1754
diff changeset
284 default: break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
285 }
986
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
286
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
287 MarkWholeScreenDirty();
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
288 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
289
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
290 void IConsoleSwitch(void)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
291 {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
292 switch (_iconsole_mode) {
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
293 case ICONSOLE_CLOSED:
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
294 _iconsole_win = AllocateWindowDesc(&_iconsole_window_desc);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
295 _iconsole_win->height = _screen.height / 3;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
296 _iconsole_win->width = _screen.width;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
297 _iconsole_mode = ICONSOLE_OPENED;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
298 SETBIT(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
299 break;
1397
7e8611386aea (svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater <Darkvater@openttd.org>
parents: 1390
diff changeset
300 case ICONSOLE_OPENED: case ICONSOLE_FULL:
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
301 DeleteWindowById(WC_CONSOLE, 0);
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
302 _iconsole_win = NULL;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
303 _iconsole_mode = ICONSOLE_CLOSED;
1397
7e8611386aea (svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater <Darkvater@openttd.org>
parents: 1390
diff changeset
304 CLRBIT(_no_scroll, SCROLL_CON);
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
305 break;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
306 }
986
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
307
df1bd17d8f18 (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 <darkvater@openttd.org>
parents: 959
diff changeset
308 MarkWholeScreenDirty();
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
309 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
310
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
311 void IConsoleClose(void) {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();}
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
312 void IConsoleOpen(void) {if (_iconsole_mode == ICONSOLE_CLOSED) IConsoleSwitch();}
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
313
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
314 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
315 * Add the entered line into the history so you can look it back
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
316 * scroll, etc. Put it to the beginning as it is the latest text
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
317 * @param cmd Text to be entered into the 'history'
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
318 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
319 void IConsoleHistoryAdd(const char *cmd)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
320 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
321 free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
322
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
323 memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
324 _iconsole_history[0] = strdup(cmd);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
325 IConsoleResetHistoryPos();
141
c1b1024d9f3f (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater <darkvater@openttd.org>
parents: 136
diff changeset
326 }
c1b1024d9f3f (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater <darkvater@openttd.org>
parents: 136
diff changeset
327
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
328 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
329 * Navigate Up/Down in the history of typed commands
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
330 * @param direction Go further back in history (+1), go to recently typed commands (-1)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
331 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
332 void IConsoleHistoryNavigate(signed char direction)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
333 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
334 int i = _iconsole_historypos + direction;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
335
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
336 // watch out for overflows, just wrap around
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
337 if (i < 0) i = ICON_HISTORY_SIZE - 1;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
338 if (i >= ICON_HISTORY_SIZE) i = 0;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
339
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
340 if (direction > 0)
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
341 if (_iconsole_history[i] == NULL) i = 0;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
342
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
343 if (direction < 0) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
344 while (i > 0 && _iconsole_history[i] == NULL) i--;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
345 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
346
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
347 _iconsole_historypos = i;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
348 IConsoleClearCommand();
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
349 // copy history to 'command prompt / bash'
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
350 assert(_iconsole_history[i] != NULL && IS_INT_INSIDE(i, 0, ICON_HISTORY_SIZE));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
351 ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
1390
f641c4f29274 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater <Darkvater@openttd.org>
parents: 1379
diff changeset
352 UpdateTextBufferSize(&_iconsole_cmdline);
141
c1b1024d9f3f (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater <darkvater@openttd.org>
parents: 136
diff changeset
353 }
c1b1024d9f3f (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater <darkvater@openttd.org>
parents: 136
diff changeset
354
1588
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
355 /**
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
356 * Handle the printing of text entered into the console or redirected there
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
357 * by any other means. Text can be redirected to other players in a network game
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
358 * as well as to a logfile. If the network server is a dedicated server, all activities
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
359 * are also logged. All lines to print are added to a temporary buffer which can be
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
360 * used as a history to print them onscreen
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
361 * @param color_code the colour of the command. Red in case of errors, etc.
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
362 * @param string the message entered or output on the console (notice, error, etc.)
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
363 */
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
364 void IConsolePrint(uint16 color_code, const char* string)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
365 {
1243
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
366 #ifdef ENABLE_NETWORK
1026
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
367 if (_redirect_console_to_client != 0) {
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
368 /* Redirect the string to the client */
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
369 SEND_COMMAND(PACKET_SERVER_RCON)(NetworkFindClientStateFromIndex(_redirect_console_to_client), color_code, string);
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
370 return;
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
371 }
1243
e2033fc4f250 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater <darkvater@openttd.org>
parents: 1230
diff changeset
372 #endif
1026
db6416ec34ba (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight <truelight@openttd.org>
parents: 1008
diff changeset
373
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
374 if (_network_dedicated) {
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
375 printf("%s\n", string);
1046
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
376 IConsoleWriteToLogFile(string);
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
377 return;
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
378 }
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
379
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
380 if (!_iconsole_inited) return;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
381
1588
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
382 /* move up all the strings in the buffer one place and do the same for colour
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
383 * to accomodate for the new command/message */
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
384 free(_iconsole_buffer[0]);
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
385 memmove(&_iconsole_buffer[0], &_iconsole_buffer[1], sizeof(_iconsole_buffer[0]) * ICON_BUFFER);
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
386 _iconsole_buffer[ICON_BUFFER] = strdup(string);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
387
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
388 { // filter out unprintable characters
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
389 char *i;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
390 for (i = _iconsole_buffer[ICON_BUFFER]; *i != '\0'; i++)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
391 if (!IsValidAsciiChar((byte)*i)) *i = ' ';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
392 }
1588
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
393
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
394 memmove(&_iconsole_cbuffer[0], &_iconsole_cbuffer[1], sizeof(_iconsole_cbuffer[0]) * ICON_BUFFER);
cf447f2bbced (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like öä, etc. Diff approved by the code-police.
Darkvater <Darkvater@openttd.org>
parents: 1483
diff changeset
395 _iconsole_cbuffer[ICON_BUFFER] = color_code;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
396
1046
76fbc6938454 (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 <darkvater@openttd.org>
parents: 1026
diff changeset
397 IConsoleWriteToLogFile(string);
650
72efe36394c8 (svn r1083) Fix: the console "script" command saves all output to the textfile, not only printf stuff (sign_de)
dominik <dominik@openttd.org>
parents: 644
diff changeset
398
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
399 if (_iconsole_win != NULL) SetWindowDirty(_iconsole_win);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
400 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
401
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
402 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
403 * Handle the printing of text entered into the console or redirected there
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
404 * by any other means. Uses printf() style format, for more information look
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
405 * at @IConsolePrint()
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
406 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
407 void CDECL IConsolePrintF(uint16 color_code, const char *s, ...)
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
408 {
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
409 va_list va;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
410 char buf[ICON_MAX_STREAMSIZE];
247
fca3d55c0984 (svn r248) -Feature: console script files "exec myscript.file"
darkvater <darkvater@openttd.org>
parents: 229
diff changeset
411
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
412 va_start(va, s);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
413 vsnprintf(buf, sizeof(buf), s, va);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
414 va_end(va);
247
fca3d55c0984 (svn r248) -Feature: console script files "exec myscript.file"
darkvater <darkvater@openttd.org>
parents: 229
diff changeset
415
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
416 IConsolePrint(color_code, buf);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
417 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
418
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
419 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
420 * It is possible to print debugging information to the console,
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
421 * which is achieved by using this function. Can only be used by
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
422 * @debug() in debug.c. You need at least a level 2 (developer) for debugging
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
423 * messages to show up
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
424 */
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
425 void IConsoleDebug(const char* string)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
426 {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
427 if (_stdlib_developer > 1)
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
428 IConsolePrintF(_icolour_dbg, "dbg: %s", string);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
429 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
430
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
431 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
432 * It is possible to print warnings to the console. These are mostly
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
433 * errors or mishaps, but non-fatal. You need at least a level 1 (developer) for
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
434 * debugging messages to show up
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
435 */
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
436 void IConsoleWarning(const char* string)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
437 {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
438 if (_stdlib_developer > 0)
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
439 IConsolePrintF(_icolour_warn, "WARNING: %s", string);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
440 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
441
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
442 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
443 * It is possible to print error information to the console. This can include
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
444 * game errors, or errors in general you would want the user to notice
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
445 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
446 void IConsoleError(const char* string)
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
447 {
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
448 IConsolePrintF(_icolour_err, "ERROR: %s", string);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
449 }
554
8e054ea3d0d4 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight <truelight@openttd.org>
parents: 543
diff changeset
450
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
451 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
452 * Change a string into its number representation. Supports
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
453 * decimal and hexadecimal numbers as well as 'on'/'off' 'true'/'false'
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
454 * @param *value the variable a successfull conversion will be put in
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
455 * @param *arg the string to be converted
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
456 * @return Return true on success or false on failure
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
457 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
458 bool GetArgumentInteger(uint32 *value, const char *arg)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
459 {
1773
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
460 char *endptr;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
461
1773
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
462 if (strcmp(arg, "on") == 0 || strcmp(arg, "true") == 0) {
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
463 *value = 1;
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
464 return true;
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
465 }
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
466 if (strcmp(arg, "off") == 0 || strcmp(arg, "false") == 0) {
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
467 *value = 0;
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
468 return true;
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
469 }
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
470
1773
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
471 *value = strtoul(arg, &endptr, 0);
9a6b53ee6a1d (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater <Darkvater@openttd.org>
parents: 1771
diff changeset
472 return (arg == endptr) ? false : true;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
473 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
474
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
475 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
476 * Perhaps ugly macro, but this saves us the trouble of writing the same function
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
477 * three types, just with different variables. Yes, templates would be handy. It was
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
478 * either this define or an even more ugly void* magic function
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
479 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
480 #define IConsoleAddSorted(_base, item_new, IConsoleType, type) \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
481 { \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
482 IConsoleType *item, *item_before; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
483 /* first command */ \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
484 if (_base == NULL) { \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
485 _base = item_new; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
486 return; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
487 } \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
488 \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
489 item_before = NULL; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
490 item = _base; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
491 \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
492 /* BEGIN - Alphabetically insert the commands into the linked list */ \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
493 while (item != NULL) { \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
494 int i = strcmp(item->name, item_new->name); \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
495 if (i == 0) { \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
496 IConsoleError(type " with this name already exists; insertion aborted"); \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
497 free(item_new); \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
498 return; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
499 } \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
500 \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
501 if (i > 0) break; /* insert at this position */ \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
502 \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
503 item_before = item; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
504 item = item->next; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
505 } \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
506 \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
507 if (item_before == NULL) { \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
508 _base = item_new; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
509 } else \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
510 item_before->next = item_new; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
511 \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
512 item_new->next = item; \
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
513 /* END - Alphabetical insert */ \
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
514 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
515
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
516 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
517 * Register a new command to be used in the console
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
518 * @param name name of the command that will be used
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
519 * @param proc function that will be called upon execution of command
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
520 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
521 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc)
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
522 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
523 char *new_cmd = strdup(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
524 IConsoleCmd *item_new = malloc(sizeof(IConsoleCmd));
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
525
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
526 item_new->next = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
527 item_new->proc = proc;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
528 item_new->name = new_cmd;
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
529
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
530 item_new->hook.access = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
531 item_new->hook.pre = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
532 item_new->hook.post = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
533
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
534 IConsoleAddSorted(_iconsole_cmds, item_new, IConsoleCmd, "a command");
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
535 }
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
536
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
537 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
538 * Find the command pointed to by its string
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
539 * @param name command to be found
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
540 * @return return Cmdstruct of the found command, or NULL on failure
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
541 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
542 IConsoleCmd *IConsoleCmdGet(const char *name)
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
543 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
544 IConsoleCmd *item;
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
545
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
546 for (item = _iconsole_cmds; item != NULL; item = item->next) {
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
547 if (strcmp(item->name, name) == 0) return item;
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
548 }
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
549 return NULL;
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
550 }
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
551
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
552 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
553 * Register a an alias for an already existing command in the console
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
554 * @param name name of the alias that will be used
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
555 * @param cmd name of the command that 'name' will be alias of
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
556 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
557 void IConsoleAliasRegister(const char *name, const char *cmd)
1095
a744cbd0f378 (svn r1596) Add some more statics
tron <tron@openttd.org>
parents: 1046
diff changeset
558 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
559 char *new_alias = strdup(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
560 char *cmd_aliased = strdup(cmd);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
561 IConsoleAlias *item_new = malloc(sizeof(IConsoleAlias));
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
562
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
563 item_new->next = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
564 item_new->cmdline = cmd_aliased;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
565 item_new->name = new_alias;
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
566
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
567 IConsoleAddSorted(_iconsole_aliases, item_new, IConsoleAlias, "an alias");
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
568 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
569
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
570 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
571 * Find the alias pointed to by its string
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
572 * @param name alias to be found
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
573 * @return return Aliasstruct of the found alias, or NULL on failure
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
574 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
575 IConsoleAlias *IConsoleAliasGet(const char *name)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
576 {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
577 IConsoleAlias* item;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
578
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
579 for (item = _iconsole_aliases; item != NULL; item = item->next) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
580 if (strcmp(item->name, name) == 0) return item;
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
581 }
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
582
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
583 return NULL;
634
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
584 }
6471338a8aa9 (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight <truelight@openttd.org>
parents: 618
diff changeset
585
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
586 /** copy in an argument into the aliasstream */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
587 static inline int IConsoleCopyInParams(char *dst, const char *src, uint bufpos)
554
8e054ea3d0d4 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight <truelight@openttd.org>
parents: 543
diff changeset
588 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
589 int len = min(ICON_MAX_STREAMSIZE - bufpos, strlen(src));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
590 strncpy(dst, src, len);
554
8e054ea3d0d4 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight <truelight@openttd.org>
parents: 543
diff changeset
591
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
592 return len;
554
8e054ea3d0d4 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight <truelight@openttd.org>
parents: 543
diff changeset
593 }
8e054ea3d0d4 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight <truelight@openttd.org>
parents: 543
diff changeset
594
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
595 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
596 * An alias is just another name for a command, or for more commands
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
597 * Execute it as well.
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
598 * @param *alias is the alias of the command
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
599 * @param tokencount the number of parameters passed
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
600 * @param *tokens are the parameters given to the original command (0 is the first param)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
601 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
602 void IConsoleAliasExec(const IConsoleAlias *alias, byte tokencount, char *tokens[ICON_TOKEN_COUNT])
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
603 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
604 const char *cmdptr;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
605 char *aliases[ICON_MAX_ALIAS_LINES], aliasstream[ICON_MAX_STREAMSIZE];
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
606 int i;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
607 uint a_index, astream_i;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
608
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
609 memset(&aliases, 0, sizeof(aliases));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
610 memset(&aliasstream, 0, sizeof(aliasstream));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
611
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
612 aliases[0] = aliasstream;
1819
3ad217ef533e (svn r2323) Remove unused dereferencing
tron <tron@openttd.org>
parents: 1805
diff changeset
613 for (cmdptr = alias->cmdline, a_index = 0, astream_i = 0; *cmdptr != '\0'; cmdptr++) {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
614 if (a_index >= lengthof(aliases) || astream_i >= lengthof(aliasstream)) break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
615
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
616 switch (*cmdptr) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
617 case '\'': /* ' will double for "" */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
618 aliasstream[astream_i++] = '"';
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
619 break;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
620 case ';': /* Cmd seperator, start new command */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
621 aliasstream[astream_i] = '\0';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
622 aliases[++a_index] = &aliasstream[++astream_i];
1819
3ad217ef533e (svn r2323) Remove unused dereferencing
tron <tron@openttd.org>
parents: 1805
diff changeset
623 cmdptr++;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
624 break;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
625 case '%': /* Some or all parameters */
1819
3ad217ef533e (svn r2323) Remove unused dereferencing
tron <tron@openttd.org>
parents: 1805
diff changeset
626 cmdptr++;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
627 switch (*cmdptr) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
628 case '+': { /* All parameters seperated: "[param 1]" "[param 2]" */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
629 for (i = 0; i != tokencount; i++) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
630 aliasstream[astream_i++] = '"';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
631 astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
632 aliasstream[astream_i++] = '"';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
633 aliasstream[astream_i++] = ' ';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
634 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
635 } break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
636 case '!': { /* Merge the parameters to one: "[param 1] [param 2] [param 3...]" */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
637 aliasstream[astream_i++] = '"';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
638 for (i = 0; i != tokencount; i++) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
639 astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
640 aliasstream[astream_i++] = ' ';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
641 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
642 aliasstream[astream_i++] = '"';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
643
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
644 } break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
645 default: { /* One specific parameter: %A = [param 1] %B = [param 2] ... */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
646 int param = *cmdptr - 'A';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
647
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
648 if (param < 0 || param >= tokencount) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
649 IConsoleError("too many or wrong amount of parameters passed to alias, aborting");
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
650 IConsolePrintF(_icolour_warn, "Usage of alias '%s': %s", alias->name, alias->cmdline);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
651 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
652 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
653
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
654 aliasstream[astream_i++] = '"';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
655 astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[param], astream_i);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
656 aliasstream[astream_i++] = '"';
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
657 } break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
658 } break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
659
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
660 default:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
661 aliasstream[astream_i++] = *cmdptr;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
662 break;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
663 }
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
664 }
554
8e054ea3d0d4 (svn r954) -Fix: [Console] Hook fixes (sign_de)
truelight <truelight@openttd.org>
parents: 543
diff changeset
665
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
666 for (i = 0; i <= (int)a_index; i++) IConsoleCmdExec(aliases[i]); // execute each alias in turn
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
667 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
668
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
669 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
670 * Special function for adding string-type variables. They in addition
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
671 * also need a 'size' value saying how long their string buffer is.
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
672 * @param size the length of the string buffer
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
673 * For more information see @IConsoleVarRegister()
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
674 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
675 void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
676 {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
677 IConsoleVar *var;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
678 IConsoleVarRegister(name, addr, ICONSOLE_VAR_STRING, help);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
679 var = IConsoleVarGet(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
680 var->size = size;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
681 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
682
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
683 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
684 * Register a new variable to be used in the console
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
685 * @param name name of the variable that will be used
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
686 * @param addr memory location the variable will point to
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
687 * @param help the help string shown for the variable
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
688 * @param type the type of the variable (simple atomic) so we know which values it can get
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
689 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
690 void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
691 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
692 char *new_cmd = strdup(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
693 IConsoleVar *item_new = malloc(sizeof(IConsoleVar));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
694
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
695 item_new->help = (help != NULL) ? strdup(help) : NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
696
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
697 item_new->next = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
698 item_new->name = new_cmd;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
699 item_new->addr = addr;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
700 item_new->proc = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
701 item_new->type = type;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
702
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
703 item_new->hook.access = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
704 item_new->hook.pre = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
705 item_new->hook.post = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
706
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
707 IConsoleAddSorted(_iconsole_vars, item_new, IConsoleVar, "a variable");
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
708 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
709
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
710 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
711 * Find the variable pointed to by its string
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
712 * @param name variable to be found
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
713 * @return return Varstruct of the found variable, or NULL on failure
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
714 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
715 IConsoleVar *IConsoleVarGet(const char *name)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
716 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
717 IConsoleVar *item;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
718 for (item = _iconsole_vars; item != NULL; item = item->next) {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
719 if (strcmp(item->name, name) == 0) return item;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
720 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
721
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
722 return NULL;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
723 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
724
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
725 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
726 * Set a new value to a console variable
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
727 * @param *var the variable being set/changed
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
728 * @param value the new value given to the variable, cast properly
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
729 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
730 static void IConsoleVarSetValue(const IConsoleVar *var, uint32 value)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
731 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
732 switch (var->type) {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
733 case ICONSOLE_VAR_BOOLEAN:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
734 *(bool*)var->addr = (value != 0);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
735 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
736 case ICONSOLE_VAR_BYTE:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
737 *(byte*)var->addr = (byte)value;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
738 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
739 case ICONSOLE_VAR_UINT16:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
740 *(uint16*)var->addr = (byte)value;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
741 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
742 case ICONSOLE_VAR_INT16:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
743 *(int16*)var->addr = (int16)value;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
744 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
745 case ICONSOLE_VAR_UINT32:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
746 *(uint32*)var->addr = (uint32)value;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
747 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
748 case ICONSOLE_VAR_INT32:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
749 *(int32*)var->addr = (int32)value;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
750 break;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
751 default: NOT_REACHED();
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
752 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
753
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
754 IConsoleVarPrintSetValue(var);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
755 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
756
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
757 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
758 * Set a new value to a string-type variable. Basically this
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
759 * means to copy the new value over to the container.
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
760 * @param *var the variable in question
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
761 * @param *value the new value
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
762 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
763 static void IConsoleVarSetStringvalue(const IConsoleVar *var, char *value)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
764 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
765 if (var->type != ICONSOLE_VAR_STRING || var->addr == NULL) return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
766
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
767 ttd_strlcpy((char*)var->addr, (char*)value, var->size);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
768 IConsoleVarPrintSetValue(var); // print out the new value, giving feedback
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
769 return;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
770 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
771
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
772 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
773 * Query the current value of a variable and return it
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
774 * @param *var the variable queried
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
775 * @return current value of the variable
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
776 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
777 static uint32 IConsoleVarGetValue(const IConsoleVar *var)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
778 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
779 uint32 result = 0;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
780
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
781 switch (var->type) {
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
782 case ICONSOLE_VAR_BOOLEAN:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
783 result = *(bool*)var->addr;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
784 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
785 case ICONSOLE_VAR_BYTE:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
786 result = *(byte*)var->addr;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
787 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
788 case ICONSOLE_VAR_UINT16:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
789 result = *(uint16*)var->addr;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
790 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
791 case ICONSOLE_VAR_INT16:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
792 result = *(int16*)var->addr;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
793 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
794 case ICONSOLE_VAR_UINT32:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
795 result = *(uint32*)var->addr;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
796 break;
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
797 case ICONSOLE_VAR_INT32:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
798 result = *(int32*)var->addr;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
799 break;
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
800 default: NOT_REACHED();
222
d1b097f4593b (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater <darkvater@openttd.org>
parents: 220
diff changeset
801 }
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
802 return result;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
803 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
804
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
805 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
806 * Get the value of the variable and put it into a printable
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
807 * string form so we can use it for printing
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
808 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
809 static char *IConsoleVarGetStringValue(const IConsoleVar *var)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
810 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
811 static char tempres[50];
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
812 char *value = tempres;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
813
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
814 switch (var->type) {
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
815 case ICONSOLE_VAR_BOOLEAN:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
816 snprintf(tempres, sizeof(tempres), "%s", (*(bool*)var->addr) ? "on" : "off");
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
817 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
818 case ICONSOLE_VAR_BYTE:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
819 snprintf(tempres, sizeof(tempres), "%u", *(byte*)var->addr);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
820 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
821 case ICONSOLE_VAR_UINT16:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
822 snprintf(tempres, sizeof(tempres), "%u", *(uint16*)var->addr);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
823 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
824 case ICONSOLE_VAR_UINT32:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
825 snprintf(tempres, sizeof(tempres), "%u", *(uint32*)var->addr);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
826 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
827 case ICONSOLE_VAR_INT16:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
828 snprintf(tempres, sizeof(tempres), "%i", *(int16*)var->addr);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
829 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
830 case ICONSOLE_VAR_INT32:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
831 snprintf(tempres, sizeof(tempres), "%i", *(int32*)var->addr);
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
832 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
833 case ICONSOLE_VAR_STRING:
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
834 value = (char*)var->addr;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
835 default: NOT_REACHED();
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
836 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
837
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
838 return value;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
839 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
840
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
841 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
842 * Print out the value of the variable when asked
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
843 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
844 void IConsoleVarPrintGetValue(const IConsoleVar *var)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
845 {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
846 char *value;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
847 /* Some variables need really specific handling, handle this in its
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
848 * callback function */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
849 if (var->proc != NULL) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
850 var->proc(0, NULL);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
851 return;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
852 }
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
853
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
854 value = IConsoleVarGetStringValue(var);
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
855 IConsolePrintF(_icolour_warn, "Current value for '%s' is: %s", var->name, value);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
856 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
857
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
858 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
859 * Print out the value of the variable after it has been assigned
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
860 * a new value, thus giving us feedback on the action
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
861 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
862 void IConsoleVarPrintSetValue(const IConsoleVar *var)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
863 {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
864 char *value = IConsoleVarGetStringValue(var);
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
865 IConsolePrintF(_icolour_warn, "'%s' changed to: %s", var->name, value);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
866 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
867
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
868 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
869 * Execute a variable command. Without any parameters, print out its value
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
870 * with parameters it assigns a new value to the variable
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
871 * @param *var the variable that we will be querying/changing
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
872 * @param tokencount how many additional parameters have been given to the commandline
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
873 * @param *token the actual parameters the variable was called with
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
874 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
875 void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[ICON_TOKEN_COUNT])
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
876 {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
877 const char *tokenptr = token[0];
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
878 byte t_index = tokencount;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
879 uint32 value;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
880
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
881 if (tokencount == 0) { /* Just print out value */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
882 IConsoleVarPrintGetValue(var);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
883 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
884 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
885
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
886 /* Use of assignment sign is not mandatory but supported, so just 'ignore it appropiately' */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
887 if (strcmp(tokenptr, "=") == 0) tokencount--;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
888
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
889 if (tokencount == 1) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
890 /* Some variables need really special handling, handle it in their callback procedure */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
891 if (var->proc != NULL) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
892 var->proc(tokencount, &token[t_index - tokencount]); // set the new value
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
893 var->proc(0, NULL); // print out new value
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
894 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
895 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
896 /* Strings need special processing. No need to convert the argument to
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
897 * an integer value, just copy over the argument on a one-by-one basis */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
898 if (var->type == ICONSOLE_VAR_STRING) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
899 IConsoleVarSetStringvalue(var, token[t_index - tokencount]);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
900 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
901 } else if (GetArgumentInteger(&value, token[t_index - tokencount])) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
902 IConsoleVarSetValue(var, value);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
903 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
904 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
905
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
906 /* Increase or decrease the value by one. This of course can only happen to 'number' types */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
907 if (strcmp(tokenptr, "++") == 0 && var->type != ICONSOLE_VAR_STRING) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
908 IConsoleVarSetValue(var, IConsoleVarGetValue(var) + 1);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
909 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
910 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
911
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
912 if (strcmp(tokenptr, "--") == 0 && var->type != ICONSOLE_VAR_STRING) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
913 IConsoleVarSetValue(var, IConsoleVarGetValue(var) - 1);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
914 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
915 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
916 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
917
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
918 IConsoleError("invalid variable assignment");
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
919 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
920
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
921 // * ************************* * //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
922 // * hooking code * //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
923 // * ************************* * //
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
924 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
925 * General internal hooking code that is the same for both commands and variables
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
926 * @param hooks @IConsoleHooks structure that will be set according to
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
927 * @param type type access trigger
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
928 * @param proc function called when the hook criteria is met
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
929 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
930 static void IConsoleHookAdd(IConsoleHooks *hooks, IConsoleHookTypes type, IConsoleHook *proc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
931 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
932 if (hooks == NULL || proc == NULL) return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
933
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
934 switch (type) {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
935 case ICONSOLE_HOOK_ACCESS:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
936 hooks->access = proc;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
937 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
938 case ICONSOLE_HOOK_PRE_ACTION:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
939 hooks->pre = proc;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
940 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
941 case ICONSOLE_HOOK_POST_ACTION:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
942 hooks->post = proc;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
943 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
944 default: NOT_REACHED();
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
945 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
946 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
947
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
948 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
949 * Handle any special hook triggers. If the hook type is met check if
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
950 * there is a function associated with that and if so, execute it
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
951 * @param hooks @IConsoleHooks structure that will be checked
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
952 * @param type type of hook, trigger that needs to be activated
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
953 * @return true on a successfull execution of the hook command or if there
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
954 * is no hook/trigger present at all. False otherwise
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
955 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
956 static bool IConsoleHookHandle(IConsoleHooks *hooks, IConsoleHookTypes type)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
957 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
958 IConsoleHook *proc = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
959 if (hooks == NULL) return false;
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 518
diff changeset
960
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
961 switch (type) {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
962 case ICONSOLE_HOOK_ACCESS:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
963 proc = hooks->access;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
964 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
965 case ICONSOLE_HOOK_PRE_ACTION:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
966 proc = hooks->pre;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
967 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
968 case ICONSOLE_HOOK_POST_ACTION:
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
969 proc = hooks->post;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
970 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
971 default: NOT_REACHED();
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
972 }
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
973
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
974 return (proc == NULL) ? true : proc();
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
975 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
976
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
977 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
978 * Add a hook to a command that will be triggered at certain points
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
979 * @param name name of the command that the hook is added to
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
980 * @param type type of hook that is added (ACCESS, BEFORE and AFTER change)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
981 * @param proc function called when the hook criteria is met
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
982 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
983 void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
984 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
985 IConsoleCmd *cmd = IConsoleCmdGet(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
986 if (cmd == NULL) return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
987 IConsoleHookAdd(&cmd->hook, type, proc);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
988 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
989
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
990 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
991 * Add a hook to a variable that will be triggered at certain points
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
992 * @param name name of the variable that the hook is added to
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
993 * @param type type of hook that is added (ACCESS, BEFORE and AFTER change)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
994 * @param proc function called when the hook criteria is met
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
995 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
996 void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
997 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
998 IConsoleVar *var = IConsoleVarGet(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
999 if (var == NULL) return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1000 IConsoleHookAdd(&var->hook, type, proc);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1001 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1002
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1003 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1004 * Add a callback function to the variable. Some variables need
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1005 * very special processing, which can only be done with custom code
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1006 * @param name name of the variable the callback function is added to
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1007 * @param proc the function called
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1008 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1009 void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1010 {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1011 IConsoleVar *var = IConsoleVarGet(name);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1012 if (var == NULL) return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1013 var->proc = proc;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1014 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1015
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1016 /**
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1017 * Execute a given command passed to us. First chop it up into
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1018 * individual tokens (seperated by spaces), then execute it if possible
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1019 * @param cmdstr string to be parsed and executed
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1020 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1021 void IConsoleCmdExec(const char *cmdstr)
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1022 {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1023 IConsoleCmd *cmd = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1024 IConsoleAlias *alias = NULL;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1025 IConsoleVar *var = NULL;
1109
aa09f0ca9ea0 (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron <tron@openttd.org>
parents: 1095
diff changeset
1026
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1027 const char *cmdptr;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1028 char *tokens[ICON_TOKEN_COUNT], tokenstream[ICON_MAX_STREAMSIZE];
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1029 uint t_index, tstream_i;
1726
aff32b2460fe (svn r2230) Oops, revert wrongly committed local console.c. Also add the endian_target.h and endian_host.h to the ignore list
Darkvater <Darkvater@openttd.org>
parents: 1725
diff changeset
1030
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1031 bool longtoken = false;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1032 bool foundtoken = false;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1033
1819
3ad217ef533e (svn r2323) Remove unused dereferencing
tron <tron@openttd.org>
parents: 1805
diff changeset
1034 for (cmdptr = cmdstr; *cmdptr != '\0'; cmdptr++) {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1035 if (!IsValidAsciiChar(*cmdptr)) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1036 IConsoleError("command contains malformed characters, aborting");
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
1037 IConsolePrintF(_icolour_err, "ERROR: command was: '%s'", cmdstr);
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1038 return;
1379
9e0a3d4702d9 (svn r1883) -Fix: [1109400] Better test if a string actually contains any console command
tron <tron@openttd.org>
parents: 1243
diff changeset
1039 }
9e0a3d4702d9 (svn r1883) -Fix: [1109400] Better test if a string actually contains any console command
tron <tron@openttd.org>
parents: 1243
diff changeset
1040 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1041
640
38b9e89a812d (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik <dominik@openttd.org>
parents: 634
diff changeset
1042 if (_stdlib_con_developer)
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
1043 IConsolePrintF(_icolour_dbg, "condbg: executing cmdline: '%s'", cmdstr);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1044
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1045 memset(&tokens, 0, sizeof(tokens));
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1046 memset(&tokenstream, 0, sizeof(tokenstream));
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1047
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1048 /* 1. Split up commandline into tokens, seperated by spaces, commands
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1049 * enclosed in "" are taken as one token. We can only go as far as the amount
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1050 * of characters in our stream or the max amount of tokens we can handle */
1819
3ad217ef533e (svn r2323) Remove unused dereferencing
tron <tron@openttd.org>
parents: 1805
diff changeset
1051 for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) {
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1052 if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1053
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1054 switch (*cmdptr) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1055 case ' ': /* Token seperator */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1056 if (!foundtoken) break;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1057
1746
241ba7323b9e (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater <Darkvater@openttd.org>
parents: 1743
diff changeset
1058 if (longtoken) {
241ba7323b9e (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater <Darkvater@openttd.org>
parents: 1743
diff changeset
1059 tokenstream[tstream_i] = *cmdptr;
241ba7323b9e (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater <Darkvater@openttd.org>
parents: 1743
diff changeset
1060 } else {
241ba7323b9e (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater <Darkvater@openttd.org>
parents: 1743
diff changeset
1061 tokenstream[tstream_i] = '\0';
241ba7323b9e (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater <Darkvater@openttd.org>
parents: 1743
diff changeset
1062 foundtoken = false;
241ba7323b9e (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater <Darkvater@openttd.org>
parents: 1743
diff changeset
1063 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1064
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1065 tstream_i++;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1066 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1067 case '"': /* Tokens enclosed in "" are one token */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1068 longtoken = !longtoken;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1069 break;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1070 default: /* Normal character */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1071 tokenstream[tstream_i++] = *cmdptr;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1072
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1073 if (!foundtoken) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1074 tokens[t_index++] = &tokenstream[tstream_i - 1];
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1075 foundtoken = true;
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
1076 }
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1077 break;
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1078 }
289
61f1ea337ebc (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater <darkvater@openttd.org>
parents: 274
diff changeset
1079 }
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1080
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1081 if (_stdlib_con_developer) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1082 uint i;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1083 for (i = 0; tokens[i] != NULL; i++)
1805
9c91d08b3943 (svn r2309) - CodeChange: Change all _iconsole_color_whatever into _icolour_wtv (abbreviated). Besides the changed into proper english, yes this commit is pretty useless ;)
Darkvater <Darkvater@openttd.org>
parents: 1773
diff changeset
1084 IConsolePrintF(_icolour_dbg, "condbg: token %d is: '%s'", i, tokens[i]);
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1085 }
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1086
1828
b15c8dfef71a (svn r2333) - CodeChange: also don't execute command if user has typed all spaces (eg nothing worthwhile). Suggested and implemented by Tron.
Darkvater <Darkvater@openttd.org>
parents: 1827
diff changeset
1087 if (tokens[0] == '\0') return; // don't execute empty commands
1739
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1088 /* 2. Determine type of command (cmd, alias or variable) and execute
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1089 * First try commands, then aliases, and finally variables. Execute
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1090 * the found action taking into account its hooking code
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1091 */
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1092 cmd = IConsoleCmdGet(tokens[0]);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1093 if (cmd != NULL) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1094 if (IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_ACCESS)) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1095 IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_PRE_ACTION);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1096 if (cmd->proc(t_index, tokens)) { // index started with 0
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1097 IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_POST_ACTION);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1098 } else cmd->proc(0, NULL); // if command failed, give help
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1099 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1100 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1101 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1102
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1103 t_index--; // ignore the variable-name for comfort for both aliases and variaables
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1104 alias = IConsoleAliasGet(tokens[0]);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1105 if (alias != NULL) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1106 IConsoleAliasExec(alias, t_index, &tokens[1]);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1107 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1108 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1109
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1110 var = IConsoleVarGet(tokens[0]);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1111 if (var != NULL) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1112 if (IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_ACCESS)) {
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1113 IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_PRE_ACTION);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1114 IConsoleVarExec(var, t_index, &tokens[1]);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1115 if (t_index != 0) // value has indeed been changed
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1116 IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_POST_ACTION);
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1117 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1118 return;
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1119 }
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1120
9c888f74a57e (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater <Darkvater@openttd.org>
parents: 1726
diff changeset
1121 IConsoleError("command or variable not found");
135
5f7d4f435388 (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater <darkvater@openttd.org>
parents: 129
diff changeset
1122 }