From dee2415d4ae88ed64b1ce96ae6b6e7755b0d059d Mon Sep 17 00:00:00 2001 From: Marco Costa Date: Fri, 29 Mar 2024 16:42:25 -0300 Subject: [PATCH] simplify SOLDIERTYPE::GetDiseaseContactProtection( ) --- Tactical/Soldier Control.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 46a09d69d..7ff397021 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -19938,22 +19938,19 @@ FLOAT SOLDIERTYPE::GetDiseaseContactProtection( ) // if we wear special equipment, lower our chances of being infected FLOAT bestfacegear = 0.0f; FLOAT bestprotectivegear = 0.0f; - INT8 invsize = (INT8)inv.size( ); // remember inventorysize, so we don't call size() repeatedly - for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) + for ( const auto &item : inv.get() ) { - if ( inv[bLoop].exists( ) ) + if ( item.exists( ) ) { - OBJECTTYPE* pObj = &(inv[bLoop]); - - if ( pObj && (*pObj)[0]->data.objectStatus >= USABLE ) + if ( item[0]->data.objectStatus >= USABLE ) { - if ( HasItemFlag( pObj->usItem, DISEASEPROTECTION_1 ) ) + if ( HasItemFlag( item.usItem, DISEASEPROTECTION_1 ) ) { - bestfacegear = max( bestfacegear, (FLOAT)((*pObj)[0]->data.objectStatus / 100) ); + bestfacegear = max( bestfacegear, (FLOAT)(item[0]->data.objectStatus / 100) ); } - if ( HasItemFlag( pObj->usItem, DISEASEPROTECTION_2 ) ) + if ( HasItemFlag( item.usItem, DISEASEPROTECTION_2 ) ) { - bestprotectivegear = max( bestprotectivegear, (FLOAT)((*pObj)[0]->data.objectStatus / 100) ); + bestprotectivegear = max( bestprotectivegear, (FLOAT)(item[0]->data.objectStatus / 100) ); } } }