4
|
1 |
(*
|
|
2 |
* Hedgewars, a worms-like game
|
|
3 |
* Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
|
|
4 |
*
|
183
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; version 2 of the License
|
4
|
8 |
*
|
183
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
4
|
13 |
*
|
183
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
4
|
17 |
*)
|
|
18 |
|
|
19 |
unit uGame;
|
|
20 |
interface
|
|
21 |
uses SDLh;
|
|
22 |
{$INCLUDE options.inc}
|
|
23 |
|
|
24 |
procedure DoGameTick(Lag: integer);
|
|
25 |
|
|
26 |
////////////////////
|
|
27 |
implementation
|
|
28 |
////////////////////
|
72
|
29 |
uses uMisc, uConsts, uWorld, uKeys, uTeams, uIO, uAI, uGears, uConsole;
|
4
|
30 |
|
|
31 |
procedure DoGameTick(Lag: integer);
|
|
32 |
const SendEmptyPacketTicks: LongWord = 0;
|
|
33 |
var i: integer;
|
|
34 |
begin
|
167
|
35 |
if not CurrentTeam.ExtDriven then
|
4
|
36 |
begin
|
113
|
37 |
NetGetNextCmd; // its for the case when receiving "/say" message
|
|
38 |
isInLag:= false;
|
|
39 |
inc(SendEmptyPacketTicks, Lag);
|
4
|
40 |
if SendEmptyPacketTicks >= cSendEmptyPacketTime then
|
|
41 |
begin
|
143
|
42 |
SendIPC('+');
|
4
|
43 |
SendEmptyPacketTicks:= 0
|
113
|
44 |
end
|
4
|
45 |
end;
|
|
46 |
|
72
|
47 |
if Lag > 100 then Lag:= 100
|
109
|
48 |
else if GameType = gmtSave then Lag:= 2500;
|
4
|
49 |
|
89
|
50 |
i:= 1;
|
|
51 |
while (GameState <> gsExit) and (i <= Lag) do
|
|
52 |
begin
|
4
|
53 |
if not CurrentTeam.ExtDriven then
|
|
54 |
begin
|
|
55 |
with CurrentTeam^ do
|
|
56 |
if Hedgehogs[CurrHedgehog].BotLevel <> 0 then ProcessBot;
|
|
57 |
ProcessGears
|
|
58 |
end else
|
|
59 |
begin
|
|
60 |
NetGetNextCmd;
|
|
61 |
if isInLag then
|
|
62 |
case GameType of
|
113
|
63 |
gmtNet: break;
|
4
|
64 |
gmtDemo: begin
|
|
65 |
GameState:= gsExit;
|
|
66 |
exit
|
72
|
67 |
end;
|
|
68 |
gmtSave: begin
|
|
69 |
RestoreTeamsFromSave;
|
|
70 |
isSoundEnabled:= isSEBackup;
|
|
71 |
GameType:= gmtLocal
|
|
72 |
end;
|
4
|
73 |
end
|
|
74 |
else ProcessGears
|
|
75 |
end;
|
89
|
76 |
inc(i)
|
162
|
77 |
end
|
4
|
78 |
end;
|
|
79 |
|
|
80 |
end.
|