- Fixed compiling .)
authorunc0rr
Wed, 01 Feb 2006 20:42:53 +0000
changeset 57 e1a77ae57065
parent 56 a29135563e94
child 58 69962d94a007
- Fixed compiling .) - Fixed camera following gears
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
hedgewars/uCollisions.pas
hedgewars/uGears.pas
hedgewars/uLand.pas
hedgewars/uLandGraphics.pas
hedgewars/uTeams.pas
hedgewars/uWorld.pas
--- a/hedgewars/CCHandlers.inc	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Wed Feb 01 20:42:53 2006 +0000
@@ -324,7 +324,6 @@
            PInteger(@s[6])^:= TargetPoint.Y;
            SendIPC(s)
            end;
-        AdjustMPoint;
         State:= State and not gstHHChooseTarget;
         end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', true)
 end;
--- a/hedgewars/GSHandlers.inc	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Wed Feb 01 20:42:53 2006 +0000
@@ -627,6 +627,7 @@
       end else // gsttmpFlag = 0
    if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
 end;
+
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepDynamite(Gear: PGear);
 begin
--- a/hedgewars/uCollisions.pas	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/uCollisions.pas	Wed Feb 01 20:42:53 2006 +0000
@@ -56,7 +56,7 @@
 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
 
 implementation
-uses uMisc, uConsts, uLand, uGraphics;
+uses uMisc, uConsts, uLand, uLandGraphics;
 
 type TCollisionEntry = record
                        X, Y, Radius: integer;
--- a/hedgewars/uGears.pas	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/uGears.pas	Wed Feb 01 20:42:53 2006 +0000
@@ -75,7 +75,7 @@
 var CurAmmoGear: PGear = nil;
 
 implementation
-uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, uLand, uIO, uGraphics;
+uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, uLand, uIO, uLandGraphics;
 var GearsList: PGear = nil;
     RopePoints: record
                 Count: Longword;
--- a/hedgewars/uLand.pas	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/uLand.pas	Wed Feb 01 20:42:53 2006 +0000
@@ -65,9 +65,11 @@
 SHA1Init(ctx);
 SHA1Update(ctx, @Land, sizeof(Land));
 dig:= SHA1Final(ctx);
+{$IFDEF DEBUGFILE}
 AddFileLog('SHA1 Land digest: {'+inttostr(dig.LongWords[0])+':'
            +inttostr(dig.LongWords[1])+':'+inttostr(dig.LongWords[2])+':'
            +inttostr(dig.LongWords[3])+':'+inttostr(dig.LongWords[4])+'}');
+{$ENDIF}
 end;
 
 procedure DrawBezierEdge(var pa: TPixAr);
--- a/hedgewars/uLandGraphics.pas	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/uLandGraphics.pas	Wed Feb 01 20:42:53 2006 +0000
@@ -47,58 +47,110 @@
   if (dx = dy) then FillCircleLines(x, y, dx, dy, Value);
 end;
 
+procedure ClearLandPixel(y, x: integer);
+var p: integer;
+begin
+p:= integer(LandSurface.pixels);
+case LandSurface.format.BytesPerPixel of
+     1: ;// not supported
+     2: PWord(p + LandSurface.pitch*y + x * 2)^:= 0;
+     3: begin
+        PByte(p + LandSurface.pitch*y + x * 3 + 0)^:= 0;
+        PByte(p + LandSurface.pitch*y + x * 3 + 1)^:= 0;
+        PByte(p + LandSurface.pitch*y + x * 3 + 2)^:= 0;
+        end;
+     4: PLongword(p + LandSurface.pitch*y + x * 4)^:= 0;
+     end;
+end;
+
+procedure SetLandPixel(y, x: integer);
+var p: integer;
+begin
+p:= integer(LandSurface.pixels);
+case LandSurface.format.BytesPerPixel of
+     1: ;// not supported
+     2: PWord(p + LandSurface.pitch*y + x * 2)^:= cExplosionBorderColor;
+     3: begin
+     PByte(p + LandSurface.pitch*y + x * 3 + 0)^:= cExplosionBorderColor and $FF;
+     PByte(p + LandSurface.pitch*y + x * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
+     PByte(p + LandSurface.pitch*y + x * 3 + 2)^:= (cExplosionBorderColor shr 16);
+        end;
+     4: PLongword(p + LandSurface.pitch*y + x * 4)^:= cExplosionBorderColor;
+     end;
+end;
+
+procedure FillLandCircleLines0(x, y, dx, dy: integer);
+var i: integer;
+begin
+if ((y + dy) and $FFFFFC00) = 0 then
+   for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y + dy, i);
+if ((y - dy) and $FFFFFC00) = 0 then
+   for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y - dy, i);
+if ((y + dx) and $FFFFFC00) = 0 then
+   for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y + dx, i);
+if ((y - dx) and $FFFFFC00) = 0 then
+   for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y - dx, i);
+end;
+
+procedure FillLandCircleLinesEBC(x, y, dx, dy: integer);
+var i: integer;
+begin
+if ((y + dy) and $FFFFFC00) = 0 then
+   for i:= max(x - dx, 0) to min(x + dx, 2047) do
+       if Land[y + dy, i] <> 0 then SetLandPixel(y + dy, i);
+if ((y - dy) and $FFFFFC00) = 0 then
+   for i:= max(x - dx, 0) to min(x + dx, 2047) do
+       if Land[y - dy, i] <> 0 then SetLandPixel(y - dy, i);
+if ((y + dx) and $FFFFFC00) = 0 then
+   for i:= max(x - dy, 0) to min(x + dy, 2047) do
+       if Land[y + dx, i] <> 0 then SetLandPixel(y + dx, i);
+if ((y - dx) and $FFFFFC00) = 0 then
+   for i:= max(x - dy, 0) to min(x + dy, 2047) do
+       if Land[y - dx, i] <> 0 then SetLandPixel(y - dx, i);
+end;
+
 procedure DrawExplosion(X, Y, Radius: integer);
-var ty, tx, p: integer;
+var dx, dy, d: integer;
 begin
 FillRoundInLand(X, Y, Radius, 0);
 
 if SDL_MustLock(LandSurface) then
    SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
 
-p:= integer(LandSurface.pixels);
-case LandSurface.format.BytesPerPixel of
-     1: ;// not supported
-     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
-     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-                begin
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
-                end;
-     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
+  dx:= 0;
+  dy:= Radius;
+  d:= 3 - 2 * Radius;
+  while (dx < dy) do
+     begin
+     FillLandCircleLines0(x, y, dx, dy);
+     if (d < 0)
+     then d:= d + 4 * dx + 6
+     else begin
+          d:= d + 4 * (dx - dy) + 10;
+          dec(dy)
+          end;
+     inc(dx)
      end;
-
-inc(Radius, 4);
-
-case LandSurface.format.BytesPerPixel of
-     1: ;// not supported
-     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
-     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                begin
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
-                end;
-     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
+  if (dx = dy) then FillLandCircleLines0(x, y, dx, dy);
+  inc(Radius, 4);
+  dx:= 0;
+  dy:= Radius;
+  d:= 3 - 2 * Radius;
+  while (dx < dy) do
+     begin
+     FillLandCircleLinesEBC(x, y, dx, dy);
+     if (d < 0)
+     then d:= d + 4 * dx + 6
+     else begin
+          d:= d + 4 * (dx - dy) + 10;
+          dec(dy)
+          end;
+     inc(dx)
      end;
-
+  if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);  
+  
 if SDL_MustLock(LandSurface) then
    SDL_UnlockSurface(LandSurface);
-
-SDL_UpdateRect(LandSurface, X - Radius, Y - Radius, Radius * 2, Radius * 2)
 end;
 
 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
--- a/hedgewars/uTeams.pas	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/uTeams.pas	Wed Feb 01 20:42:53 2006 +0000
@@ -244,7 +244,6 @@
         isCursorVisible:= true
         end else begin
         Gear.State:= Gear.State and not gstHHChooseTarget;
-        AdjustMPoint;
         isCursorVisible:= false
         end;
      ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
--- a/hedgewars/uWorld.pas	Wed Jan 25 19:45:39 2006 +0000
+++ b/hedgewars/uWorld.pas	Wed Feb 01 20:42:53 2006 +0000
@@ -42,7 +42,6 @@
 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
 procedure AddCaption(s: shortstring; Color, Group: LongWord);
 procedure MoveWorld;
-procedure AdjustMPoint;
 
 {$IFDEF COUNTTICKS}
 var cntTicks: LongWord;
@@ -312,12 +311,10 @@
 var s: string[9];
 begin
 if not (CurrentTeam.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
-
 if (FollowGear <> nil) then
-   if abs(CursorPoint.X - prevPoint.X + CursorPoint.Y - prevpoint.Y) > 4 then
+   if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
       begin
       FollowGear:= nil;
-      AdjustMPoint;
       exit
       end
       else begin
@@ -376,13 +373,6 @@
 if WorldDx > cScreenWidth then WorldDx:=  cScreenWidth;
 end;
 
-procedure AdjustMPoint;
-begin
-prevPoint.x:= cScreenWidth div 2;
-prevPoint.y:= cScreenHeight div 2;
-SDL_WarpMouse(prevPoint.X, prevPoint.Y);
-end;
-
 initialization
 FillChar(Captions, sizeof(Captions), 0)