Repair flame dependancy on wind
authorunc0rr
Tue, 28 Oct 2008 18:42:21 +0000
changeset 1433 4af291d5d79c
parent 1432 ab212288d34d
child 1434 75fe933483c7
Repair flame dependancy on wind
hedgewars/GSHandlers.inc
hedgewars/uFloat.pas
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Mon Oct 27 21:01:18 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Tue Oct 28 18:42:21 2008 +0000
@@ -752,39 +752,39 @@
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
 DeleteCI(HHGear);
 if (HHGear^.State and gstMoving) <> 0 then
-   if TestCollisionYwithGear(HHGear, 1) then
-      begin
-      CheckHHDamage(HHGear);
-      HHGear^.dY:= _0;
-      HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping);
-      end else
-      begin
-      if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
-      HHGear^.X:= HHGear^.X + HHGear^.dX;
-      HHGear^.Y:= HHGear^.Y + HHGear^.dY;
-      Gear^.X:= Gear^.X + HHGear^.dX;
-      Gear^.Y:= Gear^.Y + HHGear^.dY;
-      HHGear^.dY:= HHGear^.dY + cGravity;
-      tt:= Gear^.Elasticity;
-      tx:= _0;
-      ty:= _0;
-      while tt > _20 do
-            begin
-            if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
-             or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
-                begin
-                Gear^.X:= Gear^.X + tx;
-                Gear^.Y:= Gear^.Y + ty;
-                Gear^.Elasticity:= tt;
-                Gear^.doStep:= @doStepRopeWork;
-                with HHGear^ do State:= State and not gstAttacking;
-                tt:= _0
-                end;
-            tx:= tx + Gear^.dX + Gear^.dX;
-            ty:= ty + Gear^.dY + Gear^.dY;
-            tt:= tt - _2;
-            end;
-      end;
+if TestCollisionYwithGear(HHGear, 1) then
+	begin
+	CheckHHDamage(HHGear);
+	HHGear^.dY:= _0;
+	HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping);
+	end else
+	begin
+	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
+	HHGear^.X:= HHGear^.X + HHGear^.dX;
+	HHGear^.Y:= HHGear^.Y + HHGear^.dY;
+	Gear^.X:= Gear^.X + HHGear^.dX;
+	Gear^.Y:= Gear^.Y + HHGear^.dY;
+	HHGear^.dY:= HHGear^.dY + cGravity;
+	tt:= Gear^.Elasticity;
+	tx:= _0;
+	ty:= _0;
+	while tt > _20 do
+		begin
+		if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
+		or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
+			begin
+			Gear^.X:= Gear^.X + tx;
+			Gear^.Y:= Gear^.Y + ty;
+			Gear^.Elasticity:= tt;
+			Gear^.doStep:= @doStepRopeWork;
+			with HHGear^ do State:= State and not gstAttacking;
+			tt:= _0
+			end;
+		tx:= tx + Gear^.dX + Gear^.dX;
+		ty:= ty + Gear^.dY + Gear^.dY;
+		tt:= tt - _2;
+		end;
+	end;
 
 CheckCollision(Gear);
 
@@ -801,14 +801,14 @@
 	end;
 
 if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then
-   begin
-   with PHedgehog(Gear^.Hedgehog)^.Gear^ do
-        begin
-        State:= State and not gstAttacking;
-        Message:= Message and not gm_Attack
-        end;
-   DeleteGear(Gear)
-   end
+	begin
+	with PHedgehog(Gear^.Hedgehog)^.Gear^ do
+		begin
+		State:= State and not gstAttacking;
+		Message:= Message and not gm_Attack
+		end;
+	DeleteGear(Gear)
+	end
 end;
 
 procedure doStepRope(Gear: PGear);
@@ -1079,12 +1079,16 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepFlame(Gear: PGear);
+var cWindFactor: hwFloat;
 begin
 AllInactive:= false;
+
 if not TestCollisionYwithGear(Gear, 1) then
 	begin
-	if hwAbs(Gear^.dX - cWindSpeed) > _0_1 then
-		Gear^.dX:= (Gear^.dX - cWindSpeed) * _0_5 + cWindSpeed;
+	cWindFactor:= cWindSpeed * 270;
+	
+	if hwAbs(Gear^.dX - cWindFactor) > _0_01 then
+		Gear^.dX:= (Gear^.dX - cWindFactor) * _0_998 + cWindFactor;
 
 	Gear^.dY:= Gear^.dY + cGravity;
 	if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995;
--- a/hedgewars/uFloat.pas	Mon Oct 27 21:01:18 2008 +0000
+++ b/hedgewars/uFloat.pas	Tue Oct 28 18:42:21 2008 +0000
@@ -99,6 +99,7 @@
            _0_93: hwFloat = (isNegative: false; QWordValue:  3994319585);
            _0_96: hwFloat = (isNegative: false; QWordValue:  4123168604);
           _0_995: hwFloat = (isNegative: false; QWordValue:  4273492459);
+          _0_998: hwFloat = (isNegative: false; QWordValue:  4294967296);
           _0_999: hwFloat = (isNegative: false; QWordValue:  4290672328);
             _1_9: hwFloat = (isNegative: false; QWordValue:  8160437862);
               _0: hwFloat = (isNegative: false; QWordValue:           0);
@@ -278,9 +279,11 @@
 
 function hwSqr(const t: hwFloat): hwFloat;
 begin
-hwSqr.isNegative:=false;
-hwSqr.QWordValue:= QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32);
-hwSqr.Round:= hwSqr.Round + t.Round * t.Round
+hwSqr.isNegative:= false;
+hwSqr.QWordValue:=
+	  ((QWord(t.Round) * t.Round) shl 32)
+	+ QWord(t.Round) * t.Frac * 2
+	+ ((QWord(t.Frac) * t.Frac) shr 32);
 end;
 
 function hwSqrt(const t: hwFloat): hwFloat;
--- a/hedgewars/uGears.pas	Mon Oct 27 21:01:18 2008 +0000
+++ b/hedgewars/uGears.pas	Tue Oct 28 18:42:21 2008 +0000
@@ -88,7 +88,7 @@
 procedure DeleteGear(Gear: PGear); forward;
 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward;
 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
-procedure AmmoFlameWork(Ammo: PGear); forward;
+//procedure AmmoFlameWork(Ammo: PGear); forward;
 function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward;
 procedure SpawnBoxOfSmth; forward;
 procedure AfterAttack; forward;
@@ -1129,8 +1129,12 @@
 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
 if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false);
-if (Mask and EXPLAllDamageInRadius)=0 then dmgRadius:= Radius shl 1
-                                      else dmgRadius:= Radius;
+
+if (Mask and EXPLAllDamageInRadius) = 0 then
+	dmgRadius:= Radius shl 1
+else
+	dmgRadius:= Radius;
+
 Gear:= GearsList;
 while Gear <> nil do
 	begin
@@ -1314,17 +1318,19 @@
 t:= GearsList;
 rX:= sqr(rX);
 rY:= sqr(rY);
+
 while t <> nil do
-      begin
-      if (t <> Gear) and (t^.Kind = Kind) then
-         if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then
-            exit(t);
-      t:= t^.NextGear
-      end;
+	begin
+	if (t <> Gear) and (t^.Kind = Kind) then
+		if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then
+		exit(t);
+	t:= t^.NextGear
+	end;
+
 CheckGearNear:= nil
 end;
 
-procedure AmmoFlameWork(Ammo: PGear);
+{procedure AmmoFlameWork(Ammo: PGear);
 var t: PGear;
 begin
 t:= GearsList;
@@ -1342,7 +1348,7 @@
 			end;
 	t:= t^.NextGear
 	end;
-end;
+end;}
 
 function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear;
 var t: PGear;