hedgewars/CCHandlers.inc
author unc0rr
Mon, 22 Aug 2005 13:35:41 +0000
changeset 1 30f2d1037d5d
child 4 bcbd7adb4e4b
permissions -rw-r--r--
Add current sources. hw, hwserv and runhelper are compilable under Windows and *nix with FreePascal (and use -Od option) and run well on these OSes Hedge.dpr can be run only in Windows... to be ported
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     1
(*
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     2
 * Hedgewars, a worms-like game
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     4
 *
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     6
 *
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
     9
 * with the Software without restriction, including without limitation the
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    12
 * furnished to do so, subject to the following conditions:
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    13
 *
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    15
 *    this list of conditions and the following disclaimer.
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    18
 *    and/or other materials provided with the distribution.
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    20
 *    derived from this software without specific prior written permission.
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    21
 *
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    32
 *)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    33
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    34
function CheckNoTeamOrHH: boolean;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    35
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    36
Result:= (CurrentTeam=nil) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = nil);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    37
{$IFDEF DEBUGFILE}
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    38
if Result then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    39
   if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil')
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    40
                        else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil')
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    41
{$ENDIF}
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    42
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    43
////////////////////////////////////////////////////////////////////////////////
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    44
procedure chQuit(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    45
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    46
GameState:= gsExit
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    47
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    48
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    49
procedure chAddTeam(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    50
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    51
if isDeveloperMode then AddTeam;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    52
if GameType = gmtDemo then CurrentTeam.ExtDriven:= true
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    53
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    54
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    55
procedure chTeamLocal(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    56
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    57
if not isDeveloperMode then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    58
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    59
CurrentTeam.ExtDriven:= true
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    60
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    61
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    62
procedure chName(var id: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    63
var s: shortstring;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    64
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    65
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    66
SplitBySpace(id, s);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    67
if s[1]='"' then Delete(s, 1, 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    68
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    69
if id = 'team' then CurrentTeam.TeamName:= s
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    70
else if (id[1]='h')and(id[2]='h')and(id[3]>='0')and(id[3]<='7') then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    71
   CurrentTeam.Hedgehogs[byte(id[3])-48].Name:= s
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    72
else OutError(errmsgUnknownVariable + ' "' + id + '"')
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    73
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    74
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    75
procedure chGrave(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    76
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    77
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    78
if s[1]='"' then Delete(s, 1, 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    79
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    80
CurrentTeam.GraveName:= s
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    81
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    82
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    83
procedure chFort(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    84
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    85
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    86
if s[1]='"' then Delete(s, 1, 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    87
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    88
CurrentTeam.FortName:= s
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    89
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    90
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    91
procedure chColor(var id: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    92
var c: integer;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    93
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    94
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    95
val(id, CurrentTeam.Color, c);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    96
AdjustColor(CurrentTeam.Color)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    97
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    98
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
    99
procedure chAdd(var id: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   100
var s: shortstring;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   101
    c: integer;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   102
    Gear: PGear;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   103
    b: byte;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   104
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   105
if (not isDeveloperMode)or(CurrentTeam=nil) then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   106
SplitBySpace(id, s);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   107
if (id[1]='h')and(id[2]='h')and(id[3]>='0')and(id[3]<='7') then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   108
   begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   109
   b:= byte(id[3])-48;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   110
   val(s, CurrentTeam.Hedgehogs[b].BotLevel, c);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   111
   Gear:= AddGear(0, 0, gtHedgehog, 0);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   112
   Gear.Hedgehog:= @CurrentTeam.Hedgehogs[b];
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   113
   PHedgehog(Gear.Hedgehog).Team:= CurrentTeam;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   114
   CurrentTeam.Hedgehogs[b].Gear:= Gear
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   115
   end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   116
else OutError(errmsgUnknownVariable + ' "' + id + '"', true)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   117
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   118
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   119
procedure chBind(var id: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   120
var s: shortstring;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   121
    b: integer;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   122
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   123
if CurrentTeam = nil then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   124
SplitBySpace(id, s);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   125
if s[1]='"' then Delete(s, 1, 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   126
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   127
b:= KeyNameToCode(id);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   128
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"')
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   129
         else CurrentTeam.Aliases[b]:= s
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   130
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   131
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   132
procedure chLeft_p(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   133
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   134
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   135
if not CurrentTeam.ExtDriven then SendIPC('L');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   136
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   137
    Message:= Message or gm_Left
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   138
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   139
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   140
procedure chLeft_m(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   141
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   142
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   143
if not CurrentTeam.ExtDriven then SendIPC('l');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   144
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   145
     Message:= Message and not gm_Left
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   146
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   147
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   148
procedure chRight_p(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   149
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   150
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   151
if not CurrentTeam.ExtDriven then SendIPC('R');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   152
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   153
    Message:= Message or gm_Right
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   154
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   155
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   156
procedure chRight_m(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   157
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   158
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   159
if not CurrentTeam.ExtDriven then SendIPC('r');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   160
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   161
     Message:= Message and not gm_Right
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   162
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   163
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   164
procedure chUp_p(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   165
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   166
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   167
if not CurrentTeam.ExtDriven then SendIPC('U');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   168
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   169
    Message:= Message or gm_Up
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   170
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   171
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   172
procedure chUp_m(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   173
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   174
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   175
if not CurrentTeam.ExtDriven then SendIPC('u');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   176
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   177
     Message:= Message and not gm_Up
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   178
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   179
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   180
procedure chDown_p(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   181
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   182
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   183
if not CurrentTeam.ExtDriven then SendIPC('D');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   184
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   185
    Message:= Message or gm_Down
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   186
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   187
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   188
procedure chDown_m(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   189
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   190
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   191
if not CurrentTeam.ExtDriven then SendIPC('d');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   192
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   193
     Message:= Message and not gm_Down
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   194
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   195
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   196
procedure chLJump(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   197
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   198
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   199
if not CurrentTeam.ExtDriven then SendIPC('j');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   200
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   201
    Message:= Message or gm_LJump
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   202
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   203
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   204
procedure chHJump(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   205
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   206
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   207
if not CurrentTeam.ExtDriven then SendIPC('J');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   208
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   209
    Message:= Message or gm_HJump
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   210
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   211
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   212
procedure chAttack_p(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   213
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   214
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   215
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   216
     begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   217
     {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear.State = '+inttostr(State));{$ENDIF}
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   218
     if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   219
        begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   220
        FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   221
        if not CurrentTeam.ExtDriven then SendIPC('A');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   222
        Message:= Message or gm_Attack
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   223
        end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   224
     end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   225
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   226
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   227
procedure chAttack_m(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   228
var xx, yy: real;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   229
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   230
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   231
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^,
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   232
     CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   233
     begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   234
     {$IFDEF DEBUGFILE}AddFileLog('/-attack: Gear.State = '+inttostr(State)+' CurAmmoGear = '+inttostr(longword(CurAmmoGear)));{$ENDIF}
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   235
     if CurAmmoGear <> nil then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   236
        begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   237
        Message:= Message and not gm_Attack;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   238
        if not CurrentTeam.ExtDriven then SendIPC('a')
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   239
        end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   240
     if (((State and (gstHHDriven or gstAttacking)) = (gstHHDriven or gstAttacking))and
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   241
        ((State and (gstAttacked or gstMoving or gstHHChooseTarget)) = 0)and
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   242
        (((State and gstFalling  ) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   243
        (((State and gstHHJumping) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0)))and
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   244
        (CurAmmoGear = nil) then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   245
        begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   246
        if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   247
           begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   248
           StopSound(sndThrowPowerUp);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   249
           PlaySound(sndThrowRelease);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   250
           end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   251
        xx:= Sign(dX)*Sin(Angle*pi/cMaxAngle);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   252
        yy:= -Cos(Angle*pi/cMaxAngle);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   253
             case Ammo[CurSlot, CurAmmo].AmmoType of
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   254
                      amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   255
                      amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   256
                          amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   257
                      amShotgun: begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   258
                                 PlaySound(sndShotgunReload);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   259
                                 FollowGear:= AddGear(round(X + xx*20), round(Y + yy*20), gtShotgunShot,  0, xx * 0.5, 0.5 * yy);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   260
                                 end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   261
                         amSkip: TurnTimeLeft:= 0;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   262
                   amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHHalfHeight, gtPickHammer, 0);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   263
                         amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   264
                  end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   265
        Power:= 0;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   266
        if CurAmmoGear <> nil then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   267
           begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   268
           CurAmmoGear.Message:= Gear.Message;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   269
           exit
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   270
           end else
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   271
           begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   272
           Message:= Message and not gm_Attack;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   273
           if not CurrentTeam.ExtDriven then SendIPC('a')
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   274
           end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   275
        AfterAttack
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   276
        end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   277
     end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   278
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   279
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   280
procedure chSwitch(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   281
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   282
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   283
if not CurrentTeam.ExtDriven then SendIPC('S');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   284
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   285
     Message:= Message or gm_Switch
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   286
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   287
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   288
procedure chNextTurn(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   289
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   290
if AllInactive then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   291
   begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   292
   if not CurrentTeam.ExtDriven then SendIPC('N');
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   293
   {$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF}
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   294
   SwitchHedgehog;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   295
   end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   296
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   297
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   298
procedure chSay(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   299
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   300
WriteLnToConsole('> ' + s);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   301
SendIPC('s'+s)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   302
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   303
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   304
procedure chTimer(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   305
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   306
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   307
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   308
     if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   309
        begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   310
        Ammo[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   311
        with CurrentTeam^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   312
             ApplyAmmoChanges(@Hedgehogs[CurrHedgehog]);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   313
        if not CurrentTeam.ExtDriven then SendIPC(s);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   314
        end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   315
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   316
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   317
procedure chSlot(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   318
var slot: LongWord;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   319
    caSlot, caAmmo: PLongword;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   320
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   321
if (s[0] <> #1) or (CurrentTeam = nil) then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   322
slot:= byte(s[1]) - 49;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   323
if slot > cMaxSlot then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   324
if not CurrentTeam.ExtDriven then SendIPC(char(byte(s[1]) + 79));
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   325
with CurrentTeam^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   326
     begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   327
     with Hedgehogs[CurrHedgehog] do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   328
          begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   329
          if ((Gear.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   330
             or ((Gear.State and gstHHDriven) = 0) then exit; // во время стрельбы исключает смену оружия
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   331
          if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   332
                               else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   333
          if caSlot^ = slot then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   334
             begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   335
             inc(caAmmo^);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   336
             if (caAmmo^ > cMaxSlotAmmo) or (Ammo[slot, caAmmo^].Count = 0) then caAmmo^:= 0
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   337
             end else
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   338
             if Ammo[slot, 0].Count > 0 then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   339
                begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   340
                caSlot^:= slot;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   341
                caAmmo^:= 0;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   342
                end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   343
          TargetPoint.X:= NoPointX;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   344
          end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   345
     ApplyAmmoChanges(@Hedgehogs[CurrHedgehog])
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   346
     end
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   347
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   348
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   349
procedure chPut(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   350
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   351
if CheckNoTeamOrHH then exit;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   352
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   353
     if (State and gstHHChooseTarget) <> 0 then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   354
        begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   355
        isCursorVisible:= false;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   356
        if not CurrentTeam.ExtDriven then
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   357
           begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   358
           SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   359
           dec(TargetPoint.X, WorldDx);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   360
           dec(TargetPoint.Y, WorldDy);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   361
           s[0]:= #9;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   362
           s[1]:= 'p';
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   363
           PInteger(@s[2])^:= TargetPoint.X;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   364
           PInteger(@s[6])^:= TargetPoint.Y;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   365
           SendIPC(s)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   366
           end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   367
        AdjustMPoint;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   368
        State:= State and not gstHHChooseTarget;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   369
        end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', true)
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   370
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   371
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   372
procedure chCapture(var s: shortstring);
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   373
begin
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   374
flagMakeCapture:= true
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   375
end;
30f2d1037d5d Add current sources.
unc0rr
parents:
diff changeset
   376