author | koda |
Sat, 24 Sep 2011 03:00:57 +0200 | |
changeset 6006 | a211dcca5016 |
parent 5809 | 5883d62b648b |
child 5824 | 2e5835130d9a |
child 6247 | 6dfad55fd71c |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2004-2011 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 |
//////////////////// |
|
4438 | 29 |
uses uKeys, uTeams, uIO, uAI, uGears, uSound, uMobile, uVisualGears, uTypes, uVariables; |
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; |
5130
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
4976
diff
changeset
|
43 |
|
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
4976
diff
changeset
|
44 |
if (GameType = gmtDemo) then |
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
4976
diff
changeset
|
45 |
if isSpeed then Lag:= Lag * 10 |
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
4976
diff
changeset
|
46 |
else |
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
4976
diff
changeset
|
47 |
if cOnlyStats then Lag:= High(LongInt); |
5638
e35ba2a400d8
Try to avoid overlapping voices for major statements (not things like byebye or oof)
nemo
parents:
5357
diff
changeset
|
48 |
PlayNextVoice; |
89 | 49 |
i:= 1; |
50 |
while (GameState <> gsExit) and (i <= Lag) do |
|
51 |
begin |
|
351 | 52 |
if not CurrentTeam^.ExtDriven then |
4 | 53 |
begin |
602 | 54 |
if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
4 | 55 |
ProcessGears |
56 |
end else |
|
57 |
begin |
|
58 |
NetGetNextCmd; |
|
59 |
if isInLag then |
|
60 |
case GameType of |
|
4075 | 61 |
gmtNet: begin |
62 |
// just update the health bars |
|
63 |
AddVisualGear(0, 0, vgtTeamHealthSorter); |
|
64 |
break; |
|
65 |
end; |
|
4 | 66 |
gmtDemo: begin |
67 |
GameState:= gsExit; |
|
68 |
exit |
|
72 | 69 |
end; |
70 |
gmtSave: begin |
|
71 |
RestoreTeamsFromSave; |
|
519 | 72 |
SetBinds(CurrentTeam^.Binds); |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
73 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
72 | 74 |
isSoundEnabled:= isSEBackup; |
5809 | 75 |
PlayMusic; |
3902
3aac7ca07b0e
have Saves restart net when loaded, also resumes music
koda
parents:
3663
diff
changeset
|
76 |
GameType:= gmtLocal; |
4049
fe799b5d601b
fix issue 63 and draw health bars right away for savefiles
koda
parents:
4048
diff
changeset
|
77 |
AddVisualGear(0, 0, vgtTeamHealthSorter); |
5357
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5174
diff
changeset
|
78 |
AddVisualGear(0, 0, vgtSmoothWindBar); |
4048 | 79 |
{$IFDEF IPHONEOS}InitIPC;{$ENDIF} |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5167
diff
changeset
|
80 |
uMobile.SaveFinished(); |
72 | 81 |
end; |
4 | 82 |
end |
83 |
else ProcessGears |
|
84 |
end; |
|
89 | 85 |
inc(i) |
162 | 86 |
end |
4 | 87 |
end; |
88 |
||
89 |
end. |