annotate console.c @ 222:d1b097f4593b draft

(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron) -CodeLayout: Remove trailing spaces and Windows linebreaks
author darkvater <darkvater@openttd.org>
date Sun, 12 Sep 2004 21:49:38 +0000
parents 9b7653080948
children f5f5d6e51c92
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"
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
3 #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
4 #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
5 #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
6 #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
7 #include "variables.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 "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
9 #include <stdarg.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
10 #include "console.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
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
12 // ** main console ** //
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
13 static bool _iconsole_inited;
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
14 static byte* _iconsole_buffer[80];
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
15 static byte _iconsole_cbuffer[80];
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
16 static byte _iconsole_cmdline[255];
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
17 static byte _iconsole_cmdpos;
136
b1efd00ffd88 (svn r137) Fix: console sometime didn't open (sign_de)
dominik <dominik@openttd.org>
parents: 135
diff changeset
18 static byte _iconsole_mode = ICONSOLE_CLOSED;
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
19 static Window *_iconsole_win = NULL;
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
20 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
21
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
22 // ** console cursor ** //
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
23 static bool _icursor_state;
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
24 static byte _icursor_rate;
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
25 static byte _icursor_counter;
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
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
27 // ** stdlib ** //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
28 byte _stdlib_developer=1;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
29 bool _stdlib_con_developer=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
30
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
31 // ** main console cmd buffer ** // sign_de: especialy for Celestar :D
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
32 static byte* _iconsole_cmdbuffer[20];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
33 static byte _iconsole_cmdbufferpos;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
34
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
35 // ** console window ** //
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
36 static void IConsoleWndProc(Window *w, WindowEvent *e);
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 169
diff changeset
37 static const Widget _iconsole_window_widgets[] = {{WIDGETS_END}};
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
38 static const WindowDesc _iconsole_window_desc = {
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
39 0, 0, 2, 2,
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
40 WC_CONSOLE,0,
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
41 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
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
42 _iconsole_window_widgets,
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 IConsoleWndProc,
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 };
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
45
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
46 /* *************** */
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
47 /* end of header */
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 /* *************** */
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
49
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
50 void IConsoleClearCommand()
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
51 {
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
52 int i;
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
53 for (i=0; i<255; i++) _iconsole_cmdline[i]=0;
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
54 _iconsole_cmdpos=0;
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 SetWindowDirty(_iconsole_win);
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 }
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
57
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
58 static void IConsoleWndProc(Window *w, WindowEvent *e)
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
59 {
209
59df4d519c43 (svn r210) -Fix: Console key closes window in front
signde <signde@openttd.org>
parents: 205
diff changeset
60 // only do window events with the console
59df4d519c43 (svn r210) -Fix: Console key closes window in front
signde <signde@openttd.org>
parents: 205
diff changeset
61 w = FindWindowById(WC_CONSOLE, 0);
59df4d519c43 (svn r210) -Fix: Console key closes window in front
signde <signde@openttd.org>
parents: 205
diff changeset
62
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
63 switch(e->event) {
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
64
169
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
65 case WE_PAINT:
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
66 GfxFillRect(w->left,w->top,w->width,w->height-1,0);
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
67 {
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
68 int i=_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
69 int max=(w->height/12)-1;
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
70 while ((i>_iconsole_scroll-max) && (_iconsole_buffer[i]!=NULL)) {
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
71 DoDrawString(_iconsole_buffer[i],5,w->height-(((_iconsole_scroll+2)-i)*12),_iconsole_cbuffer[i]);
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 i--;
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
73 }
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
74 DoDrawString("]",5,w->height-12,_iconsole_color_commands);
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
75 DoDrawString((char *)&_iconsole_cmdline,10,w->height-12,_iconsole_color_commands);
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
76 }
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
77 break;
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
78
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
79 case WE_TICK:
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
80
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
81 _icursor_counter++;
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
82 if (_icursor_counter>_icursor_rate) {
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
83 _icursor_state=!_icursor_state;
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
84 {
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 int posx;
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
86 int posy;
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
87 int color;
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
88 _cur_dpi=&_screen;
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
89 if (_icursor_state) color=14; else color=0;
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
90 posx=10+GetStringWidth((char *)&_iconsole_cmdline);
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
91 posy=w->height-3;
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
92 GfxFillRect(posx,posy,posx+5,posy+1,color);
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
93 _video_driver->make_dirty(posx,posy,5,1);
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
94 }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
95 _icursor_counter=0;
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
96 }
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
97 break;
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
98
169
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
99 case WE_DESTROY:
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
100 _iconsole_win=NULL;
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
101 _iconsole_mode=ICONSOLE_CLOSED;
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
102 break;
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
103
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
104 case WE_KEYPRESS:
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
105 e->keypress.cont=false;
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
106 if (e->keypress.keycode == (WKC_UP))
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
107 {
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
108 IConsoleCmdBufferNavigate(+1);
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
109 SetWindowDirty(w);
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
110 } else
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
111 if (e->keypress.keycode == (WKC_DOWN))
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
112 {
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
113 IConsoleCmdBufferNavigate(-1);
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
114 SetWindowDirty(w);
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
115 } else
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
116 if (e->keypress.keycode == (WKC_SHIFT | WKC_PAGEUP))
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
117 {
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
118 if ((_iconsole_scroll - ((w->height/12)-1))<0) {
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
119 _iconsole_scroll = 0;
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
120 } else {
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
121 _iconsole_scroll -= (w->height/12)-1;
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
122 }
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
123 SetWindowDirty(w);
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
124 } else
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
125 if (e->keypress.keycode == (WKC_SHIFT | WKC_PAGEDOWN))
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
126 {
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
127 if ((_iconsole_scroll + ((w->height/12)-1))>79) {
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
128 _iconsole_scroll = 79;
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
129 } else {
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
130 _iconsole_scroll += (w->height/12)-1;
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
131 }
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
132 SetWindowDirty(w);
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
133 } else
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
134 if (e->keypress.keycode == (WKC_SHIFT | WKC_UP))
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
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
136 if ((_iconsole_scroll - 1)<0) {
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
137 _iconsole_scroll = 0;
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
138 } else {
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
139 _iconsole_scroll -= 1;
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
140 }
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
141 SetWindowDirty(w);
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
142 } else
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
143 if (e->keypress.keycode == (WKC_SHIFT | WKC_DOWN))
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
144 {
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
145 if ((_iconsole_scroll + 1)>79) {
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
146 _iconsole_scroll = 79;
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
147 } else {
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
148 _iconsole_scroll += 1;
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
149 }
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
150 SetWindowDirty(w);
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
151 } else
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
152 if (e->keypress.keycode == WKC_BACKQUOTE)
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
153 {
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
154 IConsoleSwitch();
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
155 } else
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
156 if (e->keypress.keycode == WKC_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
157 {
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
158 IConsolePrintF(_iconsole_color_commands, "] %s", _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
159 IConsoleCmdBufferAdd(_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
160 IConsoleCmdExec((byte *) _iconsole_cmdline);
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
161 IConsoleClearCommand();
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
162 } else
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
163 if (e->keypress.keycode == WKC_BACKSPACE)
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
164 {
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
165 if (_iconsole_cmdpos!=0) _iconsole_cmdpos--;
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
166 _iconsole_cmdline[_iconsole_cmdpos]=0;
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
167 SetWindowDirty(w);
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
168 _iconsole_cmdbufferpos=19;
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
169 } else
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
170 if (IS_INT_INSIDE((e->keypress.ascii), 32, 256))
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
171 {
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
172 _iconsole_scroll=79;
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
173 _iconsole_cmdline[_iconsole_cmdpos]=e->keypress.ascii;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
174 if (_iconsole_cmdpos!=255) _iconsole_cmdpos++;
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
175 SetWindowDirty(w);
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
176 _iconsole_cmdbufferpos=19;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
177 } else e->keypress.cont=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
178 break;
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 }
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
182
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
183 void IConsoleInit()
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
184 {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
185 int i;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
186 #if defined(WITH_REV)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
187 extern char _openttd_revision[];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
188 #endif
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
189 _iconsole_color_default = 1;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
190 _iconsole_color_error = 3;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
191 _iconsole_color_debug = 5;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
192 _iconsole_color_commands = 2;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
193 _iconsole_scroll=79;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
194 _iconsole_cmdbufferpos=19;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
195 _iconsole_inited=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
196 _iconsole_mode=ICONSOLE_CLOSED;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
197 _iconsole_win=NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
198 _icursor_state=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
199 _icursor_rate=5;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
200 _icursor_counter=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
201 for (i=0;i<20;i++) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
202 _iconsole_cmdbuffer[i]=NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
203 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
204 for (i=0;i<80;i++) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
205 _iconsole_buffer[i]=NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
206 _iconsole_cbuffer[i]=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
207 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
208 IConsoleStdLibRegister();
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
209 #if defined(WITH_REV)
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
210 IConsolePrintF(13,"OpenTTD Game Console Revision 4 - %s",_openttd_revision);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
211 #else
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
212 IConsolePrint(13,"OpenTTD Game Console Revision 4");
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
213 #endif
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
214 IConsolePrint(12,"---------------------------------");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
215 IConsolePrint(12,"use \"help\" for more info");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
216 IConsolePrint(12,"");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
217 IConsoleClearCommand();
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
218 IConsoleCmdBufferAdd("");
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
219 }
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
220
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
221 void IConsoleClear()
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
222 {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
223 int i;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
224 for (i=0;i<80;i++) if (_iconsole_buffer[i]!=NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
225 free(_iconsole_buffer[i]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
226 }
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
227 }
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
228
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 void IConsoleFree()
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
230 {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
231 _iconsole_inited=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
232 IConsoleClear();
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
233 }
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
234
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
235 void IConsoleResize()
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
236 {
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
237 if (_iconsole_win!=NULL) {
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
238 _iconsole_win->height = _screen.height / 3;
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
239 _iconsole_win->width= _screen.width;
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
240 }
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
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
243 void IConsoleSwitch()
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
244 {
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
245 if (_iconsole_mode==ICONSOLE_CLOSED) {
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
246 _iconsole_win = AllocateWindowDesc(&_iconsole_window_desc);
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
247 _iconsole_win->height = _screen.height / 3;
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
248 _iconsole_win->width= _screen.width;
136
b1efd00ffd88 (svn r137) Fix: console sometime didn't open (sign_de)
dominik <dominik@openttd.org>
parents: 135
diff changeset
249 _iconsole_mode=ICONSOLE_OPENED;
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
250 } else
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
251 if (_iconsole_mode==ICONSOLE_OPENED) {
209
59df4d519c43 (svn r210) -Fix: Console key closes window in front
signde <signde@openttd.org>
parents: 205
diff changeset
252 DeleteWindowById(WC_CONSOLE,0);
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
253 _iconsole_win=NULL;
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
254 _iconsole_mode=ICONSOLE_CLOSED;
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
255 }
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
256 MarkWholeScreenDirty();
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
257 MarkAllViewportsDirty(0,0,_screen.width,_screen.height);
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
258 _video_driver->make_dirty(0,0,_screen.width,_screen.height);
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
259 }
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
260
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
261 void IConsoleClose()
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
262 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
263 if (_iconsole_mode==ICONSOLE_OPENED) IConsoleSwitch();
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
264 _iconsole_mode=ICONSOLE_CLOSED;
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 }
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
266
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
267 void IConsoleOpen()
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
268 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
269 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
270 }
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
271
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
272 void IConsoleCmdBufferAdd(const byte * cmd)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
273 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
274 int i;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
275 if (_iconsole_cmdbufferpos != 19) return;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
276 if (_iconsole_cmdbuffer[18]!=NULL) free(_iconsole_cmdbuffer[18]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
277 for (i=18; i>0; i--) _iconsole_cmdbuffer[i]=_iconsole_cmdbuffer[i-1];
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
278 i=strlen(cmd);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
279 _iconsole_cmdbuffer[0]=malloc(i+1);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
280 memset(((void *)_iconsole_cmdbuffer[0]),0,i+1);
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
281 memcpy(((void *)_iconsole_cmdbuffer[0]),cmd,i);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
282 _iconsole_cmdbuffer[0][i]=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
283 _iconsole_cmdbufferpos = 19;
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
284 }
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
285
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
286 void IConsoleCmdBufferNavigate(signed char direction)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
287 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
288 int i;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
289 i=_iconsole_cmdbufferpos + direction;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
290 if (i<0) i=19;
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
291 if (i>19) i=0;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
292 if (direction>0) while (_iconsole_cmdbuffer[i]==NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
293 i++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
294 if (i>19) i=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
295 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
296 if (direction<0) while (_iconsole_cmdbuffer[i]==NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
297 i--;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
298 if (i<0) i=19;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
299 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
300 _iconsole_cmdbufferpos = i;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
301 IConsoleClearCommand();
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
302 memcpy((void *)_iconsole_cmdline,(void *)_iconsole_cmdbuffer[i],strlen(_iconsole_cmdbuffer[i]));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
303 _iconsole_cmdpos =strlen(_iconsole_cmdbuffer[i]);
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
304 }
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
305
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
306 void IConsolePrint(byte color_code, const byte* 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
307 {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
308 byte * _ex;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
309 byte * _new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
310 byte _exc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
311 byte _newc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
312 int i,j;
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
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
314 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
315
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
316 _newc=color_code;
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
317 i=strlen(string);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
318 _new=malloc(i+1);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
319 memset(_new,0,i+1);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
320 memcpy(_new,string,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
321
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
322 for (j=0;j<i;j++) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
323 if (_new[j]<0x1F) _new[j]=0x20;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
324 }
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
325
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
326 i=79;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
327 while (i>=0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
328 _ex=_iconsole_buffer[i];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
329 _exc=_iconsole_cbuffer[i];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
330 _iconsole_buffer[i]=_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
331 _iconsole_cbuffer[i]=_newc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
332 _new=_ex;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
333 _newc=_exc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
334 i--;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
335 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
336 if (_ex!=NULL) free(_ex);
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
337
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
338 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
339 }
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
340
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
341
169
ebd4e4ced31b (svn r170) -Fix: [1022902] network fix .. console fix bug [1018523]. Fixes some variable initialization errors and a console.h warning (sign_de)
darkvater <darkvater@openttd.org>
parents: 141
diff changeset
342 void CDECL IConsolePrintF(byte 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
343 {
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
344 va_list va;
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
345 char buf[1024];
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
346 va_start(va, s);
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
347 vsprintf(buf, s, va);
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
348 va_end(va);
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
349 IConsolePrint(color_code, (byte *) &buf);
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
350 }
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
351
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
352 void IConsoleDebug(byte* string)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
353 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
354 if (_stdlib_developer>1) IConsolePrintF(_iconsole_color_debug, "DEBUG: %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
355 }
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
356
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
357 void IConsoleError(const byte* string)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
358 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
359 if (_stdlib_developer>0) IConsolePrintF(_iconsole_color_error, "ERROR: %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
360 }
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
361
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
362 void IConsoleCmdRegister(const byte * name, void * addr)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
363 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
364 byte * _new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
365 _iconsole_cmd * item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
366 _iconsole_cmd * item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
367 int 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
368
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
369 i=strlen(name);
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
370 _new=malloc(i+1);
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
371 memset(_new,0,i+1);
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
372 memcpy(_new,name,i);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
373
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
374 item_new = malloc(sizeof(_iconsole_cmd));
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
375
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
376 item_new->_next = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
377 item_new->addr = addr;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
378 item_new->name = _new;
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
379
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
380 item_new->hook_access = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
381 item_new->hook_after_exec = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
382 item_new->hook_before_exec = 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
383
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
384 item = _iconsole_cmds;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
385 if (item == NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
386 _iconsole_cmds = item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
387 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
388 while (item->_next != NULL) { item = item->_next; };
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
389 item->_next = item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
390 }
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
391 }
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
392
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
393 void* IConsoleCmdGet(const byte * name)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
394 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
395 _iconsole_cmd * item;
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
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
397 item = _iconsole_cmds;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
398 while (item != NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
399 if (strcmp(item->name,name)==0) return item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
400 item = item->_next;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
401 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
402 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
403 }
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
404
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
405 void IConsoleVarRegister(const byte * name, void * addr, byte type)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
406 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
407 byte * _new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
408 _iconsole_var * item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
409 _iconsole_var * item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
410 int 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
411
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
412 i=strlen(name)+1;
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
413 _new=malloc(i+1);
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
414 memset(_new,0,i+1);
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
415 _new[0]='*';
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
416 memcpy(_new+1,name,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
417
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
418 item_new = malloc(sizeof(_iconsole_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
419
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
420 item_new->_next = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
421 item_new->addr = addr;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
422 item_new->name = _new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
423 item_new->type = type;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
424 item_new->_malloc = false;
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
425
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
426 item_new->hook_access = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
427 item_new->hook_after_change = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
428 item_new->hook_before_change = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
429
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
430 item = _iconsole_vars;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
431 if (item == NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
432 _iconsole_vars = item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
433 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
434 while (item->_next != NULL) { item = item->_next; };
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
435 item->_next = item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
436 }
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
437 }
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
438
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
439 void IConsoleVarMemRegister(byte * name, byte type) /* XXX TRON */
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
440 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
441 _iconsole_var * item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
442 item = IConsoleVarAlloc(type);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
443 IConsoleVarInsert(item,name);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
444 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
445
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
446
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
447 void IConsoleVarInsert(_iconsole_var * var, const byte * name)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
448 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
449 byte * _new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
450 _iconsole_var * item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
451 _iconsole_var * item_new;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
452 int 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
453
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
454 item_new = 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
455
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
456 // dont allow to build variable rings
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
457 if (item_new->_next != NULL) return;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
458
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
459 i=strlen(name)+1;
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
460 _new=malloc(i+1);
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
461 memset(_new,0,i+1);
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
462 _new[0]='*';
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
463 memcpy(_new+1,name,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
464
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
465 item_new->name = _new;
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
466
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
467 item = _iconsole_vars;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
468 if (item == NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
469 _iconsole_vars = item_new;
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
470 } else {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
471 while (item->_next != NULL) { item = item->_next; };
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
472 item->_next = item_new;
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 }
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
475
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
476
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
477 _iconsole_var * IConsoleVarGet(const byte * name)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
478 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
479 _iconsole_var * item;
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
480
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
481 item = _iconsole_vars;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
482 while (item != NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
483 if (strcmp(item->name,name)==0) return item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
484 item = item->_next;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
485 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
486 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
487 }
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
488
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
489 _iconsole_var * IConsoleVarAlloc(byte type)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
490 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
491 _iconsole_var * item;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
492 item=malloc(sizeof(_iconsole_var));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
493 item->_next = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
494 item->name = "";
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
495 item->type = type;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
496 switch (item->type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
497 case ICONSOLE_VAR_BOOLEAN:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
498 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
499 item->addr=malloc(sizeof(bool));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
500 memset(item->addr,0,sizeof(bool));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
501 item->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
502 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
503 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
504 case ICONSOLE_VAR_BYTE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
505 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
506 item->addr=malloc(sizeof(byte));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
507 memset(item->addr,0,sizeof(byte));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
508 item->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
509 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
510 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
511 case ICONSOLE_VAR_UINT16:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
512 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
513 item->addr=malloc(sizeof(unsigned short));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
514 memset(item->addr,0,sizeof(unsigned short));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
515 item->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
516 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
517 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
518 case ICONSOLE_VAR_UINT32:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
519 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
520 item->addr=malloc(sizeof(unsigned int));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
521 memset(item->addr,0,sizeof(unsigned int));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
522 item->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
523 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
524 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
525 case ICONSOLE_VAR_INT16:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
526 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
527 item->addr=malloc(sizeof(signed short));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
528 memset(item->addr,0,sizeof(signed short));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
529 item->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
530 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
531 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
532 case ICONSOLE_VAR_INT32:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
533 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
534 item->addr=malloc(sizeof(signed int));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
535 memset(item->addr,0,sizeof(signed int));
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
536 item->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
537 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
538 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
539 default:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
540 item->addr = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
541 item->_malloc = false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
542 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
543 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
544
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
545 item->hook_access = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
546 item->hook_after_change = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
547 item->hook_before_change = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
548 return item;
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
549 }
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
550
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
551
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
552 void IConsoleVarFree(_iconsole_var * var)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
553 {
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
554 if (var->_malloc)
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
555 free(var->addr);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
556 free(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
557 }
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
558
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
559 void IConsoleVarSetString(_iconsole_var * var, const byte * string)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
560 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
561 int l;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
562
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
563 if (string == NULL) return;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
564
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
565 if (var->_malloc) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
566 free(var->addr);
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
567 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
568
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
569 l=strlen(string);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
570 var->addr=malloc(l+1);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
571 var->_malloc=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
572 memset(var->addr,0,l);
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
573 memcpy(var->addr, string, l);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
574 ((byte *)var->addr)[l]=0;
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
575 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
576
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
577 void IConsoleVarSetValue(_iconsole_var * var, int value) {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
578 switch (var->type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
579 case ICONSOLE_VAR_BOOLEAN:
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
580 *(bool *)var->addr = (value != 0);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
581 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
582 case ICONSOLE_VAR_BYTE:
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
583 *(byte *)var->addr = value;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
584 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
585 case ICONSOLE_VAR_UINT16:
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
586 *(unsigned short *)var->addr = value;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
587 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
588 case ICONSOLE_VAR_UINT32:
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
589 *(unsigned int *)var->addr = value;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
590 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
591 case ICONSOLE_VAR_INT16:
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
592 *(signed short *)var->addr = value;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
593 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
594 case ICONSOLE_VAR_INT32:
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
595 *(signed int *)var->addr = value;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
596 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
597 default:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
598 break;
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
599 }
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
600 }
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
601
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
602 void IConsoleVarDump(_iconsole_var * var, const byte * dump_desc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
603 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
604 byte var_b; // TYPE BYTE
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
605 unsigned short var_ui16; // TYPE UINT16
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
606 unsigned int var_ui32; // TYPE UINT32
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
607 signed short var_i16; // TYPE INT16
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
608 signed int var_i32; // TYPE INT32
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
609 byte * var_s; // TYPE 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
610
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
611 if (dump_desc==NULL) dump_desc = var->name;
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
612
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
613 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
614 case ICONSOLE_VAR_BOOLEAN:
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
615 {
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
616 if (*(bool *)var->addr) {
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
617 IConsolePrintF(_iconsole_color_default, "%s = true",dump_desc);
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
618 } else {
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
619 IConsolePrintF(_iconsole_color_default, "%s = false",dump_desc);
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
620 }
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
621 }
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
622 break;
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
623 case ICONSOLE_VAR_BYTE:
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
624 {
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
625 var_b=*(byte *)var->addr;
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
626 IConsolePrintF(_iconsole_color_default, "%s = %i",dump_desc,var_b);
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
627 }
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
628 break;
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
629 case ICONSOLE_VAR_UINT16:
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
630 {
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
631 var_ui16=*(unsigned short *)var->addr;
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
632 IConsolePrintF(_iconsole_color_default, "%s = %i",dump_desc,var_ui16);
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
633 }
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
634 break;
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
635 case ICONSOLE_VAR_UINT32:
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
636 {
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
637 var_ui32=*(unsigned int *)var->addr;
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
638 IConsolePrintF(_iconsole_color_default, "%s = %i",dump_desc,var_ui32);
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
639 }
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
640 break;
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
641 case ICONSOLE_VAR_INT16:
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
642 {
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
643 var_i16=*(signed short *)var->addr;
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
644 IConsolePrintF(_iconsole_color_default, "%s = %i",dump_desc,var_i16);
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
645 }
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
646 break;
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
647 case ICONSOLE_VAR_INT32:
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
648 {
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
649 var_i32=*(signed int *)var->addr;
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
650 IConsolePrintF(_iconsole_color_default, "%s = %i",dump_desc,var_i32);
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
651 }
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
652 break;
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
653 case ICONSOLE_VAR_STRING:
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
654 {
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
655 var_s=(byte *)var->addr;
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
656 IConsolePrintF(_iconsole_color_default, "%s = %s",dump_desc,var_s);
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
657 }
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
658 break;
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
659 case ICONSOLE_VAR_REFERENCE:
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
660 IConsolePrintF(_iconsole_color_default, "%s = @%s",dump_desc,((_iconsole_var *)var->addr)->name);
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
661 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
662 case ICONSOLE_VAR_UNKNOWN:
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
663 case ICONSOLE_VAR_POINTER:
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
664 {
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
665 var_i32=(signed int)((byte *)var->addr);
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
666 IConsolePrintF(_iconsole_color_default, "%s = @%i",dump_desc,var_i32);
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
667 }
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 break;
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
669 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
670 }
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
671
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
672 // * ************************* * //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
673 // * hooking code * //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
674 // * ************************* * //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
675
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
676 void IConsoleVarHook(const byte * name, byte type, void * proc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
677 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
678 _iconsole_var * hook_var;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
679 hook_var = IConsoleVarGet(name);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
680 if (hook_var == NULL) return;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
681 switch (type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
682 case ICONSOLE_HOOK_BEFORE_CHANGE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
683 hook_var->hook_after_change = proc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
684 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
685 case ICONSOLE_HOOK_AFTER_CHANGE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
686 hook_var->hook_after_change = proc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
687 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
688 case ICONSOLE_HOOK_ACCESS:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
689 hook_var->hook_access = proc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
690 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
691 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
692 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
693
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
694 bool IConsoleVarHookHandle(_iconsole_var * hook_var, byte type)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
695 {
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
696 bool (*proc)(_iconsole_var * hook_var) = NULL;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
697 switch (type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
698 case ICONSOLE_HOOK_BEFORE_CHANGE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
699 proc = hook_var->hook_before_change;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
700 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
701 case ICONSOLE_HOOK_AFTER_CHANGE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
702 proc = hook_var->hook_after_change;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
703 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
704 case ICONSOLE_HOOK_ACCESS:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
705 proc = hook_var->hook_access;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
706 break;
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
707 default: return true;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
708 }
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
709
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
710 return proc(hook_var);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
711 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
712
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
713 void IConsoleCmdHook(const byte * name, byte type, void * proc)
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
714 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
715 _iconsole_cmd * hook_cmd;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
716 hook_cmd = IConsoleCmdGet(name);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
717 if (hook_cmd == NULL) return;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
718 switch (type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
719 case ICONSOLE_HOOK_AFTER_EXEC:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
720 hook_cmd->hook_after_exec = proc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
721 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
722 case ICONSOLE_HOOK_BEFORE_EXEC:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
723 hook_cmd->hook_before_exec = proc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
724 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
725 case ICONSOLE_HOOK_ACCESS:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
726 hook_cmd->hook_access = proc;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
727 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
728 }
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
729 }
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
730
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
731 bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
732 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
733 bool (*proc)(_iconsole_cmd * hook_cmd);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
734 switch (type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
735 case ICONSOLE_HOOK_AFTER_EXEC:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
736 proc = hook_cmd->hook_after_exec;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
737 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
738 case ICONSOLE_HOOK_BEFORE_EXEC:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
739 proc = hook_cmd->hook_before_exec;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
740 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
741 case ICONSOLE_HOOK_ACCESS:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
742 proc = hook_cmd->hook_access;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
743 break;
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
744 default:
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
745 proc = NULL;
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
746 break;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
747 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
748 if (proc == NULL) return true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
749 return proc(hook_cmd);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
750 }
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
751
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
752 void IConsoleCmdExec(byte * cmdstr)
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
753 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
754 _iconsole_var * (*function)(byte argc, byte* argv[], byte argt[]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
755 byte * tokens[20];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
756 byte tokentypes[20];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
757 byte * tokenstream;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
758 byte * tokenstream_s;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
759 byte execution_mode;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
760 _iconsole_var * var = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
761 _iconsole_var * result = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
762 _iconsole_cmd * cmd = 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
763
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
764 bool longtoken;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
765 bool valid_token;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
766 bool skip_lt_change;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
767
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
768 int c;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
769 int i;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
770 int l;
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
771
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
772 //** clearing buffer **//
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
773
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
774 for (i=0;i<20;i++) { tokens[i]=NULL; tokentypes[i]=ICONSOLE_VAR_NONE; };
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
775 tokenstream_s=tokenstream=malloc(1024);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
776 memset(tokenstream,0,1024);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
777
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
778 //** parsing **//
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
779
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
780 longtoken=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
781 valid_token=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
782 skip_lt_change=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
783 l=strlen((char *) cmdstr);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
784 i=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
785 c=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
786 tokens[c] = tokenstream;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
787 while (i<l) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
788 if (cmdstr[i]=='"') {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
789 if (longtoken) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
790 if (cmdstr[i+1]=='"') {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
791 i++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
792 *tokenstream = '"';
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
793 tokenstream++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
794 skip_lt_change=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
795 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
796 longtoken=!longtoken;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
797 }
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
798 } else {
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
799 longtoken=!longtoken;
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
800 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
801 if (!skip_lt_change) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
802 if (!longtoken) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
803 if (valid_token) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
804 c++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
805 *tokenstream = 0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
806 tokenstream++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
807 tokens[c] = tokenstream;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
808 valid_token = false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
809 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
810 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
811 skip_lt_change=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
812 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
813 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
814 else if ((!longtoken) && (cmdstr[i]==' ')) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
815 if (valid_token) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
816 c++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
817 *tokenstream = 0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
818 tokenstream++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
819 tokens[c] = tokenstream;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
820 valid_token = false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
821 }
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
822 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
823 else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
824 valid_token=true;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
825 *tokenstream = cmdstr[i];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
826 tokenstream++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
827 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
828 i++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
829 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
830
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
831 tokenstream--;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
832 if (!(*tokenstream==0)) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
833 c++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
834 tokenstream++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
835 *tokenstream = 0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
836 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
837
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
838 //** interpreting **//
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
839
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
840 for (i=0; i<c; i++) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
841 tokentypes[i]=ICONSOLE_VAR_UNKNOWN;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
842 if (tokens[i]!=NULL) if (i>0) if (strlen((char *) tokens[i])>0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
843 if (tokens[i][0]=='*') {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
844 if ((i==2) && (tokentypes[1]==ICONSOLE_VAR_UNKNOWN) && (strcmp(tokens[1],"<<")==0)) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
845 // dont change the variable to an pointer if execution_mode 4 is being prepared
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
846 // this is used to assign one variable the value of the other one [token 0 and 2]
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
847 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
848 var = IConsoleVarGet(tokens[i]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
849 if (var!=NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
850 tokens[i]=(byte *)var->addr;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
851 tokentypes[i]=var->type;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
852 }
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
853 }
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
854 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
855 if (tokens[i]!=NULL) if (tokens[i][0]=='@') if (tokens[i][1]=='*') {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
856 var = IConsoleVarGet(tokens[i]+1);
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
857 if (var!=NULL) {
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
858 tokens[i]=(byte *)var;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
859 tokentypes[i]=ICONSOLE_VAR_REFERENCE;
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
860 }
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
861 }
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
862 }
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
863 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
864
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
865 execution_mode=0;
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
866
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
867 function = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
868 cmd = IConsoleCmdGet(tokens[0]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
869 if (cmd != NULL) function = cmd->addr;
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
870
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
871 if (function != NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
872 execution_mode=1; // this is a command
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
873 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
874 var = IConsoleVarGet(tokens[0]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
875 if (var != NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
876 execution_mode=2; // this is a variable
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
877 if (c>2) if (strcmp(tokens[1],"<<")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
878 // this is command to variable mode [normal]
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
879
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
880 function = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
881 cmd = IConsoleCmdGet(tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
882 if (cmd != NULL) function = cmd->addr;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
883
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
884 if (function != NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
885 execution_mode=3;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
886 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
887 result = IConsoleVarGet(tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
888 if (result != NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
889 execution_mode=4;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
890 }
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
891 }
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
892 }
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
893 }
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
894 }
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
895
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
896 //** executing **//
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
897 if (_stdlib_con_developer) IConsolePrintF(_iconsole_color_debug,"CONDEBUG: execution_mode: %i",execution_mode);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
898 switch (execution_mode) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
899 case 0:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
900 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
901 // not found
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
902 IConsoleError("command or variable not found");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
903 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
904 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
905 case 1:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
906 if (IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_ACCESS)) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
907 // execution with command syntax
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
908 IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_BEFORE_EXEC);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
909 result = function(c,tokens,tokentypes);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
910 if (result!=NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
911 IConsoleVarDump(result,"result");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
912 IConsoleVarFree(result);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
913 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
914 IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_AFTER_EXEC);
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
915 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
916 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
917 case 2:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
918 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
919 // execution with variable syntax
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
920 if (IConsoleVarHookHandle(var,ICONSOLE_HOOK_ACCESS)) if ((c==2) || (c==3)) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
921 // ** variable modifications ** //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
922 IConsoleVarHookHandle(var,ICONSOLE_HOOK_BEFORE_CHANGE);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
923 switch (var->type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
924 case ICONSOLE_VAR_BOOLEAN:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
925 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
926 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
927 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
928 *(bool *)var->addr=(atoi((char *) tokens[2])!=0);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
929 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
930 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
931 *(bool *)var->addr=false;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
932 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
933 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
934 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
935 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
936 *(bool *)var->addr=!*(bool *)var->addr;
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
937 IConsoleVarDump(var,NULL);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
938 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
939 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
940 *(bool *)var->addr=!*(bool *)var->addr;
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
941 IConsoleVarDump(var,NULL);
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
942 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
943 else { IConsoleError("operation not supported"); }
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
944 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
945 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
946 case ICONSOLE_VAR_BYTE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
947 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
948 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
949 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
950 *(byte *)var->addr=atoi((char *) tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
951 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
952 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
953 *(byte *)var->addr=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
954 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
955 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
956 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
957 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
958 (*(byte *)var->addr)++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
959 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
960 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
961 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
962 (*(byte *)var->addr)--;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
963 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
964 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
965 else { IConsoleError("operation not supported"); }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
966 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
967 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
968 case ICONSOLE_VAR_UINT16:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
969 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
970 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
971 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
972 *(unsigned short *)var->addr=atoi((char *) tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
973 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
974 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
975 *(unsigned short *)var->addr=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
976 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
977 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
978 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
979 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
980 (*(unsigned short *)var->addr)++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
981 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
982 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
983 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
984 (*(unsigned short *)var->addr)--;
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
985 IConsoleVarDump(var,NULL);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
986 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
987 else { IConsoleError("operation not supported"); }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
988 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
989 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
990 case ICONSOLE_VAR_UINT32:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
991 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
992 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
993 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
994 *(unsigned int *)var->addr=atoi((char *) tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
995 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
996 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
997 *(unsigned int *)var->addr=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
998 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
999 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1000 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1001 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1002 (*(unsigned int *)var->addr)++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1003 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1004 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1005 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1006 (*(unsigned int *)var->addr)--;
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
1007 IConsoleVarDump(var,NULL);
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
1008 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1009 else { IConsoleError("operation not supported"); }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
1010 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1011 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1012 case ICONSOLE_VAR_INT16:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1013 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1014 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1015 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1016 *(signed short *)var->addr=atoi((char *) tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1017 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1018 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1019 *(signed short *)var->addr=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1020 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1021 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1022 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1023 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1024 (*(signed short *)var->addr)++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1025 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1026 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1027 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1028 (*(signed short *)var->addr)--;
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
1029 IConsoleVarDump(var,NULL);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1030 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1031 else { IConsoleError("operation not supported"); }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1032 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1033 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1034 case ICONSOLE_VAR_INT32:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1035 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1036 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1037 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1038 *(signed int *)var->addr=atoi((char *) tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1039 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1040 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1041 *(signed int *)var->addr=0;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1042 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1043 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1044 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1045 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1046 (*(signed int *)var->addr)++;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1047 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1048 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1049 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1050 (*(signed int *)var->addr)--;
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
1051 IConsoleVarDump(var,NULL);
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
1052 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1053 else { IConsoleError("operation not supported"); }
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
1054 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1055 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1056 case ICONSOLE_VAR_STRING:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1057 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1058 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1059 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1060 IConsoleVarSetString(var, tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1061 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1062 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1063 IConsoleVarSetString(var, "");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1064 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1065 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1066 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1067 else { IConsoleError("operation not supported"); }
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
1068 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1069 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1070 case ICONSOLE_VAR_POINTER:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1071 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1072 if (strcmp(tokens[1],"=")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1073 if (c==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1074 if (tokentypes[2]==ICONSOLE_VAR_UNKNOWN) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1075 var->addr = (void *)atoi(tokens[2]);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1076 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1077 var->addr = (void *)tokens[2];
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1078 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1079 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1080 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1081 var->addr = NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1082 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1083 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1084 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1085 else if (strcmp(tokens[1],"++")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1086 var->addr = ((char *)var->addr)+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
1087 IConsoleVarDump(var,NULL);
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1088 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1089 else if (strcmp(tokens[1],"--")==0) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1090 var->addr = ((char *)var->addr)-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
1091 IConsoleVarDump(var,NULL);
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
1092 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1093 else { IConsoleError("operation not supported"); }
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
1094 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1095 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
1096 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1097 IConsoleVarHookHandle(var,ICONSOLE_HOOK_AFTER_CHANGE);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1098 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1099 if (c==1) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1100 // ** variable output ** //
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1101 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1102 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1103 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1104 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1105 case 3:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1106 case 4:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1107 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1108 // execute command with result or assign a variable
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
1109 if (execution_mode==3) {
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
1110 if (IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_ACCESS)) {
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
1111 int i;
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
1112 int diff;
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
1113 void * temp;
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
1114 byte temp2;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1115
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
1116 // tokenshifting
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
1117 for (diff=0; diff<2; diff++) {
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
1118 temp=tokens[0];
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
1119 temp2=tokentypes[0];
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
1120 for (i=1; i<20; i++) {
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
1121 tokens[i-1]=tokens[i];
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
1122 tokentypes[i-1]=tokentypes[i];
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
1123 }
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
1124 tokens[19]=temp;
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
1125 tokentypes[19]=temp2;
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
1126 }
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
1127 IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_BEFORE_EXEC);
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
1128 result = function(c,tokens,tokentypes);
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
1129 IConsoleCmdHookHandle(cmd,ICONSOLE_HOOK_AFTER_EXEC);
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
1130 } else
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
1131 execution_mode=255;
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1132 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1133
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1134 if (IConsoleVarHookHandle(var,ICONSOLE_HOOK_ACCESS)) if (result!=NULL) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1135 if (result ->type != var -> type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1136 IConsoleError("variable type missmatch");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1137 } else {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1138 IConsoleVarHookHandle(var,ICONSOLE_HOOK_BEFORE_CHANGE);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1139 switch (result->type) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1140 case ICONSOLE_VAR_BOOLEAN:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1141 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1142 (*(bool *)var->addr)=(*(bool *)result->addr);
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
1143 IConsoleVarDump(var,NULL);
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
1144 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1145 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1146 case ICONSOLE_VAR_BYTE:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1147 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1148 (*(byte *)var->addr)=(*(byte *)result->addr);
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
1149 IConsoleVarDump(var,NULL);
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
1150 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1151 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1152 case ICONSOLE_VAR_UINT16:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1153 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1154 (*(unsigned short *)var->addr)=(*(unsigned short *)result->addr);
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
1155 IConsoleVarDump(var,NULL);
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
1156 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1157 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1158 case ICONSOLE_VAR_UINT32:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1159 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1160 (*(unsigned int *)var->addr)=(*(unsigned int *)result->addr);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1161 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1162 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1163 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1164 case ICONSOLE_VAR_INT16:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1165 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1166 (*(signed short *)var->addr)=(*(signed short *)result->addr);
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
1167 IConsoleVarDump(var,NULL);
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
1168 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1169 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1170 case ICONSOLE_VAR_INT32:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1171 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1172 (*(signed int *)var->addr)=(*(signed int *)result->addr);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1173 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1174 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1175 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1176 case ICONSOLE_VAR_POINTER:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1177 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1178 var->addr=result->addr;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1179 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1180 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1181 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1182 case ICONSOLE_VAR_STRING:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1183 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1184 IConsoleVarSetString(var,result->addr);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1185 IConsoleVarDump(var,NULL);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1186 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1187 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1188 default:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1189 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1190 IConsoleError("variable type missmatch");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1191 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1192 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1193 }
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1194 IConsoleVarHookHandle(var,ICONSOLE_HOOK_AFTER_CHANGE);
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
1195 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1196
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1197 if (execution_mode==3) {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1198 IConsoleVarFree(result);
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1199 result = 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
1200 }
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
1201 }
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
1202
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
1203 }
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1204 break;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1205 default:
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1206 {
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1207 // execution mode invalid
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1208 IConsoleError("invalid execution mode");
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1209 }
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
1210 }
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
1211
220
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1212 //** freeing the tokens **//
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1213 for (i=0;i<20;i++) tokens[i]=NULL;
9b7653080948 (svn r221) -Feature: console command and variable hooking
signde <signde@openttd.org>
parents: 209
diff changeset
1214 free(tokenstream_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
1215
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
1216 }