hedgewars/runhelper.dpr
author unc0rr
Sun, 11 Sep 2005 11:45:01 +0000
changeset 15 6200cca92480
parent 4 bcbd7adb4e4b
permissions -rw-r--r--
- Minor code simplifying - Stub for spawning cases with ammo on turn end
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     1
(*
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     2
 * Hedgewars, a worms-like game
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     3
 * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     4
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     6
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     9
 * with the Software without restriction, including without limitation the
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    12
 * furnished to do so, subject to the following conditions:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    15
 *    this list of conditions and the following disclaimer.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
 *    and/or other materials provided with the distribution.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    20
 *    derived from this software without specific prior written permission.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    32
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    33
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    34
program runhelper;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    35
{$APPTYPE CONSOLE}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    36
{$J+}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    37
uses SDLh;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    38
var servsock, clsock: PTCPSocket;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    39
    ip: TIPAddress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    40
    event: TSDL_Event;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    41
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    42
procedure Send(s: shortstring);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    43
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    44
SDLNet_TCP_Send(clsock, @s, succ(byte(s[0])))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    45
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    46
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    47
procedure SendConfig;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    48
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    49
Send('TL');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    50
Send('e$gmflags 1');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    51
Send('eaddteam');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    52
Send('ename team "C0CuCKAzZz"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    53
Send('ename hh0 "Йожык"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    54
Send('ename hh1 "Ёжик"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    55
Send('ename hh2 "Ёжык"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    56
Send('ename hh3 "Йожик"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    57
Send('ename hh4 "Ёжик без ножек"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    58
Send('ename hh5 "Just hedgehog"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    59
Send('ename hh6 "Ёжик без головы"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    60
Send('ename hh7 "Валасатый йож"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    61
Send('ebind left  "+left"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    62
Send('ebind right "+right"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    63
Send('ebind up    "+up"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    64
Send('ebind down  "+down"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    65
Send('ebind F1  "slot 1"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    66
Send('ebind F2  "slot 2"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    67
Send('ebind F3  "slot 3"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    68
Send('ebind F4  "slot 4"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    69
Send('ebind F5  "slot 5"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    70
Send('ebind F6  "slot 6"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    71
Send('ebind F7  "slot 7"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    72
Send('ebind F8  "slot 8"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    73
Send('ebind F10 "quit"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    74
Send('ebind F11 "capture"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    75
Send('ebind space     "+attack"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    76
Send('ebind return    "ljump"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    77
Send('ebind backspace "hjump"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    78
Send('ebind tab       "switch"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    79
Send('ebind 1 "timer 1"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    80
Send('ebind 2 "timer 2"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    81
Send('ebind 3 "timer 3"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    82
Send('ebind 4 "timer 4"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    83
Send('ebind 5 "timer 5"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    84
Send('ebind mousel "put"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    85
Send('egrave "coffin"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    86
Send('efort "Barrelhouse"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    87
Send('ecolor 65535');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    88
Send('eadd hh0 0');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    89
Send('eadd hh1 0');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    90
Send('eadd hh2 0');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    91
Send('eadd hh3 0');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    92
Send('eaddteam');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    93
Send('ename team "-= ЕЖЫ =-"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    94
Send('ename hh0 "Маленький"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    95
Send('ename hh1 "Удаленький"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    96
Send('ename hh2 "Игольчатый"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    97
Send('ename hh3 "Стреляный"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    98
Send('ename hh4 "Ежиха"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    99
Send('ename hh5 "Ежонок"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   100
Send('ename hh6 "Инфернальный"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   101
Send('ename hh7 "X"');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   102
Send('egrave Bone');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
Send('ecolor 16776960');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   104
Send('eadd hh0 1');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   105
Send('eadd hh1 1');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   106
Send('eadd hh2 1');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   107
Send('eadd hh3 1');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   108
Send('efort Barrelhouse');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   109
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   110
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   111
procedure ParseCmd(s: shortstring);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   112
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   113
case s[1] of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   114
     '?': Send('!');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   115
     'C': SendConfig;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   116
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   117
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   118
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   119
procedure DoIt;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   120
const ss: string = '';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   121
var s: shortstring;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   122
    i: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   123
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   124
i:= SDLNet_TCP_Recv(clsock, @s[1], 255);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   125
if i <= 0  then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   126
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   127
   if i = -1 then exit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   128
   SDLNet_TCP_Close(clsock);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   129
   clsock:= nil;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   130
   ss:= '';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   132
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   133
byte(s[0]):= i;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   134
ss:= ss + s;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   135
while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   136
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   137
      s:= copy(ss, 2, byte(ss[1]));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   138
      Delete(ss, 1, Succ(byte(ss[1])));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   139
      ParseCmd(s)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   140
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   141
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   142
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   143
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   144
WriteLn('run hw 640 480 avematan 46631 (CVSKGIHSVHX) 1');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   145
SDL_Init(0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   146
SDLNet_Init;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   147
ip.host:= 0;     
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   148
ip.port:= $27B6;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   149
servsock:= SDLNet_TCP_Open(ip);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   150
repeat
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   151
  if clsock = nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   152
     clsock:= SDLNet_TCP_Accept(servsock);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   153
  if clsock <> nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   154
     DoIt;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   155
  SDL_PollEvent(@event);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   156
  SDL_Delay(1)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   157
until event.type_ = SDL_QUITEV;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   158
SDLNet_Quit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   159
SDL_Quit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   160
end.