# HG changeset patch # User unc0rr # Date 1200869626 0 # Node ID 7a966319476713a3b628f67e8dce4941dfb5fb32 # Parent 6b314e907f6d68ceb92341cbbe61b344bfee4423 - Remove debug - Fix sqrt computation diff -r 6b314e907f6d -r 7a9663194767 hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Sun Jan 20 22:17:03 2008 +0000 +++ b/hedgewars/uAIAmmoTests.pas Sun Jan 20 22:53:46 2008 +0000 @@ -123,7 +123,6 @@ begin ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); ap.Power:= hwRound(r * cMaxPower) - random((Level - 1) * 17 + 1); -AddFilelog('r = '+floattostr(r)+' power = '+ inttostr(hwRound(r * cMaxPower))+' ==> '+inttostr(ap.Power)); ap.ExplR:= 100; ap.ExplX:= EX; ap.ExplY:= EY; diff -r 6b314e907f6d -r 7a9663194767 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Sun Jan 20 22:17:03 2008 +0000 +++ b/hedgewars/uFloat.pas Sun Jan 20 22:53:46 2008 +0000 @@ -130,7 +130,7 @@ {$ENDIF} implementation -uses uConsts; +uses uConsts, uMisc; {$IFDEF FPC} @@ -286,12 +286,22 @@ c: hwFloat; begin hwSqrt.isNegative:= false; -l:= 0; -r:= t.QWordValue div 2 + 1; + +if t.Round = 0 then + begin + l:= t.QWordValue; + r:= $100000000 + end else + begin + l:= $100000000; + r:= t.QWordValue + end; + repeat c.QWordValue:= (l + r) div 2; if hwSqr(c).QWordValue > t.QWordValue then r:= c.QWordValue else l:= c.QWordValue until r - l <= 1; + hwSqrt.QWordValue:= l end;