286 procedure AddBorder(Surface: PSDL_Surface); |
286 procedure AddBorder(Surface: PSDL_Surface); |
287 var tmpsurf: PSDL_Surface; |
287 var tmpsurf: PSDL_Surface; |
288 r, rr: TSDL_Rect; |
288 r, rr: TSDL_Rect; |
289 x, yd, yu: integer; |
289 x, yd, yu: integer; |
290 begin |
290 begin |
291 tmpsurf:= LoadImage(Pathz[ptThemeCurrent] + '/Border.png', false); |
291 tmpsurf:= LoadImage(Pathz[ptThemeCurrent] + '/Border', false); |
292 for x:= 0 to 2047 do |
292 for x:= 0 to 2047 do |
293 begin |
293 begin |
294 yd:= 1023; |
294 yd:= 1023; |
295 repeat |
295 repeat |
296 while (yd > 0 ) and (Land[yd, x] = 0) do dec(yd); |
296 while (yd > 0 ) and (Land[yd, x] = 0) do dec(yd); |
495 p:= TeamsList; |
495 p:= TeamsList; |
496 TryDo(p <> nil, 'No teams on map!', true); |
496 TryDo(p <> nil, 'No teams on map!', true); |
497 with PixelFormat^ do |
497 with PixelFormat^ do |
498 LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0); |
498 LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0); |
499 SDL_FillRect(LandSurface, nil, 0); |
499 SDL_FillRect(LandSurface, nil, 0); |
500 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p.FortName + 'L.png', false); |
500 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p.FortName + 'L', false); |
501 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface); |
501 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface); |
502 SDL_FreeSurface(tmpsurf); |
502 SDL_FreeSurface(tmpsurf); |
503 p:= p.Next; |
503 p:= p.Next; |
504 TryDo(p <> nil, 'Only one team on map!', true); |
504 TryDo(p <> nil, 'Only one team on map!', true); |
505 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p.FortName + 'R.png', false); |
505 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p.FortName + 'R', false); |
506 BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface); |
506 BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface); |
507 SDL_FreeSurface(tmpsurf); |
507 SDL_FreeSurface(tmpsurf); |
508 p:= p.Next; |
508 p:= p.Next; |
509 TryDo(p = nil, 'More than 2 teams on map in forts mode!', true); |
509 TryDo(p = nil, 'More than 2 teams on map in forts mode!', true); |
510 end; |
510 end; |
512 procedure LoadMap; |
512 procedure LoadMap; |
513 var p, x, y, i: Longword; |
513 var p, x, y, i: Longword; |
514 begin |
514 begin |
515 WriteLnToConsole('Loading land from file...'); |
515 WriteLnToConsole('Loading land from file...'); |
516 AddProgress; |
516 AddProgress; |
517 LandSurface:= LoadImage(Pathz[ptMapCurrent] + '/map.png', false); |
517 LandSurface:= LoadImage(Pathz[ptMapCurrent] + '/map', false); |
518 TryDo((LandSurface.w = 2048) and (LandSurface.h = 1024), 'Map dimensions should be 2048x1024!', true); |
518 TryDo((LandSurface.w = 2048) and (LandSurface.h = 1024), 'Map dimensions should be 2048x1024!', true); |
519 |
519 |
520 if SDL_MustLock(LandSurface) then |
520 if SDL_MustLock(LandSurface) then |
521 SDLTry(SDL_LockSurface(LandSurface) >= 0, true); |
521 SDLTry(SDL_LockSurface(LandSurface) >= 0, true); |
522 |
522 |