Skip to content

Commit

Permalink
Avoid divide by zero in vehicle::print_fuel_indicator
Browse files Browse the repository at this point in the history
Cap can be zero on wrecks, so it's important we check for it.

Fixes #64407
  • Loading branch information
pjf committed Mar 21, 2023
1 parent b738ae2 commit 7945343
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vehicle_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void vehicle::print_fuel_indicator( const catacurses::window &win, const point &
int indf = ( amnt / 20 ) % 5;
mvwprintz( win, p + point( indf, 0 ), f_color, "%c", fsyms[indf] );
if( verbose ) {
if( debug_mode ) {
if( debug_mode || cap == 0 ) {
mvwprintz( win, p + point( 6, 0 ), f_color, "%d/%d", f_left, cap );
} else {
mvwprintz( win, p + point( 6, 0 ), f_color, "%d", f_left * 100 / cap );
Expand All @@ -453,7 +453,7 @@ void vehicle::print_fuel_indicator( const catacurses::window &win, const point &
rate += power_to_energy_bat( net_battery_charge_rate( /* include_reactors = */ true ), 1_hours );
units = _( "kJ" );
}
if( rate != 0 ) {
if( rate != 0 && cap != 0 ) {
int tank_use = 0;
nc_color tank_color = c_light_green;
std::string tank_goal = _( "full" );
Expand Down

0 comments on commit 7945343

Please sign in to comment.