Prevent selecting secondaries with ammo==0
derhass reported that using demo content allows the user to select non-demo weapons, which then render incorrectly. derhass observed the problem when the game automatically changed weapons, but affected users can also select the missing weapon by hand. Demo data sets non-demo weapons to have zero ammo_usage, so a player has "enough" rounds even when he has none. Past releases blocked this through the dedicated secondary_weapon_flags field. Add an explicit check for non-zero ammo. Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/165>
This commit is contained in:
parent
ceafa62d64
commit
472c492ac4
|
@ -229,8 +229,9 @@ has_weapon_result player_has_primary_weapon(int weapon_num)
|
||||||
has_weapon_result player_has_secondary_weapon(int weapon_num)
|
has_weapon_result player_has_secondary_weapon(int weapon_num)
|
||||||
{
|
{
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
|
const auto secondary_ammo = get_local_player_secondary_ammo()[weapon_num];
|
||||||
const auto weapon_index = Secondary_weapon_to_weapon_info[weapon_num];
|
const auto weapon_index = Secondary_weapon_to_weapon_info[weapon_num];
|
||||||
if (Weapon_info[weapon_index].ammo_usage <= get_local_player_secondary_ammo()[weapon_num])
|
if (secondary_ammo && Weapon_info[weapon_index].ammo_usage <= secondary_ammo)
|
||||||
return_value = has_weapon_result::has_weapon_flag | has_weapon_result::has_energy_flag | has_weapon_result::has_ammo_flag;
|
return_value = has_weapon_result::has_weapon_flag | has_weapon_result::has_energy_flag | has_weapon_result::has_ammo_flag;
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue