261 p: PLongwordArray; |
261 p: PLongwordArray; |
262 begin |
262 begin |
263 TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true); |
263 TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true); |
264 |
264 |
265 if SDL_MustLock(Surface) then |
265 if SDL_MustLock(Surface) then |
266 SDLTry(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true); |
266 if SDLCheck(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true) then exit; |
267 |
267 |
268 p:= Surface^.pixels; |
268 p:= Surface^.pixels; |
269 for y:= 0 to LAND_HEIGHT - 1 do |
269 for y:= 0 to LAND_HEIGHT - 1 do |
270 begin |
270 begin |
271 for x:= 0 to LAND_WIDTH - 1 do |
271 for x:= 0 to LAND_WIDTH - 1 do |
449 disableLandBack:= true; |
449 disableLandBack:= true; |
450 |
450 |
451 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
451 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
452 cpY:= LAND_HEIGHT - tmpsurf^.h; |
452 cpY:= LAND_HEIGHT - tmpsurf^.h; |
453 if SDL_MustLock(tmpsurf) then |
453 if SDL_MustLock(tmpsurf) then |
454 SDLTry(SDL_LockSurface(tmpsurf) >= 0, 'SDL_LockSurface', true); |
454 SDLCheck(SDL_LockSurface(tmpsurf) >= 0, 'SDL_LockSurface', true); |
455 |
455 |
|
456 if allOK then |
|
457 begin |
456 p:= tmpsurf^.pixels; |
458 p:= tmpsurf^.pixels; |
457 for y:= 0 to Pred(tmpsurf^.h) do |
459 for y:= 0 to Pred(tmpsurf^.h) do |
458 begin |
460 begin |
459 for x:= 0 to Pred(tmpsurf^.w) do |
461 for x:= 0 to Pred(tmpsurf^.w) do |
460 SetLand(Land[cpY + y, cpX + x], p^[x]); |
462 SetLand(Land[cpY + y, cpX + x], p^[x]); |
461 p:= PLongwordArray(@(p^[tmpsurf^.pitch div 4])); |
463 p:= PLongwordArray(@(p^[tmpsurf^.pitch div 4])); |
462 end; |
464 end; |
463 |
465 |
464 if SDL_MustLock(tmpsurf) then |
466 if SDL_MustLock(tmpsurf) then |
465 SDL_UnlockSurface(tmpsurf); |
467 SDL_UnlockSurface(tmpsurf); |
466 if not disableLandBack then |
468 if not disableLandBack then |
467 begin |
469 begin |
468 // freed in freeModule() below |
470 // freed in freeModule() below |
469 LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); |
471 LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); |
470 if (LandBackSurface <> nil) and GrayScale then |
472 if (LandBackSurface <> nil) and GrayScale then |
471 Surface2GrayScale(LandBackSurface) |
473 Surface2GrayScale(LandBackSurface) |
472 end; |
474 end; |
|
475 end; |
473 end; |
476 end; |
474 if (tmpsurf <> nil) then |
477 if (tmpsurf <> nil) then |
475 SDL_FreeSurface(tmpsurf); |
478 SDL_FreeSurface(tmpsurf); |
476 tmpsurf:= nil; |
479 tmpsurf:= nil; |
477 end; |
480 end; |