Don't update all land texture when drawing tunnel (saves video throughput)
authorunc0rr
Mon, 28 Jan 2008 17:26:57 +0000
changeset 772 e8d530ca77be
parent 771 86fbe8753a7c
child 773 748e10fb8d74
Don't update all land texture when drawing tunnel (saves video throughput)
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Mon Jan 28 17:11:19 2008 +0000
+++ b/hedgewars/uLandGraphics.pas	Mon Jan 28 17:26:57 2008 +0000
@@ -187,8 +187,8 @@
      end;
   if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
 
-d:= max(Y - Radius, 0);
-dy:= min(Y + Radius, 1023) - d;
+d:= max(Y - Radius - 1, 0);
+dy:= min(Y + Radius + 1, 1023) - d;
 UpdateLandTexture(d, dy)
 end;
 
@@ -223,8 +223,10 @@
 //
 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
 var nx, ny, dX8, dY8: hwFloat;
-    i, t, tx, ty: Longint;
+    i, t, tx, ty, stY: Longint;
 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
+stY:= hwRound(Y);
+
 nx:= X + dY * (HalfWidth + 8);
 ny:= Y - dX * (HalfWidth + 8);
 
@@ -277,7 +279,9 @@
     ny:= ny + dX;
     end;
 
-UpdateLandTexture(0, 1024)
+t:= max(stY - HalfWidth * 3 div 2 - 4, 0);
+ty:= min(stY + HalfWidth * 3 div 2 + 4, 1023) - t;
+UpdateLandTexture(t, ty)
 end;
 
 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
@@ -342,7 +346,6 @@
 
 y:= max(cpY, 0);
 h:= min(cpY + Image^.h, 1023) - y;
-addfilelog(inttostr(y) + ' <<<<<<<<>>>>>>>> '+inttostr(h));
 UpdateLandTexture(y, h)
 end;