From 645598f3d555741ef732abfc58d5b928acfa5aa5 Mon Sep 17 00:00:00 2001 From: Lesh Date: Sun, 2 Jul 2006 20:02:39 +0000 Subject: [PATCH] good news - i fixed nasty freeze with throwing items through window. make your tests again. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@324 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/physics.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp index c791d58c..0f7a0161 100644 --- a/TileEngine/physics.cpp +++ b/TileEngine/physics.cpp @@ -100,6 +100,8 @@ FLOAT CalculateForceFromRange( INT16 sRange, FLOAT dDegrees ); UINT16 RandomGridFromRadius( INT16 sSweetGridNo, INT8 ubMinRadius, INT8 ubMaxRadius ); +// Lesh: needed to fix item throwing through window +extern INT16 DirIncrementer[8]; void HandleArmedObjectImpact( REAL_OBJECT *pObject ); void ObjectHitWindow( INT16 sGridNo, UINT16 usStructureID, BOOLEAN fBlowWindowSouth, BOOLEAN fLargeForce ); @@ -1881,6 +1883,18 @@ DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 1750")); if ( ubLevel == 0 ) { sInterGridNo = SoldierToLocationWindowTest( pSoldier, sGridNo ); + + // Lesh: fixing nasty freeze when throwing item through window + // sometimes SoldierToLocationWindowTest returns same value as pSoldier->sGridNo + // this leads to fault in FindBestAngleForTrajectory function and it subroutines loops + // supplied by invalid data + if ( pSoldier->sGridNo == sInterGridNo ) + { + // bad news - i can't throw item at myself + // so use dir incrementer + UINT8 ubDir = atan8( CenterX(pSoldier->sGridNo), CenterY(pSoldier->sGridNo), CenterX(sGridNo), CenterY(sGridNo) ); + sInterGridNo += DirIncrementer[ubDir]; + } } else {