From c55b927f8b26bbeb83f9b2ca951a970effca0a1c Mon Sep 17 00:00:00 2001 From: Wanne Date: Sat, 9 Feb 2008 09:41:24 +0000 Subject: [PATCH] - bugfix: Bobby Rays filter buttons (again). Now it should work - bugfix: Hand to hand combat (knifes, claws, ...) was disabled in auto battle. This was done in revision 51 because of CTDs that always occured there. I enabled hand to hand combat and tested ~50 auto battles. No single CTD. It seems that the CTD has been fixed since revision 51. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1788 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/BobbyRGuns.cpp | 8 ++++---- Strategic/Auto Resolve.cpp | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Laptop/BobbyRGuns.cpp b/Laptop/BobbyRGuns.cpp index 42dee5b7..ea29acc3 100644 --- a/Laptop/BobbyRGuns.cpp +++ b/Laptop/BobbyRGuns.cpp @@ -3058,14 +3058,14 @@ void CalcFirstIndexForPage( STORE_INVENTORY *pInv, UINT32 uiItemClass ) //Get to the first index on the page for(i=gusFirstItemIndex; i<=gusLastItemIndex; i++) { + bCntItem = FALSE; + if (guiCurrentUsedFilterMode == -1) { bCntItem = TRUE; } else { - bCntItem = FALSE; - usItemIndex = pInv[ i ].usItemIndex; switch (guiCurrentUsedFilterMode) @@ -3130,6 +3130,8 @@ void CalcFirstIndexForPage( STORE_INVENTORY *pInv, UINT32 uiItemClass ) //Get to the first index on the page for(i=gusFirstItemIndex; i<=gusLastItemIndex; i++) { + bCntItem = FALSE; + if( Item[ pInv[ i ].usItemIndex ].usItemClass & uiItemClass ) { if (uiItemClass == IC_BOBBY_GUN) @@ -3140,8 +3142,6 @@ void CalcFirstIndexForPage( STORE_INVENTORY *pInv, UINT32 uiItemClass ) } else { - bCntItem = FALSE; - usItemIndex = LaptopSaveInfo.BobbyRayInventory[ i ].usItemIndex; if (Weapon[ Item[usItemIndex].ubClassIndex ].ubWeaponType == guiCurrentGunFilterMode) diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index c9b7328e..d4bfd6ef 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -4128,7 +4128,8 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget ) else { OBJECTTYPE *pItem; - //OBJECTTYPE tempItem; + OBJECTTYPE tempItem; + PlayAutoResolveSample( (UINT8)(BULLET_IMPACT_1+PreRandom(3)), RATE_11025, 50, 1, MIDDLEPAN ); if( !pTarget->pSoldier->bLife ) { //Soldier already dead (can't kill him again!) @@ -4146,19 +4147,21 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget ) pAttacker->pSoldier->usAttackingWeapon = pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ].usItem; } - //if( pAttacker->bWeaponSlot != HANDPOS ) - //{ //switch items - // memcpy( &tempItem, &pAttacker->pSoldier->inv[ HANDPOS ], sizeof( OBJECTTYPE ) ); - // memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], sizeof( OBJECTTYPE ) ); //CTD - // iImpact = HTHImpact( pAttacker->pSoldier, pTarget->pSoldier, ubAccuracy, (BOOLEAN)(fKnife | fClaw) ); - // memcpy( &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], &pAttacker->pSoldier->inv[ HANDPOS ], sizeof( OBJECTTYPE ) ); - // memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &tempItem, sizeof( OBJECTTYPE ) ); - //} - //else - //{ - // iImpact = HTHImpact( pAttacker->pSoldier, pTarget->pSoldier, ubAccuracy, (BOOLEAN)(fKnife || fClaw) ); - //} - iImpact = 0; + // WANNE: Does this lead to a CTD -> no I did not get any CTD, so I reenabled it + if( pAttacker->bWeaponSlot != HANDPOS ) + { + //switch items + memcpy( &tempItem, &pAttacker->pSoldier->inv[ HANDPOS ], sizeof( OBJECTTYPE ) ); + memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], sizeof( OBJECTTYPE ) ); //CTD + iImpact = HTHImpact( pAttacker->pSoldier, pTarget->pSoldier, ubAccuracy, (BOOLEAN)(fKnife | fClaw) ); + memcpy( &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], &pAttacker->pSoldier->inv[ HANDPOS ], sizeof( OBJECTTYPE ) ); + memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &tempItem, sizeof( OBJECTTYPE ) ); + } + else + { + iImpact = HTHImpact( pAttacker->pSoldier, pTarget->pSoldier, ubAccuracy, (BOOLEAN)(fKnife || fClaw) ); + } + iNewLife = pTarget->pSoldier->bLife - iImpact; if( pAttacker->uiFlags & CELL_MERC )