# HG changeset patch # User Wuzzy # Date 1507291393 -7200 # Node ID 161c10db4f274f8f36be299af2b012f6366b9f30 # Parent 913d256691314aef5506816f0fce011a10e4af69 Fix teleport allowing you to teleport in land if you clicked beyond the wrap-around border diff -r 913d25669131 -r 161c10db4f27 ChangeLog.txt --- a/ChangeLog.txt Thu Oct 05 18:26:08 2017 +0200 +++ b/ChangeLog.txt Fri Oct 06 14:03:13 2017 +0200 @@ -49,6 +49,7 @@ * Fixed incorrect time box tooltip when in Sudden Death * Fixed cake taking over 200 seconds to explode when its stuck and can't move * Fixed Birdy descending into water when hog took damage or died before it got picked up + * Fixed teleportation being able to teleport in land if you clicked in the "dark" area of the wrap world edge * Remove buggy /finish chat command * Various other fixes diff -r 913d25669131 -r 161c10db4f27 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Thu Oct 05 18:26:08 2017 +0200 +++ b/hedgewars/uGearsHandlersMess.pas Fri Oct 06 14:03:13 2017 +0200 @@ -2865,6 +2865,7 @@ valid:= false; lx:= Gear^.Target.X - SpritesData[sprHHTelepMask].Width div 2; // left + lx:= CalcWorldWrap(lx, SpritesData[sprHHTelepMask].Width); // Take world edge into account ty:= Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2; // top // remember original target location diff -r 913d25669131 -r 161c10db4f27 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Thu Oct 05 18:26:08 2017 +0200 +++ b/hedgewars/uGearsUtils.pas Fri Oct 06 14:03:13 2017 +0200 @@ -56,6 +56,7 @@ function GetUtility(Hedgehog: PHedgehog): TAmmoType; function WorldWrap(var Gear: PGear): boolean; +function CalcWorldWrap(X, radius: LongInt): LongInt; function IsHogLocal(HH: PHedgehog): boolean; @@ -1598,6 +1599,27 @@ end; end; +// Takes an X coordinate and corrects if according to the world edge rules +// Wrap-around: X will be wrapped +// Bouncy: X will be kept inside the legal land (taking radius into account) +// Other world edges: Just returns X +// radius is a radius (gear radius) tolerance for an appropriate distance from bouncy world edges. +// Set radius to 0 if you don't care. +function CalcWorldWrap(X, radius: LongInt): LongInt; +begin + if WorldEdge = weWrap then + if X < LongInt(leftX) then + X:= X + (LongInt(rightX) - LongInt(leftX)) + else if X > LongInt(rightX) then + X:= X - (LongInt(rightX) - LongInt(leftX)) + else if WorldEdge = weBounce then + if X - radius < LongInt(leftX) then + X:= LongInt(leftX) + radius + else if X + radius > LongInt(rightX) then + X:= LongInt(rightX) - radius; + CalcWorldWrap:= X; +end; + procedure AddBounceEffectForGear(Gear: PGear); var boing: PVisualGear; begin