hedgewars/uGame.pas
changeset 7687 c73fd8cfa7c0
parent 7670 9485b88f6a44
child 7837 3e031b3b33e6
equal deleted inserted replaced
7613:ce6ead3327b2 7687:c73fd8cfa7c0
    24 procedure DoGameTick(Lag: LongInt);
    24 procedure DoGameTick(Lag: LongInt);
    25 
    25 
    26 ////////////////////
    26 ////////////////////
    27     implementation
    27     implementation
    28 ////////////////////
    28 ////////////////////
    29 uses uInputHandler, 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 SDL13}, 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
    36 if isPaused then
    37     begin
    39     begin
    38     NetGetNextCmd; // its for the case of receiving "/say" message
    40     NetGetNextCmd; // its for the case of receiving "/say" message
    39     isInLag:= false;
    41     isInLag:= false;
    40     SendKeepAliveMessage(Lag)
    42     SendKeepAliveMessage(Lag)
    41     end;
    43     end;
    42 if Lag > 100 then
    44 if GameType <> gmtRecord then
    43     Lag:= 100
    45     begin
    44 else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then
    46     if Lag > 100 then
    45     Lag:= 2500;
    47         Lag:= 100
       
    48     else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then
       
    49         Lag:= 2500;
    46 
    50 
    47 if (GameType = gmtDemo) then 
    51     if (GameType = gmtDemo) then 
    48     if isSpeed then
    52         if isSpeed then
    49         begin
    53         begin
    50             i:= RealTicks-SpeedStart;
    54             i:= RealTicks-SpeedStart;
    51             if i < 2000 then Lag:= Lag*5
    55             if i < 2000 then Lag:= Lag*5
    52             else if i < 4000 then Lag:= Lag*10
    56             else if i < 4000 then Lag:= Lag*10
    53             else if i < 6000 then Lag:= Lag*20
    57             else if i < 6000 then Lag:= Lag*20
    54             else if i < 8000 then Lag:= Lag*40
    58             else if i < 8000 then Lag:= Lag*40
    55             else Lag:= Lag*80;
    59             else Lag:= Lag*80;
    56         end
    60         end
    57     else
    61         else
    58         if cOnlyStats then
    62             if cOnlyStats then
    59             Lag:= High(LongInt);
    63                 Lag:= High(LongInt);
       
    64     end;
    60 PlayNextVoice;
    65 PlayNextVoice;
    61 i:= 1;
    66 i:= 1;
    62 while (GameState <> gsExit) and (i <= Lag) do
    67 while (GameState <> gsExit) and (i <= Lag) do
    63     begin
    68     begin
    64     if not CurrentTeam^.ExtDriven then
    69     if not CurrentTeam^.ExtDriven then
    76                 gmtNet: begin
    81                 gmtNet: begin
    77                         // just update the health bars
    82                         // just update the health bars
    78                         AddVisualGear(0, 0, vgtTeamHealthSorter);
    83                         AddVisualGear(0, 0, vgtTeamHealthSorter);
    79                         break;
    84                         break;
    80                         end;
    85                         end;
    81                 gmtDemo: begin
    86                 gmtDemo, gmtRecord: begin
    82                         GameState:= gsExit;
    87                         GameState:= gsExit;
    83                         exit
    88                         exit
    84                         end;
    89                         end;
    85                 gmtSave: begin
    90                 gmtSave: begin
    86                         RestoreTeamsFromSave;
    91                         RestoreTeamsFromSave;
    87                         SetBinds(CurrentTeam^.Binds);
    92                         SetBinds(CurrentTeam^.Binds);
    88                         //CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos
    93                         StopMessages(gmLeft or gmRight or gmUp or gmDown);
    89                         ResetSound;   // restore previous sound state
    94                         ResetSound;   // restore previous sound state
    90                         PlayMusic;
    95                         PlayMusic;
    91                         GameType:= gmtLocal;
    96                         GameType:= gmtLocal;
    92                         AddVisualGear(0, 0, vgtTeamHealthSorter);
    97                         AddVisualGear(0, 0, vgtTeamHealthSorter);
    93                         AddVisualGear(0, 0, vgtSmoothWindBar);
    98                         AddVisualGear(0, 0, vgtSmoothWindBar);