# HG changeset patch # User sheepluva # Date 1418289771 -3600 # Node ID ae9ad773569047c4bca54b7f514a8c329c127506 # Parent 4456836514edb4a82c30962f3effa63cf43eb9af wrap explosions! diff -r 4456836514ed -r ae9ad7735690 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Thu Dec 11 09:50:31 2014 +0100 +++ b/hedgewars/uGearsUtils.pas Thu Dec 11 10:22:51 2014 +0100 @@ -81,6 +81,7 @@ fX, fY, tdX, tdY: hwFloat; vg: PVisualGear; i, cnt: LongInt; + wrap: boolean; begin if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); if Radius > 25 then KickFlakes(Radius, X, Y); @@ -104,6 +105,11 @@ fX:= int2hwFloat(X); fY:= int2hwFloat(Y); Gear:= GearsList; + +// we might have to run twice if weWrap is enabled +wrap:= false; +repeat; + while Gear <> nil do begin dmg:= 0; @@ -188,6 +194,27 @@ AddVisualGear(X, Y, vgtChunk) end; +if (WorldEdge = weWrap) then + begin + // already wrapped? let's not wrap again! + if wrap then + break; + + // Radius + 5 because that's the actual radius the explosion changes graphically + if X + (Radius + 5) > LongInt(rightX) then + begin + dec(X, playWidth); + wrap:= true; + end + else if X - (Radius + 5) < LongInt(leftX) then + begin + inc(X, playWidth); + wrap:= true; + end; + end; + +until (not wrap); + uAIMisc.AwareOfExplosion(0, 0, 0) end;