4
|
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');
|
|
51 |
Send('eaddteam');
|
|
52 |
Send('ename team "C0CuCKAzZz"');
|
|
53 |
Send('ename hh0 "Йожык"');
|
|
54 |
Send('ename hh1 "Ёжик"');
|
|
55 |
Send('ename hh2 "Ёжык"');
|
|
56 |
Send('ename hh3 "Йожик"');
|
|
57 |
Send('ename hh4 "Ёжик без ножек"');
|
|
58 |
Send('ename hh5 "Just hedgehog"');
|
|
59 |
Send('ename hh6 "Ёжик без головы"');
|
|
60 |
Send('ename hh7 "Валасатый йож"');
|
|
61 |
Send('ebind left "+left"');
|
|
62 |
Send('ebind right "+right"');
|
|
63 |
Send('ebind up "+up"');
|
|
64 |
Send('ebind down "+down"');
|
|
65 |
Send('ebind F1 "slot 1"');
|
|
66 |
Send('ebind F2 "slot 2"');
|
|
67 |
Send('ebind F3 "slot 3"');
|
|
68 |
Send('ebind F4 "slot 4"');
|
|
69 |
Send('ebind F5 "slot 5"');
|
|
70 |
Send('ebind F6 "slot 6"');
|
|
71 |
Send('ebind F7 "slot 7"');
|
|
72 |
Send('ebind F8 "slot 8"');
|
|
73 |
Send('ebind F10 "quit"');
|
|
74 |
Send('ebind F11 "capture"');
|
|
75 |
Send('ebind space "+attack"');
|
|
76 |
Send('ebind return "ljump"');
|
|
77 |
Send('ebind backspace "hjump"');
|
|
78 |
Send('ebind tab "switch"');
|
|
79 |
Send('ebind 1 "timer 1"');
|
|
80 |
Send('ebind 2 "timer 2"');
|
|
81 |
Send('ebind 3 "timer 3"');
|
|
82 |
Send('ebind 4 "timer 4"');
|
|
83 |
Send('ebind 5 "timer 5"');
|
|
84 |
Send('ebind mousel "put"');
|
|
85 |
Send('egrave "coffin"');
|
|
86 |
Send('efort "Barrelhouse"');
|
|
87 |
Send('ecolor 65535');
|
|
88 |
Send('eadd hh0 0');
|
|
89 |
Send('eadd hh1 0');
|
|
90 |
Send('eadd hh2 0');
|
|
91 |
Send('eadd hh3 0');
|
|
92 |
Send('eaddteam');
|
|
93 |
Send('ename team "-= ЕЖЫ =-"');
|
|
94 |
Send('ename hh0 "Маленький"');
|
|
95 |
Send('ename hh1 "Удаленький"');
|
|
96 |
Send('ename hh2 "Игольчатый"');
|
|
97 |
Send('ename hh3 "Стреляный"');
|
|
98 |
Send('ename hh4 "Ежиха"');
|
|
99 |
Send('ename hh5 "Ежонок"');
|
|
100 |
Send('ename hh6 "Инфернальный"');
|
|
101 |
Send('ename hh7 "X"');
|
|
102 |
Send('egrave Bone');
|
|
103 |
Send('ecolor 16776960');
|
|
104 |
Send('eadd hh0 1');
|
|
105 |
Send('eadd hh1 1');
|
|
106 |
Send('eadd hh2 1');
|
|
107 |
Send('eadd hh3 1');
|
|
108 |
Send('efort Barrelhouse');
|
|
109 |
end;
|
|
110 |
|
|
111 |
procedure ParseCmd(s: shortstring);
|
|
112 |
begin
|
|
113 |
case s[1] of
|
|
114 |
'?': Send('!');
|
|
115 |
'C': SendConfig;
|
|
116 |
end;
|
|
117 |
end;
|
|
118 |
|
|
119 |
procedure DoIt;
|
|
120 |
const ss: string = '';
|
|
121 |
var s: shortstring;
|
|
122 |
i: integer;
|
|
123 |
begin
|
|
124 |
i:= SDLNet_TCP_Recv(clsock, @s[1], 255);
|
|
125 |
if i <= 0 then
|
|
126 |
begin
|
|
127 |
if i = -1 then exit;
|
|
128 |
SDLNet_TCP_Close(clsock);
|
|
129 |
clsock:= nil;
|
|
130 |
ss:= '';
|
|
131 |
exit
|
|
132 |
end;
|
|
133 |
byte(s[0]):= i;
|
|
134 |
ss:= ss + s;
|
|
135 |
while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
|
|
136 |
begin
|
|
137 |
s:= copy(ss, 2, byte(ss[1]));
|
|
138 |
Delete(ss, 1, Succ(byte(ss[1])));
|
|
139 |
ParseCmd(s)
|
|
140 |
end;
|
|
141 |
end;
|
|
142 |
|
|
143 |
begin
|
|
144 |
WriteLn('run hw 640 480 avematan 46631 (CVSKGIHSVHX) 1');
|
|
145 |
SDL_Init(0);
|
|
146 |
SDLNet_Init;
|
|
147 |
ip.host:= 0;
|
|
148 |
ip.port:= $27B6;
|
|
149 |
servsock:= SDLNet_TCP_Open(ip);
|
|
150 |
repeat
|
|
151 |
if clsock = nil then
|
|
152 |
clsock:= SDLNet_TCP_Accept(servsock);
|
|
153 |
if clsock <> nil then
|
|
154 |
DoIt;
|
|
155 |
SDL_PollEvent(@event);
|
|
156 |
SDL_Delay(1)
|
|
157 |
until event.type_ = SDL_QUITEV;
|
|
158 |
SDLNet_Quit;
|
|
159 |
SDL_Quit
|
|
160 |
end.
|