22 interface |
22 interface |
23 |
23 |
24 procedure DoGameTick(Lag: LongInt); |
24 procedure DoGameTick(Lag: LongInt); |
25 |
25 |
26 //////////////////// |
26 //////////////////// |
27 implementation |
27 implementation |
28 //////////////////// |
28 //////////////////// |
29 uses uKeys, uTeams, uIO, uAI, uGears, uSound, uMobile, uVisualGears, uTypes, uVariables{$IFDEF SDL13}, uTouch{$ENDIF}; |
29 uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uMobile, |
|
30 uVisualGears, uTypes, uVariables, uCommands, uConsts |
|
31 {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF}; |
30 |
32 |
31 procedure DoGameTick(Lag: LongInt); |
33 procedure DoGameTick(Lag: LongInt); |
32 var i: LongInt; |
34 var i: LongInt; |
33 begin |
35 begin |
34 if isPaused then exit; |
36 if isPaused then |
|
37 exit; |
35 if (not CurrentTeam^.ExtDriven) then |
38 if (not CurrentTeam^.ExtDriven) then |
36 begin |
39 begin |
37 NetGetNextCmd; // its for the case of receiving "/say" message |
40 NetGetNextCmd; // its for the case of receiving "/say" message |
38 isInLag:= false; |
41 isInLag:= false; |
39 SendKeepAliveMessage(Lag) |
42 SendKeepAliveMessage(Lag) |
40 end; |
43 end; |
41 if Lag > 100 then Lag:= 100 |
44 if GameType <> gmtRecord then |
42 else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; |
45 begin |
|
46 if Lag > 100 then |
|
47 Lag:= 100 |
|
48 else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then |
|
49 Lag:= 2500; |
43 |
50 |
44 if (GameType = gmtDemo) then |
51 if (GameType = gmtDemo) then |
45 if isSpeed then Lag:= Lag * 10 |
52 if isSpeed then |
46 else |
53 begin |
47 if cOnlyStats then Lag:= High(LongInt); |
54 i:= RealTicks-SpeedStart; |
|
55 if i < 2000 then Lag:= Lag*5 |
|
56 else if i < 4000 then Lag:= Lag*10 |
|
57 else if i < 6000 then Lag:= Lag*20 |
|
58 else if i < 8000 then Lag:= Lag*40 |
|
59 else Lag:= Lag*80; |
|
60 end |
|
61 else |
|
62 if cOnlyStats then |
|
63 Lag:= High(LongInt); |
|
64 end; |
48 PlayNextVoice; |
65 PlayNextVoice; |
49 i:= 1; |
66 i:= 1; |
50 while (GameState <> gsExit) and (i <= Lag) do |
67 while (GameState <> gsExit) and (i <= Lag) do |
51 begin |
68 begin |
52 if not CurrentTeam^.ExtDriven then |
69 if not CurrentTeam^.ExtDriven then |
53 begin |
70 begin |
54 if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
71 if CurrentHedgehog^.BotLevel <> 0 then |
55 ProcessGears; |
72 ProcessBot; |
56 {$IFDEF SDL13}ProcessTouch;{$ENDIF} |
73 ProcessGears; |
57 end else |
74 {$IFDEF SDL13}ProcessTouch;{$ENDIF} |
58 begin |
75 end |
59 NetGetNextCmd; |
76 else |
60 if isInLag then |
77 begin |
61 case GameType of |
78 NetGetNextCmd; |
|
79 if isInLag then |
|
80 case GameType of |
62 gmtNet: begin |
81 gmtNet: begin |
63 // just update the health bars |
82 // just update the health bars |
64 AddVisualGear(0, 0, vgtTeamHealthSorter); |
83 AddVisualGear(0, 0, vgtTeamHealthSorter); |
65 break; |
84 break; |
66 end; |
85 end; |
67 gmtDemo: begin |
86 gmtDemo, gmtRecord: begin |
68 GameState:= gsExit; |
87 GameState:= gsExit; |
69 exit |
88 exit |
70 end; |
89 end; |
71 gmtSave: begin |
90 gmtSave: begin |
72 RestoreTeamsFromSave; |
91 RestoreTeamsFromSave; |
73 SetBinds(CurrentTeam^.Binds); |
92 SetBinds(CurrentTeam^.Binds); |
74 //CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
93 StopMessages(gmLeft or gmRight or gmUp or gmDown); |
75 isSoundEnabled:= isSEBackup; |
94 ResetSound; // restore previous sound state |
76 PlayMusic; |
95 PlayMusic; |
77 GameType:= gmtLocal; |
96 GameType:= gmtLocal; |
78 AddVisualGear(0, 0, vgtTeamHealthSorter); |
97 AddVisualGear(0, 0, vgtTeamHealthSorter); |
79 AddVisualGear(0, 0, vgtSmoothWindBar); |
98 AddVisualGear(0, 0, vgtSmoothWindBar); |
80 {$IFDEF IPHONEOS}InitIPC;{$ENDIF} |
99 {$IFDEF IPHONEOS}InitIPC;{$ENDIF} |
81 uMobile.SaveLoadingEnded(); |
100 uMobile.SaveLoadingEnded(); |
82 end; |
101 end; |
83 end |
102 end |
84 else ProcessGears |
103 else ProcessGears |
85 end; |
104 end; |
86 inc(i) |
105 inc(i) |
87 end |
106 end |
88 end; |
107 end; |
89 |
108 |
90 end. |
109 end. |