From ed5fb7dec8e73c3876ba3f512032807e689b8f19 Mon Sep 17 00:00:00 2001 From: Overhaul Date: Fri, 9 Nov 2007 09:14:41 +0000 Subject: [PATCH] Fix infinite recursion for tank sighting. This could have a side effect of causing sight glitches, but that's much better than a stack overflow/CTD. Added SNIPER orders to soldier debug info screen git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1589 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/opplist.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index fa95a921..81e7240f 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -1251,6 +1251,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir, // let tanks see and be seen further (at night) if ( (TANK( pSoldier ) && sDistVisible > 0) || (pSubject && TANK( pSubject ) ) ) { +#if 0 if ( TANK(pSoldier) && sDistVisible > 0 && pSubject) { sDistVisible = __max( sDistVisible + 5, pSubject->GetMaxDistanceVisible(pSoldier->sGridNo, pSoldier->bLevel) ); @@ -1258,6 +1259,11 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir, else { sDistVisible = __max( sDistVisible + 5, pSoldier->GetMaxDistanceVisible() ); } +#endif + // 0verhaul: This bit of code 1) seems to have no real reason to exist (MaxDistVisible just calls this function anyway), + // and 2) causes infinite recursion because MaxDistVisible just calls this function, which comes right back here. Just + // add 5 to sDistVisible and go on. + sDistVisible = sDistVisible + 5; } if ( gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[ bLevel ] & (MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS) ) @@ -4495,6 +4501,7 @@ void DebugSoldierPage4( ) case FARPATROL: swprintf( szOrders, L"FAR PATROL" ); break; case POINTPATROL: swprintf( szOrders, L"POINT PATROL" ); break; case RNDPTPATROL: swprintf( szOrders, L"RND PT PATROL" ); break; + case SNIPER: swprintf( szOrders, L"SNIPER" ); break; default: swprintf( szOrders, L"UNKNOWN" ); break; } switch( pSoldier->bAttitude )