Free land texture, reset sky colour.
authornemo
Mon, 22 Aug 2011 15:35:37 -0400
changeset 5654 1cb68f420aa6
parent 5653 fa58dea8a9ad
child 5656 2524ee087cc1
Free land texture, reset sky colour.
hedgewars/uLandObjects.pas
hedgewars/uLandTexture.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
--- a/hedgewars/uLandObjects.pas	Mon Aug 22 10:56:19 2011 -0400
+++ b/hedgewars/uLandObjects.pas	Mon Aug 22 15:35:37 2011 -0400
@@ -409,24 +409,24 @@
     if key = 'sky' then
         begin
         i:= Pos(',', s);
-        c1.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
+        SkyColor.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
         Delete(s, 1, i);
         i:= Pos(',', s);
-        c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
+        SkyColor.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
         Delete(s, 1, i);
-        c1.b:= StrToInt(Trim(s));
+        SkyColor.b:= StrToInt(Trim(s));
         if cGrayScale then
             begin
-            t:= round(c1.r * RGB_LUMINANCE_RED + c1.g * RGB_LUMINANCE_GREEN + c1.b * RGB_LUMINANCE_BLUE);
+            t:= round(SkyColor.r * RGB_LUMINANCE_RED + SkyColor.g * RGB_LUMINANCE_GREEN + SkyColor.b * RGB_LUMINANCE_BLUE);
             if t > 255 then t:= 255;
-            c1.r:= t;
-            c1.g:= t;
-            c1.b:= t
+            SkyColor.r:= t;
+            SkyColor.g:= t;
+            SkyColor.b:= t
             end;
-        glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
-        SDSkyColor.r:= byte(c1.r * SDTint div 255);
-        SDSkyColor.g:= byte(c1.g * SDTint div 255);
-        SDSkyColor.b:= byte(c1.b * SDTint div 255);
+        glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99);
+        SDSkyColor.r:= byte(SkyColor.r * SDTint div 255);
+        SDSkyColor.g:= byte(SkyColor.g * SDTint div 255);
+        SDSkyColor.b:= byte(SkyColor.b * SDTint div 255);
         end
     else if key = 'border' then
         begin
@@ -646,24 +646,24 @@
         if ((cReducedQuality and rqNoBackground) <> 0) then
             begin
             i:= Pos(',', s);
-            c1.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
+            RQSkyColor.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
             Delete(s, 1, i);
             i:= Pos(',', s);
-            c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
+            RQSkyColor.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
             Delete(s, 1, i);
-            c1.b:= StrToInt(Trim(s));
+            RQSkyColor.b:= StrToInt(Trim(s));
             if cGrayScale then
                 begin
-                t:= round(c1.r * RGB_LUMINANCE_RED + c1.g * RGB_LUMINANCE_GREEN + c1.b * RGB_LUMINANCE_BLUE);
+                t:= round(RQSkyColor.r * RGB_LUMINANCE_RED + RQSkyColor.g * RGB_LUMINANCE_GREEN + RQSkyColor.b * RGB_LUMINANCE_BLUE);
                 if t > 255 then t:= 255;
-                c1.r:= t;
-                c1.g:= t;
-                c1.b:= t
+                RQSkyColor.r:= t;
+                RQSkyColor.g:= t;
+                RQSkyColor.b:= t
                 end;
-            glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
-            SDSkyColor.r:= byte(c1.r * SDTint div 255);
-            SDSkyColor.g:= byte(c1.g * SDTint div 255);
-            SDSkyColor.b:= byte(c1.b * SDTint div 255);
+            glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99);
+            SDSkyColor.r:= byte(RQSkyColor.r * SDTint div 255);
+            SDSkyColor.g:= byte(RQSkyColor.g * SDTint div 255);
+            SDSkyColor.b:= byte(RQSkyColor.b * SDTint div 255);
             end
         end
     end;
--- a/hedgewars/uLandTexture.pas	Mon Aug 22 10:56:19 2011 -0400
+++ b/hedgewars/uLandTexture.pas	Mon Aug 22 15:35:37 2011 -0400
@@ -26,6 +26,7 @@
 procedure freeModule;
 procedure UpdateLandTexture(X, Width, Y, Height: LongInt);
 procedure DrawLand(dX, dY: LongInt);
+procedure ResetLand;
 
 implementation
 uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender;
@@ -122,29 +123,34 @@
 procedure initModule;
 begin
     if (cReducedQuality and rqBlurryLand) = 0 then
-    begin
+        begin
         LANDTEXARW:= LAND_WIDTH div TEXSIZE;
         LANDTEXARH:= LAND_HEIGHT div TEXSIZE;
-    end
+        end
     else
-    begin
+        begin
         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
-    end;
+        end;
 
     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
 end;
 
-procedure freeModule;
+procedure ResetLand;
 var x, y: LongInt;
 begin
     for x:= 0 to LANDTEXARW -1 do
         for y:= 0 to LANDTEXARH - 1 do
             with LandTextures[x, y] do
-            begin
-                FreeTexture(tex);
+                begin
+                if tex <> nil then FreeTexture(tex);
                 tex:= nil;
-            end;
+                end;
+end;
+
+procedure freeModule;
+begin
+    ResetLand;
     if LandBackSurface <> nil then
         SDL_FreeSurface(LandBackSurface);
     LandBackSurface:= nil;
--- a/hedgewars/uStore.pas	Mon Aug 22 10:56:19 2011 -0400
+++ b/hedgewars/uStore.pas	Mon Aug 22 15:35:37 2011 -0400
@@ -1029,8 +1029,12 @@
     SetupOpenGL();
     if reinit then
         begin
+        if ((cReducedQuality and rqNoBackground) = 0) then 
+             glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99)
+        else glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99);
         StoreRelease(true);
         StoreLoad(true);
+        ResetLand;
         UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT)
         end;
 end;
--- a/hedgewars/uVariables.pas	Mon Aug 22 10:56:19 2011 -0400
+++ b/hedgewars/uVariables.pas	Mon Aug 22 15:35:37 2011 -0400
@@ -2294,7 +2294,7 @@
     bShowFinger: boolean;
     Frames: Longword;
     WaterColor, DeepWaterColor: TSDL_Color;
-    SDSkyColor: TSDL_Color;
+    SkyColor, RQSkyColor, SDSkyColor: TSDL_Color;
     SkyOffset: LongInt;
     HorizontOffset: LongInt;
 {$IFDEF COUNTTICKS}