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