From ce06c378274278b3ffea28d30a7695584d4a7cfd Mon Sep 17 00:00:00 2001 From: Flugente Date: Sat, 4 Jul 2020 18:52:34 +0000 Subject: [PATCH] Added safety check git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8840 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/LOS.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index c8dbec7c4..ef4602605 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -7434,7 +7434,9 @@ 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 // the same bullet cannot hit a shield multiple times - if ( lastriotshieldholder != pStructure->usStructureID && pStructure->fFlags & STRUCTURE_PERSON ) + if ( lastriotshieldholder != pStructure->usStructureID + && pStructure->fFlags & STRUCTURE_PERSON + && pStructure->usStructureID < TOTAL_SOLDIERS ) { SOLDIERTYPE* pTarget = MercPtrs[pStructure->usStructureID]; @@ -7651,7 +7653,9 @@ 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 && pStructure->fFlags & STRUCTURE_PERSON ) + if ( lastriotshieldholder != pStructure->usStructureID + && pStructure->fFlags & STRUCTURE_PERSON + && pStructure->usStructureID < TOTAL_SOLDIERS ) { SOLDIERTYPE* pTarget = MercPtrs[pStructure->usStructureID];