From 3740d8b7c47a7f4c223194bbd0959db10217087b Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 27 Jun 2021 15:32:02 +0000 Subject: [PATCH] Anti-materiel bullets are no longer stopped when they apply damage to a structure, thus restoring piercing ability for them. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9114 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/LOS.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index a6f16e90..9c0a1cf5 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -7553,6 +7553,15 @@ void MoveBullet( INT32 iBullet ) } } + // Flugente: required check as it's possible anti-materiel bullets will destroy a structure mid-flight + if ( !pStructure->pShape ) + { + // Moved here to keep ABC >0 as long as possible + RemoveBullet( iBullet ); + // ReduceAttackBusyCount( ); + return; + } + if (((*(pStructure->pShape))[pBullet->bLOSIndexX][pBullet->bLOSIndexY] & AtHeight[iCurrCubesAboveLevelZ]) > 0) { if (pStructure->fFlags & STRUCTURE_PERSON) @@ -7728,16 +7737,6 @@ void MoveBullet( INT32 iBullet ) // play animation to indicate structure being hit BulletHitStructure( pBullet, pStructure->usStructureID, 1, pBullet->qCurrX, pBullet->qCurrY, pBullet->qCurrZ, FALSE ); gubLocalStructureNumTimesHit[iStructureLoop] = 1; - - // Flugente: anti-materiel rifles have to be handled slightly different - we have to remove the bullet after impact. - // Otherwise we might destroy a structure, but this function won't 'realize' it, leading to invalid memory access - if ( pBullet->usFlags & BULLET_FLAG_ANTIMATERIEL ) - { - // Moved here to keep ABC >0 as long as possible - RemoveBullet( iBullet ); - // ReduceAttackBusyCount( ); - return; - } } } } @@ -7746,7 +7745,8 @@ void MoveBullet( INT32 iBullet ) // Flugente: a riot shield would cover the entire front of a tile. We thus cannot check whether the person would be hit, as the bullet might miss a soldier // Instead, we check whether the structure is indeed a person, whether that person has a riot shield equipped, and whether that shield faces the bullet before it would hit the soldier - if ( lastriotshieldholder != pStructure->usStructureID + if ( pStructure + && lastriotshieldholder != pStructure->usStructureID && pStructure->fFlags & STRUCTURE_PERSON && pStructure->usStructureID < TOTAL_SOLDIERS ) {