# HG changeset patch # User sheepluva # Date 1277539193 -7200 # Node ID c601630a12d52cf070a0c29f9025a74f8bd3de3c # Parent 3e51dad040261237c5f893f795fb142558356121 portal: * clean up obsolete code in order to remove the rare cases of wrong-sided portals * fix formula of last commit notice: since last commit portals can happen to move faster than 1000px/sec, I'll take care of that soon ;) diff -r 3e51dad04026 -r c601630a12d5 hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Sat Jun 26 08:14:53 2010 +0200 +++ b/hedgewars/GSHandlers.inc Sat Jun 26 09:59:53 2010 +0200 @@ -3297,7 +3297,7 @@ var x, y, tx, ty: LongInt; //, bx, by, tangle: LongInt; - s, dx, dy: hwFloat; + s: hwFloat; procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean); var @@ -3350,20 +3350,10 @@ // making a normalized normal vector s := _1/DistanceI(tx,ty); - dx := -s * ty; - dy := s * tx; - - // make sure the vector is pointing outwards - if not (Gear^.dX*dx + Gear^.dY*dy).isNegative then - begin - dx := -dx; - dy := -dy; - end; - - Gear^.dX := dx; - Gear^.dY := dy; - - Gear^.DirAngle := DxDy2Angle(-dy,dx); + Gear^.dX := s * ty; + Gear^.dY := -s * tx; + + Gear^.DirAngle := DxDy2Angle(-Gear^.dY,Gear^.dX); if not Gear^.dX.isNegative then Gear^.DirAngle := 180-Gear^.DirAngle; if ((Gear^.IntersectGear = nil) @@ -3394,7 +3384,7 @@ // to the shot speed (which we triple previously btw) // (This is done my projecting the hog movement vector onto the shot movement vector and then adding the resulting length // to the scaler) - s := _3 * s + (newPortal^.dX * CurrentHedgehog^.Gear^.dX + newPortal^.dY * CurrentHedgehog^.Gear^.dY ) / s; + s := (_2 * s + (newPortal^.dX * CurrentHedgehog^.Gear^.dX + newPortal^.dY * CurrentHedgehog^.Gear^.dY ) / s) / s; newPortal^.dX := newPortal^.dX * s; newPortal^.dY := newPortal^.dY * s;