hedgewars/hwengine.dpr
changeset 155 401f4ea24715
parent 109 ab0340f580c2
child 158 e6c3223f3bca
equal deleted inserted replaced
154:5667e6f38704 155:401f4ea24715
   182 {$IFDEF DEBUGFILE}
   182 {$IFDEF DEBUGFILE}
   183 AddFileLog('Prefix: "' + PathPrefix +'"');
   183 AddFileLog('Prefix: "' + PathPrefix +'"');
   184 for i:= 0 to ParamCount do
   184 for i:= 0 to ParamCount do
   185     AddFileLog(inttostr(i) + ': ' + ParamStr(i));
   185     AddFileLog(inttostr(i) + ': ' + ParamStr(i));
   186 {$ENDIF}
   186 {$ENDIF}
   187 if ParamCount = 7 then
   187 case ParamCount of
   188    begin
   188   7: begin
   189    val(ParamStr(1), cScreenWidth, c);
   189      val(ParamStr(1), cScreenWidth, c);
   190    val(ParamStr(2), cScreenHeight, c);
   190      val(ParamStr(2), cScreenHeight, c);
   191    cBitsStr:= ParamStr(3);
   191      cBitsStr:= ParamStr(3);
   192    val(cBitsStr, cBits, c);
   192      val(cBitsStr, cBits, c);
   193    val(ParamStr(4), ipcPort, c);
   193      val(ParamStr(4), ipcPort, c);
   194    cFullScreen:= ParamStr(5) = '1';
   194      cFullScreen:= ParamStr(5) = '1';
   195    isSoundEnabled:= ParamStr(6) = '1';
   195      isSoundEnabled:= ParamStr(6) = '1';
   196    cLocaleFName:= ParamStr(7);
   196      cLocaleFName:= ParamStr(7);
   197    end else OutError(errmsgShouldntRun, true)
   197      end;
       
   198   2: begin
       
   199      val(ParamStr(1), ipcPort, c);
       
   200      GameType:= gmtLandPreview;
       
   201      if ParamStr(2) <> 'landpreview' then OutError(errmsgShouldntRun, true);
       
   202      end
       
   203    else
       
   204    OutError(errmsgShouldntRun, true)
       
   205    end
   198 end;
   206 end;
   199 
   207 
   200 procedure ShowMainWindow;
   208 procedure ShowMainWindow;
   201 var flags: Longword;
   209 var flags: Longword;
   202 begin
   210 begin
   206 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   214 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   207 TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
   215 TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
   208 PixelFormat:= SDLPrimSurface.format;
   216 PixelFormat:= SDLPrimSurface.format;
   209 SDL_ShowCursor(0);
   217 SDL_ShowCursor(0);
   210 end;
   218 end;
       
   219 
       
   220 ////////////////////////////////////////////////////////////////////////////////
       
   221 procedure Game;
       
   222 begin
       
   223 WriteToConsole('Init SDL... ');
       
   224 SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
       
   225 WriteLnToConsole(msgOK);
       
   226 
       
   227 WriteToConsole('Init SDL_ttf... ');
       
   228 SDLTry(TTF_Init >= 0, true);
       
   229 WriteLnToConsole(msgOK);
       
   230 
       
   231 ShowMainWindow;
       
   232 
       
   233 InitKbdKeyTable;
       
   234 InitIPC;
       
   235 WriteLnToConsole(msgGettingConfig);
       
   236 
       
   237 LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName);
       
   238 
       
   239 SendIPCAndWaitReply('C');        // ask for game config
       
   240 InitTeams;
       
   241 
       
   242 if isSoundEnabled then InitSound;
       
   243 InitWorld;
       
   244 
       
   245 StoreInit;
       
   246 
       
   247 isDeveloperMode:= false;
       
   248 
       
   249 TryDo(InitStepsFlags = cifAllInited,
       
   250       'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')',
       
   251       true);
       
   252 
       
   253 MainLoop
       
   254 end;
       
   255 
       
   256 procedure GenLandPreview;
       
   257 begin
       
   258 InitIPC;
       
   259 SendIPCAndWaitReply('C');
       
   260 TryDo(InitStepsFlags = cifRandomize,
       
   261       'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')',
       
   262       true);
       
   263 GenPreview;
       
   264 SendIPCRaw(@Preview, sizeof(Preview));
       
   265 SendIPCAndWaitReply('+');
       
   266 end;
       
   267 
   211 ////////////////////////////////////////////////////////////////////////////////
   268 ////////////////////////////////////////////////////////////////////////////////
   212 /////////////////////////////// m a i n ////////////////////////////////////////
   269 /////////////////////////////// m a i n ////////////////////////////////////////
   213 ////////////////////////////////////////////////////////////////////////////////
   270 ////////////////////////////////////////////////////////////////////////////////
   214 
   271 
   215 begin
   272 begin
   216 WriteLnToConsole('-= HedgeWars 0.2 =-');
   273 WriteLnToConsole('-= HedgeWars 0.2 =-');
   217 WriteLnToConsole('  -= by unC0Rr =-  ');
   274 WriteLnToConsole('  -= by unC0Rr =-  ');
   218 GetParams;
   275 GetParams;
   219 Randomize;
   276 Randomize;
   220 
   277 
   221 WriteToConsole('Init SDL... ');
   278 if GameType = gmtLandPreview then GenLandPreview
   222 SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
   279                              else Game
   223 WriteLnToConsole(msgOK);
       
   224 
       
   225 WriteToConsole('Init SDL_ttf... ');
       
   226 SDLTry(TTF_Init >= 0, true);
       
   227 WriteLnToConsole(msgOK);
       
   228 
       
   229 ShowMainWindow;
       
   230 
       
   231 InitKbdKeyTable;
       
   232 InitIPC;
       
   233 WriteLnToConsole(msgGettingConfig);
       
   234 
       
   235 LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName);
       
   236 
       
   237 SendIPCAndWaitReply('C');        // ask for game config
       
   238 InitTeams;
       
   239 
       
   240 if isSoundEnabled then InitSound;
       
   241 InitWorld;
       
   242 
       
   243 StoreInit;
       
   244 
       
   245 isDeveloperMode:= false;
       
   246 
       
   247 TryDo(InitStepsFlags = cifAllInited,
       
   248       'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')',
       
   249       true);
       
   250 
       
   251 MainLoop
       
   252 
       
   253 end.
   280 end.