1 (* |
1 (* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
482 if SDL_MustLock(tmpsurf) then |
482 if SDL_MustLock(tmpsurf) then |
483 SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
483 SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
484 |
484 |
485 p:= tmpsurf^.pixels; |
485 p:= tmpsurf^.pixels; |
486 for y:= 0 to Pred(tmpsurf^.h) do |
486 for y:= 0 to Pred(tmpsurf^.h) do |
487 begin |
487 begin |
488 for x:= 0 to Pred(tmpsurf^.w) do |
488 for x:= 0 to Pred(tmpsurf^.w) do |
489 begin |
489 SetLand(Land[cpY + y, cpX + x], p^[x]); |
490 // this an if instead of masking colours to avoid confusing map creators |
490 p:= @(p^[tmpsurf^.pitch div 4]); |
491 if ((AMask and p^[x]) = 0) then |
|
492 Land[cpY + y, cpX + x]:= 0 |
|
493 else if p^[x] = $FFFFFFFF then // white |
|
494 Land[cpY + y, cpX + x]:= lfObject |
|
495 else if p^[x] = AMask then // black |
|
496 begin |
|
497 Land[cpY + y, cpX + x]:= lfBasic; |
|
498 disableLandBack:= false |
|
499 end |
|
500 else if p^[x] = (AMask or RMask) then // red |
|
501 Land[cpY + y, cpX + x]:= lfIndestructible |
|
502 else if p^[x] = (AMask or BMask) then // blue |
|
503 Land[cpY + y, cpX + x]:= lfObject or lfIce |
|
504 else if p^[x] = (AMask or GMask) then // green |
|
505 Land[cpY + y, cpX + x]:= lfObject or lfBouncy |
|
506 end; |
491 end; |
507 p:= @(p^[tmpsurf^.pitch div 4]); |
|
508 end; |
|
509 |
492 |
510 if SDL_MustLock(tmpsurf) then |
493 if SDL_MustLock(tmpsurf) then |
511 SDL_UnlockSurface(tmpsurf); |
494 SDL_UnlockSurface(tmpsurf); |
512 if not disableLandBack then |
495 if not disableLandBack then |
513 begin |
496 begin |