Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move string consts into single file #38181

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions src/cata_string_consts.h

Large diffs are not rendered by default.

88 changes: 44 additions & 44 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ veh_interact::veh_interact( vehicle &veh, const point &p )
for( const auto &e : vpart_info::all() ) {
const vpart_info &vp = e.second;
vpart_shapes[ vp.name() + vp.item ].push_back( &vp );
if( vp.has_flag( "WHEEL" ) ) {
if( vp.has_flag( flag_WHEEL ) ) {
wheel_types.push_back( &vp );
}
}
Expand Down Expand Up @@ -648,7 +648,7 @@ bool veh_interact::can_install_part()
if( is_drive_conflict() ) {
return false;
}
if( sel_vpart_info->has_flag( "FUNNEL" ) ) {
if( sel_vpart_info->has_flag( flag_FUNNEL ) ) {
if( std::none_of( parts_here.begin(), parts_here.end(), [&]( const int e ) {
return veh->parts[e].is_tank();
} ) ) {
Expand All @@ -661,7 +661,7 @@ bool veh_interact::can_install_part()
}
}

if( sel_vpart_info->has_flag( "TURRET" ) ) {
if( sel_vpart_info->has_flag( flag_TURRET ) ) {
if( std::any_of( parts_here.begin(), parts_here.end(), [&]( const int e ) {
return veh->parts[e].is_turret();
} ) ) {
Expand All @@ -674,11 +674,11 @@ bool veh_interact::can_install_part()
}
}

bool is_engine = sel_vpart_info->has_flag( "ENGINE" );
bool is_engine = sel_vpart_info->has_flag( flag_ENGINE );
//count current engines, some engines don't require higher skill
int engines = 0;
int dif_eng = 0;
if( is_engine && sel_vpart_info->has_flag( "E_HIGHER_SKILL" ) ) {
if( is_engine && sel_vpart_info->has_flag( flag_E_HIGHER_SKILL ) ) {
for( const vpart_reference &vp : veh->get_avail_parts( "ENGINE" ) ) {
if( vp.has_feature( "E_HIGHER_SKILL" ) ) {
engines++;
Expand All @@ -688,7 +688,7 @@ bool veh_interact::can_install_part()
}

int dif_steering = 0;
if( sel_vpart_info->has_flag( "STEERABLE" ) ) {
if( sel_vpart_info->has_flag( flag_STEERABLE ) ) {
std::set<int> axles;
for( auto &p : veh->steering ) {
if( !veh->part_flag( p, "TRACKED" ) ) {
Expand Down Expand Up @@ -738,7 +738,7 @@ bool veh_interact::can_install_part()
bool use_aid = false;
bool use_str = false;
item base( sel_vpart_info->item );
if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) {
if( sel_vpart_info->has_flag( flag_NEEDS_JACKING ) ) {
qual = quality_JACK;
lvl = jack_quality( *veh );
str = veh->lift_strength();
Expand Down Expand Up @@ -846,7 +846,7 @@ bool veh_interact::do_install( std::string &msg )
tab_filters[1] = [&]( const vpart_info * p ) {
auto &part = *p;
return part.has_flag( VPFLAG_CARGO ) && // Cargo
!part.has_flag( "TURRET" );
!part.has_flag( flag_TURRET );
};
tab_filters[2] = [&]( const vpart_info * p ) {
auto &part = *p;
Expand All @@ -860,44 +860,44 @@ bool veh_interact::do_install( std::string &msg )
};
tab_filters[3] = [&]( const vpart_info * p ) {
auto &part = *p;
return part.has_flag( "TRACK" ) || //Util
return part.has_flag( flag_TRACK ) || //Util
part.has_flag( VPFLAG_FRIDGE ) ||
part.has_flag( VPFLAG_FREEZER ) ||
part.has_flag( "KITCHEN" ) ||
part.has_flag( "WELDRIG" ) ||
part.has_flag( "CRAFTRIG" ) ||
part.has_flag( "CHEMLAB" ) ||
part.has_flag( "FORGE" ) ||
part.has_flag( "HORN" ) ||
part.has_flag( "BEEPER" ) ||
part.has_flag( "AUTOPILOT" ) ||
part.has_flag( "WATCH" ) ||
part.has_flag( "ALARMCLOCK" ) ||
part.has_flag( flag_KITCHEN ) ||
part.has_flag( flag_WELDRIG ) ||
part.has_flag( flag_CRAFTRIG ) ||
part.has_flag( flag_CHEMLAB ) ||
part.has_flag( flag_FORGE ) ||
part.has_flag( flag_HORN ) ||
part.has_flag( flag_BEEPER ) ||
part.has_flag( flag_AUTOPILOT ) ||
part.has_flag( flag_WATCH ) ||
part.has_flag( flag_ALARMCLOCK ) ||
part.has_flag( VPFLAG_RECHARGE ) ||
part.has_flag( "VISION" ) ||
part.has_flag( "POWER_TRANSFER" ) ||
part.has_flag( "FAUCET" ) ||
part.has_flag( "STEREO" ) ||
part.has_flag( "CHIMES" ) ||
part.has_flag( "MUFFLER" ) ||
part.has_flag( "REMOTE_CONTROLS" ) ||
part.has_flag( "CURTAIN" ) ||
part.has_flag( "SEATBELT" ) ||
part.has_flag( "SECURITY" ) ||
part.has_flag( "SEAT" ) ||
part.has_flag( "BED" ) ||
part.has_flag( "SPACE_HEATER" ) ||
part.has_flag( "COOLER" ) ||
part.has_flag( "DOOR_MOTOR" ) ||
part.has_flag( "WATER_PURIFIER" ) ||
part.has_flag( "WORKBENCH" );
part.has_flag( flag_VISION ) ||
part.has_flag( flag_POWER_TRANSFER ) ||
part.has_flag( flag_FAUCET ) ||
part.has_flag( flag_STEREO ) ||
part.has_flag( flag_CHIMES ) ||
part.has_flag( flag_MUFFLER ) ||
part.has_flag( flag_REMOTE_CONTROLS ) ||
part.has_flag( flag_CURTAIN ) ||
part.has_flag( flag_SEATBELT ) ||
part.has_flag( flag_SECURITY ) ||
part.has_flag( flag_SEAT ) ||
part.has_flag( flag_BED ) ||
part.has_flag( flag_SPACE_HEATER ) ||
part.has_flag( flag_COOLER ) ||
part.has_flag( flag_DOOR_MOTOR ) ||
part.has_flag( flag_WATER_PURIFIER ) ||
part.has_flag( flag_WORKBENCH );
};
tab_filters[4] = [&]( const vpart_info * p ) {
auto &part = *p;
return( part.has_flag( VPFLAG_OBSTACLE ) || // Hull
part.has_flag( "ROOF" ) ||
part.has_flag( flag_ROOF ) ||
part.has_flag( VPFLAG_ARMOR ) ) &&
!part.has_flag( "WHEEL" ) &&
!part.has_flag( flag_WHEEL ) &&
!tab_filters[3]( p );
};
tab_filters[5] = [&]( const vpart_info * p ) {
Expand All @@ -907,7 +907,7 @@ bool veh_interact::do_install( std::string &msg )
part.has_flag( VPFLAG_CONTROLS ) ||
part.location == "fuel_source" ||
part.location == "on_battery_mount" ||
( part.location.empty() && part.has_flag( "FUEL_TANK" ) );
( part.location.empty() && part.has_flag( flag_FUEL_TANK ) );
};

// Other: everything that's not in the other filters
Expand Down Expand Up @@ -983,7 +983,7 @@ bool veh_interact::do_install( std::string &msg )
default:
break;
}
if( veh->is_foldable() && !sel_vpart_info->has_flag( "FOLDABLE" ) &&
if( veh->is_foldable() && !sel_vpart_info->has_flag( flag_FOLDABLE ) &&
!query_yn( _( "Installing this part will make the vehicle unfoldable. Continue?" ) ) ) {
return true;
}
Expand Down Expand Up @@ -1660,7 +1660,7 @@ bool veh_interact::can_remove_part( int idx, const player &p )
bool use_aid = false;
bool use_str = false;
item base( sel_vpart_info->item );
if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) {
if( sel_vpart_info->has_flag( flag_NEEDS_JACKING ) ) {
qual = quality_JACK;
lvl = jack_quality( *veh );
str = veh->lift_strength();
Expand Down Expand Up @@ -2014,7 +2014,7 @@ void veh_interact::move_cursor( const point &d, int dstart_at )
if( pt.base.damage() > 0 && pt.info().is_repairable() ) {
need_repair.push_back( i );
}
if( pt.info().has_flag( "WHEEL" ) ) {
if( pt.info().has_flag( flag_WHEEL ) ) {
wheel = &pt;
}
}
Expand Down Expand Up @@ -2558,9 +2558,9 @@ void veh_interact::display_details( const vpart_info *part )
std::string label;
if( part->has_flag( VPFLAG_SEATBELT ) ) {
label = small_mode ? _( "Str" ) : _( "Strength" );
} else if( part->has_flag( "HORN" ) ) {
} else if( part->has_flag( flag_HORN ) ) {
label = _( "Noise" );
} else if( part->has_flag( "MUFFLER" ) ) {
} else if( part->has_flag( flag_MUFFLER ) ) {
label = small_mode ? _( "NoisRed" ) : _( "Noise Reduction" );
} else if( part->has_flag( VPFLAG_EXTENDS_VISION ) ) {
label = _( "Range" );
Expand Down
31 changes: 16 additions & 15 deletions src/veh_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "game_constants.h"
#include "item.h"
#include "mapdata.h"
#include "cata_string_consts.h"

class npc;

Expand Down Expand Up @@ -402,15 +403,15 @@ void vpart_info::load( const JsonObject &jo, const std::string &src )
def.damage_reduction = load_damage_array( dred );
}

if( def.has_flag( "ENGINE" ) ) {
if( def.has_flag( flag_ENGINE ) ) {
load_engine( def.engine_info, jo, def.fuel_type );
}

if( def.has_flag( "WHEEL" ) ) {
if( def.has_flag( flag_WHEEL ) ) {
load_wheel( def.wheel_info, jo );
}

if( def.has_flag( "WORKBENCH" ) ) {
if( def.has_flag( flag_WORKBENCH ) ) {
load_workbench( def.workbench_info, jo );
}

Expand Down Expand Up @@ -576,7 +577,7 @@ void vpart_info::check()
if( part.folded_volume < 0_ml ) {
debugmsg( "vehicle part %s has negative folded volume", part.id.c_str() );
}
if( part.has_flag( "FOLDABLE" ) && part.folded_volume == 0_ml ) {
if( part.has_flag( flag_FOLDABLE ) && part.folded_volume == 0_ml ) {
debugmsg( "vehicle part %s has folding part with zero folded volume", part.name() );
}
if( !item::type_is_defined( part.default_ammo ) ) {
Expand All @@ -601,13 +602,13 @@ void vpart_info::check()
part.id.c_str(), part.fuel_type.c_str() );
part.fuel_type = "null";
}
if( part.has_flag( "TURRET" ) && !base_item_type.gun ) {
if( part.has_flag( flag_TURRET ) && !base_item_type.gun ) {
debugmsg( "vehicle part %s has the TURRET flag, but is not made from a gun item", part.id.c_str() );
}
if( !part.emissions.empty() && !part.has_flag( "EMITTER" ) ) {
if( !part.emissions.empty() && !part.has_flag( flag_EMITTER ) ) {
debugmsg( "vehicle part %s has emissions set, but the EMITTER flag is not set", part.id.c_str() );
}
if( part.has_flag( "EMITTER" ) ) {
if( part.has_flag( flag_EMITTER ) ) {
if( part.emissions.empty() ) {
debugmsg( "vehicle part %s has the EMITTER flag, but no emissions were set", part.id.c_str() );
} else {
Expand All @@ -619,7 +620,7 @@ void vpart_info::check()
}
}
}
if( part.has_flag( "WHEEL" ) && !base_item_type.wheel ) {
if( part.has_flag( flag_WHEEL ) && !base_item_type.wheel ) {
debugmsg( "vehicle part %s has the WHEEL flag, but base item %s is not a wheel. THIS WILL CRASH!",
part.id.c_str(), part.item );
}
Expand Down Expand Up @@ -681,7 +682,7 @@ int vpart_info::format_description( std::string &msg, const nc_color &format_col
long_descrip += description.translated();
}
for( const auto &flagid : flags ) {
if( flagid == "ALARMCLOCK" || flagid == "WATCH" ) {
if( flagid == flag_ALARMCLOCK || flagid == flag_WATCH ) {
continue;
}
json_flag flag = json_flag::get( flagid );
Expand All @@ -692,15 +693,15 @@ int vpart_info::format_description( std::string &msg, const nc_color &format_col
long_descrip += _( flag.info() );
}
}
if( ( has_flag( "SEAT" ) || has_flag( "BED" ) ) && !has_flag( "BELTABLE" ) ) {
json_flag nobelt = json_flag::get( "NONBELTABLE" );
if( ( has_flag( flag_SEAT ) || has_flag( flag_BED ) ) && !has_flag( flag_BELTABLE ) ) {
json_flag nobelt = json_flag::get( flag_NONBELTABLE );
long_descrip += " " + _( nobelt.info() );
}
if( has_flag( "BOARDABLE" ) && has_flag( "OPENABLE" ) ) {
json_flag nobelt = json_flag::get( "DOOR" );
if( has_flag( flag_BOARDABLE ) && has_flag( flag_OPENABLE ) ) {
json_flag nobelt = json_flag::get( flag_DOOR );
long_descrip += " " + _( nobelt.info() );
}
if( has_flag( "TURRET" ) ) {
if( has_flag( flag_TURRET ) ) {
class::item base( item );
long_descrip += string_format( _( "\nRange: %1$5d Damage: %2$5.0f" ),
base.gun_range( true ),
Expand Down Expand Up @@ -1067,7 +1068,7 @@ void vehicle_prototype::finalize()
}
}

if( pt.part.obj().has_flag( "CARGO" ) ) {
if( pt.part.obj().has_flag( flag_CARGO ) ) {
cargo_spots.insert( pt.pos );
}
}
Expand Down
Loading