src/console.cpp
author rubidium
Tue, 16 Dec 2008 17:58:27 +0000
changeset 10426 4a77f7049b5e
parent 10211 c30661d29107
permissions -rw-r--r--
(svn r14679) -Fix [FS#2431]: opening the OSK on the chatbox did disable map scrolling (with keyboard) until another window with editbox was opened and closed. Just "refcount" the open edit boxes instead of setting/clearing a bit when opening/closing a window.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9100
diff changeset
     3
/** @file console.cpp Handling of the in-game console. */
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
     4
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     5
#include "stdafx.h"
8130
d2eb7d04f6e1 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8121
diff changeset
     6
#include "core/alloc_func.hpp"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8131
diff changeset
     7
#include "string_func.h"
9419
c5b9860081a1 (svn r13333) -Fix: compilance without networking enabled.
rubidium
parents: 9339
diff changeset
     8
#include "strings_type.h"
c5b9860081a1 (svn r13333) -Fix: compilance without networking enabled.
rubidium
parents: 9339
diff changeset
     9
#include "core/math_func.hpp"
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9419
diff changeset
    10
#include "console_internal.h"
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9419
diff changeset
    11
#include "network/network.h"
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9419
diff changeset
    12
#include "network/network_func.h"
9085
8b3897a75aed (svn r12944) -Codechange: use rev.h instead of externs at many places
smatz
parents: 8268
diff changeset
    13
#include "rev.h"
274
c50812e83a14 (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    14
9339
189117c9c937 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 9337
diff changeset
    15
#include <stdarg.h>
189117c9c937 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 9337
diff changeset
    16
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    17
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    18
301
3b69e7025af9 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    19
#define ICON_BUFFER 79
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    20
#define ICON_HISTORY_SIZE 20
301
3b69e7025af9 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    21
#define ICON_LINE_HEIGHT 12
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    22
#define ICON_RIGHT_BORDERWIDTH 10
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    23
#define ICON_BOTTOM_BORDERWIDTH 12
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
    24
#define ICON_MAX_ALIAS_LINES 40
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    25
#define ICON_TOKEN_COUNT 20
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    26
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
    27
/* console parser */
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
    28
IConsoleCmd   *_iconsole_cmds;    ///< list of registred commands
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
    29
IConsoleVar   *_iconsole_vars;    ///< list of registred vars
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
    30
IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
    31
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
    32
/* ** stdlib ** */
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    33
byte _stdlib_developer = 1;
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    34
bool _stdlib_con_developer = false;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    35
FILE *_iconsole_output_file;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    36
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    37
void IConsoleInit()
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    38
{
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
    39
	_iconsole_output_file = NULL;
1243
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    40
#ifdef ENABLE_NETWORK /* Initialize network only variables */
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    41
	_redirect_console_to_client = 0;
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    42
#endif
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    43
9339
189117c9c937 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 9337
diff changeset
    44
	IConsoleGUIInit();
1243
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    45
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    46
	IConsoleStdLibRegister();
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    47
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    48
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    49
static void IConsoleWriteToLogFile(const char *string)
1046
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    50
{
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    51
	if (_iconsole_output_file != NULL) {
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
    52
		/* if there is an console output file ... also print it there */
9100
3ad0412f8ddf (svn r12960) -Codechange: handle return values of (some) file system related functions.
rubidium
parents: 9085
diff changeset
    53
		if (fwrite(string, strlen(string), 1, _iconsole_output_file) != 1 ||
3ad0412f8ddf (svn r12960) -Codechange: handle return values of (some) file system related functions.
rubidium
parents: 9085
diff changeset
    54
				fwrite("\n", 1, 1, _iconsole_output_file) != 1) {
3ad0412f8ddf (svn r12960) -Codechange: handle return values of (some) file system related functions.
rubidium
parents: 9085
diff changeset
    55
			fclose(_iconsole_output_file);
3ad0412f8ddf (svn r12960) -Codechange: handle return values of (some) file system related functions.
rubidium
parents: 9085
diff changeset
    56
			_iconsole_output_file = NULL;
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
    57
			IConsolePrintF(CC_DEFAULT, "cannot write to log file");
9100
3ad0412f8ddf (svn r12960) -Codechange: handle return values of (some) file system related functions.
rubidium
parents: 9085
diff changeset
    58
		}
1046
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    59
	}
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    60
}
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    61
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    62
bool CloseConsoleLogIfActive()
1046
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    63
{
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    64
	if (_iconsole_output_file != NULL) {
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
    65
		IConsolePrintF(CC_DEFAULT, "file output complete");
1046
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    66
		fclose(_iconsole_output_file);
1127
be5e8f11e2fd (svn r1628) -Fix: [1107893] script command; log file pointer was not reset to NULL after logging was closed
darkvater
parents: 1109
diff changeset
    67
		_iconsole_output_file = NULL;
1046
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    68
		return true;
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    69
	}
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    70
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    71
	return false;
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    72
}
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    73
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    74
void IConsoleFree()
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    75
{
9339
189117c9c937 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 9337
diff changeset
    76
	IConsoleGUIFree();
1046
f1d46abf7d35 (svn r1547) -Feature: windows dedicated (if anyone would run that, but ok), is now functioning correctly. There is no other way but to create a new thread, but that's only MS braindeadness
darkvater
parents: 1026
diff changeset
    77
	CloseConsoleLogIfActive();
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    78
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    79
1588
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    80
/**
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    81
 * Handle the printing of text entered into the console or redirected there
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10201
diff changeset
    82
 * by any other means. Text can be redirected to other clients in a network game
1588
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    83
 * as well as to a logfile. If the network server is a dedicated server, all activities
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    84
 * are also logged. All lines to print are added to a temporary buffer which can be
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    85
 * used as a history to print them onscreen
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    86
 * @param color_code the colour of the command. Red in case of errors, etc.
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    87
 * @param string the message entered or output on the console (notice, error, etc.)
7f0385ebdcfe (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
    88
 */
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
    89
void IConsolePrint(ConsoleColour color_code, const char *string)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    90
{
5182
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
    91
	char *str;
1243
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    92
#ifdef ENABLE_NETWORK
1026
02cc18821508 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1008
diff changeset
    93
	if (_redirect_console_to_client != 0) {
02cc18821508 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1008
diff changeset
    94
		/* Redirect the string to the client */
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9419
diff changeset
    95
		NetworkServerSendRcon(_redirect_console_to_client, color_code, string);
1026
02cc18821508 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1008
diff changeset
    96
		return;
02cc18821508 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1008
diff changeset
    97
	}
1243
cb9e17e38c00 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
    98
#endif
1026
02cc18821508 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1008
diff changeset
    99
5182
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   100
	/* Create a copy of the string, strip if of colours and invalid
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   101
	 * characters and (when applicable) assign it to the console buffer */
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   102
	str = strdup(string);
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   103
	str_strip_colours(str);
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   104
	str_validate(str);
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   105
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   106
	if (_network_dedicated) {
7031
aaabe0fec34d (svn r10295) -Fix [FS#775]: flush stdout on dedicated server output to ensure an update of stdout (Zuu)
truelight
parents: 6422
diff changeset
   107
		fprintf(stdout, "%s\n", str);
aaabe0fec34d (svn r10295) -Fix [FS#775]: flush stdout on dedicated server output to ensure an update of stdout (Zuu)
truelight
parents: 6422
diff changeset
   108
		fflush(stdout);
5182
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   109
		IConsoleWriteToLogFile(str);
1ea4df8be34e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   110
		free(str); // free duplicated string since it's not used anymore
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   111
		return;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   112
	}
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   113
9339
189117c9c937 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 9337
diff changeset
   114
	IConsoleWriteToLogFile(str);
189117c9c937 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 9337
diff changeset
   115
	IConsoleGUIPrint(color_code, str);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   116
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   117
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   118
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   119
 * Handle the printing of text entered into the console or redirected there
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   120
 * by any other means. Uses printf() style format, for more information look
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6416
diff changeset
   121
 * at IConsolePrint()
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   122
 */
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   123
void CDECL IConsolePrintF(ConsoleColour color_code, const char *s, ...)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   124
{
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   125
	va_list va;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   126
	char buf[ICON_MAX_STREAMSIZE];
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   127
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   128
	va_start(va, s);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   129
	vsnprintf(buf, sizeof(buf), s, va);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   130
	va_end(va);
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   131
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   132
	IConsolePrint(color_code, buf);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   133
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   134
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   135
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   136
 * It is possible to print debugging information to the console,
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   137
 * which is achieved by using this function. Can only be used by
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   138
 * debug() in debug.cpp. You need at least a level 2 (developer) for debugging
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   139
 * messages to show up
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5182
diff changeset
   140
 * @param dbg debugging category
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5182
diff changeset
   141
 * @param string debugging message
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   142
 */
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5182
diff changeset
   143
void IConsoleDebug(const char *dbg, const char *string)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   144
{
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   145
	if (_stdlib_developer > 1)
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   146
		IConsolePrintF(CC_DEBUG, "dbg: [%s] %s", dbg, string);
247
1cbc32ff06eb (svn r248) -Feature: console script files "exec myscript.file"
darkvater
parents: 229
diff changeset
   147
}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   148
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   149
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   150
 * It is possible to print warnings to the console. These are mostly
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   151
 * errors or mishaps, but non-fatal. You need at least a level 1 (developer) for
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   152
 * debugging messages to show up
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   153
 */
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   154
void IConsoleWarning(const char *string)
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   155
{
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   156
	if (_stdlib_developer > 0)
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   157
		IConsolePrintF(CC_WARNING, "WARNING: %s", string);
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   158
}
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   159
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   160
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   161
 * It is possible to print error information to the console. This can include
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   162
 * game errors, or errors in general you would want the user to notice
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   163
 */
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   164
void IConsoleError(const char *string)
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   165
{
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   166
	IConsolePrintF(CC_ERROR, "ERROR: %s", string);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   167
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   168
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   169
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   170
 * Change a string into its number representation. Supports
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   171
 * decimal and hexadecimal numbers as well as 'on'/'off' 'true'/'false'
7372
6fac48ff7c4d (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7341
diff changeset
   172
 * @param *value the variable a successful conversion will be put in
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   173
 * @param *arg the string to be converted
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   174
 * @return Return true on success or false on failure
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   175
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   176
bool GetArgumentInteger(uint32 *value, const char *arg)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   177
{
1773
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   178
	char *endptr;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   179
1773
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   180
	if (strcmp(arg, "on") == 0 || strcmp(arg, "true") == 0) {
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   181
		*value = 1;
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   182
		return true;
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   183
	}
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   184
	if (strcmp(arg, "off") == 0 || strcmp(arg, "false") == 0) {
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   185
		*value = 0;
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   186
		return true;
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   187
	}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   188
1773
40297275e218 (svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
Darkvater
parents: 1771
diff changeset
   189
	*value = strtoul(arg, &endptr, 0);
1899
81214598ab45 (svn r2405) Simplify a few '? true : false' and '? false : true', especially the latter is confusing
tron
parents: 1891
diff changeset
   190
	return arg != endptr;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   191
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   192
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   193
/*  * *************************
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   194
    * hooking code            *
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   195
    * *************************/
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   196
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   197
/**
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   198
 * General internal hooking code that is the same for both commands and variables
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   199
 * @param hooks IConsoleHooks structure that will be set according to
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   200
 * @param type type access trigger
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   201
 * @param proc function called when the hook criteria is met
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   202
 */
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   203
static void IConsoleHookAdd(IConsoleHooks *hooks, IConsoleHookTypes type, IConsoleHook *proc)
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   204
{
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   205
	if (hooks == NULL || proc == NULL) return;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   206
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   207
	switch (type) {
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   208
		case ICONSOLE_HOOK_ACCESS:
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   209
			hooks->access = proc;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   210
			break;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   211
		case ICONSOLE_HOOK_PRE_ACTION:
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   212
			hooks->pre = proc;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   213
			break;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   214
		case ICONSOLE_HOOK_POST_ACTION:
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   215
			hooks->post = proc;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   216
			break;
1889
91c51eadc8d9 (svn r2395) - Fix: oops, forgot a break in a console switch.
Darkvater
parents: 1879
diff changeset
   217
		default: NOT_REACHED();
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   218
	}
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   219
}
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   220
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   221
/**
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   222
 * Handle any special hook triggers. If the hook type is met check if
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   223
 * there is a function associated with that and if so, execute it
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   224
 * @param hooks IConsoleHooks structure that will be checked
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   225
 * @param type type of hook, trigger that needs to be activated
7372
6fac48ff7c4d (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7341
diff changeset
   226
 * @return true on a successful execution of the hook command or if there
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   227
 * is no hook/trigger present at all. False otherwise
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   228
 */
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   229
static bool IConsoleHookHandle(const IConsoleHooks *hooks, IConsoleHookTypes type)
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   230
{
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   231
	IConsoleHook *proc = NULL;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   232
	if (hooks == NULL) return false;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   233
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   234
	switch (type) {
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   235
		case ICONSOLE_HOOK_ACCESS:
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   236
			proc = hooks->access;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   237
			break;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   238
		case ICONSOLE_HOOK_PRE_ACTION:
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   239
			proc = hooks->pre;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   240
			break;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   241
		case ICONSOLE_HOOK_POST_ACTION:
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   242
			proc = hooks->post;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   243
			break;
1889
91c51eadc8d9 (svn r2395) - Fix: oops, forgot a break in a console switch.
Darkvater
parents: 1879
diff changeset
   244
		default: NOT_REACHED();
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   245
	}
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   246
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   247
	return (proc == NULL) ? true : proc();
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   248
}
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   249
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   250
/**
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   251
 * Add a hook to a command that will be triggered at certain points
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   252
 * @param name name of the command that the hook is added to
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   253
 * @param type type of hook that is added (ACCESS, BEFORE and AFTER change)
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   254
 * @param proc function called when the hook criteria is met
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   255
 */
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   256
void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc)
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   257
{
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   258
	IConsoleCmd *cmd = IConsoleCmdGet(name);
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   259
	if (cmd == NULL) return;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   260
	IConsoleHookAdd(&cmd->hook, type, proc);
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   261
}
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   262
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   263
/**
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   264
 * Add a hook to a variable that will be triggered at certain points
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   265
 * @param name name of the variable that the hook is added to
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   266
 * @param type type of hook that is added (ACCESS, BEFORE and AFTER change)
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   267
 * @param proc function called when the hook criteria is met
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   268
 */
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   269
void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc)
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   270
{
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   271
	IConsoleVar *var = IConsoleVarGet(name);
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   272
	if (var == NULL) return;
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   273
	IConsoleHookAdd(&var->hook, type, proc);
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   274
}
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   275
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   276
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   277
 * Perhaps ugly macro, but this saves us the trouble of writing the same function
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   278
 * three types, just with different variables. Yes, templates would be handy. It was
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   279
 * either this define or an even more ugly void* magic function
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   280
 */
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   281
#define IConsoleAddSorted(_base, item_new, IConsoleType, type)                 \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   282
{                                                                              \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   283
	IConsoleType *item, *item_before;                                            \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   284
	/* first command */                                                          \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   285
	if (_base == NULL) {                                                         \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   286
		_base = item_new;                                                          \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   287
		return;                                                                    \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   288
	}                                                                            \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   289
                                                                               \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   290
	item_before = NULL;                                                          \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   291
	item = _base;                                                                \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   292
                                                                               \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   293
	/* BEGIN - Alphabetically insert the commands into the linked list */        \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   294
	while (item != NULL) {                                                       \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   295
		int i = strcmp(item->name, item_new->name);                                \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   296
		if (i == 0) {                                                              \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   297
			IConsoleError(type " with this name already exists; insertion aborted"); \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   298
			free(item_new);                                                          \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   299
			return;                                                                  \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   300
		}                                                                          \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   301
                                                                               \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   302
		if (i > 0) break; /* insert at this position */                            \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   303
                                                                               \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   304
		item_before = item;                                                        \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   305
		item = item->next;                                                         \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   306
	}                                                                            \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   307
                                                                               \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   308
	if (item_before == NULL) {                                                   \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   309
		_base = item_new;                                                          \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   310
	} else {                                                                     \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   311
		item_before->next = item_new;                                              \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   312
  }                                                                            \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   313
                                                                               \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   314
	item_new->next = item;                                                       \
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   315
	/* END - Alphabetical insert */                                              \
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   316
}
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   317
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   318
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   319
 * Register a new command to be used in the console
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   320
 * @param name name of the command that will be used
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   321
 * @param proc function that will be called upon execution of command
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   322
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   323
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc)
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   324
{
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   325
	char *new_cmd = strdup(name);
5609
dc6a58930ba4 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5587
diff changeset
   326
	IConsoleCmd *item_new = MallocT<IConsoleCmd>(1);
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   327
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   328
	item_new->next = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   329
	item_new->proc = proc;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   330
	item_new->name = new_cmd;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   331
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   332
	item_new->hook.access = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   333
	item_new->hook.pre = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   334
	item_new->hook.post = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   335
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   336
	IConsoleAddSorted(_iconsole_cmds, item_new, IConsoleCmd, "a command");
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   337
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   338
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   339
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   340
 * Find the command pointed to by its string
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   341
 * @param name command to be found
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   342
 * @return return Cmdstruct of the found command, or NULL on failure
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   343
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   344
IConsoleCmd *IConsoleCmdGet(const char *name)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   345
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   346
	IConsoleCmd *item;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   347
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   348
	for (item = _iconsole_cmds; item != NULL; item = item->next) {
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   349
		if (strcmp(item->name, name) == 0) return item;
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   350
	}
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   351
	return NULL;
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   352
}
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   353
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   354
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   355
 * Register a an alias for an already existing command in the console
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   356
 * @param name name of the alias that will be used
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   357
 * @param cmd name of the command that 'name' will be alias of
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   358
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   359
void IConsoleAliasRegister(const char *name, const char *cmd)
1725
e391da994698 (svn r2229) - Fix: [ 1188777 ] Non-existing sprite #5125 (presignal). The DOS grf file trgi.grf has 6 less sprites than the windows one. This results in some segfaults for certain sprites. Fixed it by added a dummy grf file consisting ofr 6 sprites and loaded when using DOS gfx at the appropiate place.
Darkvater
parents: 1588
diff changeset
   360
{
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   361
	char *new_alias = strdup(name);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   362
	char *cmd_aliased = strdup(cmd);
5609
dc6a58930ba4 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5587
diff changeset
   363
	IConsoleAlias *item_new = MallocT<IConsoleAlias>(1);
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   364
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   365
	item_new->next = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   366
	item_new->cmdline = cmd_aliased;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   367
	item_new->name = new_alias;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   368
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   369
	IConsoleAddSorted(_iconsole_aliases, item_new, IConsoleAlias, "an alias");
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   370
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   371
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   372
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   373
 * Find the alias pointed to by its string
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   374
 * @param name alias to be found
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   375
 * @return return Aliasstruct of the found alias, or NULL on failure
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   376
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   377
IConsoleAlias *IConsoleAliasGet(const char *name)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   378
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   379
	IConsoleAlias* item;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   380
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   381
	for (item = _iconsole_aliases; item != NULL; item = item->next) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   382
		if (strcmp(item->name, name) == 0) return item;
634
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   383
	}
754b2df37bfa (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
   384
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   385
	return NULL;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   386
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   387
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   388
/** copy in an argument into the aliasstream */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   389
static inline int IConsoleCopyInParams(char *dst, const char *src, uint bufpos)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   390
{
10211
c30661d29107 (svn r14431) -Fix (r14414): alias parameter "evaluation" would remove the last byte of the parameters.
rubidium
parents: 10207
diff changeset
   391
	/* len is the amount of bytes to add excluding the '\0'-termination */
c30661d29107 (svn r14431) -Fix (r14414): alias parameter "evaluation" would remove the last byte of the parameters.
rubidium
parents: 10207
diff changeset
   392
	int len = min(ICON_MAX_STREAMSIZE - bufpos - 1, (uint)strlen(src));
c30661d29107 (svn r14431) -Fix (r14414): alias parameter "evaluation" would remove the last byte of the parameters.
rubidium
parents: 10207
diff changeset
   393
	strecpy(dst, src, dst + len);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   394
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   395
	return len;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   396
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   397
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   398
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   399
 * An alias is just another name for a command, or for more commands
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   400
 * Execute it as well.
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   401
 * @param *alias is the alias of the command
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   402
 * @param tokencount the number of parameters passed
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   403
 * @param *tokens are the parameters given to the original command (0 is the first param)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   404
 */
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   405
static void IConsoleAliasExec(const IConsoleAlias *alias, byte tokencount, char *tokens[ICON_TOKEN_COUNT])
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   406
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   407
	const char *cmdptr;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   408
	char *aliases[ICON_MAX_ALIAS_LINES], aliasstream[ICON_MAX_STREAMSIZE];
3017
a75caf4efa2d (svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents: 2817
diff changeset
   409
	uint i;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   410
	uint a_index, astream_i;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   411
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   412
	memset(&aliases, 0, sizeof(aliases));
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   413
	memset(&aliasstream, 0, sizeof(aliasstream));
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   414
1866
87ae212e7eda (svn r2372) - Fix (console): update the example scripts in the scripts/ directory to reflect the new console functionality
Darkvater
parents: 1833
diff changeset
   415
	if (_stdlib_con_developer)
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   416
		IConsolePrintF(CC_DEBUG, "condbg: requested command is an alias; parsing...");
1866
87ae212e7eda (svn r2372) - Fix (console): update the example scripts in the scripts/ directory to reflect the new console functionality
Darkvater
parents: 1833
diff changeset
   417
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   418
	aliases[0] = aliasstream;
1819
b352924c4a27 (svn r2323) Remove unused dereferencing
tron
parents: 1805
diff changeset
   419
	for (cmdptr = alias->cmdline, a_index = 0, astream_i = 0; *cmdptr != '\0'; cmdptr++) {
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   420
		if (a_index >= lengthof(aliases) || astream_i >= lengthof(aliasstream)) break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   421
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   422
		switch (*cmdptr) {
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   423
		case '\'': // ' will double for ""
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   424
			aliasstream[astream_i++] = '"';
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   425
			break;
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   426
		case ';': // Cmd seperator, start new command
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   427
			aliasstream[astream_i] = '\0';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   428
			aliases[++a_index] = &aliasstream[++astream_i];
1819
b352924c4a27 (svn r2323) Remove unused dereferencing
tron
parents: 1805
diff changeset
   429
			cmdptr++;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   430
			break;
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   431
		case '%': // Some or all parameters
1819
b352924c4a27 (svn r2323) Remove unused dereferencing
tron
parents: 1805
diff changeset
   432
			cmdptr++;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   433
			switch (*cmdptr) {
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   434
			case '+': { // All parameters seperated: "[param 1]" "[param 2]"
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   435
				for (i = 0; i != tokencount; i++) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   436
					aliasstream[astream_i++] = '"';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   437
					astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   438
					aliasstream[astream_i++] = '"';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   439
					aliasstream[astream_i++] = ' ';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   440
				}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   441
			} break;
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   442
			case '!': { // Merge the parameters to one: "[param 1] [param 2] [param 3...]"
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   443
				aliasstream[astream_i++] = '"';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   444
				for (i = 0; i != tokencount; i++) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   445
					astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   446
					aliasstream[astream_i++] = ' ';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   447
				}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   448
				aliasstream[astream_i++] = '"';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   449
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   450
			} break;
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   451
				default: { // One specific parameter: %A = [param 1] %B = [param 2] ...
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   452
				int param = *cmdptr - 'A';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   453
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   454
				if (param < 0 || param >= tokencount) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   455
					IConsoleError("too many or wrong amount of parameters passed to alias, aborting");
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   456
					IConsolePrintF(CC_WARNING, "Usage of alias '%s': %s", alias->name, alias->cmdline);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   457
					return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   458
				}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   459
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   460
				aliasstream[astream_i++] = '"';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   461
				astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[param], astream_i);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   462
				aliasstream[astream_i++] = '"';
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   463
			} break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   464
			} break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   465
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   466
		default:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   467
			aliasstream[astream_i++] = *cmdptr;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   468
			break;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   469
		}
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   470
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   471
3017
a75caf4efa2d (svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents: 2817
diff changeset
   472
	for (i = 0; i <= a_index; i++) IConsoleCmdExec(aliases[i]); // execute each alias in turn
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
   473
}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   474
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   475
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   476
 * Special function for adding string-type variables. They in addition
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   477
 * also need a 'size' value saying how long their string buffer is.
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   478
 * @param name name of the variable that will be used
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   479
 * @param addr memory location the variable will point to
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   480
 * @param size the length of the string buffer
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   481
 * @param help the help string shown for the variable
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6247
diff changeset
   482
 * For more information see IConsoleVarRegister()
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   483
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   484
void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   485
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   486
	IConsoleVar *var;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   487
	IConsoleVarRegister(name, addr, ICONSOLE_VAR_STRING, help);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   488
	var = IConsoleVarGet(name);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   489
	var->size = size;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   490
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   491
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   492
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   493
 * Register a new variable to be used in the console
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   494
 * @param name name of the variable that will be used
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   495
 * @param addr memory location the variable will point to
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   496
 * @param help the help string shown for the variable
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   497
 * @param type the type of the variable (simple atomic) so we know which values it can get
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   498
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   499
void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   500
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   501
	char *new_cmd = strdup(name);
5609
dc6a58930ba4 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5587
diff changeset
   502
	IConsoleVar *item_new = MallocT<IConsoleVar>(1);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   503
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   504
	item_new->help = (help != NULL) ? strdup(help) : NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   505
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   506
	item_new->next = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   507
	item_new->name = new_cmd;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   508
	item_new->addr = addr;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   509
	item_new->proc = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   510
	item_new->type = type;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   511
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   512
	item_new->hook.access = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   513
	item_new->hook.pre = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   514
	item_new->hook.post = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   515
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   516
	IConsoleAddSorted(_iconsole_vars, item_new, IConsoleVar, "a variable");
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   517
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   518
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   519
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   520
 * Find the variable pointed to by its string
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   521
 * @param name variable to be found
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   522
 * @return return Varstruct of the found variable, or NULL on failure
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   523
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   524
IConsoleVar *IConsoleVarGet(const char *name)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   525
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   526
	IConsoleVar *item;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   527
	for (item = _iconsole_vars; item != NULL; item = item->next) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   528
		if (strcmp(item->name, name) == 0) return item;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   529
	}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   530
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   531
	return NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   532
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   533
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   534
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   535
 * Set a new value to a console variable
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   536
 * @param *var the variable being set/changed
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   537
 * @param value the new value given to the variable, cast properly
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   538
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   539
static void IConsoleVarSetValue(const IConsoleVar *var, uint32 value)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   540
{
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   541
	IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_PRE_ACTION);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   542
	switch (var->type) {
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   543
		case ICONSOLE_VAR_BOOLEAN:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   544
			*(bool*)var->addr = (value != 0);
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   545
			break;
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   546
		case ICONSOLE_VAR_BYTE:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   547
			*(byte*)var->addr = (byte)value;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   548
			break;
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   549
		case ICONSOLE_VAR_UINT16:
2145
708916e35e63 (svn r2655) An uint16 is an uint16, not a byte - fix wrong cast
tron
parents: 1899
diff changeset
   550
			*(uint16*)var->addr = (uint16)value;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   551
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   552
		case ICONSOLE_VAR_INT16:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   553
			*(int16*)var->addr = (int16)value;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   554
			break;
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   555
		case ICONSOLE_VAR_UINT32:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   556
			*(uint32*)var->addr = (uint32)value;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   557
			break;
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   558
		case ICONSOLE_VAR_INT32:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   559
			*(int32*)var->addr = (int32)value;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   560
			break;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   561
		default: NOT_REACHED();
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 220
diff changeset
   562
	}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   563
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   564
	IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_POST_ACTION);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   565
	IConsoleVarPrintSetValue(var);
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   566
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   567
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   568
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   569
 * Set a new value to a string-type variable. Basically this
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   570
 * means to copy the new value over to the container.
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   571
 * @param *var the variable in question
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   572
 * @param *value the new value
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   573
 */
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   574
static void IConsoleVarSetStringvalue(const IConsoleVar *var, const char *value)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   575
{
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   576
	if (var->type != ICONSOLE_VAR_STRING || var->addr == NULL) return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   577
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   578
	IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_PRE_ACTION);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   579
	ttd_strlcpy((char*)var->addr, value, var->size);
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   580
	IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_POST_ACTION);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   581
	IConsoleVarPrintSetValue(var); // print out the new value, giving feedback
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   582
	return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   583
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   584
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   585
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   586
 * Query the current value of a variable and return it
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   587
 * @param *var the variable queried
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   588
 * @return current value of the variable
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   589
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   590
static uint32 IConsoleVarGetValue(const IConsoleVar *var)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   591
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   592
	uint32 result = 0;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   593
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   594
	switch (var->type) {
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   595
		case ICONSOLE_VAR_BOOLEAN:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   596
			result = *(bool*)var->addr;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   597
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   598
		case ICONSOLE_VAR_BYTE:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   599
			result = *(byte*)var->addr;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   600
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   601
		case ICONSOLE_VAR_UINT16:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   602
			result = *(uint16*)var->addr;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   603
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   604
		case ICONSOLE_VAR_INT16:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   605
			result = *(int16*)var->addr;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   606
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   607
		case ICONSOLE_VAR_UINT32:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   608
			result = *(uint32*)var->addr;
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   609
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   610
		case ICONSOLE_VAR_INT32:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   611
			result = *(int32*)var->addr;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   612
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   613
		default: NOT_REACHED();
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   614
	}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   615
	return result;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   616
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   617
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   618
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   619
 * Get the value of the variable and put it into a printable
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   620
 * string form so we can use it for printing
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   621
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   622
static char *IConsoleVarGetStringValue(const IConsoleVar *var)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   623
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   624
	static char tempres[50];
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   625
	char *value = tempres;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   626
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   627
	switch (var->type) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   628
		case ICONSOLE_VAR_BOOLEAN:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   629
			snprintf(tempres, sizeof(tempres), "%s", (*(bool*)var->addr) ? "on" : "off");
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   630
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   631
		case ICONSOLE_VAR_BYTE:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   632
			snprintf(tempres, sizeof(tempres), "%u", *(byte*)var->addr);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   633
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   634
		case ICONSOLE_VAR_UINT16:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   635
			snprintf(tempres, sizeof(tempres), "%u", *(uint16*)var->addr);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   636
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   637
		case ICONSOLE_VAR_UINT32:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   638
			snprintf(tempres, sizeof(tempres), "%u",  *(uint32*)var->addr);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   639
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   640
		case ICONSOLE_VAR_INT16:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   641
			snprintf(tempres, sizeof(tempres), "%i", *(int16*)var->addr);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   642
			break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   643
		case ICONSOLE_VAR_INT32:
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   644
			snprintf(tempres, sizeof(tempres), "%i",  *(int32*)var->addr);
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   645
			break;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   646
		case ICONSOLE_VAR_STRING:
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   647
			value = (char*)var->addr;
1889
91c51eadc8d9 (svn r2395) - Fix: oops, forgot a break in a console switch.
Darkvater
parents: 1879
diff changeset
   648
			break;
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   649
		default: NOT_REACHED();
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   650
	}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   651
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   652
	return value;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   653
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   654
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   655
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   656
 * Print out the value of the variable when asked
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   657
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   658
void IConsoleVarPrintGetValue(const IConsoleVar *var)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   659
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   660
	char *value;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   661
	/* Some variables need really specific handling, handle this in its
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   662
	 * callback function */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   663
	if (var->proc != NULL) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   664
		var->proc(0, NULL);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   665
		return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   666
	}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   667
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   668
	value = IConsoleVarGetStringValue(var);
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   669
	IConsolePrintF(CC_WARNING, "Current value for '%s' is:  %s", var->name, value);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   670
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   671
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   672
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   673
 * Print out the value of the variable after it has been assigned
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   674
 * a new value, thus giving us feedback on the action
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   675
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   676
void IConsoleVarPrintSetValue(const IConsoleVar *var)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   677
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   678
	char *value = IConsoleVarGetStringValue(var);
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   679
	IConsolePrintF(CC_WARNING, "'%s' changed to:  %s", var->name, value);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   680
}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   681
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   682
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   683
 * Execute a variable command. Without any parameters, print out its value
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   684
 * with parameters it assigns a new value to the variable
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   685
 * @param *var the variable that we will be querying/changing
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   686
 * @param tokencount how many additional parameters have been given to the commandline
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   687
 * @param *token the actual parameters the variable was called with
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   688
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   689
void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[ICON_TOKEN_COUNT])
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   690
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   691
	const char *tokenptr = token[0];
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   692
	byte t_index = tokencount;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   693
	uint32 value;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   694
1866
87ae212e7eda (svn r2372) - Fix (console): update the example scripts in the scripts/ directory to reflect the new console functionality
Darkvater
parents: 1833
diff changeset
   695
	if (_stdlib_con_developer)
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   696
		IConsolePrintF(CC_DEBUG, "condbg: requested command is a variable");
1866
87ae212e7eda (svn r2372) - Fix (console): update the example scripts in the scripts/ directory to reflect the new console functionality
Darkvater
parents: 1833
diff changeset
   697
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   698
	if (tokencount == 0) { /* Just print out value */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   699
		IConsoleVarPrintGetValue(var);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   700
		return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   701
	}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   702
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   703
	/* Use of assignment sign is not mandatory but supported, so just 'ignore it appropiately' */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   704
	if (strcmp(tokenptr, "=") == 0) tokencount--;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   705
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   706
	if (tokencount == 1) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   707
		/* Some variables need really special handling, handle it in their callback procedure */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   708
		if (var->proc != NULL) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   709
			var->proc(tokencount, &token[t_index - tokencount]); // set the new value
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   710
			return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   711
		}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   712
		/* Strings need special processing. No need to convert the argument to
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   713
		 * an integer value, just copy over the argument on a one-by-one basis */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   714
		if (var->type == ICONSOLE_VAR_STRING) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   715
			IConsoleVarSetStringvalue(var, token[t_index - tokencount]);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   716
			return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   717
		} else if (GetArgumentInteger(&value, token[t_index - tokencount])) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   718
			IConsoleVarSetValue(var, value);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   719
			return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   720
		}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   721
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   722
		/* Increase or decrease the value by one. This of course can only happen to 'number' types */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   723
		if (strcmp(tokenptr, "++") == 0 && var->type != ICONSOLE_VAR_STRING) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   724
			IConsoleVarSetValue(var, IConsoleVarGetValue(var) + 1);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   725
			return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   726
		}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   727
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   728
		if (strcmp(tokenptr, "--") == 0 && var->type != ICONSOLE_VAR_STRING) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   729
			IConsoleVarSetValue(var, IConsoleVarGetValue(var) - 1);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   730
			return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   731
		}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   732
	}
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   733
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   734
	IConsoleError("invalid variable assignment");
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   735
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   736
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   737
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   738
 * Add a callback function to the variable. Some variables need
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   739
 * very special processing, which can only be done with custom code
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   740
 * @param name name of the variable the callback function is added to
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   741
 * @param proc the function called
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   742
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   743
void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   744
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   745
	IConsoleVar *var = IConsoleVarGet(name);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   746
	if (var == NULL) return;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   747
	var->proc = proc;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   748
}
1109
ecb98f43ba2c (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1095
diff changeset
   749
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   750
/**
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   751
 * Execute a given command passed to us. First chop it up into
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   752
 * individual tokens (seperated by spaces), then execute it if possible
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   753
 * @param cmdstr string to be parsed and executed
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   754
 */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   755
void IConsoleCmdExec(const char *cmdstr)
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   756
{
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   757
	IConsoleCmd   *cmd    = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   758
	IConsoleAlias *alias  = NULL;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   759
	IConsoleVar   *var    = NULL;
1726
0f014227480a (svn r2230) Oops, revert wrongly committed local console.c. Also add the endian_target.h and endian_host.h to the ignore list
Darkvater
parents: 1725
diff changeset
   760
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   761
	const char *cmdptr;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   762
	char *tokens[ICON_TOKEN_COUNT], tokenstream[ICON_MAX_STREAMSIZE];
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   763
	uint t_index, tstream_i;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   764
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   765
	bool longtoken = false;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   766
	bool foundtoken = false;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   767
1866
87ae212e7eda (svn r2372) - Fix (console): update the example scripts in the scripts/ directory to reflect the new console functionality
Darkvater
parents: 1833
diff changeset
   768
	if (cmdstr[0] == '#') return; // comments
87ae212e7eda (svn r2372) - Fix (console): update the example scripts in the scripts/ directory to reflect the new console functionality
Darkvater
parents: 1833
diff changeset
   769
1819
b352924c4a27 (svn r2323) Remove unused dereferencing
tron
parents: 1805
diff changeset
   770
	for (cmdptr = cmdstr; *cmdptr != '\0'; cmdptr++) {
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5101
diff changeset
   771
		if (!IsValidChar(*cmdptr, CS_ALPHANUMERAL)) {
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   772
			IConsoleError("command contains malformed characters, aborting");
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   773
			IConsolePrintF(CC_ERROR, "ERROR: command was: '%s'", cmdstr);
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   774
			return;
1379
496ceb83c845 (svn r1883) -Fix: [1109400] Better test if a string actually contains any console command
tron
parents: 1243
diff changeset
   775
		}
496ceb83c845 (svn r1883) -Fix: [1109400] Better test if a string actually contains any console command
tron
parents: 1243
diff changeset
   776
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   777
640
7f08d269c3f4 (svn r1073) - condebugger extended a bit [shows the commandline] (sign_de)
dominik
parents: 634
diff changeset
   778
	if (_stdlib_con_developer)
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   779
		IConsolePrintF(CC_DEBUG, "condbg: executing cmdline: '%s'", cmdstr);
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   780
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   781
	memset(&tokens, 0, sizeof(tokens));
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   782
	memset(&tokenstream, 0, sizeof(tokenstream));
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   783
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   784
	/* 1. Split up commandline into tokens, seperated by spaces, commands
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   785
	 * enclosed in "" are taken as one token. We can only go as far as the amount
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   786
	 * of characters in our stream or the max amount of tokens we can handle */
1819
b352924c4a27 (svn r2323) Remove unused dereferencing
tron
parents: 1805
diff changeset
   787
	for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) {
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   788
		if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   789
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   790
		switch (*cmdptr) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   791
		case ' ': /* Token seperator */
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   792
			if (!foundtoken) break;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   793
1746
80dc66ca63b5 (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater
parents: 1743
diff changeset
   794
			if (longtoken) {
80dc66ca63b5 (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater
parents: 1743
diff changeset
   795
				tokenstream[tstream_i] = *cmdptr;
80dc66ca63b5 (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater
parents: 1743
diff changeset
   796
			} else {
80dc66ca63b5 (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater
parents: 1743
diff changeset
   797
				tokenstream[tstream_i] = '\0';
80dc66ca63b5 (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater
parents: 1743
diff changeset
   798
				foundtoken = false;
80dc66ca63b5 (svn r2250) - Fix (regression): arguments with spaces in them were incorrectly parsed
Darkvater
parents: 1743
diff changeset
   799
			}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   800
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   801
			tstream_i++;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   802
			break;
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   803
		case '"': // Tokens enclosed in "" are one token
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   804
			longtoken = !longtoken;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   805
			break;
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   806
		case '\\': // Escape character for ""
4905
d4c91a45f346 (svn r6875) -Feature: Allow for " to be in console tokens. Escape them with \. eg \".
Darkvater
parents: 4634
diff changeset
   807
			if (cmdptr[1] == '"' && tstream_i + 1 < lengthof(tokenstream)) {
d4c91a45f346 (svn r6875) -Feature: Allow for " to be in console tokens. Escape them with \. eg \".
Darkvater
parents: 4634
diff changeset
   808
				tokenstream[tstream_i++] = *++cmdptr;
d4c91a45f346 (svn r6875) -Feature: Allow for " to be in console tokens. Escape them with \. eg \".
Darkvater
parents: 4634
diff changeset
   809
				break;
d4c91a45f346 (svn r6875) -Feature: Allow for " to be in console tokens. Escape them with \. eg \".
Darkvater
parents: 4634
diff changeset
   810
			}
d4c91a45f346 (svn r6875) -Feature: Allow for " to be in console tokens. Escape them with \. eg \".
Darkvater
parents: 4634
diff changeset
   811
			/* fallthrough */
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
   812
		default: // Normal character
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   813
			tokenstream[tstream_i++] = *cmdptr;
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   814
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   815
			if (!foundtoken) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   816
				tokens[t_index++] = &tokenstream[tstream_i - 1];
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   817
				foundtoken = true;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   818
			}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   819
			break;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   820
		}
289
6dd77b0ac456 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   821
	}
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   822
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   823
	if (_stdlib_con_developer) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   824
		uint i;
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   825
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   826
		for (i = 0; tokens[i] != NULL; i++) {
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
   827
			IConsolePrintF(CC_DEBUG, "condbg: token %d is: '%s'", i, tokens[i]);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   828
		}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   829
	}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   830
1828
5775957dc871 (svn r2333) - CodeChange: also don't execute command if user has typed all spaces (eg nothing worthwhile). Suggested and implemented by Tron.
Darkvater
parents: 1827
diff changeset
   831
	if (tokens[0] == '\0') return; // don't execute empty commands
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   832
	/* 2. Determine type of command (cmd, alias or variable) and execute
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   833
	 * First try commands, then aliases, and finally variables. Execute
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   834
	 * the found action taking into account its hooking code
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   835
	 */
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   836
	cmd = IConsoleCmdGet(tokens[0]);
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   837
	if (cmd != NULL) {
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   838
		if (IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_ACCESS)) {
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   839
			IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_PRE_ACTION);
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   840
			if (cmd->proc(t_index, tokens)) { // index started with 0
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   841
				IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_POST_ACTION);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   842
			} else {
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   843
				cmd->proc(0, NULL); // if command failed, give help
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   844
			}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   845
		}
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   846
		return;
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   847
	}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   848
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   849
	t_index--; // ignore the variable-name for comfort for both aliases and variaables
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   850
	alias = IConsoleAliasGet(tokens[0]);
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   851
	if (alias != NULL) {
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   852
		IConsoleAliasExec(alias, t_index, &tokens[1]);
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   853
		return;
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   854
	}
1739
4c8fb3905cbd (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   855
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   856
	var = IConsoleVarGet(tokens[0]);
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   857
	if (var != NULL) {
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   858
		if (IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_ACCESS)) {
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   859
			IConsoleVarExec(var, t_index, &tokens[1]);
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   860
		}
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   861
		return;
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   862
	}
1833
2605fb698bec (svn r2338) - CodeChange: only call the variable hooks when you set their value not when you query them
Darkvater
parents: 1828
diff changeset
   863
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3559
diff changeset
   864
	IConsoleError("command or variable not found");
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   865
}