Skip to content

Commit

Permalink
Prevent displaying fake parts in vehicle interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade committed May 29, 2022
1 parent b0077ce commit 0a41d24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ shared_ptr_fast<ui_adaptor> veh_interact::create_or_get_ui_adaptor()

werase( w_parts );
veh->print_part_list( w_parts, 0, getmaxy( w_parts ) - 1, getmaxx( w_parts ), cpart, highlight_part,
true );
true, false );
wnoutrefresh( w_parts );

werase( w_msg );
Expand Down Expand Up @@ -2502,8 +2502,8 @@ void veh_interact::display_veh()
std::vector<int> structural_parts = veh->all_parts_at_location( "structure" );
for( auto &structural_part : structural_parts ) {
const int p = structural_part;
int sym = veh->part_sym( p );
nc_color col = veh->part_color( p );
int sym = veh->part_sym( p, false, false );
nc_color col = veh->part_color( p, false, false );

const point q = ( veh->part( p ).mount + dd ).rotate( 3 );

Expand All @@ -2525,8 +2525,8 @@ void veh_interact::display_veh()
if( ovp && &ovp->vehicle() != veh ) {
obstruct = true;
}
nc_color col = cpart >= 0 ? veh->part_color( cpart ) : c_black;
int sym = cpart >= 0 ? veh->part_sym( cpart ) : ' ';
nc_color col = cpart >= 0 ? veh->part_color( cpart, false, false ) : c_black;
int sym = cpart >= 0 ? veh->part_sym( cpart, false, false ) : ' ';
mvwputch( w_disp, point( hw, hh ), obstruct ? red_background( col ) : hilite( col ),
special_symbol( sym ) );
wnoutrefresh( w_disp );
Expand Down
6 changes: 3 additions & 3 deletions src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ class vehicle
void deserialize( const JsonObject &data );
// Vehicle parts list - all the parts on a single tile
int print_part_list( const catacurses::window &win, int y1, int max_y, int width, int p,
int hl = -1, bool detail = false ) const;
int hl = -1, bool detail = false, bool include_fakes = true ) const;

// Vehicle parts descriptions - descriptions for all the parts on a single tile
void print_vparts_descs( const catacurses::window &win, int max_y, int width, int p,
Expand Down Expand Up @@ -1168,11 +1168,11 @@ class vehicle
int index_of_part( const vehicle_part *part, bool check_removed = false ) const;

// get symbol for map
char part_sym( int p, bool exact = false ) const;
char part_sym( int p, bool exact = false, bool include_fake = true ) const;
std::string part_id_string( int p, char &part_mod ) const;

// get color for map
nc_color part_color( int p, bool exact = false ) const;
nc_color part_color( int p, bool exact = false, bool include_fake = true ) const;

// Get all printable fuel types
std::vector<itype_id> get_printable_fuel_types() const;
Expand Down
12 changes: 6 additions & 6 deletions src/vehicle_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ std::string vehicle::disp_name() const
return string_format( _( "the %s" ), name );
}

char vehicle::part_sym( const int p, const bool exact ) const
char vehicle::part_sym( const int p, const bool exact, const bool include_fake ) const
{
if( p < 0 || p >= static_cast<int>( parts.size() ) || parts[p].removed ) {
return ' ';
}

int displayed_part = exact ? p : part_displayed_at( parts[p].mount, true );
int displayed_part = exact ? p : part_displayed_at( parts[p].mount, include_fake );
if( displayed_part == -1 ) {
displayed_part = p;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ std::string vehicle::part_id_string( const int p, char &part_mod ) const
return vp.id.str() + ( vp.variant.empty() ? "" : "_" + vp.variant );
}

nc_color vehicle::part_color( const int p, const bool exact ) const
nc_color vehicle::part_color( const int p, const bool exact, const bool include_fake ) const
{
if( p < 0 || p >= static_cast<int>( parts.size() ) ) {
return c_black;
Expand All @@ -114,7 +114,7 @@ nc_color vehicle::part_color( const int p, const bool exact ) const
if( parm >= 0 ) {
col = part_info( parm ).color;
} else {
const int displayed_part = exact ? p : part_displayed_at( parts[p].mount, true );
const int displayed_part = exact ? p : part_displayed_at( parts[p].mount, include_fake );

if( displayed_part < 0 || displayed_part >= static_cast<int>( parts.size() ) ) {
return c_black;
Expand Down Expand Up @@ -164,12 +164,12 @@ nc_color vehicle::part_color( const int p, const bool exact ) const
* @param detail Whether or not to show detailed contents for fuel components.
*/
int vehicle::print_part_list( const catacurses::window &win, int y1, const int max_y, int width,
int p, int hl /*= -1*/, bool detail ) const
int p, int hl /*= -1*/, bool detail, bool include_fakes ) const
{
if( p < 0 || p >= static_cast<int>( parts.size() ) ) {
return y1;
}
std::vector<int> pl = this->parts_at_relative( parts[p].mount, true, true );
std::vector<int> pl = this->parts_at_relative( parts[p].mount, true, include_fakes );
int y = y1;
for( size_t i = 0; i < pl.size(); i++ ) {
const vehicle_part &vp = parts[ pl [ i ] ];
Expand Down

0 comments on commit 0a41d24

Please sign in to comment.