Prevent camera from moving with auto camera disabled when remote teams are targetting
authornemo
Sat, 12 Jan 2013 18:37:10 -0500
changeset 8373 209c9ba77a09
parent 8372 3c193ec03e09
child 8376 c11cc7246df7
Prevent camera from moving with auto camera disabled when remote teams are targetting
hedgewars/uIO.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uIO.pas	Sun Jan 13 01:02:08 2013 +0400
+++ b/hedgewars/uIO.pas	Sat Jan 12 18:37:10 2013 -0500
@@ -339,10 +339,12 @@
             // these are equations solved for CursorPoint
             // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx;
             // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy;
-            if not (CurrentTeam^.ExtDriven and bShowAmmoMenu) then
+            if CurrentTeam^.ExtDriven then
                begin
-               CursorPoint.X:= LongInt(SDLNet_Read32(@(headcmd^.X))) + WorldDx;
-               CursorPoint.Y:= cScreenHeight - LongInt(SDLNet_Read32(@(headcmd^.Y))) - WorldDy
+               TargetCursorPoint.X:= LongInt(SDLNet_Read32(@(headcmd^.X))) + WorldDx;
+               TargetCursorPoint.Y:= cScreenHeight - LongInt(SDLNet_Read32(@(headcmd^.Y))) - WorldDy;
+               if not bShowAmmoMenu and autoCameraOn then
+                    CursorPoint:= TargetCursorPoint
                end
              end;
         'w': ParseCommand('setweap ' + headcmd^.str[2], true);
--- a/hedgewars/uVariables.pas	Sun Jan 13 01:02:08 2013 +0400
+++ b/hedgewars/uVariables.pas	Sat Jan 12 18:37:10 2013 -0500
@@ -177,8 +177,9 @@
     SDWaterColorArray : array[0..3] of HwColor4f;
     SDTint          : LongInt;
 
-    CursorPoint     : TPoint;
-    TargetPoint     : TPoint;
+    TargetCursorPoint     : TPoint;
+    CursorPoint           : TPoint;
+    TargetPoint           : TPoint;
 
     ScreenFade      : TScreenFade;
     ScreenFadeValue : LongInt;
--- a/hedgewars/uWorld.pas	Sun Jan 13 01:02:08 2013 +0400
+++ b/hedgewars/uWorld.pas	Sat Jan 12 18:37:10 2013 -0500
@@ -75,7 +75,7 @@
     FPS: Longword;
     CountTicks: Longword;
     SoundTimerTicks: Longword;
-    prevPoint: TPoint;
+    prevPoint, prevTargetPoint: TPoint;
     amSel: TAmmoType = amNothing;
     missionTex: PTexture;
     missionTimer: LongInt;
@@ -223,6 +223,8 @@
 uCursor.init();
 prevPoint.X:= 0;
 prevPoint.Y:= cScreenHeight div 2;
+prevTargetPoint.X:= 0;
+prevTargetPoint.Y:= 0;
 WorldDx:=  -(LAND_WIDTH div 2) + cScreenWidth div 2;
 WorldDy:=  -(LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
 
@@ -642,6 +644,7 @@
             AMShiftX:= AMShiftTargetX;
             AMShiftY:= AMShiftTargetY;
             prevPoint:= CursorPoint;
+            prevTargetPoint:= TargetCursorPoint;
             AMState:= AMHidden;
             end;
     end;
@@ -1630,6 +1633,7 @@
     begin
     if not bShowAmmoMenu then
         begin
+        if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint;
         with CurrentHedgehog^ do
             if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
                 begin
@@ -1638,9 +1642,9 @@
             i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos;
             with Ammoz[CurAmmoType] do
                 if PosCount > 1 then
-                    DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
+                    DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
                 end;
-        DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
+        DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)
         end
     end;
 isFirstFrame:= false
@@ -1652,7 +1656,7 @@
 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt;
 begin
 {$IFNDEF MOBILE}
-if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu))) and cHasFocus and (GameState <> gsConfirm) then
+if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then
     uCursor.updatePosition();
 {$ENDIF}
 z:= round(200/zoom);
@@ -1723,7 +1727,8 @@
     EdgesDist:= cGearScrEdgesDist;
 
 // this generates the border around the screen that moves the camera when cursor is near it
-if isCursorVisible or ((FollowGear <> nil) and autoCameraOn) then
+if (CurrentTeam^.ExtDriven and isCursorVisible and autoCameraOn) or
+   (not CurrentTeam^.ExtDriven and isCursorVisible) or ((FollowGear <> nil) and autoCameraOn) then
     begin
     if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then
         begin