- 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
This commit is contained in:
Wanne
2009-10-31 17:33:15 +00:00
parent 8f1f24499b
commit ea1b814e8f
4 changed files with 51 additions and 33 deletions
+36 -27
View File
@@ -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();
}
}
}
+11 -2
View File
@@ -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 )