hedgewars/hw.dpr
author unc0rr
Wed, 26 Oct 2005 17:26:39 +0000
changeset 18 d49c23eba8ba
parent 10 edf56dca1587
child 23 16322d14f068
permissions -rw-r--r--
Start to write QT frontend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     1
(*
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     2
 * Hedgewars, a worms-like game
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     3
 * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     4
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     6
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
     9
 * with the Software without restriction, including without limitation the
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    12
 * furnished to do so, subject to the following conditions:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    13
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    15
 *    this list of conditions and the following disclaimer.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    18
 *    and/or other materials provided with the distribution.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    20
 *    derived from this software without specific prior written permission.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    21
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    32
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    33
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    34
program hedgewars;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    35
{$APPTYPE CONSOLE}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    36
uses
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    37
  SDLh,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    38
  uConsts in 'uConsts.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    39
  uGame in 'uGame.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    40
  uMisc in 'uMisc.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    41
  uStore in 'uStore.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    42
  uWorld in 'uWorld.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    43
  uIO in 'uIO.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    44
  uGears in 'uGears.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    45
  uConsole in 'uConsole.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    46
  uKeys in 'uKeys.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    47
  uTeams in 'uTeams.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    48
  uSound in 'uSound.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    49
  uRandom in 'uRandom.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    50
  uAI in 'uAI.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    51
  uAIActions in 'uAIActions.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    52
  uAIMisc in 'uAIMisc.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    53
  uAIAmmoTests in 'uAIAmmoTests.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    54
  uCollisions in 'uCollisions.pas',
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    55
  uLand in 'uLand.pas';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    56
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    57
{$INCLUDE options.inc}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    58
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    59
// also: GSHandlers.inc
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    60
//       CCHandlers.inc
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    61
//       HHHandlers.inc
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    62
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    63
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    64
procedure OnDestroy; forward;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    65
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    66
////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    67
procedure DoTimer(Lag: integer);  // - обработка таймера
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    68
const cCons: boolean = false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    69
var s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    70
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    71
case GameState of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    72
   gsLandGen: begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    73
              if (GameFlags and gfForts) = 0 then GenLandSurface
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    74
                                             else MakeFortsMap;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    75
              GameState:= gsStart;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    76
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    77
     gsStart: begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    78
              AssignHHCoords;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 4
diff changeset
    79
              AddMiscGears;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    80
              AdjustColor(cColorNearBlack);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    81
              AdjustColor(cWhiteColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    82
              StoreLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    83
              AdjustColor(cConsoleSplitterColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    84
              ResetKbd;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    85
              SoundLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    86
              PlayMusic;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    87
              GameState:= gsGame
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    88
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    89
     gsGame : begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    90
              ProcessKbd;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    91
              DoGameTick(Lag);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    92
              DrawWorld(Lag, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    93
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    94
   gsConsole: begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    95
              DoGameTick(Lag);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    96
              DrawWorld(Lag, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    97
              DrawConsole(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    98
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    99
     gsExit : begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   100
              OnDestroy;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   101
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   102
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   103
SDL_Flip(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   104
if flagMakeCapture then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   105
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   106
   flagMakeCapture:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   107
   s:= 'hw_' + ParamStr(5) + '_' + inttostr(GameTicks) + '.bmp';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   108
   WriteLnToConsole('Saving ' + s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   109
   SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(PChar(s), 'wb'), 1)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   110
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   111
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   112
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   113
////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   114
procedure OnDestroy;   // - очищаем память
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   115
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   116
{$IFDEF DEBUGFILE}AddFileLog('Freeing resources...');{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   117
if isSoundEnabled then ReleaseSound;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   118
StoreRelease;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   119
CloseIPC;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   120
TTF_Quit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   121
SDL_Quit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   122
halt
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   123
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   124
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   125
///////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   126
procedure MainLoop;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   127
var PrevTime,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   128
    CurrTime: Cardinal;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   129
    event: TSDL_Event;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   130
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   131
PrevTime:= SDL_GetTicks;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   132
repeat
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   133
while SDL_PollEvent(@event) <> 0 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   134
      case event.type_ of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   135
           SDL_KEYDOWN: case GameState of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   136
                             gsGame: if event.key.keysym.sym = 96 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   137
                                        begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   138
                                        cConsoleYAdd:= cConsoleHeight;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   139
                                        GameState:= gsConsole
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   140
                                        end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   141
                          gsConsole: KeyPressConsole(event.key.keysym.sym);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   142
                             end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   143
           SDL_QUITEV: isTerminated:= true
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   144
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   145
CurrTime:= SDL_GetTicks;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   146
if PrevTime + cTimerInterval <= CurrTime then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   147
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   148
   DoTimer(CurrTime - PrevTime);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   149
   PrevTime:= CurrTime
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   150
   end else {sleep(1)};
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   151
IPCCheckSock
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   152
until isTerminated
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   153
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   154
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   155
////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   156
procedure GetParams;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   157
var c: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   158
{$IFDEF DEBUGFILE}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   159
    i: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   160
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   161
for i:= 0 to ParamCount do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   162
    AddFileLog(inttostr(i) + ': ' + ParamStr(i));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   163
{$ELSE}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   164
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   165
{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   166
if ParamCount=6 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   167
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   168
   //TODO: сделать передачу через IPC
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   169
   val(ParamStr(1), cScreenWidth, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   170
   val(ParamStr(2), cScreenHeight, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   171
   Pathz[ptThemeCurrent]:= Pathz[ptThemes] + ParamStr(3)+'/';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   172
   val(ParamStr(4), ipcPort, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   173
   SetRandomParams(ParamStr(5), rndfillstr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   174
   cFullScreen:= ParamStr(6)[1] = '1'
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   175
   end else OutError(errmsgShouldntRun, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   176
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   177
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   178
procedure ShowMainWindow;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   179
var flags: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   180
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   181
flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   182
if cFullScreen then flags:= flags or SDL_FULLSCREEN
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   183
               else SDL_WM_SetCaption('Hedgewars', nil);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   184
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   185
TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   186
PixelFormat:= SDLPrimSurface.format;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   187
SDL_ShowCursor(0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   188
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   189
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   190
/////////////////////////////// m a i n ////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   191
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   192
{$INCLUDE revision.inc}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   193
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   194
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   195
WriteLnToConsole('HedgeWars 0.1, svn '+cRevision);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   196
WriteLnToConsole('  -= by unC0Rr =-  ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   197
GetParams;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   198
Randomize;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   199
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   200
WriteToConsole('Init SDL... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   201
SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   202
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   203
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   204
WriteToConsole('Init SDL_ttf... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   205
SDLTry(TTF_Init >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   206
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   207
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   208
ShowMainWindow;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   209
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   210
InitKbdKeyTable;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   211
InitIPC;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   212
WriteLnToConsole(msgGettingConfig);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   213
SendIPCAndWaitReply('C');        // запрос конфига игры
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   214
InitTeams;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   215
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   216
if isSoundEnabled then InitSound;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   217
InitWorld;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   218
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   219
StoreInit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   220
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   221
isDeveloperMode:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   222
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   223
MainLoop
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   224
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   225
end.