# HG changeset patch # User Wuzzy # Date 1508623171 -7200 # Node ID 83d62800d2152d9217c9989ffe728b4e2df29380 # Parent bb75ad94878b4c8f21c6095d4d46b597dd43af15 Move CalcWorldWrap to uUtils.pas diff -r bb75ad94878b -r 83d62800d215 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Sat Oct 21 23:27:58 2017 +0200 +++ b/hedgewars/uGearsUtils.pas Sat Oct 21 23:59:31 2017 +0200 @@ -57,7 +57,6 @@ function GetUtility(Hedgehog: PHedgehog): TAmmoType; function WorldWrap(var Gear: PGear): boolean; -function CalcWorldWrap(X, radius: LongInt): LongInt; function IsHogLocal(HH: PHedgehog): boolean; @@ -1629,27 +1628,6 @@ 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 diff -r bb75ad94878b -r 83d62800d215 hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Sat Oct 21 23:27:58 2017 +0200 +++ b/hedgewars/uUtils.pas Sat Oct 21 23:59:31 2017 +0200 @@ -77,6 +77,8 @@ function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; +function CalcWorldWrap(X, radius: LongInt): LongInt; + function read1stLn(filePath: shortstring): shortstring; function readValueFromINI(key, filePath: shortstring): shortstring; @@ -556,6 +558,27 @@ GetLaunchY:= 0*) 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; + function CheckNoTeamOrHH: boolean; begin CheckNoTeamOrHH:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil);