Patch by nemo:
authorunc0rr
Fri, 03 Apr 2009 16:33:33 +0000
changeset 1939 4b8e4cd9e7c0
parent 1938 da7f27122fd2
child 1940 bbdca883b5f9
Patch by nemo: - Hackish way of skipping some textures load in reduced quality mode - Clipping sprite rendering function
hedgewars/uGears.pas
hedgewars/uStore.pas
--- a/hedgewars/uGears.pas	Fri Apr 03 16:29:09 2009 +0000
+++ b/hedgewars/uGears.pas	Fri Apr 03 16:33:33 2009 +0000
@@ -656,7 +656,7 @@
 procedure DrawHH(Gear: PGear);
 var t: LongInt;
 	amt: TAmmoType;
-	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite`
+	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite
 	lx, ly, dx, dy, ax, ay, aAngle, dAngle: real;  // laser, change
 	defaultPos, HatVisible: boolean;
     VertexBuffer: array [0..1] of TVertex2f;
@@ -881,7 +881,15 @@
 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
 				defaultPos:= false
 				end;
-			amGirder: DrawSprite(sprGirder, sx-256, sy-256, 0);
+			amGirder: begin
+                DrawSpriteClipped(sprGirder, 
+                                  sx-256, 
+                                  sy-256, 
+                                  LongInt(topY)+WorldDy, 
+                                  LongInt(rightX)+WorldDx, 
+                                  cWaterLine+WorldDy,
+                                  LongInt(leftX)+WorldDx);
+                end;
 		end;
 
 		case amt of
@@ -1714,7 +1722,10 @@
 	repeat
 		inc(x, Delta);
 		cnt:= 0;
-		y:= -Gear^.Radius * 2;
+        if topY > 1024 then
+		    y:= 1024-Gear^.Radius * 2
+        else 
+		    y:= topY-Gear^.Radius * 2;
 		while y < LAND_HEIGHT do
 			begin
 			repeat
--- a/hedgewars/uStore.pas	Fri Apr 03 16:29:09 2009 +0000
+++ b/hedgewars/uStore.pas	Fri Apr 03 16:33:33 2009 +0000
@@ -33,6 +33,7 @@
 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt);
 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
+procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture);
 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, Frames: LongInt);
@@ -267,6 +268,8 @@
 AddProgress;
 for ii:= Low(TSprite) to High(TSprite) do
 	with SpritesData[ii] do
+        if (not cReducedQuality) or 
+           ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
 			begin
 			if AltPath = ptNone then
 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, true, true, true)
@@ -507,6 +510,30 @@
 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture)
 end;
 
+procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
+var r: TSDL_Rect;
+begin
+r.x:= 0;
+r.y:= 0;
+r.w:= SpritesData[Sprite].Width;
+r.h:= SpritesData[Sprite].Height;
+
+if (X < LeftX) then
+    r.x:= LeftX - X;
+if (Y < TopY) then
+    r.y:= TopY - Y;
+
+if (Y + SpritesData[Sprite].Height > BottomY) then
+    r.h:= BottomY - Y + 1;
+if (X + SpritesData[Sprite].Width > RightX) then
+    r.w:= RightX - X + 1;
+
+dec(r.h, r.y);
+dec(r.w, r.x);
+
+DrawFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture)
+end;
+
 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
 var r: TSDL_Rect;
 begin