hedgewars/uGame.pas
author unc0rr
Sat, 18 Nov 2006 18:17:03 +0000
changeset 248 aab204fe5061
parent 196 993cf173218b
child 281 5b483aa9f2ab
permissions -rw-r--r--
Place QLabel with developers info on the QScrollArea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
     1
(*
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
     2
 * Hedgewars, a worms-like game
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
     3
 * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
     4
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
    12
 * GNU General Public License for more details.
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 167
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    17
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    18
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    19
unit uGame;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    20
interface
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    21
{$INCLUDE options.inc}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    22
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    23
procedure DoGameTick(Lag: integer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    24
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    25
////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    26
   implementation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    27
////////////////////
72
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    28
uses uMisc, uConsts, uWorld, uKeys, uTeams, uIO, uAI, uGears, uConsole;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    29
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    30
procedure DoGameTick(Lag: integer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    31
const SendEmptyPacketTicks: LongWord = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    32
var i: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    33
begin
167
805fa9a27e9e "Trusted" binds
unc0rr
parents: 162
diff changeset
    34
if not CurrentTeam.ExtDriven then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    35
   begin
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
    36
   NetGetNextCmd; // its for the case when receiving "/say" message
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
    37
   isInLag:= false;
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
    38
   inc(SendEmptyPacketTicks, Lag);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    39
   if SendEmptyPacketTicks >= cSendEmptyPacketTime then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    40
      begin
143
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
    41
      SendIPC('+');
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    42
      SendEmptyPacketTicks:= 0
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
    43
      end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    44
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    45
72
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    46
if Lag > 100 then Lag:= 100
109
ab0340f580c2 - Initialize translations earlier
unc0rr
parents: 108
diff changeset
    47
else if GameType = gmtSave then Lag:= 2500;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    48
89
f9db56409a86 - Fix various bugs
unc0rr
parents: 79
diff changeset
    49
i:= 1;
f9db56409a86 - Fix various bugs
unc0rr
parents: 79
diff changeset
    50
while (GameState <> gsExit) and (i <= Lag) do
f9db56409a86 - Fix various bugs
unc0rr
parents: 79
diff changeset
    51
    begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    52
    if not CurrentTeam.ExtDriven then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    53
       begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    54
       with CurrentTeam^ do
191
a03c2d037e24 Bots are in the same thread as game. Fixes FreePascal issues.
unc0rr
parents: 183
diff changeset
    55
           if Hedgehogs[CurrHedgehog].BotLevel <> 0 then ProcessBot(Frames);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    56
       ProcessGears
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    57
       end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    58
       begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    59
       NetGetNextCmd;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    60
       if isInLag then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    61
          case GameType of
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
    62
                gmtNet: break;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    63
               gmtDemo: begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    64
                        GameState:= gsExit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    65
                        exit
72
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    66
                        end;
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    67
               gmtSave: begin
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    68
                        RestoreTeamsFromSave;
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    69
                        isSoundEnabled:= isSEBackup;
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    70
                        GameType:= gmtLocal
aeb2ac1878dc Basic save support in engine
unc0rr
parents: 32
diff changeset
    71
                        end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    72
               end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    73
          else ProcessGears
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    74
       end;
89
f9db56409a86 - Fix various bugs
unc0rr
parents: 79
diff changeset
    75
    inc(i)
162
4822f6face35 Ammo menu now works!
unc0rr
parents: 143
diff changeset
    76
    end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    77
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    78
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 3
diff changeset
    79
end.