Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tactical/Item Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ LBENODE* OBJECTTYPE::GetLBEPointer(unsigned int index)

}

bool OBJECTTYPE::exists()
bool OBJECTTYPE::exists() const
{
return(this && ubNumberOfObjects && usItem);
}
Expand Down
2 changes: 1 addition & 1 deletion Tactical/Item Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class OBJECTTYPE

bool operator==(OBJECTTYPE& compare);
bool operator==(const OBJECTTYPE& compare)const;
bool exists();
bool exists() const;
bool IsActiveLBE(unsigned int index);
bool HasAnyActiveLBEs(SOLDIERTYPE * pSoldier = NULL, UINT8 iter = 0);
LBENODE* GetLBEPointer(unsigned int index);
Expand Down
21 changes: 11 additions & 10 deletions Tactical/Soldier Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ unsigned int Inventory::size( ) const {
return inv.size( );
}

auto Inventory::get() const -> const std::vector<OBJECTTYPE>& {
return inv;
}

// Assignment operator
Inventory& Inventory::operator=(const Inventory& src)
{
Expand Down Expand Up @@ -19934,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) );
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Tactical/Soldier Control.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ class Inventory {
// How any slots are there in this inventory?
unsigned int size() const;

// const-only accessor
auto get() const -> const std::vector<OBJECTTYPE>&;

//temporarily? public
std::vector<int> bNewItemCount;
std::vector<int> bNewItemCycleCount;
Expand Down