hedgewars/hw.dpr
author unc0rr
Tue, 10 Jan 2006 19:53:18 +0000
changeset 43 e297fea1a2f3
parent 37 2b7f2a43b999
permissions -rw-r--r--
- Removed dark pixels on the corners of health case - Cleaned up dynamite code - Dynamite sprite - Frontend shows error messages from engine (except IPC-related :) ) - changed IPC-related stuff in 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',
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 10
diff changeset
    55
  uLand in 'uLand.pas',
24
79c411363184 Add theme objects to land
unc0rr
parents: 23
diff changeset
    56
  uLandTemplates in 'uLandTemplates.pas',
79c411363184 Add theme objects to land
unc0rr
parents: 23
diff changeset
    57
  uLandObjects in 'uLandObjects.pas';
4
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
{$INCLUDE options.inc}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    60
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    61
// also: GSHandlers.inc
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    62
//       CCHandlers.inc
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    63
//       HHHandlers.inc
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    64
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
procedure OnDestroy; forward;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    67
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    68
////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    69
procedure DoTimer(Lag: integer);  // - обработка таймера
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    70
const cCons: boolean = false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    71
var s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    72
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    73
case GameState of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    74
   gsLandGen: begin
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 24
diff changeset
    75
              GenMap;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    76
              GameState:= gsStart;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    77
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    78
     gsStart: begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    79
              AssignHHCoords;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 4
diff changeset
    80
              AddMiscGears;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    81
              AdjustColor(cColorNearBlack);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    82
              AdjustColor(cWhiteColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    83
              StoreLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    84
              AdjustColor(cConsoleSplitterColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    85
              ResetKbd;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    86
              SoundLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    87
              PlayMusic;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    88
              GameState:= gsGame
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    89
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    90
     gsGame : begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    91
              ProcessKbd;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    92
              DoGameTick(Lag);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    93
              DrawWorld(Lag, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    94
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    95
   gsConsole: begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    96
              DoGameTick(Lag);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    97
              DrawWorld(Lag, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    98
              DrawConsole(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
    99
              end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   100
     gsExit : begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   101
              OnDestroy;
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
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   104
SDL_Flip(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   105
if flagMakeCapture then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   106
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   107
   flagMakeCapture:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   108
   s:= 'hw_' + ParamStr(5) + '_' + inttostr(GameTicks) + '.bmp';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   109
   WriteLnToConsole('Saving ' + s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   110
   SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(PChar(s), 'wb'), 1)
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
end;
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
////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   115
procedure OnDestroy;   // - очищаем память
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   116
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   117
{$IFDEF DEBUGFILE}AddFileLog('Freeing resources...');{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   118
if isSoundEnabled then ReleaseSound;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   119
StoreRelease;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   120
CloseIPC;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   121
TTF_Quit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   122
SDL_Quit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   123
halt
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   124
end;
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
///////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   127
procedure MainLoop;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   128
var PrevTime,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   129
    CurrTime: Cardinal;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   130
    event: TSDL_Event;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   131
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   132
PrevTime:= SDL_GetTicks;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   133
repeat
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   134
while SDL_PollEvent(@event) <> 0 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   135
      case event.type_ of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   136
           SDL_KEYDOWN: case GameState of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   137
                             gsGame: if event.key.keysym.sym = 96 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   138
                                        begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   139
                                        cConsoleYAdd:= cConsoleHeight;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   140
                                        GameState:= gsConsole
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   141
                                        end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   142
                          gsConsole: KeyPressConsole(event.key.keysym.sym);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   143
                             end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   144
           SDL_QUITEV: isTerminated:= true
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   145
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   146
CurrTime:= SDL_GetTicks;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   147
if PrevTime + cTimerInterval <= CurrTime then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   148
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   149
   DoTimer(CurrTime - PrevTime);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   150
   PrevTime:= CurrTime
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   151
   end else {sleep(1)};
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   152
IPCCheckSock
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   153
until isTerminated
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   154
end;
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
////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   157
procedure GetParams;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   158
var c: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   159
{$IFDEF DEBUGFILE}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   160
    i: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   161
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   162
for i:= 0 to ParamCount do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   163
    AddFileLog(inttostr(i) + ': ' + ParamStr(i));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   164
{$ELSE}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   165
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   166
{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   167
if ParamCount=6 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   168
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   169
   //TODO: сделать передачу через IPC
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   170
   val(ParamStr(1), cScreenWidth, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   171
   val(ParamStr(2), cScreenHeight, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   172
   Pathz[ptThemeCurrent]:= Pathz[ptThemes] + ParamStr(3)+'/';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   173
   val(ParamStr(4), ipcPort, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   174
   SetRandomParams(ParamStr(5), rndfillstr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   175
   cFullScreen:= ParamStr(6)[1] = '1'
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   176
   end else OutError(errmsgShouldntRun, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   177
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   178
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   179
procedure ShowMainWindow;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   180
var flags: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   181
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   182
flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   183
if cFullScreen then flags:= flags or SDL_FULLSCREEN
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   184
               else SDL_WM_SetCaption('Hedgewars', nil);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   185
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   186
TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   187
PixelFormat:= SDLPrimSurface.format;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   188
SDL_ShowCursor(0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   189
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   190
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   191
/////////////////////////////// m a i n ////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   192
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   193
{$INCLUDE revision.inc}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   194
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   195
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   196
WriteLnToConsole('HedgeWars 0.1, svn '+cRevision);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   197
WriteLnToConsole('  -= by unC0Rr =-  ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   198
GetParams;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   199
Randomize;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   200
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   201
WriteToConsole('Init SDL... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   202
SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   203
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   204
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   205
WriteToConsole('Init SDL_ttf... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   206
SDLTry(TTF_Init >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   207
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   208
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   209
ShowMainWindow;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   210
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   211
InitKbdKeyTable;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   212
InitIPC;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   213
WriteLnToConsole(msgGettingConfig);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   214
SendIPCAndWaitReply('C');        // запрос конфига игры
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   215
InitTeams;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   216
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   217
if isSoundEnabled then InitSound;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   218
InitWorld;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   219
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   220
StoreInit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   221
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   222
isDeveloperMode:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   223
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   224
MainLoop
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   225
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 2
diff changeset
   226
end.