Skip to content

Commit

Permalink
Remove vehicle::part_flag(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
irwiss committed Jul 10, 2023
1 parent 1f5aaac commit dc6881b
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 300 deletions.
32 changes: 16 additions & 16 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5222,40 +5222,40 @@ static bool process_map_items( map &here, item_stack &items, safe_reference<item

static void process_vehicle_items( vehicle &cur_veh, int part )
{
bool washing_machine_finished = false;
vehicle_part &vp = cur_veh.part( part );
const vpart_info &vpi = vp.info();

const bool washer_here = cur_veh.part( part ).enabled &&
( cur_veh.part_flag( part, VPFLAG_WASHING_MACHINE ) ||
cur_veh.part_flag( part, VPFLAG_DISHWASHER ) );
const bool washer_here = vp.enabled &&
( vpi.has_flag( VPFLAG_WASHING_MACHINE ) ||
vpi.has_flag( VPFLAG_DISHWASHER ) );

if( washer_here ) {
bool washing_machine_finished = false;
for( item &n : cur_veh.get_items( part ) ) {
const time_duration washing_time = 90_minutes;
const time_duration time_left = washing_time - n.age();
if( time_left <= 0_turns ) {
n.unset_flag( flag_FILTHY );
washing_machine_finished = true;
cur_veh.part( part ).enabled = false;
vp.enabled = false;
} else if( calendar::once_every( 15_minutes ) ) {
//~ %1$d: Number of minutes remaining, %2$s: Name of the vehicle
add_msg( _( "It should take %1$d minutes to finish washing items in the %2$s." ),
to_minutes<int>( time_left ) + 1, cur_veh.name );
break;
}
}
if( washing_machine_finished && !cur_veh.part_flag( part, VPFLAG_APPLIANCE ) ) {
if( washing_machine_finished && !vpi.has_flag( VPFLAG_APPLIANCE ) ) {
//~ %1$s: Cleaner, %2$s: Name of the vehicle
add_msg( _( "The %1$s in the %2$s has finished washing." ), cur_veh.part( part ).name( false ),
cur_veh.name );
add_msg( _( "The %1$s in the %2$s has finished washing." ), vp.name( false ), cur_veh.name );
} else if( washing_machine_finished ) {
add_msg( _( "The %1$s has finished washing." ), cur_veh.part( part ).name( false ) );
add_msg( _( "The %1$s has finished washing." ), vp.name( false ) );
}
}

const bool autoclave_here = cur_veh.part_flag( part, VPFLAG_AUTOCLAVE ) &&
cur_veh.part( part ).enabled;
bool autoclave_finished = false;
const bool autoclave_here = vpi.has_flag( VPFLAG_AUTOCLAVE ) && vp.enabled;
if( autoclave_here ) {
bool autoclave_finished = false;
for( item &n : cur_veh.get_items( part ) ) {
const time_duration cycle_time = 90_minutes;
const time_duration time_left = cycle_time - n.age();
Expand All @@ -5264,7 +5264,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part )
n.unset_flag( flag_NO_STERILE );
}
autoclave_finished = true;
cur_veh.part( part ).enabled = false;
vp.enabled = false;
} else if( calendar::once_every( 15_minutes ) ) {
const int minutes = to_minutes<int>( time_left ) + 1;
//~ %1$d: Number of minutes remaining, %2$s: Name of the vehicle
Expand All @@ -5274,7 +5274,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part )
break;
}
}
if( autoclave_finished && !cur_veh.part_flag( part, VPFLAG_APPLIANCE ) ) {
if( autoclave_finished && !vpi.has_flag( VPFLAG_APPLIANCE ) ) {
add_msg( _( "The autoclave in the %s has finished its cycle." ), cur_veh.name );
} else if( autoclave_finished ) {
add_msg( _( "The autoclave has finished its cycle." ) );
Expand All @@ -5283,8 +5283,8 @@ static void process_vehicle_items( vehicle &cur_veh, int part )

const int recharge_part_idx = cur_veh.part_with_feature( part, VPFLAG_RECHARGE, true );
if( recharge_part_idx >= 0 ) {
vehicle_part recharge_part = cur_veh.part( recharge_part_idx );
if( !recharge_part.removed && !recharge_part.is_broken() && recharge_part.enabled ) {
const vehicle_part &recharge_part = cur_veh.part( recharge_part_idx );
if( !recharge_part.removed && recharge_part.enabled ) {
for( item &n : cur_veh.get_items( part ) ) {
if( !n.has_flag( flag_RECHARGE ) && !n.has_flag( flag_USE_UPS ) ) {
continue;
Expand Down
3 changes: 2 additions & 1 deletion src/pathfinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ std::vector<tripoint> map::route( const tripoint &f, const tripoint &t,

newg += 2 * hp / bash + 8 + 4;
} else if( part >= 0 ) {
if( !doors || !veh->part_flag( part, VPFLAG_OPENABLE ) ) {
const vehicle_part &vp = veh->part( part );
if( !doors || !vp.info().has_flag( VPFLAG_OPENABLE ) ) {
// Won't be openable, don't try from other sides
layer.state[index] = ASL_CLOSED;
}
Expand Down
2 changes: 1 addition & 1 deletion src/veh_appliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ bool veh_app_interact::can_unplug()
{
vehicle_part_range vpr = veh->get_all_parts();
return std::any_of( vpr.begin(), vpr.end(), []( const vpart_reference & ref ) {
return ref.vehicle().part_flag( static_cast<int>( ref.part_index() ), "POWER_TRANSFER" );
return ref.info().has_flag( "POWER_TRANSFER" );
} );
}

Expand Down
Loading

0 comments on commit dc6881b

Please sign in to comment.