hedgewars/hwengine.pas
changeset 6580 6155187bf599
parent 6415 af2047bb4f70
child 6598 fa518383563b
equal deleted inserted replaced
6579:fc52f7c22c9b 6580:6155187bf599
    53 begin
    53 begin
    54     if isPaused = false then
    54     if isPaused = false then
    55         inc(RealTicks, Lag);
    55         inc(RealTicks, Lag);
    56 
    56 
    57     case GameState of
    57     case GameState of
    58         gsLandGen: begin
    58         gsLandGen:
    59                 GenMap;
    59             begin
    60                 ParseCommand('sendlanddigest', true);
    60             GenMap;
    61                 GameState:= gsStart;
    61             ParseCommand('sendlanddigest', true);
       
    62             GameState:= gsStart;
       
    63             end;
       
    64         gsStart:
       
    65             begin
       
    66             if HasBorder then
       
    67                 DisableSomeWeapons;
       
    68             AddClouds;
       
    69             AddFlakes;
       
    70             AssignHHCoords;
       
    71             AddMiscGears;
       
    72             StoreLoad;
       
    73             InitWorld;
       
    74             ResetKbd;
       
    75             SoundLoad;
       
    76             if GameType = gmtSave then
       
    77                 begin
       
    78                 isSEBackup:= isSoundEnabled;
       
    79                 isSoundEnabled:= false
    62                 end;
    80                 end;
    63         gsStart: begin
    81             FinishProgress;
    64                 if HasBorder then DisableSomeWeapons;
    82             PlayMusic;
    65                 AddClouds;
    83             SetScale(zoom);
    66                 AddFlakes;
    84             ScriptCall('onGameStart');
    67                 AssignHHCoords;
    85             GameState:= gsGame;
    68                 AddMiscGears;
    86             end;
    69                 StoreLoad;
    87         gsConfirm, gsGame:
    70                 InitWorld;
    88             begin
    71                 ResetKbd;
    89             DrawWorld(Lag); // never place between ProcessKbd and DoGameTick - bugs due to /put cmd and isCursorVisible
    72                 SoundLoad;
    90             ProcessKbd;
    73                 if GameType = gmtSave then
    91             if not isPaused then
    74                     begin
    92                 begin
    75                     isSEBackup:= isSoundEnabled;
    93                 DoGameTick(Lag);
    76                     isSoundEnabled:= false
    94                 ProcessVisualGears(Lag);
    77                     end;
       
    78                 FinishProgress;
       
    79                 PlayMusic;
       
    80                 SetScale(zoom);
       
    81                 ScriptCall('onGameStart');
       
    82                 GameState:= gsGame;
       
    83                 end;
    95                 end;
    84         gsConfirm,
    96             end;
    85         gsGame: begin
    97         gsChat:
    86                 DrawWorld(Lag); // never place between ProcessKbd and DoGameTick - bugs due to /put cmd and isCursorVisible
    98             begin
    87                 ProcessKbd;
    99             DrawWorld(Lag);
    88                 if not isPaused then
   100             if not isPaused then
    89                     begin
   101                 begin
    90                     DoGameTick(Lag);
   102                 DoGameTick(Lag);
    91                     ProcessVisualGears(Lag);
   103                 ProcessVisualGears(Lag);
    92                     end;
       
    93                 end;
   104                 end;
    94         gsChat: begin
   105             end;
    95                 DrawWorld(Lag);
   106         gsExit:
    96                 if not isPaused then
   107             begin
    97                     begin
   108             isTerminated:= true;
    98                     DoGameTick(Lag);
   109             end;
    99                     ProcessVisualGears(Lag);
   110         gsSuspend:
   100                     end;
   111             exit;
   101                 end;
   112             end;
   102         gsExit: begin
       
   103                 isTerminated:= true;
       
   104                 end;
       
   105         gsSuspend: exit;
       
   106         end;
       
   107 
   113 
   108 {$IFDEF SDL13}
   114 {$IFDEF SDL13}
   109     SDL_GL_SwapWindow(SDLwindow);
   115     SDL_GL_SwapWindow(SDLwindow);
   110 {$ELSE}
   116 {$ELSE}
   111     SDL_GL_SwapBuffers();
   117     SDL_GL_SwapBuffers();
   112 {$ENDIF}
   118 {$ENDIF}
   113 
   119 
   114     if flagMakeCapture then
   120     if flagMakeCapture then
   115     begin
   121         begin
   116         flagMakeCapture:= false;
   122         flagMakeCapture:= false;
   117         s:= 'hw_' + FormatDateTime('YYYY-MM-DD_HH-mm-ss', Now()) + inttostr(GameTicks);
   123         s:= 'hw_' + FormatDateTime('YYYY-MM-DD_HH-mm-ss', Now()) + inttostr(GameTicks);
   118 
   124 
   119         playSound(sndShutter);
   125         playSound(sndShutter);
   120         if MakeScreenshot(s) then WriteLnToConsole('Screenshot saved: ' + s)
   126         
   121         else begin
   127         if MakeScreenshot(s) then
       
   128             WriteLnToConsole('Screenshot saved: ' + s)
       
   129         else
       
   130             begin
   122             WriteLnToConsole('Screenshot failed.');
   131             WriteLnToConsole('Screenshot failed.');
   123             AddChatString(#5 + 'screen capture failed (lack of memory or write permissions)');
   132             AddChatString(#5 + 'screen capture failed (lack of memory or write permissions)');
   124             end
   133             end
   125     end;
   134         end;
   126 end;
   135 end;
   127 
   136 
   128 ////////////////////
   137 ////////////////////
   129 procedure OnDestroy;
   138 procedure OnDestroy;
   130 begin
   139 begin
   160         SDL_PumpEvents();
   169         SDL_PumpEvents();
   161         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL13}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
   170         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL13}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
   162         begin
   171         begin
   163             case event.type_ of
   172             case event.type_ of
   164 {$IFDEF SDL13}
   173 {$IFDEF SDL13}
   165                 SDL_KEYDOWN: if GameState = gsChat then
   174                 SDL_KEYDOWN:
       
   175                 if GameState = gsChat then
   166                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
   176                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
   167                     KeyPressChat(event.key.keysym.sym);
   177                     KeyPressChat(event.key.keysym.sym);
       
   178                     
   168                 SDL_WINDOWEVENT:
   179                 SDL_WINDOWEVENT:
   169                     if event.window.event = SDL_WINDOWEVENT_SHOWN then
   180                     if event.window.event = SDL_WINDOWEVENT_SHOWN then
   170                         begin
   181                         begin
   171                         cHasFocus:= true;
   182                         cHasFocus:= true;
   172                         onFocusStateChanged()
   183                         onFocusStateChanged()
   187                         cNewScreenWidth:= max(2 * (event.window.data1 div 2), cMinScreenWidth);
   198                         cNewScreenWidth:= max(2 * (event.window.data1 div 2), cMinScreenWidth);
   188                         cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight);
   199                         cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight);
   189                         cScreenResizeDelay:= RealTicks+500;
   200                         cScreenResizeDelay:= RealTicks+500;
   190                         *)
   201                         *)
   191                         end;
   202                         end;
   192                 SDL_FINGERMOTION: onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId);
   203                         
   193                 SDL_FINGERDOWN: onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
   204                 SDL_FINGERMOTION:
   194                 SDL_FINGERUP: onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
   205                     onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId);
       
   206                 
       
   207                 SDL_FINGERDOWN:
       
   208                     onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
       
   209                 
       
   210                 SDL_FINGERUP:
       
   211                     onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
   195 {$ELSE}
   212 {$ELSE}
   196                 SDL_KEYDOWN: if GameState = gsChat then
   213                 SDL_KEYDOWN:
   197                     KeyPressChat(event.key.keysym.unicode);
   214                     if GameState = gsChat then
   198                 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true;
   215                         KeyPressChat(event.key.keysym.unicode);
   199                 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true;
   216                     
       
   217                 SDL_MOUSEBUTTONDOWN:
       
   218                     if event.button.button = SDL_BUTTON_WHEELDOWN then
       
   219                         wheelDown:= true;
       
   220                 
       
   221                 SDL_MOUSEBUTTONUP:
       
   222                     if event.button.button = SDL_BUTTON_WHEELUP then
       
   223                         wheelUp:= true;
       
   224                     
   200                 SDL_ACTIVEEVENT:
   225                 SDL_ACTIVEEVENT:
   201                     if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
   226                     if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
   202                         begin
   227                         begin
   203                         prevFocusState:= cHasFocus;
   228                         prevFocusState:= cHasFocus;
   204                         cHasFocus:= event.active.gain = 1;
   229                         cHasFocus:= event.active.gain = 1;
   205                         if prevFocusState xor cHasFocus then
   230                         if prevFocusState xor cHasFocus then
   206                             onFocusStateChanged()
   231                             onFocusStateChanged()
   207                         end;
   232                         end;
   208                 SDL_VIDEORESIZE: begin
   233                         
       
   234                 SDL_VIDEORESIZE:
       
   235                     begin
   209                     // using lower values than cMinScreenWidth or cMinScreenHeight causes widget overlap and off-screen widget parts
   236                     // using lower values than cMinScreenWidth or cMinScreenHeight causes widget overlap and off-screen widget parts
   210                     // Change by sheepluva:
   237                     // Change by sheepluva:
   211                     // Let's only use even numbers for custom width/height since I ran into scaling issues with odd width values.
   238                     // Let's only use even numbers for custom width/height since I ran into scaling issues with odd width values.
   212                     // Maybe just fixes the symptom not the actual cause(?), I'm too tired to find out :P
   239                     // Maybe just fixes the symptom not the actual cause(?), I'm too tired to find out :P
   213                     cNewScreenWidth:= max(2 * (event.resize.w div 2), cMinScreenWidth);
   240                     cNewScreenWidth:= max(2 * (event.resize.w div 2), cMinScreenWidth);
   214                     cNewScreenHeight:= max(2 * (event.resize.h div 2), cMinScreenHeight);
   241                     cNewScreenHeight:= max(2 * (event.resize.h div 2), cMinScreenHeight);
   215                     cScreenResizeDelay:= RealTicks+500;
   242                     cScreenResizeDelay:= RealTicks+500;
   216                     end;
   243                     end;
   217 {$ENDIF}
   244 {$ENDIF}
   218                 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
   245                 SDL_JOYAXISMOTION:
   219                 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value);
   246                     ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
   220                 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true);
   247                 SDL_JOYHATMOTION:
   221                 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false);
   248                     ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value);
   222                 SDL_QUITEV: isTerminated:= true
   249                 SDL_JOYBUTTONDOWN:
   223             end; //end case event.type_ of
   250                     ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true);
   224         end; //end while SDL_PollEvent(@event) <> 0 do
   251                 SDL_JOYBUTTONUP:
   225 
   252                     ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false);
   226         if (cScreenResizeDelay <> 0) and (cScreenResizeDelay < RealTicks) and ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then
   253                 SDL_QUITEV:
       
   254                     isTerminated:= true
       
   255         end; //end case event.type_ of
       
   256     end; //end while SDL_PollEvent(@event) <> 0 do
       
   257 
       
   258         if (cScreenResizeDelay <> 0) and (cScreenResizeDelay < RealTicks)
       
   259         and ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then
   227             begin
   260             begin
   228             cScreenResizeDelay:= 0;
   261             cScreenResizeDelay:= 0;
   229             cScreenWidth:= cNewScreenWidth;
   262             cScreenWidth:= cNewScreenWidth;
   230             cScreenHeight:= cNewScreenHeight;
   263             cScreenHeight:= cNewScreenHeight;
   231 
   264 
   249     end;
   282     end;
   250 end;
   283 end;
   251 
   284 
   252 ///////////////
   285 ///////////////
   253 procedure Game{$IFDEF HWLIBRARY}(gameArgs: PPChar); cdecl; export{$ENDIF};
   286 procedure Game{$IFDEF HWLIBRARY}(gameArgs: PPChar); cdecl; export{$ENDIF};
   254 var p: TPathType;
   287 var
       
   288     p: TPathType;
   255     s: shortstring;
   289     s: shortstring;
   256     i: LongInt;
   290     i: LongInt;
   257 begin
   291 begin
   258 {$IFDEF HWLIBRARY}
   292 {$IFDEF HWLIBRARY}
   259     cBits:= 32;
   293     cBits:= 32;
   263     val(gameArgs[0], ipcPort);
   297     val(gameArgs[0], ipcPort);
   264     val(gameArgs[1], cScreenWidth);
   298     val(gameArgs[1], cScreenWidth);
   265     val(gameArgs[2], cScreenHeight);
   299     val(gameArgs[2], cScreenHeight);
   266     val(gameArgs[3], cReducedQuality);
   300     val(gameArgs[3], cReducedQuality);
   267     cLocaleFName:= gameArgs[4];
   301     cLocaleFName:= gameArgs[4];
   268     if (Length(cLocaleFName) > 6) then cLocale := Copy(cLocaleFName,1,5)
   302     
   269     else cLocale := Copy(cLocaleFName,1,2);
   303     if (Length(cLocaleFName) > 6) then
       
   304         cLocale := Copy(cLocaleFName,1,5)
       
   305     else
       
   306         cLocale := Copy(cLocaleFName,1,2);
       
   307         
   270     UserNick:= gameArgs[5];
   308     UserNick:= gameArgs[5];
   271     isSoundEnabled:= gameArgs[6] = '1';
   309     isSoundEnabled:= gameArgs[6] = '1';
   272     isMusicEnabled:= gameArgs[7] = '1';
   310     isMusicEnabled:= gameArgs[7] = '1';
   273     cAltDamage:= gameArgs[8] = '1';
   311     cAltDamage:= gameArgs[8] = '1';
   274     PathPrefix:= gameArgs[9];
   312     PathPrefix:= gameArgs[9];
   283 
   321 
   284     initEverything(true);
   322     initEverything(true);
   285     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
   323     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
   286     AddFileLog('Prefix: "' + PathPrefix +'"');
   324     AddFileLog('Prefix: "' + PathPrefix +'"');
   287     AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
   325     AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
       
   326     
   288     for i:= 0 to ParamCount do
   327     for i:= 0 to ParamCount do
   289         AddFileLog(inttostr(i) + ': ' + ParamStr(i));
   328         AddFileLog(inttostr(i) + ': ' + ParamStr(i));
   290 
   329 
   291     for p:= Succ(Low(TPathType)) to High(TPathType) do
   330     for p:= Succ(Low(TPathType)) to High(TPathType) do
   292         if (p <> ptMapCurrent) and (p <> ptData) then UserPathz[p]:= UserPathPrefix + '/Data/' + Pathz[p];
   331         if (p <> ptMapCurrent) and (p <> ptData) then
       
   332             UserPathz[p]:= UserPathPrefix + '/Data/' + Pathz[p];
   293 
   333 
   294     UserPathz[ptData]:= UserPathPrefix + '/Data';
   334     UserPathz[ptData]:= UserPathPrefix + '/Data';
   295 
   335 
   296     for p:= Succ(Low(TPathType)) to High(TPathType) do
   336     for p:= Succ(Low(TPathType)) to High(TPathType) do
   297         if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p];
   337         if p <> ptMapCurrent then
       
   338             Pathz[p]:= PathPrefix + '/' + Pathz[p];
   298 
   339 
   299     WriteToConsole('Init SDL... ');
   340     WriteToConsole('Init SDL... ');
   300     SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
   341     SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
   301     WriteLnToConsole(msgOK);
   342     WriteLnToConsole(msgOK);
   302 
   343 
   306     WriteToConsole('Init SDL_ttf... ');
   347     WriteToConsole('Init SDL_ttf... ');
   307     SDLTry(TTF_Init() <> -1, true);
   348     SDLTry(TTF_Init() <> -1, true);
   308     WriteLnToConsole(msgOK);
   349     WriteLnToConsole(msgOK);
   309 
   350 
   310     // show main window
   351     // show main window
   311     if cFullScreen then ParseCommand('fullscr 1', true)
   352     if cFullScreen then
   312     else ParseCommand('fullscr 0', true);
   353         ParseCommand('fullscr 1', true)
       
   354     else
       
   355         ParseCommand('fullscr 0', true);
   313 
   356 
   314     ControllerInit(); // has to happen before InitKbdKeyTable to map keys
   357     ControllerInit(); // has to happen before InitKbdKeyTable to map keys
   315     InitKbdKeyTable();
   358     InitKbdKeyTable();
   316     AddProgress();
   359     AddProgress();
   317 
   360 
   360     MainLoop();
   403     MainLoop();
   361     // clean up SDL and GL context
   404     // clean up SDL and GL context
   362     OnDestroy();
   405     OnDestroy();
   363     // clean up all the other memory allocated
   406     // clean up all the other memory allocated
   364     freeEverything(true);
   407     freeEverything(true);
   365     if alsoShutdownFrontend then halt;
   408     if alsoShutdownFrontend then
       
   409         halt;
   366 end;
   410 end;
   367 
   411 
   368 procedure initEverything (complete:boolean);
   412 procedure initEverything (complete:boolean);
   369 begin
   413 begin
   370     Randomize();
   414     Randomize();
   371 
   415 
   372     if complete then cLogfileBase:= 'game'
   416     if complete then
   373     else cLogfileBase:= 'preview';
   417         cLogfileBase:= 'game'
       
   418     else
       
   419         cLogfileBase:= 'preview';
   374 
   420 
   375     // uConsts does not need initialization as they are all consts
   421     // uConsts does not need initialization as they are all consts
   376     uUtils.initModule;
   422     uUtils.initModule;
   377     uMisc.initModule;
   423     uMisc.initModule;
   378     uVariables.initModule;
   424     uVariables.initModule;
   384     uLandPainted.initModule;
   430     uLandPainted.initModule;
   385 
   431 
   386     uIO.initModule;
   432     uIO.initModule;
   387 
   433 
   388     if complete then
   434     if complete then
   389     begin
   435         begin
   390 {$IFDEF ANDROID}GLUnit.init;{$ENDIF}
   436 {$IFDEF ANDROID}GLUnit.init;{$ENDIF}
   391 {$IFDEF SDL13}uTouch.initModule;{$ENDIF}
   437 {$IFDEF SDL13}uTouch.initModule;{$ENDIF}
   392         uAI.initModule;
   438         uAI.initModule;
   393         //uAIActions does not need initialization
   439         //uAIActions does not need initialization
   394         //uAIAmmoTests does not need initialization
   440         //uAIAmmoTests does not need initialization
   412         uStore.initModule;
   458         uStore.initModule;
   413         uTeams.initModule;
   459         uTeams.initModule;
   414         uVisualGears.initModule;
   460         uVisualGears.initModule;
   415         uWorld.initModule;
   461         uWorld.initModule;
   416         uCaptions.initModule;
   462         uCaptions.initModule;
   417     end;
   463         end;
   418 end;
   464 end;
   419 
   465 
   420 procedure freeEverything (complete:boolean);
   466 procedure freeEverything (complete:boolean);
   421 begin
   467 begin
   422     if complete then
   468     if complete then
   423     begin
   469         begin
   424         uCaptions.freeModule;
   470         uCaptions.freeModule;
   425         uWorld.freeModule;
   471         uWorld.freeModule;
   426         uVisualGears.freeModule;
   472         uVisualGears.freeModule;
   427         uTeams.freeModule;
   473         uTeams.freeModule;
   428         uStore.freeModule;          //stub
   474         uStore.freeModule;          //stub
   444         uAmmos.freeModule;
   490         uAmmos.freeModule;
   445         uAIMisc.freeModule;         //stub
   491         uAIMisc.freeModule;         //stub
   446         //uAIAmmoTests does not need to be freed
   492         //uAIAmmoTests does not need to be freed
   447         //uAIActions does not need to be freed
   493         //uAIActions does not need to be freed
   448         uAI.freeModule;             //stub
   494         uAI.freeModule;             //stub
   449     end;
   495         end;
   450 
   496 
   451     uIO.freeModule;             //stub
   497     uIO.freeModule;             //stub
   452     uLand.freeModule;
   498     uLand.freeModule;
   453     uLandPainted.freeModule;
   499     uLandPainted.freeModule;
   454 
   500 
   460     uMisc.freeModule;           // uMisc closes the debug log.
   506     uMisc.freeModule;           // uMisc closes the debug log.
   461 end;
   507 end;
   462 
   508 
   463 /////////////////////////
   509 /////////////////////////
   464 procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF};
   510 procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF};
   465 var Preview: TPreview;
   511 var
       
   512     Preview: TPreview;
   466 begin
   513 begin
   467     initEverything(false);
   514     initEverything(false);
   468 {$IFDEF HWLIBRARY}
   515 {$IFDEF HWLIBRARY}
   469     WriteLnToConsole('Preview connecting on port ' + inttostr(port));
   516     WriteLnToConsole('Preview connecting on port ' + inttostr(port));
   470     ipcPort:= port;
   517     ipcPort:= port;
   500     WriteLn(' --stats-only');
   547     WriteLn(' --stats-only');
   501     WriteLn();
   548     WriteLn();
   502     WriteLn('Read documentation online at http://code.google.com/p/hedgewars/wiki/CommandLineOptions for more information');
   549     WriteLn('Read documentation online at http://code.google.com/p/hedgewars/wiki/CommandLineOptions for more information');
   503     WriteLn();
   550     WriteLn();
   504     Write('PARSED COMMAND: ');
   551     Write('PARSED COMMAND: ');
       
   552     
   505     for i:=0 to ParamCount do
   553     for i:=0 to ParamCount do
   506         Write(ParamStr(i) + ' ');
   554         Write(ParamStr(i) + ' ');
       
   555         
   507     WriteLn();
   556     WriteLn();
   508 end;
   557 end;
   509 
   558 
   510 ////////////////////
   559 ////////////////////
   511 {$INCLUDE "ArgParsers.inc"}
   560 {$INCLUDE "ArgParsers.inc"}
   527 ////////////////////////////////////////////////////////////////////////////////
   576 ////////////////////////////////////////////////////////////////////////////////
   528 /////////////////////////////// m a i n ////////////////////////////////////////
   577 /////////////////////////////// m a i n ////////////////////////////////////////
   529 ////////////////////////////////////////////////////////////////////////////////
   578 ////////////////////////////////////////////////////////////////////////////////
   530 begin
   579 begin
   531     GetParams();
   580     GetParams();
   532     if (Length(cLocaleFName) > 6) then cLocale := Copy(cLocaleFName,1,5)
   581     if (Length(cLocaleFName) > 6) then
   533     else cLocale := Copy(cLocaleFName,1,2);
   582         cLocale := Copy(cLocaleFName,1,5)
   534 
   583     else
   535     if GameType = gmtLandPreview then GenLandPreview()
   584         cLocale := Copy(cLocaleFName,1,2);
   536     else if GameType = gmtSyntax then DisplayUsage()
   585 
       
   586     if GameType = gmtLandPreview then
       
   587         GenLandPreview()
       
   588     else if GameType = gmtSyntax then
       
   589         DisplayUsage()
   537     else Game();
   590     else Game();
   538 
   591 
   539     // return 1 when engine is not called correctly
   592     // return 1 when engine is not called correctly
   540     ExitCode:= LongInt(GameType = gmtSyntax);
   593     ExitCode:= LongInt(GameType = gmtSyntax);
   541 {$ENDIF}
   594 {$ENDIF}