# HG changeset patch # User unc0rr # Date 1367524008 -14400 # Node ID fac5a075f021741aae842aeb59f517bb4b91145e # Parent c8a6f789398df4a34b223fe33eed2c2f0d8fbc4b# Parent 145bf64a957989dea22ea7ad80a54cbcc909ede0 merge :P diff -r 145bf64a9579 -r fac5a075f021 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu May 02 13:09:12 2013 -0400 +++ b/hedgewars/hwengine.pas Thu May 02 23:46:48 2013 +0400 @@ -220,10 +220,7 @@ SDL_MOUSEBUTTONDOWN: if GameState = gsConfirm then - begin - resetPosition(); - ParseCommand('quit', true); - end + ParseCommand('quit', true) else ProcessMouse(event.button, true); diff -r 145bf64a9579 -r fac5a075f021 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Thu May 02 13:09:12 2013 -0400 +++ b/hedgewars/uAI.pas Thu May 02 23:46:48 2013 +0400 @@ -377,7 +377,7 @@ switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch) else switchCount:= 0; -if (Me^.State and gstAttacked) = 0 then +if ((Me^.State and gstAttacked) = 0) or isInMultiShoot then if Targets.Count > 0 then begin // iterate over current team hedgehogs @@ -426,7 +426,8 @@ else begin BackMe:= Me^; - while (not StopThinking) and (BestActions.Count = 0) do + i:= 12; + while (not StopThinking) and (BestActions.Count = 0) and (i > 0) do begin (* // Maybe this would get a bit of movement out of them? Hopefully not *toward* water. Need to check how often he'd choose that strategy @@ -439,6 +440,7 @@ Actions.Pos:= 0; Actions.Score:= 0; Walk(@WalkMe, Actions); + dec(i); if not StopThinking then SDL_Delay(100) end @@ -477,7 +479,7 @@ exit end; -FillBonuses((Me^.State and gstAttacked) <> 0); +FillBonuses(((Me^.State and gstAttacked) <> 0) and (not isInMultiShoot)); SDL_LockMutex(ThreadLock); ThinkThread:= SDL_CreateThread(@Think{$IFDEF SDL13}, 'think'{$ENDIF}, Me); diff -r 145bf64a9579 -r fac5a075f021 hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Thu May 02 13:09:12 2013 -0400 +++ b/hedgewars/uGearsHedgehog.pas Thu May 02 23:46:48 2013 +0400 @@ -961,8 +961,11 @@ begin Gear^.State:= Gear^.State and (not gstWinner); Gear^.State:= Gear^.State and (not gstMoving); - while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) do - Gear^.Y:= Gear^.Y+_1; + while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) and (Gear <> nil) do + Gear^.Y:= Gear^.Y + _1; + + // could become nil in CheckGearDrowning if ai's hog fails to respawn in ai survival + if Gear = nil then exit; SetLittle(Gear^.dX); Gear^.dY:= _0 end @@ -982,7 +985,10 @@ Gear^.dY:= _0; Gear^.Y:= Gear^.Y + _1 end; + CheckGearDrowning(Gear); + // could become nil if ai's hog fails to respawn in ai survival + if Gear = nil then exit; // hide target cursor if current hog is drowning if (Gear^.State and gstDrowning) <> 0 then if (CurrentHedgehog^.Gear = Gear) then diff -r 145bf64a9579 -r fac5a075f021 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Thu May 02 13:09:12 2013 -0400 +++ b/hedgewars/uGearsUtils.pas Thu May 02 23:46:48 2013 +0400 @@ -31,13 +31,13 @@ procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); procedure CheckHHDamage(Gear: PGear); procedure CalcRotationDirAngle(Gear: PGear); -procedure ResurrectHedgehog(gear: PGear); +procedure ResurrectHedgehog(var gear: PGear); procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline; procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; -function CheckGearDrowning(Gear: PGear): boolean; +function CheckGearDrowning(var Gear: PGear): boolean; procedure CheckCollision(Gear: PGear); inline; procedure CheckCollisionWithLand(Gear: PGear); inline; @@ -337,7 +337,7 @@ Gear^.DirAngle := Gear^.DirAngle - 360 end; -function CheckGearDrowning(Gear: PGear): boolean; +function CheckGearDrowning(var Gear: PGear): boolean; var skipSpeed, skipAngle, skipDecay: hwFloat; i, maxDrops, X, Y: LongInt; @@ -390,7 +390,11 @@ if Gear^.Kind = gtHedgehog then begin if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then - ResurrectHedgehog(Gear) + begin + // Gear could become nil after this, just exit to skip splashes + ResurrectHedgehog(Gear); + exit + end else begin Gear^.doStep := @doStepDrowningGear; @@ -465,7 +469,7 @@ end; -procedure ResurrectHedgehog(gear: PGear); +procedure ResurrectHedgehog(var gear: PGear); var tempTeam : PTeam; sparkles: PVisualGear; gX, gY: LongInt; @@ -507,7 +511,7 @@ RenderHealth(gear^.Hedgehog^); ScriptCall('onGearResurrect', gear^.uid); gear^.State := gstWait; - end; + end; RecountTeamHealth(tempTeam); end;