author | koda |
Sat, 09 Oct 2010 18:00:53 +0200 (2010-10-09) | |
changeset 3935 | 5ca27a0e9a63 |
parent 3928 | 2560731c860d |
child 4048 | f94d04498031 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 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 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uGame; |
22 |
interface |
|
23 |
||
371 | 24 |
procedure DoGameTick(Lag: LongInt); |
4 | 25 |
|
26 |
//////////////////// |
|
27 |
implementation |
|
28 |
//////////////////// |
|
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
3904
diff
changeset
|
29 |
uses uMisc, uConsts, uKeys, uTeams, uIO, uAI, uGears, uScript, uSound, uMobile; |
4 | 30 |
|
371 | 31 |
procedure DoGameTick(Lag: LongInt); |
32 |
var i: LongInt; |
|
4 | 33 |
begin |
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
196
diff
changeset
|
34 |
if isPaused then exit; |
1611 | 35 |
if (not CurrentTeam^.ExtDriven) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
36 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
37 |
NetGetNextCmd; // its for the case of receiving "/say" message |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
38 |
isInLag:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
39 |
SendKeepAliveMessage(Lag) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
40 |
end; |
72 | 41 |
if Lag > 100 then Lag:= 100 |
1727 | 42 |
else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; |
626 | 43 |
if (GameType = gmtDemo) and isSpeed then Lag:= Lag * 10; |
4 | 44 |
|
89 | 45 |
i:= 1; |
46 |
while (GameState <> gsExit) and (i <= Lag) do |
|
47 |
begin |
|
2814 | 48 |
ScriptCall('onGameTick'); |
351 | 49 |
if not CurrentTeam^.ExtDriven then |
4 | 50 |
begin |
602 | 51 |
if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
4 | 52 |
ProcessGears |
53 |
end else |
|
54 |
begin |
|
55 |
NetGetNextCmd; |
|
56 |
if isInLag then |
|
57 |
case GameType of |
|
113 | 58 |
gmtNet: break; |
4 | 59 |
gmtDemo: begin |
60 |
GameState:= gsExit; |
|
61 |
exit |
|
72 | 62 |
end; |
63 |
gmtSave: begin |
|
64 |
RestoreTeamsFromSave; |
|
519 | 65 |
SetBinds(CurrentTeam^.Binds); |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
66 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
72 | 67 |
isSoundEnabled:= isSEBackup; |
3902
3aac7ca07b0e
have Saves restart net when loaded, also resumes music
koda
parents:
3663
diff
changeset
|
68 |
if isSoundEnabled then playMusic; |
3aac7ca07b0e
have Saves restart net when loaded, also resumes music
koda
parents:
3663
diff
changeset
|
69 |
GameType:= gmtLocal; |
3aac7ca07b0e
have Saves restart net when loaded, also resumes music
koda
parents:
3663
diff
changeset
|
70 |
InitIPC; |
3935 | 71 |
perfExt_SaveFinishedSynching(); |
72 | 72 |
end; |
4 | 73 |
end |
74 |
else ProcessGears |
|
75 |
end; |
|
89 | 76 |
inc(i) |
162 | 77 |
end |
4 | 78 |
end; |
79 |
||
80 |
end. |