38
38
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
39
uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted;
39
uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted, uTextures;
41
41
operator=(const a, b: direction) c: Boolean;
302
302
// freed in freeModule() below
303
303
LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
304
304
if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
305
if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface);
306
307
tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Border', ifIgnoreCaps or ifTransparent);
307
308
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
1142
1143
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
1145
if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
1147
cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
1148
cpY:= LAND_HEIGHT - tmpsurf^.h;
1149
if SDL_MustLock(tmpsurf) then
1150
SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
1152
p:= tmpsurf^.pixels;
1153
for y:= 0 to Pred(tmpsurf^.h) do
1147
if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
1149
disableLandBack:= true;
1151
cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
1152
cpY:= LAND_HEIGHT - tmpsurf^.h;
1153
if SDL_MustLock(tmpsurf) then
1154
SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
1156
p:= tmpsurf^.pixels;
1157
for y:= 0 to Pred(tmpsurf^.h) do
1159
for x:= 0 to Pred(tmpsurf^.w) do
1155
for x:= 0 to Pred(tmpsurf^.w) do
1157
if ((AMask and p^[x]) = 0) then // Tiy was having trouble generating transparent black
1158
Land[cpY + y, cpX + x]:= 0
1159
else if p^[x] = (AMask or RMask) then
1160
Land[cpY + y, cpX + x]:= lfIndestructible
1161
else if p^[x] = $FFFFFFFF then
1162
Land[cpY + y, cpX + x]:= lfBasic;
1164
p:= @(p^[tmpsurf^.pitch div 4]);
1161
if ((AMask and p^[x]) = 0) then
1162
Land[cpY + y, cpX + x]:= 0
1163
else if p^[x] = $FFFFFFFF then
1164
Land[cpY + y, cpX + x]:= lfObject
1165
else if p^[x] = (AMask or RMask) then
1166
Land[cpY + y, cpX + x]:= lfIndestructible
1167
else if p^[x] = AMask then
1169
Land[cpY + y, cpX + x]:= lfBasic;
1170
disableLandBack:= false
1172
else if p^[x] = (AMask or BMask) then
1173
Land[cpY + y, cpX + x]:= lfObject or lfIce
1175
p:= @(p^[tmpsurf^.pitch div 4]);
1167
if SDL_MustLock(tmpsurf) then
1168
SDL_UnlockSurface(tmpsurf);
1170
if (tmpsurf <> nil) then
1171
SDL_FreeSurface(tmpsurf);
1178
if SDL_MustLock(tmpsurf) then
1179
SDL_UnlockSurface(tmpsurf);
1180
if not disableLandBack then
1182
// freed in freeModule() below
1183
LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
1184
if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
1185
if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface)
1188
if (tmpsurf <> nil) then
1189
SDL_FreeSurface(tmpsurf);
1175
1193
procedure LoadMap;
1234
1252
for w:= 0 to 23 do
1235
1253
for x:= leftX to rightX do
1237
Land[cWaterLine-1 - w, x]:= lfIndestructible;
1255
Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible;
1238
1256
if (x + w) mod 32 < 16 then
1241
1259
c:= AMask or RMask or GMask; // FF00FFFF
1243
1261
if (cReducedQuality and rqBlurryLand) = 0 then
1244
LandPixels[cWaterLine-1 - w, x]:= c
1262
LandPixels[Longword(cWaterLine) - 1 - w, x]:= c
1246
LandPixels[(cWaterLine-1 - w) div 2, x div 2]:= c
1264
LandPixels[(Longword(cWaterLine) - 1 - w) div 2, x div 2]:= c