Skip to content

Commit

Permalink
Moved more string consts into single file (#38220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Feb 22, 2020
1 parent a000b0b commit d9c6079
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 91 deletions.
24 changes: 24 additions & 0 deletions src/cata_string_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ static const std::string flag_ALLOWS_REMOTE_USE( "ALLOWS_REMOTE_USE" );
static const std::string flag_ALWAYS_TWOHAND( "ALWAYS_TWOHAND" );
static const std::string flag_ANESTHESIA( "ANESTHESIA" );
static const std::string flag_ANIMAL_CTRL( "ANIMAL_CTRL" );
static const std::string flag_ARMOR( "ARMOR" );
static const std::string flag_AURA( "AURA" );
static const std::string flag_AUT_START( "AUT_START" );
static const std::string flag_auto_wield( "auto_wield" );
Expand Down Expand Up @@ -1007,6 +1008,7 @@ static const std::string flag_CONDUCTIVE( "CONDUCTIVE" );
static const std::string flag_CONSOLE( "CONSOLE" );
static const std::string flag_CONSUMABLE( "CONSUMABLE" );
static const std::string flag_CONTAINER( "CONTAINER" );
static const std::string flag_CONTROL_ANIMAL( "CONTROL_ANIMAL" );
static const std::string flag_CONTROLS( "CONTROLS" );
static const std::string flag_COOKED( "COOKED" );
static const std::string flag_COOLER( "COOLER" );
Expand Down Expand Up @@ -1089,6 +1091,7 @@ static const std::string flag_FLAMMABLE_ASH( "FLAMMABLE_ASH" );
static const std::string flag_FLASH_PROTECTION( "FLASH_PROTECTION" );
static const std::string flag_FLAT( "FLAT" );
static const std::string flag_FLAT_SURF( "FLAT_SURF" );
static const std::string flag_FLOATS( "FLOATS" );
static const std::string flag_FLOTATION( "FLOTATION" );
static const std::string flag_FLOWER( "FLOWER" );
static const std::string flag_FOLDABLE( "FOLDABLE" );
Expand All @@ -1115,6 +1118,7 @@ static const std::string flag_GROWTH_HARVEST( "GROWTH_HARVEST" );
static const std::string flag_GROWTH_MATURE( "GROWTH_MATURE" );
static const std::string flag_GROWTH_SEEDLING( "GROWTH_SEEDLING" );
static const std::string flag_HALF_BOARD( "HALF_BOARD" );
static const std::string flag_HARNESS_any( "HARNESS_any" );
static const std::string flag_HEAT_IMMUNE( "HEAT_IMMUNE" );
static const std::string flag_HELI_CRASH( "HELI_CRASH" );
static const std::string flag_HELMET_COMPAT( "HELMET_COMPAT" );
Expand Down Expand Up @@ -1217,6 +1221,7 @@ static const std::string flag_NONCONDUCTIVE( "NONCONDUCTIVE" );
static const std::string flag_NPC_ACTIVATE( "NPC_ACTIVATE" );
static const std::string flag_NPC_SAFE( "NPC_SAFE" );
static const std::string flag_NUTRIENT_OVERRIDE( "NUTRIENT_OVERRIDE" );
static const std::string flag_OBSTACLE( "OBSTACLE" );
static const std::string flag_ON_CONTROLS( "ON_CONTROLS" );
static const std::string flag_ON_ROOF( "ON_ROOF" );
static const std::string flag_ONLY_ONE( "ONLY_ONE" );
Expand Down Expand Up @@ -1303,6 +1308,7 @@ static const std::string flag_SEAT( "SEAT" );
static const std::string flag_SEATBELT( "SEATBELT" );
static const std::string flag_SECRET( "SECRET" );
static const std::string flag_SECURITY( "SECURITY" );
static const std::string flag_SELF_JACK( "SELF_JACK" );
static const std::string flag_SEMITANGIBLE( "SEMITANGIBLE" );
static const std::string flag_SHARP( "SHARP" );
static const std::string flag_SHORT( "SHORT" );
Expand Down Expand Up @@ -1363,6 +1369,7 @@ static const std::string flag_UNCRAFT_LIQUIDS_CONTAINED( "UNCRAFT_LIQUIDS_CONTAI
static const std::string flag_UNCRAFT_SINGLE_CHARGE( "UNCRAFT_SINGLE_CHARGE " );
static const std::string flag_UNDERSIZE( "UNDERSIZE" );
static const std::string flag_UNDERWATER_GUN( "UNDERWATER_GUN" );
static const std::string flag_UNMOUNT_ON_DAMAGE( "UNMOUNT_ON_DAMAGE" );
static const std::string flag_UNMOUNT_ON_MOVE( "UNMOUNT_ON_MOVE" );
static const std::string flag_UNRECOVERABLE( "UNRECOVERABLE" );
static const std::string flag_UNSTABLE( "UNSTABLE" );
Expand Down Expand Up @@ -1405,6 +1412,7 @@ static const std::string flag_WRITE_MESSAGE( "WRITE_MESSAGE" );
static const std::string flag_YOUNG( "YOUNG" );
static const std::string flag_ZOOM( "ZOOM" );


static const skill_id skill_archery( "archery" );
static const skill_id skill_barter( "barter" );
static const skill_id skill_bashing( "bashing" );
Expand Down Expand Up @@ -1580,6 +1588,7 @@ static const ter_str_id ter_moss( "t_moss" );
static const ter_str_id ter_nanofab_body( "t_nanofab_body" );
static const ter_str_id ter_ov_smreb_cage( "t_ov_smreb_cage" );
static const ter_str_id ter_palisade_gate_o( "t_palisade_gate_o" );
static const ter_str_id ter_pavement( "t_pavement" );
static const ter_str_id ter_pit( "t_pit" );
static const ter_str_id ter_pit_corpsed( "t_pit_corpsed" );
static const ter_str_id ter_pit_covered( "t_pit_covered" );
Expand Down Expand Up @@ -1707,6 +1716,21 @@ static const std::string part_location_structure( "structure" );
static const std::string part_location_center( "center" );
static const std::string part_location_onroof( "on_roof" );

static const vpart_id vpart_frame_vertical( "frame_vertical" );
static const vpart_id vpart_frame_vertical_2( "frame_vertical_2" );
static const vpart_id vpart_halfboard_horizontal( "halfboard_horizontal" );
static const vpart_id vpart_horn_bicycle( "horn_bicycle" );
static const vpart_id vpart_seat( "seat" );
static const vpart_id vpart_storage_battery( "storage_battery" );
static const vpart_id vpart_turret_mount( "turret_mount" );
static const vpart_id vpart_wheel_mount_heavy( "wheel_mount_heavy" );
static const vpart_id vpart_wheel_mount_heavy_steerable( "wheel_mount_heavy_steerable" );
static const vpart_id vpart_wheel_mount_light( "wheel_mount_light" );
static const vpart_id vpart_wheel_mount_light_steerable( "wheel_mount_light_steerable" );
static const vpart_id vpart_wheel_mount_medium( "wheel_mount_medium" );
static const vpart_id vpart_wheel_mount_medium_steerable( "wheel_mount_medium_steerable" );
static const vpart_id vpart_wheel_wide( "wheel_wide" );

static const std::string GUN_MODE_VAR_NAME( "item::mode" );
static const std::string CLOTHING_MOD_VAR_PREFIX( "clothing_mod_" );

Expand Down
3 changes: 1 addition & 2 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,7 @@ static vpart_id vpart_from_item( const std::string &item_id )
}
}
debugmsg( "item %s used by construction is not base item of any vehicle part!", item_id.c_str() );
static const vpart_id frame_id( "frame_vertical_2" );
return frame_id;
return vpart_frame_vertical_2;
}

void construct::done_vehicle( const tripoint &p )
Expand Down
7 changes: 3 additions & 4 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,8 @@ static void pldrive( int x, int y )
return;
}
if( !remote ) {
static const itype_id fuel_type_animal( "animal" );
const bool has_animal_controls = veh->part_with_feature( part, "CONTROL_ANIMAL", true ) >= 0;
const bool has_controls = veh->part_with_feature( part, "CONTROLS", true ) >= 0;
const bool has_animal_controls = veh->part_with_feature( part, flag_CONTROL_ANIMAL, true ) >= 0;
const bool has_controls = veh->part_with_feature( part, flag_CONTROLS, true ) >= 0;
const bool has_animal = veh->has_engine_type( fuel_type_animal, false ) &&
veh->has_harnessed_animal();
if( !has_controls && !has_animal_controls ) {
Expand All @@ -423,7 +422,7 @@ static void pldrive( int x, int y )
return;
}
} else {
if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) {
if( empty( veh->get_avail_parts( flag_REMOTE_CONTROLS ) ) ) {
add_msg( m_info, _( "Can't drive this vehicle remotely. It has no working controls." ) );
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5591,7 +5591,7 @@ int iuse::unfold_generic( player *p, item *it, bool, const tripoint & )
g->m.destroy_vehicle( veh );
return 0;
}
const bool can_float = size( veh->get_avail_parts( "FLOATS" ) ) > 2;
const bool can_float = size( veh->get_avail_parts( flag_FLOATS ) ) > 2;

const auto invalid_pos = []( const tripoint & pp, bool can_float ) {
return ( g->m.has_flag_ter( TFLAG_DEEP_WATER, pp ) && !can_float ) ||
Expand Down Expand Up @@ -8068,7 +8068,7 @@ static bool hackveh( player &p, item &it, vehicle &veh )
if( !veh.is_locked || !veh.has_security_working() ) {
return true;
}
const bool advanced = !empty( veh.get_avail_parts( "REMOTE_CONTROLS" ) );
const bool advanced = !empty( veh.get_avail_parts( flag_REMOTE_CONTROLS ) );
if( advanced && veh.is_alarm_on ) {
p.add_msg_if_player( m_bad, _( "This vehicle's security system has locked you out!" ) );
return false;
Expand Down Expand Up @@ -8225,7 +8225,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos )
}
}
} else if( choice == 1 ) {
const auto rctrl_parts = veh->get_avail_parts( "REMOTE_CONTROLS" );
const auto rctrl_parts = veh->get_avail_parts( flag_REMOTE_CONTROLS );
// Revert to original behaviour if we can't find remote controls.
if( empty( rctrl_parts ) ) {
veh->use_controls( pos );
Expand Down
2 changes: 1 addition & 1 deletion src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6023,7 +6023,7 @@ std::unique_ptr<vehicle> map::add_vehicle_to_map(
std::vector<int> frame_indices = veh->all_parts_at_location( "structure" );

//Check for boat type vehicles that should be placeable in deep water
const bool can_float = size( veh->get_avail_parts( "FLOATS" ) ) > 2;
const bool can_float = size( veh->get_avail_parts( flag_FLOATS ) ) > 2;

//When hitting a wall, only smash the vehicle once (but walls many times)
bool needs_smashing = false;
Expand Down
2 changes: 1 addition & 1 deletion src/pathfinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ std::vector<tripoint> map::route( const tripoint &f, const tripoint &t,
part = vpobst ? vpobst->part_index() : -1;
int dummy = -1;
if( doors && veh->part_flag( part, VPFLAG_OPENABLE ) &&
( !veh->part_flag( part, "OPENCLOSE_INSIDE" ) ||
( !veh->part_flag( part, flag_OPENCLOSE_INSIDE ) ||
veh_at_internal( cur, dummy ) == veh ) ) {
// Handle car doors, but don't try to path through curtains
newg += 10; // One turn to open, 4 to move there
Expand Down
4 changes: 2 additions & 2 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,15 +1034,15 @@ bool player::has_alarm_clock() const
{
return ( has_item_with_flag( flag_ALARMCLOCK, true ) ||
( g->m.veh_at( pos() ) &&
!empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( "ALARMCLOCK" ) ) ) ||
!empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( flag_ALARMCLOCK ) ) ) ||
has_bionic( bio_watch ) );
}

bool player::has_watch() const
{
return ( has_item_with_flag( flag_WATCH, true ) ||
( g->m.veh_at( pos() ) &&
!empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( "WATCH" ) ) ) ||
!empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( flag_WATCH ) ) ) ||
has_bionic( bio_watch ) );
}

Expand Down
18 changes: 9 additions & 9 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2477,7 +2477,7 @@ void vehicle_part::deserialize( JsonIn &jsin )
// if we don't know what type of part it is, it'll cause problems later.
if( !pid.is_valid() ) {
if( pid.str() == "wheel_underbody" ) {
pid = vpart_id( "wheel_wide" );
pid = vpart_wheel_wide;
} else {
data.throw_error( "bad vehicle part", "id" );
}
Expand Down Expand Up @@ -2520,7 +2520,7 @@ void vehicle_part::deserialize( JsonIn &jsin )

// with VEHICLE tag migrate fuel tanks only if amount field exists
if( base.has_flag( flag_VEHICLE ) ) {
if( data.has_int( "amount" ) && ammo_capacity() > 0 && legacy_fuel != "battery" ) {
if( data.has_int( "amount" ) && ammo_capacity() > 0 && legacy_fuel != fuel_type_battery ) {
ammo_set( legacy_fuel, data.get_int( "amount" ) );
}

Expand Down Expand Up @@ -2686,7 +2686,7 @@ void vehicle::deserialize( JsonIn &jsin )
}

for( const vpart_reference &vp : get_any_parts( "TURRET" ) ) {
install_part( vp.mount(), vpart_id( "turret_mount" ), false );
install_part( vp.mount(), vpart_turret_mount, false );

//Forcibly set turrets' targeting mode to manual if no turret control unit is present on turret's tile on loading save
if( !has_part( global_part_pos3( vp.part() ), "TURRET_CONTROLS" ) ) {
Expand All @@ -2701,23 +2701,23 @@ void vehicle::deserialize( JsonIn &jsin )
// Add vehicle mounts to cars that are missing them.
for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_LIGHT" ) ) {
if( vp.info().has_flag( flag_STEERABLE ) ) {
install_part( vp.mount(), vpart_id( "wheel_mount_light_steerable" ), false );
install_part( vp.mount(), vpart_wheel_mount_light_steerable, false );
} else {
install_part( vp.mount(), vpart_id( "wheel_mount_light" ), false );
install_part( vp.mount(), vpart_wheel_mount_light, false );
}
}
for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_MEDIUM" ) ) {
if( vp.info().has_flag( flag_STEERABLE ) ) {
install_part( vp.mount(), vpart_id( "wheel_mount_medium_steerable" ), false );
install_part( vp.mount(), vpart_wheel_mount_medium_steerable, false );
} else {
install_part( vp.mount(), vpart_id( "wheel_mount_medium" ), false );
install_part( vp.mount(), vpart_wheel_mount_medium, false );
}
}
for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_HEAVY" ) ) {
if( vp.info().has_flag( flag_STEERABLE ) ) {
install_part( vp.mount(), vpart_id( "wheel_mount_heavy_steerable" ), false );
install_part( vp.mount(), vpart_wheel_mount_heavy_steerable, false );
} else {
install_part( vp.mount(), vpart_id( "wheel_mount_heavy" ), false );
install_part( vp.mount(), vpart_wheel_mount_heavy, false );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void vehicle::turrets_set_targeting()
turrets[sel]->enabled = false;
}

for( const vpart_reference &vp : get_avail_parts( "TURRET_CONTROLS" ) ) {
for( const vpart_reference &vp : get_avail_parts( flag_TURRET_CONTROLS ) ) {
vehicle_part &e = vp.part();
if( e.mount == turrets[sel]->mount ) {
e.enabled = turrets[sel]->enabled;
Expand Down
10 changes: 5 additions & 5 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ bool veh_interact::can_self_jack()
{
int lvl = jack_quality( *veh );

for( const vpart_reference &vp : veh->get_avail_parts( "SELF_JACK" ) ) {
for( const vpart_reference &vp : veh->get_avail_parts( flag_SELF_JACK ) ) {
if( vp.part().base.has_quality( quality_SELF_JACK, lvl ) ) {
return true;
}
Expand Down Expand Up @@ -679,8 +679,8 @@ bool veh_interact::can_install_part()
int engines = 0;
int dif_eng = 0;
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" ) ) {
for( const vpart_reference &vp : veh->get_avail_parts( flag_ENGINE ) ) {
if( vp.has_feature( flag_E_HIGHER_SKILL ) ) {
engines++;
dif_eng = dif_eng / 2 + 8;
}
Expand All @@ -691,7 +691,7 @@ bool veh_interact::can_install_part()
if( sel_vpart_info->has_flag( flag_STEERABLE ) ) {
std::set<int> axles;
for( auto &p : veh->steering ) {
if( !veh->part_flag( p, "TRACKED" ) ) {
if( !veh->part_flag( p, flag_TRACKED ) ) {
// tracked parts don't contribute to axle complexity
axles.insert( veh->parts[p].mount.x );
}
Expand Down Expand Up @@ -2987,7 +2987,7 @@ void veh_interact::complete_vehicle( player &p )
contents.clear();

// Power cables must remove parts from the target vehicle, too.
if( veh->part_flag( vehicle_part, "POWER_TRANSFER" ) ) {
if( veh->part_flag( vehicle_part, flag_POWER_TRANSFER ) ) {
veh->remove_remote_part( vehicle_part );
}

Expand Down
Loading

0 comments on commit d9c6079

Please sign in to comment.