# HG changeset patch # User Wuzzy # Date 1531325632 -7200 # Node ID d3209e0caf12e18cfa9d717fc4e7690cc734dbe3 # Parent b688e2ca9a8d5de9f332c55bb6a271c82c21229f Fix aihDoesntMatter still being attacked with air attack The calculation in TestBazooka created a sum of numbers which might have been BadTurn, a huge negative number, thus creating an overflow. diff -r b688e2ca9a8d -r d3209e0caf12 ChangeLog.txt --- a/ChangeLog.txt Wed Jul 11 17:25:53 2018 +0200 +++ b/ChangeLog.txt Wed Jul 11 18:13:52 2018 +0200 @@ -50,6 +50,7 @@ + New parameter: ShowMission: 6th param. forceDisplay: Set to true to prevent this particular mission panel to be hidden manually by player * Changed global: lfCurrentHog becomes lfCurHogCrate * Fixed variable: TotalRounds was -1 (instead of 0) in first real round after hog placement phase + * AI sometimes intentionally shot hedgehogs with aihDoesntMatter set ====================== 0.9.24.1 ==================== * Fix crash when portable portal device is fired at reduced graphics quality diff -r b688e2ca9a8d -r d3209e0caf12 hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Wed Jul 11 17:25:53 2018 +0200 +++ b/hedgewars/uAIAmmoTests.pas Wed Jul 11 18:13:52 2018 +0200 @@ -1209,20 +1209,23 @@ end; until fexit or (Y > cWaterLine); -for i:= 0 to 5 do inc(valueResult, dmg[i]); +for i:= 0 to 5 do + if dmg[i] <> BadTurn then + inc(valueResult, dmg[i]); t:= valueResult; ap.AttackPutX:= Targ.Point.X - 60; for i:= 0 to 3 do - begin - dec(t, dmg[i]); - inc(t, dmg[i + 6]); - if t > valueResult then + if dmg[i] <> BadTurn then begin - valueResult:= t; - ap.AttackPutX:= Targ.Point.X - 30 - cShift + i * 30 - end - end; + dec(t, dmg[i]); + inc(t, dmg[i + 6]); + if t > valueResult then + begin + valueResult:= t; + ap.AttackPutX:= Targ.Point.X - 30 - cShift + i * 30 + end + end; if valueResult <= 0 then valueResult:= BadTurn; diff -r b688e2ca9a8d -r d3209e0caf12 hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Wed Jul 11 17:25:53 2018 +0200 +++ b/hedgewars/uAIMisc.pas Wed Jul 11 18:13:52 2018 +0200 @@ -615,7 +615,7 @@ end end; -if hadSkips and (rate = 0) then +if hadSkips and (rate <= 0) then RealRateExplosion:= BadTurn else RealRateExplosion:= rate; @@ -701,7 +701,7 @@ else hadSkips:= true; -if hadSkips and (rate = 0) then +if hadSkips and (rate <= 0) then RateShove:= BadTurn else RateShove:= rate * 1024; @@ -807,7 +807,7 @@ end end; -if hadSkips and (rate = 0) then +if hadSkips and (rate <= 0) then RateShotgun:= BadTurn else RateShotgun:= rate * 1024; @@ -839,7 +839,7 @@ inc(rate, Score div 3 * friendlyfactor div 100) end; -if hadSkips and (rate = 0) then +if hadSkips and (rate <= 0) then RateHammer:= BadTurn else RateHammer:= rate * 1024;