From ea1b814e8f1525bfd153c951cf445da3a34391d3 Mon Sep 17 00:00:00 2001 From: Wanne Date: Sat, 31 Oct 2009 17:33:15 +0000 Subject: [PATCH] - Bugfix: Fixed CTD when throwing item (grenade, rock, throwing knife, ...) in tactical when item description box is open git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3299 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Interface Items.cpp | 63 ++++++++++++++++++++---------------- Tactical/Points.cpp | 13 ++++++-- ja2_2005Express.vcproj | 4 +-- ja2_VS2008.vcproj | 4 +-- 4 files changed, 51 insertions(+), 33 deletions(-) diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index efa2c1292..235b7f957 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -4203,26 +4203,10 @@ void RenderItemDescriptionBox( ) ubAttackAPs = BaseAPsToShootOrStab( APBPConstants[DEFAULT_APS], APBPConstants[DEFAULT_AIMSKILL], gpItemDescObject ); - if (ubAttackAPs <= EXCEPTIONAL_AP_COST) + // WANNE: Fixed CTD when trowing an item with open description box + if (ubAttackAPs != -1) { - SetFontForeground( ITEMDESC_FONTHIGHLIGHT ); - } - else - { - SetFontForeground( 5 ); - } - - //AP's - if ( !Weapon[gpItemDescObject->usItem].NoSemiAuto ) - { - swprintf( pStr, L"%2d", ubAttackAPs ); - FindFontRightCoordinates( (INT16)(gWeaponStats[ 5 ].sX + gsInvDescX + gWeaponStats[ 5 ].sValDx), (INT16)(gWeaponStats[ 5 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); - mprintf( usX, usY, pStr ); - } - - if (GetShotsPerBurst(gpItemDescObject) > 0) - { - if (GetShotsPerBurst(gpItemDescObject) >= EXCEPTIONAL_BURST_SIZE )//|| gpItemDescObject->usItem == G11) + if (ubAttackAPs <= EXCEPTIONAL_AP_COST) { SetFontForeground( ITEMDESC_FONTHIGHLIGHT ); } @@ -4230,16 +4214,41 @@ void RenderItemDescriptionBox( ) { SetFontForeground( 5 ); } - swprintf( pStr, L"%2d", ubAttackAPs + CalcAPsToBurst( APBPConstants[DEFAULT_APS], gpItemDescObject ) ); - FindFontRightCoordinates( (INT16)(gWeaponStats[ 6 ].sX + gsInvDescX + gWeaponStats[ 6 ].sValDx), (INT16)(gWeaponStats[ 6 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); - mprintf( usX, usY, pStr ); + + //AP's + if ( !Weapon[gpItemDescObject->usItem].NoSemiAuto ) + { + swprintf( pStr, L"%2d", ubAttackAPs ); + FindFontRightCoordinates( (INT16)(gWeaponStats[ 5 ].sX + gsInvDescX + gWeaponStats[ 5 ].sValDx), (INT16)(gWeaponStats[ 5 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); + mprintf( usX, usY, pStr ); + } + + if (GetShotsPerBurst(gpItemDescObject) > 0) + { + if (GetShotsPerBurst(gpItemDescObject) >= EXCEPTIONAL_BURST_SIZE )//|| gpItemDescObject->usItem == G11) + { + SetFontForeground( ITEMDESC_FONTHIGHLIGHT ); + } + else + { + SetFontForeground( 5 ); + } + swprintf( pStr, L"%2d", ubAttackAPs + CalcAPsToBurst( APBPConstants[DEFAULT_APS], gpItemDescObject ) ); + FindFontRightCoordinates( (INT16)(gWeaponStats[ 6 ].sX + gsInvDescX + gWeaponStats[ 6 ].sValDx), (INT16)(gWeaponStats[ 6 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); + mprintf( usX, usY, pStr ); + } + else if (GetAutofireShotsPerFiveAPs(gpItemDescObject) > 0) + { + SetFontForeground( 5 ); + swprintf( pStr, L"%2d", ubAttackAPs + CalcAPsToAutofire( APBPConstants[DEFAULT_APS], gpItemDescObject, 3 ) ); + FindFontRightCoordinates( (INT16)(gWeaponStats[ 6 ].sX + gsInvDescX + gWeaponStats[ 6 ].sValDx), (INT16)(gWeaponStats[ 6 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); + mprintf( usX, usY, pStr ); + } } - else if (GetAutofireShotsPerFiveAPs(gpItemDescObject) > 0) + else { - SetFontForeground( 5 ); - swprintf( pStr, L"%2d", ubAttackAPs + CalcAPsToAutofire( APBPConstants[DEFAULT_APS], gpItemDescObject, 3 ) ); - FindFontRightCoordinates( (INT16)(gWeaponStats[ 6 ].sX + gsInvDescX + gWeaponStats[ 6 ].sValDx), (INT16)(gWeaponStats[ 6 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); - mprintf( usX, usY, pStr ); + // WANNE: Close the description box after we threw the item. + DeleteItemDescriptionBox(); } } } diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index d1cb55931..7c8421365 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1402,9 +1402,18 @@ INT16 BaseAPsToShootOrStab( INT16 bAPs, INT16 bAimSkill, OBJECTTYPE * pObj ) //{ // Top *= 100; //} - Bottom = (INT32)(( 100 + bAimSkill ) * rof); + + // WANNE : Fixed CTD that occurs when trowing item (grenade, throwing knife, ...) + // with open description box in tactical + INT16 baseAPsToShootOrStab = -1; + if (rof > 0) + { + Bottom = (INT32)(( 100 + bAimSkill ) * rof); + baseAPsToShootOrStab = ( Top + Bottom / 2 ) / Bottom; + } + // (this will round to the nearest integer) - return ( Top + Bottom / 2 ) / Bottom; + return baseAPsToShootOrStab; } void GetAPChargeForShootOrStabWRTGunRaises( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCost, BOOLEAN *pfChargeTurning, BOOLEAN *pfChargeRaise ) diff --git a/ja2_2005Express.vcproj b/ja2_2005Express.vcproj index b1d8bd1cc..e6aa327fa 100644 --- a/ja2_2005Express.vcproj +++ b/ja2_2005Express.vcproj @@ -99,7 +99,7 @@