Don't allow to look too deep
authorunc0rr
Thu, 10 Sep 2009 15:22:34 +0000
changeset 2375 99f05a01a6a3
parent 2374 d584bb4b836e
child 2376 ece7b87f1334
Don't allow to look too deep
hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Thu Sep 10 12:55:10 2009 +0000
+++ b/hedgewars/uWorld.pas	Thu Sep 10 15:22:34 2009 +0000
@@ -540,7 +540,7 @@
 
 procedure MoveCamera;
 const PrevSentPointTime: LongWord = 0;
-var EdgesDist, cw: LongInt;
+var EdgesDist, cw, wdy: LongInt;
 begin
 
 cw:= round(cScreenWidth / cScaleFactor);
@@ -569,6 +569,9 @@
 		CursorPoint.y:= (prevPoint.y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8;
 		end;
 
+wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
+if WorldDy < wdy then WorldDy:= wdy;
+
 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit;
 
 if AMxShift < 210 then
@@ -626,8 +629,8 @@
 
 prevPoint:= CursorPoint;
 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
-if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater;
 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
+if WorldDy < wdy then WorldDy:= wdy;
 if WorldDx < -round(LAND_WIDTH * 2 / cScaleFactor) then WorldDx:= -round(LAND_WIDTH * 2 / cScaleFactor);
 if WorldDx > cw then WorldDx:= cw;
 end;