Added sanity check to index passed to GetWeapon() to avoid crash when the value of AvHHud::CurrentWeapon() is -1.

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@104 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
XP-Cagey 2005-05-09 07:50:58 +00:00
parent df5227cb08
commit 56353c5987
1 changed files with 8 additions and 1 deletions

View File

@ -165,7 +165,14 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WEAPON* WeaponsResource::GetWeapon( int iId ) { return rgWeapons[iId].iId ? &rgWeapons[iId] : NULL; }
WEAPON* WeaponsResource::GetWeapon( int iId )
{
if( iId < 0 || iId >= MAX_WEAPONS ) { return NULL; }
return rgWeapons[iId].iId ? &rgWeapons[iId] : NULL;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WEAPON* WeaponsResource::GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~