# HG changeset patch # User Wuzzy # Date 1560620942 -7200 # Node ID fcd697bce2a8c8ed5e9c45a560f4223fa184b7d0 # Parent 4744d7b78c755c4f77088a4a9085643501465ffe Fix mapgen flowers being placed into indestructible map border diff -r 4744d7b78c75 -r fcd697bce2a8 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sat Jun 15 19:44:52 2019 +0200 +++ b/hedgewars/uGears.pas Sat Jun 15 19:49:02 2019 +0200 @@ -1059,14 +1059,24 @@ with Hedgehogs[i] do if (Gear <> nil) and (Gear^.State and gsttmpFlag <> 0) then begin + // Get flower position x:= hwRound(Gear^.X) - SpritesData[sprTargetBee].Width div 2; y:= hwRound(Gear^.Y) - SpritesData[sprTargetBee].Height div 2; - x:= max(min(x, RightX - SpritesData[sprTargetBee].Width), LeftX); + // Calculate offset from map boundaries and border + if hasBorder then + x:= max(min(x, RightX - SpritesData[sprTargetBee].Width) - cBorderWidth, LeftX + cBorderWidth) + else + x:= max(min(x, RightX - SpritesData[sprTargetBee].Width), LeftX); y:= max(y, TopY); + + // Place flower ForcePlaceOnLand(x, y, sprTargetBee, 0, lfBasic, $FFFFFFFF, false, false, false); + + // Place hog Gear^.Y:= int2hwFloat(hwRound(Gear^.Y) - (SpritesData[sprTargetBee].Height div 2) - Gear^.Radius); AddCI(Gear); Gear^.State:= Gear^.State and (not gsttmpFlag); + AddFileLog('Placed flower for hog at coordinates (' + inttostr(x) + ',' + inttostr(y) + ')') end;