hedgewars/uLand.pas
changeset 5238 46ddaf14509d
parent 5231 29a3a9309f2c
child 5241 e1fb0fc971c6
equal deleted inserted replaced
5237:963d787a25c2 5238:46ddaf14509d
   281 procedure ColorizeLand(Surface: PSDL_Surface);
   281 procedure ColorizeLand(Surface: PSDL_Surface);
   282 var tmpsurf: PSDL_Surface;
   282 var tmpsurf: PSDL_Surface;
   283     r, rr: TSDL_Rect;
   283     r, rr: TSDL_Rect;
   284     x, yd, yu: LongInt;
   284     x, yd, yu: LongInt;
   285 begin
   285 begin
   286     tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps);
   286     tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/LandTex', ifIgnoreCaps);
       
   287     if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps);
   287     r.y:= 0;
   288     r.y:= 0;
   288     while r.y < LAND_HEIGHT do
   289     while r.y < LAND_HEIGHT do
   289     begin
   290     begin
   290         r.x:= 0;
   291         r.x:= 0;
   291         while r.x < LAND_WIDTH do
   292         while r.x < LAND_WIDTH do
   296         inc(r.y, tmpsurf^.h)
   297         inc(r.y, tmpsurf^.h)
   297     end;
   298     end;
   298     SDL_FreeSurface(tmpsurf);
   299     SDL_FreeSurface(tmpsurf);
   299 
   300 
   300     // freed in freeModule() below
   301     // freed in freeModule() below
   301     LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
   302     LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
   302 
   303     if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
   303     tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
   304 
       
   305     tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Border', ifIgnoreCaps or ifTransparent);
       
   306     if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
   304     for x:= 0 to LAND_WIDTH - 1 do
   307     for x:= 0 to LAND_WIDTH - 1 do
   305     begin
   308     begin
   306         yd:= LAND_HEIGHT - 1;
   309         yd:= LAND_HEIGHT - 1;
   307         repeat
   310         repeat
   308             while (yd > 0) and (Land[yd, x] =  0) do dec(yd);
   311             while (yd > 0) and (Land[yd, x] =  0) do dec(yd);
  1102 rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
  1105 rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
  1103 topY:= LAND_HEIGHT - playHeight;
  1106 topY:= LAND_HEIGHT - playHeight;
  1104 
  1107 
  1105 WriteLnToConsole('Generating forts land...');
  1108 WriteLnToConsole('Generating forts land...');
  1106 
  1109 
  1107 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
  1110 tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifTransparent or ifIgnoreCaps);
       
  1111 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
  1108 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
  1112 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
  1109 SDL_FreeSurface(tmpsurf);
  1113 SDL_FreeSurface(tmpsurf);
  1110 
  1114 
  1111 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
  1115 tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
       
  1116 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
  1112 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
  1117 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
  1113 SDL_FreeSurface(tmpsurf);
  1118 SDL_FreeSurface(tmpsurf);
  1114 end;
  1119 end;
  1115 
  1120 
  1116 // Hi unC0Rr.
  1121 // Loads Land[] from an image, allowing overriding standard collision
  1117 // This is a function that Tiy assures me would not be good for gameplay.
       
  1118 // It allows the setting of arbitrary portions of landscape as indestructible, or regular, or even blank.
       
  1119 // He said I could add it here only when I swore it would not impact gameplay.  Which, as far as I can tell, is true.
       
  1120 // I would just like to play with it with my friends if you do not mind.
       
  1121 // Can allow for amusing maps.
       
  1122 procedure LoadMask(mapName: shortstring);
  1122 procedure LoadMask(mapName: shortstring);
  1123 var tmpsurf: PSDL_Surface;
  1123 var tmpsurf: PSDL_Surface;
  1124     p: PLongwordArray;
  1124     p: PLongwordArray;
  1125     x, y, cpX, cpY: Longword;
  1125     x, y, cpX, cpY: Longword;
  1126 begin
  1126 begin
  1165     mapName: shortstring = '';
  1165     mapName: shortstring = '';
  1166 begin
  1166 begin
  1167 isMap:= true;
  1167 isMap:= true;
  1168 WriteLnToConsole('Loading land from file...');
  1168 WriteLnToConsole('Loading land from file...');
  1169 AddProgress;
  1169 AddProgress;
  1170 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps);
  1170 tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps);
       
  1171 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps);
  1171 if tmpsurf = nil then
  1172 if tmpsurf = nil then
  1172 begin
  1173 begin
  1173     mapName:= ExtractFileName(Pathz[ptMapCurrent]);
  1174     mapName:= ExtractFileName(Pathz[ptMapCurrent]);
  1174     tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
  1175     tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifTransparent or ifIgnoreCaps);
       
  1176     if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
  1175 end;
  1177 end;
  1176 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true);
  1178 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true);
  1177 
  1179 
  1178 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what
  1180 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what
  1179 s:= Pathz[ptMapCurrent] + '/map.cfg';
  1181 s:= Pathz[ptMapCurrent] + '/map.cfg';