hedgewars/uConsole.pas
author nemo
Sun, 29 Nov 2009 18:54:24 +0000
changeset 2649 afec403dce10
parent 2630 079ef82eac75
child 2695 ed789a7ef68d
permissions -rw-r--r--
Restore old column layout.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     1
(*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 1035
diff changeset
     2
 * Hedgewars, a free turn based strategy game
883
07a568ba44e0 Update copyright info in source files headers
unc0rr
parents: 871
diff changeset
     3
 * Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com>
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     4
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
    12
 * GNU General Public License for more details.
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 176
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    17
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    18
2630
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    19
{$INCLUDE "options.inc"}
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    20
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    21
unit uConsole;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    22
interface
988
cdff3f6f9b38 Get rid of old console
unc0rr
parents: 970
diff changeset
    23
uses uFloat;
2630
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    24
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    25
const isDeveloperMode: boolean = true;
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
    26
type TVariableType = (vtCommand, vtLongInt, vthwFloat, vtBoolean);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    27
     TCommandHandler = procedure (var params: shortstring);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    28
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    29
procedure WriteToConsole(s: shortstring);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    30
procedure WriteLnToConsole(s: shortstring);
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    31
procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
936
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
    32
procedure StopMessages(Message: Longword);
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 51
diff changeset
    33
function  GetLastConsoleLine: shortstring;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1782
diff changeset
    34
procedure SplitBySpace(var a, b: shortstring);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    35
543
465e2ec8f05f - Better randomness of placing hedgehogs on the land
unc0rr
parents: 539
diff changeset
    36
procedure doPut(putX, putY: LongInt; fromAI: boolean);
465e2ec8f05f - Better randomness of placing hedgehogs on the land
unc0rr
parents: 539
diff changeset
    37
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    38
implementation
288
929c44745fd9 Ammo schemes and ammo stores support in engine
unc0rr
parents: 281
diff changeset
    39
uses uMisc, uStore, Types, uConsts, uGears, uTeams, uIO, uKeys, uWorld, uLand,
2042
905c554d62e6 Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents: 2031
diff changeset
    40
     uRandom, uAmmos, uTriggers, uStats, uGame, uChat, SDLh, uSound, uVisualGears;
950
feb18ec0c5c2 Add nickname to message in more appropriate place
unc0rr
parents: 946
diff changeset
    41
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
    42
const cLineWidth: LongInt = 0;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    43
      cLinesCount = 256;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    44
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    45
type  PVariable = ^TVariable;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    46
      TVariable = record
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    47
                     Next: PVariable;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    48
                     Name: string[15];
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    49
                    VType: TVariableType;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    50
                  Handler: pointer;
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
    51
                  Trusted: boolean;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    52
                  end;
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    53
      TTextLine = record
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    54
                  s: shortstring;
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    55
                  end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    56
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    57
var   ConsoleLines: array[byte] of TTextLine;
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
    58
      CurrLine: LongInt = 0;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    59
      Variables: PVariable = nil;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    60
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    61
procedure SetLine(var tl: TTextLine; str: shortstring);
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    62
begin
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    63
with tl do
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    64
     s:= str;
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    65
end;
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
    66
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
    67
function RegisterVariable(Name: string; VType: TVariableType; p: pointer; Trusted: boolean): PVariable;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    68
var Result: PVariable;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    69
begin
17
a6bed8d31444 minor code review
unc0rr
parents: 4
diff changeset
    70
New(Result);
a6bed8d31444 minor code review
unc0rr
parents: 4
diff changeset
    71
TryDo(Result <> nil, 'RegisterVariable: Result = nil', true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    72
FillChar(Result^, sizeof(TVariable), 0);
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    73
Result^.Name:= Name;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    74
Result^.VType:= VType;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    75
Result^.Handler:= p;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    76
Result^.Trusted:= Trusted;
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
    77
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    78
if Variables = nil then Variables:= Result
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    79
                   else begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    80
                        Result^.Next:= Variables;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    81
                        Variables:= Result
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    82
                        end;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    83
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    84
RegisterVariable:= Result
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    85
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    86
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    87
procedure FreeVariablesList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    88
var t, tt: PVariable;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    89
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    90
tt:= Variables;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    91
Variables:= nil;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    92
while tt <> nil do
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    93
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    94
      t:= tt;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
    95
      tt:= tt^.Next;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    96
      Dispose(t)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    97
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    98
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    99
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   100
procedure SplitBySpace(var a, b: shortstring);
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   101
var i, t: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   102
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   103
i:= Pos(' ', a);
1850
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   104
if i > 0 then
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   105
	begin
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   106
	for t:= 1 to Pred(i) do
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   107
		if (a[t] >= 'A')and(a[t] <= 'Z') then Inc(a[t], 32);
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   108
	b:= copy(a, i + 1, Length(a) - i);
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   109
	byte(a[0]):= Pred(i)
a0332e79fdc9 a patch :P
unc0rr
parents: 1821
diff changeset
   110
	end else b:= '';
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   111
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   112
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   113
procedure WriteToConsole(s: shortstring);
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   114
var Len: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   115
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   116
{$IFDEF DEBUGFILE}AddFileLog('Console write: ' + s);{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   117
Write(s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   118
repeat
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
   119
Len:= cLineWidth - Length(ConsoleLines[CurrLine].s);
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
   120
SetLine(ConsoleLines[CurrLine], ConsoleLines[CurrLine].s + copy(s, 1, Len));
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   121
Delete(s, 1, Len);
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
   122
if byte(ConsoleLines[CurrLine].s[0]) = cLineWidth then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   123
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   124
   inc(CurrLine);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   125
   if CurrLine = cLinesCount then CurrLine:= 0;
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
   126
   PByte(@ConsoleLines[CurrLine].s)^:= 0
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   127
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   128
until Length(s) = 0
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   129
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   130
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   131
procedure WriteLnToConsole(s: shortstring);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   132
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   133
WriteToConsole(s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   134
WriteLn;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   135
inc(CurrLine);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   136
if CurrLine = cLinesCount then CurrLine:= 0;
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
   137
PByte(@ConsoleLines[CurrLine].s)^:= 0
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   138
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   139
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   140
procedure InitConsole;
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   141
var i: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   142
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   143
cLineWidth:= cScreenWidth div 10;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   144
if cLineWidth > 255 then cLineWidth:= 255;
785
ac538f1a629e Start console OpenGL reincarnation
unc0rr
parents: 783
diff changeset
   145
for i:= 0 to Pred(cLinesCount) do PByte(@ConsoleLines[i])^:= 0
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   146
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   147
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   148
procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   149
type PhwFloat = ^hwFloat;
495
62c1c2b4414c - Fix most of the warnings in hwengine
unc0rr
parents: 415
diff changeset
   150
var ii: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   151
    s: shortstring;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   152
    t: PVariable;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   153
    c: char;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   154
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   155
//WriteLnToConsole(CmdStr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   156
if CmdStr[0]=#0 then exit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   157
{$IFDEF DEBUGFILE}AddFileLog('ParseCommand "' + CmdStr + '"');{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   158
c:= CmdStr[1];
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   159
if c in ['/', '$'] then Delete(CmdStr, 1, 1) else c:= '/';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   160
SplitBySpace(CmdStr, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   161
t:= Variables;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   162
while t <> nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   163
      begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   164
      if t^.Name = CmdStr then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   165
         begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   166
         if TrustedSource or t^.Trusted then
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   167
            case t^.VType of
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   168
              vtCommand: if c='/' then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   169
                         begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   170
                         TCommandHandler(t^.Handler)(s);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   171
                         end;
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   172
              vtLongInt: if c='$' then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   173
                         if s[0]=#0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   174
                            begin
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   175
                            str(PLongInt(t^.Handler)^, s);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   176
                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
495
62c1c2b4414c - Fix most of the warnings in hwengine
unc0rr
parents: 415
diff changeset
   177
                            end else val(s, PLongInt(t^.Handler)^);
62c1c2b4414c - Fix most of the warnings in hwengine
unc0rr
parents: 415
diff changeset
   178
              vthwFloat: if c='$' then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   179
                         if s[0]=#0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   180
                            begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   181
                            //str(PhwFloat(t^.Handler)^:4:6, s);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   182
                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   183
                            end else; //val(s, PhwFloat(t^.Handler)^, i);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   184
             vtBoolean: if c='$' then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   185
                         if s[0]=#0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   186
                            begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   187
                            str(ord(boolean(t^.Handler^)), s);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   188
                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   189
                            end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   190
                            begin
495
62c1c2b4414c - Fix most of the warnings in hwengine
unc0rr
parents: 415
diff changeset
   191
                            val(s, ii);
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   192
                            boolean(t^.Handler^):= not (ii = 0)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   193
                            end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   194
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   195
         exit
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 312
diff changeset
   196
         end else t:= t^.Next
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   197
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   198
case c of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   199
     '$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"')
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   200
     else WriteLnToConsole(errmsgUnknownCommand  + ': "/' + CmdStr + '"') end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   201
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   202
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 51
diff changeset
   203
function GetLastConsoleLine: shortstring;
1242
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   204
var Result: shortstring;
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   205
	i: LongWord;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 51
diff changeset
   206
begin
1242
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   207
i:= (CurrLine + cLinesCount - 2) mod cLinesCount;
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   208
Result:= ConsoleLines[i].s;
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   209
1277
752b53481057 - Unbreak previously broken themes
unc0rr
parents: 1242
diff changeset
   210
Result:= Result + #10;
1242
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   211
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   212
i:= (CurrLine + cLinesCount - 1) mod cLinesCount;
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   213
Result:= Result + ConsoleLines[i].s;
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   214
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   215
GetLastConsoleLine:= Result
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 51
diff changeset
   216
end;
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 51
diff changeset
   217
936
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   218
procedure StopMessages(Message: Longword);
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   219
begin
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   220
if (Message and gm_Left) <> 0 then ParseCommand('/-left', true) else
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   221
if (Message and gm_Right) <> 0 then ParseCommand('/-right', true) else
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   222
if (Message and gm_Up) <> 0 then ParseCommand('/-up', true) else
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   223
if (Message and gm_Down) <> 0 then ParseCommand('/-down', true) else
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   224
if (Message and gm_Attack) <> 0 then ParseCommand('/-attack', true)
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   225
end;
ba582673db7d Fix 'AI may break demos playing' message while loading saves
unc0rr
parents: 917
diff changeset
   226
2599
c7153d2348f3 move compiler directives to standard pascal
koda
parents: 2578
diff changeset
   227
{$INCLUDE "CCHandlers.inc"}
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   228
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   229
initialization
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   230
InitConsole;
205
8d9aff55e6ab - Set version to 0.8
unc0rr
parents: 196
diff changeset
   231
RegisterVariable('proto'   , vtCommand, @chCheckProto   , true );
1560
e140bc57ff68 Quick replay round to spectators until current move
unc0rr
parents: 1277
diff changeset
   232
RegisterVariable('spectate', vtBoolean, @fastUntilLag   , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   233
RegisterVariable('capture' , vtCommand, @chCapture      , true );
539
6a9bf1852bbc Ability to choose which info is shown above hedgehogs
unc0rr
parents: 495
diff changeset
   234
RegisterVariable('rotmask' , vtCommand, @chRotateMask   , true );
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   235
RegisterVariable('addteam' , vtCommand, @chAddTeam      , false);
589
f382c41f658a Start implementing triggers in engine
unc0rr
parents: 546
diff changeset
   236
RegisterVariable('addtrig' , vtCommand, @chAddTrigger   , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   237
RegisterVariable('rdriven' , vtCommand, @chTeamLocal    , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   238
RegisterVariable('map'     , vtCommand, @chSetMap       , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   239
RegisterVariable('theme'   , vtCommand, @chSetTheme     , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   240
RegisterVariable('seed'    , vtCommand, @chSetSeed      , false);
1797
fedd8649fdd9 Templates filter by nemo
unc0rr
parents: 1792
diff changeset
   241
RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false);
614
0e04504bc140 - Fix some warnings
unc0rr
parents: 605
diff changeset
   242
RegisterVariable('delay'   , vtLongInt, @cInactDelay    , false);
0e04504bc140 - Fix some warnings
unc0rr
parents: 605
diff changeset
   243
RegisterVariable('casefreq', vtLongInt, @cCaseFactor    , false);
1782
e7589e37a6d6 Options for bonus box probability tuning and number of turn until sudden death
unc0rr
parents: 1654
diff changeset
   244
RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns  , false);
2578
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   245
RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false);
622
cedd47d956ec - New training (not finished yet)
unc0rr
parents: 614
diff changeset
   246
RegisterVariable('landadds', vtLongInt, @cLandAdditions , false);
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   247
RegisterVariable('gmflags' , vtLongInt, @GameFlags      , false);
2428
6800f8aa0184 Huge Smaxx patch with some fixes by me:
unc0rr
parents: 2379
diff changeset
   248
RegisterVariable('trflags' , vtLongInt, @TrainingFlags  , false);
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   249
RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false);
2578
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   250
RegisterVariable('minestime',vtLongInt, @cMinesTime     , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   251
RegisterVariable('fort'    , vtCommand, @chFort         , false);
1654
9cfa6f23e767 Start voicepacks implementation
unc0rr
parents: 1639
diff changeset
   252
RegisterVariable('voicepack',vtCommand, @chVoicepack    , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   253
RegisterVariable('grave'   , vtCommand, @chGrave        , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   254
RegisterVariable('bind'    , vtCommand, @chBind         , true );
312
c36d0b34ac3d Use new parameters, small protocol change
unc0rr
parents: 288
diff changeset
   255
RegisterVariable('addhh'   , vtCommand, @chAddHH        , false);
1242
4aca5f7b2504 Hats now fully implemented for local game
unc0rr
parents: 1066
diff changeset
   256
RegisterVariable('hat'     , vtCommand, @chSetHat       , false);
604
2f1165467a66 Let hedgehog position be taken from config, still more work is needed
unc0rr
parents: 589
diff changeset
   257
RegisterVariable('hhcoords', vtCommand, @chSetHHCoords  , false);
288
929c44745fd9 Ammo schemes and ammo stores support in engine
unc0rr
parents: 281
diff changeset
   258
RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false);
1022
f6a3fcb329ca Start exit confirmation implementation
unc0rr
parents: 991
diff changeset
   259
RegisterVariable('quit'    , vtCommand, @chQuit         , true );
f6a3fcb329ca Start exit confirmation implementation
unc0rr
parents: 991
diff changeset
   260
RegisterVariable('confirm' , vtCommand, @chConfirm      , true );
626
a30171dbcd19 's' key to speed up demo playing
unc0rr
parents: 622
diff changeset
   261
RegisterVariable('+speedup', vtCommand, @chSpeedup_p    , true );
a30171dbcd19 's' key to speed up demo playing
unc0rr
parents: 622
diff changeset
   262
RegisterVariable('-speedup', vtCommand, @chSpeedup_m    , true );
2162
2bce91404d49 - Implement zoom-in and zoom-out
unc0rr
parents: 2130
diff changeset
   263
RegisterVariable('zoomin'  , vtCommand, @chZoomIn       , true );
2bce91404d49 - Implement zoom-in and zoom-out
unc0rr
parents: 2130
diff changeset
   264
RegisterVariable('zoomout' , vtCommand, @chZoomOut      , true );
2379
d62b1f224982 - Implement zoom reset
unc0rr
parents: 2162
diff changeset
   265
RegisterVariable('zoomreset',vtCommand, @chZoomReset    , true );
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   266
RegisterVariable('skip'    , vtCommand, @chSkip         , false);
991
d17c71ee074e Enable history (bound on ` key)
unc0rr
parents: 988
diff changeset
   267
RegisterVariable('history' , vtCommand, @chHistory      , true );
946
42c5cc87cbd1 Preparing to have gsChat gamestate
unc0rr
parents: 936
diff changeset
   268
RegisterVariable('chat'    , vtCommand, @chChat         , true );
1821
6b6cf3389f92 Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents: 1797
diff changeset
   269
RegisterVariable('newgrave', vtCommand, @chNewGrave     , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   270
RegisterVariable('say'     , vtCommand, @chSay          , true );
2017
7845c77c8d31 nemo's great patch:
unc0rr
parents: 1895
diff changeset
   271
RegisterVariable('hogsay'  , vtCommand, @chHogSay       , true );
2130
708758635955 Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents: 2124
diff changeset
   272
RegisterVariable('team'    , vtCommand, @chTeamSay      , true );
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   273
RegisterVariable('ammomenu', vtCommand, @chAmmoMenu     , false);
1639
89b536a3cf3c Implement precise aiming when pressing left shift
unc0rr
parents: 1560
diff changeset
   274
RegisterVariable('+precise', vtCommand, @chPrecise_p    , false);
89b536a3cf3c Implement precise aiming when pressing left shift
unc0rr
parents: 1560
diff changeset
   275
RegisterVariable('-precise', vtCommand, @chPrecise_m    , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   276
RegisterVariable('+left'   , vtCommand, @chLeft_p       , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   277
RegisterVariable('-left'   , vtCommand, @chLeft_m       , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   278
RegisterVariable('+right'  , vtCommand, @chRight_p      , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   279
RegisterVariable('-right'  , vtCommand, @chRight_m      , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   280
RegisterVariable('+up'     , vtCommand, @chUp_p         , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   281
RegisterVariable('-up'     , vtCommand, @chUp_m         , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   282
RegisterVariable('+down'   , vtCommand, @chDown_p       , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   283
RegisterVariable('-down'   , vtCommand, @chDown_m       , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   284
RegisterVariable('+attack' , vtCommand, @chAttack_p     , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   285
RegisterVariable('-attack' , vtCommand, @chAttack_m     , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   286
RegisterVariable('switch'  , vtCommand, @chSwitch       , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   287
RegisterVariable('nextturn', vtCommand, @chNextTurn     , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   288
RegisterVariable('timer'   , vtCommand, @chTimer        , false);
1035
6f5842bc481b Hopefully done taunts implementation
unc0rr
parents: 1022
diff changeset
   289
RegisterVariable('taunt'   , vtCommand, @chTaunt        , false);
783
4f59db6f147d - New command 'set weapon'
unc0rr
parents: 771
diff changeset
   290
RegisterVariable('setweap' , vtCommand, @chSetWeapon    , false);
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   291
RegisterVariable('slot'    , vtCommand, @chSlot         , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   292
RegisterVariable('put'     , vtCommand, @chPut          , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   293
RegisterVariable('ljump'   , vtCommand, @chLJump        , false);
805fa9a27e9e "Trusted" binds
unc0rr
parents: 166
diff changeset
   294
RegisterVariable('hjump'   , vtCommand, @chHJump        , false);
970
1bd9a4eafbc3 - Quick hack for hats
unc0rr
parents: 969
diff changeset
   295
RegisterVariable('fullscr' , vtCommand, @chFullScr      , true );
175
d226d976d836 - Some improvements to volume control
unc0rr
parents: 174
diff changeset
   296
RegisterVariable('+volup'  , vtCommand, @chVol_p        , true );
d226d976d836 - Some improvements to volume control
unc0rr
parents: 174
diff changeset
   297
RegisterVariable('-volup'  , vtCommand, @chVol_m        , true );
d226d976d836 - Some improvements to volume control
unc0rr
parents: 174
diff changeset
   298
RegisterVariable('+voldown', vtCommand, @chVol_m        , true );
d226d976d836 - Some improvements to volume control
unc0rr
parents: 174
diff changeset
   299
RegisterVariable('-voldown', vtCommand, @chVol_p        , true );
176
533d03041dcd 'h' marks out current hedgehog
unc0rr
parents: 175
diff changeset
   300
RegisterVariable('findhh'  , vtCommand, @chFindhh       , true );
281
5b483aa9f2ab Pause support (mouse cursor is released when the game is paused)
unc0rr
parents: 205
diff changeset
   301
RegisterVariable('pause'   , vtCommand, @chPause        , true );
2578
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   302
RegisterVariable('+cur_u'  , vtCommand, @chCurU_p       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   303
RegisterVariable('-cur_u'  , vtCommand, @chCurU_m       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   304
RegisterVariable('+cur_d'  , vtCommand, @chCurD_p       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   305
RegisterVariable('-cur_d'  , vtCommand, @chCurD_m       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   306
RegisterVariable('+cur_l'  , vtCommand, @chCurL_p       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   307
RegisterVariable('-cur_l'  , vtCommand, @chCurL_m       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   308
RegisterVariable('+cur_r'  , vtCommand, @chCurR_p       , true );
ec8e69b23097 err, complete previous commit
koda
parents: 2428
diff changeset
   309
RegisterVariable('-cur_r'  , vtCommand, @chCurR_m       , true );
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   310
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   311
finalization
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   312
FreeVariablesList
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   313
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   314
end.