Skip to content

Commit

Permalink
cata_tiles: fix variant vehicle parts to work with ASCIITiles
Browse files Browse the repository at this point in the history
Fixes CleverRaven#44711

In the conversion of vehicle parts to variants, the fallback
code for ASCIITiles was still using the raw vehicle part id,
not the split vehicle part id with variant.  This caused all
variant vehicle parts to be unidentified in ASCIITILES.

Fix the issue by breaking up the vehicle part into its variant
string, and if a variant part is present, getting the symbol
from the symbols array.
  • Loading branch information
mlangsdorf authored and kevingranade committed Nov 6, 2020
1 parent 891488a commit 0a364a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,9 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ
col = mt.color;
}
} else if( category == C_VEHICLE_PART ) {
const vpart_id vpid( found_id.substr( 3 ) );
const std::pair<std::string,
std::string> &vpid_data = get_vpart_str_variant( found_id.substr( 3 ) );
const vpart_id vpid( vpid_data.first );
if( vpid.is_valid() ) {
const vpart_info &v = vpid.obj();

Expand All @@ -1736,6 +1738,12 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ
sym = v.sym_broken;
} else {
sym = v.sym;
if( !vpid_data.second.empty() ) {
const auto &var_data = v.symbols.find( vpid_data.second );
if( var_data != v.symbols.end() ) {
sym = var_data->second;
}
}
}
subtile = -1;

Expand Down

0 comments on commit 0a364a1

Please sign in to comment.