1140 mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
1140 mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
1141 tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1141 tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1142 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1142 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1143 end; |
1143 end; |
1144 |
1144 |
1145 if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then |
1145 |
1146 begin |
1146 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; |
1147 begin |
1148 cpY:= LAND_HEIGHT - tmpsurf^.h; |
1148 disableLandBack:= true; |
1149 if SDL_MustLock(tmpsurf) then |
1149 |
1150 SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
1150 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
1151 |
1151 cpY:= LAND_HEIGHT - tmpsurf^.h; |
1152 p:= tmpsurf^.pixels; |
1152 if SDL_MustLock(tmpsurf) then |
1153 for y:= 0 to Pred(tmpsurf^.h) do |
1153 SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
|
1154 |
|
1155 p:= tmpsurf^.pixels; |
|
1156 for y:= 0 to Pred(tmpsurf^.h) do |
|
1157 begin |
|
1158 for x:= 0 to Pred(tmpsurf^.w) do |
1154 begin |
1159 begin |
1155 for x:= 0 to Pred(tmpsurf^.w) do |
1160 if ((AMask and p^[x]) = 0) then |
1156 begin |
1161 Land[cpY + y, cpX + x]:= 0 |
1157 if ((AMask and p^[x]) = 0) then // Tiy was having trouble generating transparent black |
1162 else if p^[x] = $FFFFFFFF then |
1158 Land[cpY + y, cpX + x]:= 0 |
1163 Land[cpY + y, cpX + x]:= lfObject |
1159 else if p^[x] = (AMask or RMask) then |
1164 else if p^[x] = (AMask or RMask) then |
1160 Land[cpY + y, cpX + x]:= lfIndestructible |
1165 Land[cpY + y, cpX + x]:= lfIndestructible |
1161 else if p^[x] = $FFFFFFFF then |
1166 else if p^[x] = AMask then |
1162 Land[cpY + y, cpX + x]:= lfBasic; |
1167 begin |
1163 end; |
1168 Land[cpY + y, cpX + x]:= lfBasic; |
1164 p:= @(p^[tmpsurf^.pitch div 4]); |
1169 disableLandBack:= false |
|
1170 end |
|
1171 else if p^[x] = (AMask or BMask) then |
|
1172 Land[cpY + y, cpX + x]:= lfObject or lfIce |
1165 end; |
1173 end; |
1166 |
1174 p:= @(p^[tmpsurf^.pitch div 4]); |
1167 if SDL_MustLock(tmpsurf) then |
1175 end; |
1168 SDL_UnlockSurface(tmpsurf); |
1176 |
1169 end; |
1177 if SDL_MustLock(tmpsurf) then |
1170 if (tmpsurf <> nil) then |
1178 SDL_UnlockSurface(tmpsurf); |
1171 SDL_FreeSurface(tmpsurf); |
1179 if not disableLandBack then |
1172 tmpsurf:= nil; |
1180 begin |
|
1181 // freed in freeModule() below |
|
1182 LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); |
|
1183 if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent) |
|
1184 end; |
|
1185 end; |
|
1186 if (tmpsurf <> nil) then |
|
1187 SDL_FreeSurface(tmpsurf); |
|
1188 tmpsurf:= nil; |
1173 end; |
1189 end; |
1174 |
1190 |
1175 procedure LoadMap; |
1191 procedure LoadMap; |
1176 var tmpsurf: PSDL_Surface; |
1192 var tmpsurf: PSDL_Surface; |
1177 s: shortstring; |
1193 s: shortstring; |