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