diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 775eba95b9e54..63a92e22da6ca 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -944,7 +944,6 @@ 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" ); @@ -1008,7 +1007,6 @@ 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" ); @@ -1091,7 +1089,6 @@ 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" ); @@ -1118,7 +1115,6 @@ 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" ); @@ -1221,7 +1217,6 @@ 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" ); @@ -1308,7 +1303,6 @@ 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" ); @@ -1369,7 +1363,6 @@ 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" ); @@ -1412,7 +1405,6 @@ 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" ); @@ -1588,7 +1580,6 @@ 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" ); @@ -1716,21 +1707,6 @@ 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_" ); diff --git a/src/construction.cpp b/src/construction.cpp index 1472f5712ee19..acaa6147dcb7e 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1105,7 +1105,8 @@ 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() ); - return vpart_frame_vertical_2; + static const vpart_id frame_id( "frame_vertical_2" ); + return frame_id; } void construct::done_vehicle( const tripoint &p ) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 6230d737f48f2..958c2bcf6869b 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -408,8 +408,9 @@ static void pldrive( int x, int y ) return; } if( !remote ) { - 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; + 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 = veh->has_engine_type( fuel_type_animal, false ) && veh->has_harnessed_animal(); if( !has_controls && !has_animal_controls ) { @@ -422,7 +423,7 @@ static void pldrive( int x, int y ) return; } } else { - if( empty( veh->get_avail_parts( flag_REMOTE_CONTROLS ) ) ) { + if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) { add_msg( m_info, _( "Can't drive this vehicle remotely. It has no working controls." ) ); return; } diff --git a/src/iuse.cpp b/src/iuse.cpp index 2ef6f265bf322..0d356583760e9 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -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( flag_FLOATS ) ) > 2; + const bool can_float = size( veh->get_avail_parts( "FLOATS" ) ) > 2; const auto invalid_pos = []( const tripoint & pp, bool can_float ) { return ( g->m.has_flag_ter( TFLAG_DEEP_WATER, pp ) && !can_float ) || @@ -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( flag_REMOTE_CONTROLS ) ); + const bool advanced = !empty( veh.get_avail_parts( "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; @@ -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( flag_REMOTE_CONTROLS ); + const auto rctrl_parts = veh->get_avail_parts( "REMOTE_CONTROLS" ); // Revert to original behaviour if we can't find remote controls. if( empty( rctrl_parts ) ) { veh->use_controls( pos ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index e8df1bdc016ff..b436cffb8da70 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -6023,7 +6023,7 @@ std::unique_ptr map::add_vehicle_to_map( std::vector 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( flag_FLOATS ) ) > 2; + const bool can_float = size( veh->get_avail_parts( "FLOATS" ) ) > 2; //When hitting a wall, only smash the vehicle once (but walls many times) bool needs_smashing = false; diff --git a/src/pathfinding.cpp b/src/pathfinding.cpp index 1b24ec8a85e97..5629d5d29148e 100644 --- a/src/pathfinding.cpp +++ b/src/pathfinding.cpp @@ -345,7 +345,7 @@ std::vector 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, flag_OPENCLOSE_INSIDE ) || + ( !veh->part_flag( part, "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 diff --git a/src/player.cpp b/src/player.cpp index d58c1277f7fa6..43631a1311edb 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1034,7 +1034,7 @@ 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( flag_ALARMCLOCK ) ) ) || + !empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( "ALARMCLOCK" ) ) ) || has_bionic( bio_watch ) ); } @@ -1042,7 +1042,7 @@ 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( flag_WATCH ) ) ) || + !empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( "WATCH" ) ) ) || has_bionic( bio_watch ) ); } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index fec8ead5c5ea5..cb14a5013fd56 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -2475,7 +2475,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_wheel_wide; + pid = vpart_id( "wheel_wide" ); } else { data.throw_error( "bad vehicle part", "id" ); } @@ -2518,7 +2518,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 != fuel_type_battery ) { + if( data.has_int( "amount" ) && ammo_capacity() > 0 && legacy_fuel != "battery" ) { ammo_set( legacy_fuel, data.get_int( "amount" ) ); } @@ -2684,7 +2684,7 @@ void vehicle::deserialize( JsonIn &jsin ) } for( const vpart_reference &vp : get_any_parts( "TURRET" ) ) { - install_part( vp.mount(), vpart_turret_mount, false ); + install_part( vp.mount(), vpart_id( "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" ) ) { @@ -2699,23 +2699,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_wheel_mount_light_steerable, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_light_steerable" ), false ); } else { - install_part( vp.mount(), vpart_wheel_mount_light, false ); + install_part( vp.mount(), vpart_id( "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_wheel_mount_medium_steerable, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_medium_steerable" ), false ); } else { - install_part( vp.mount(), vpart_wheel_mount_medium, false ); + install_part( vp.mount(), vpart_id( "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_wheel_mount_heavy_steerable, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_heavy_steerable" ), false ); } else { - install_part( vp.mount(), vpart_wheel_mount_heavy, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_heavy" ), false ); } } diff --git a/src/turret.cpp b/src/turret.cpp index bdaae9db90ea4..c43d3f12d8027 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -331,7 +331,7 @@ void vehicle::turrets_set_targeting() turrets[sel]->enabled = false; } - for( const vpart_reference &vp : get_avail_parts( flag_TURRET_CONTROLS ) ) { + for( const vpart_reference &vp : get_avail_parts( "TURRET_CONTROLS" ) ) { vehicle_part &e = vp.part(); if( e.mount == turrets[sel]->mount ) { e.enabled = turrets[sel]->enabled; diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 9107ea531bf10..a21b7dddbbb4d 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -629,7 +629,7 @@ bool veh_interact::can_self_jack() { int lvl = jack_quality( *veh ); - for( const vpart_reference &vp : veh->get_avail_parts( flag_SELF_JACK ) ) { + for( const vpart_reference &vp : veh->get_avail_parts( "SELF_JACK" ) ) { if( vp.part().base.has_quality( quality_SELF_JACK, lvl ) ) { return true; } @@ -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( flag_ENGINE ) ) { - if( vp.has_feature( flag_E_HIGHER_SKILL ) ) { + for( const vpart_reference &vp : veh->get_avail_parts( "ENGINE" ) ) { + if( vp.has_feature( "E_HIGHER_SKILL" ) ) { engines++; dif_eng = dif_eng / 2 + 8; } @@ -691,7 +691,7 @@ bool veh_interact::can_install_part() if( sel_vpart_info->has_flag( flag_STEERABLE ) ) { std::set axles; for( auto &p : veh->steering ) { - if( !veh->part_flag( p, flag_TRACKED ) ) { + if( !veh->part_flag( p, "TRACKED" ) ) { // tracked parts don't contribute to axle complexity axles.insert( veh->parts[p].mount.x ); } @@ -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, flag_POWER_TRANSFER ) ) { + if( veh->part_flag( vehicle_part, "POWER_TRANSFER" ) ) { veh->remove_remote_part( vehicle_part ); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 0fb9e0c5902ea..b64019151dc74 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -183,7 +183,7 @@ void vehicle_stack::insert( const item &newitem ) units::volume vehicle_stack::max_volume() const { - if( myorigin->part_flag( part_num, flag_CARGO ) && myorigin->parts[part_num].is_available() ) { + if( myorigin->part_flag( part_num, "CARGO" ) && myorigin->parts[part_num].is_available() ) { // Set max volume for vehicle cargo to prevent integer overflow return std::min( myorigin->parts[part_num].info().size, 10000_liter ); } @@ -245,7 +245,7 @@ bool vehicle::remote_controlled( const player &p ) const return false; } - for( const vpart_reference &vp : get_avail_parts( flag_REMOTE_CONTROLS ) ) { + for( const vpart_reference &vp : get_avail_parts( "REMOTE_CONTROLS" ) ) { if( rl_dist( p.pos(), vp.pos() ) <= 40 ) { return true; } @@ -260,6 +260,7 @@ bool vehicle::remote_controlled( const player &p ) const * loading from a game saved before the vehicle construction rules overhaul). */ void vehicle::add_missing_frames() { + static const vpart_id frame_id( "frame_vertical" ); //No need to check the same spot more than once std::set locations_checked; for( auto &i : parts ) { @@ -277,7 +278,7 @@ void vehicle::add_missing_frames() } if( !found ) { // Install missing frame - parts.emplace_back( vpart_frame_vertical, i.mount, item( vpart_frame_vertical->item ) ); + parts.emplace_back( frame_id, i.mount, item( frame_id->item ) ); } } } @@ -402,7 +403,7 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) //Provide some variety to non-mint vehicles if( veh_status != 0 ) { //Leave engine running in some vehicles, if the engine has not been destroyed - if( veh_fuel_mult > 0 && !empty( get_avail_parts( flag_ENGINE ) ) && + if( veh_fuel_mult > 0 && !empty( get_avail_parts( "ENGINE" ) ) && one_in( 8 ) && !destroyEngine && !has_no_key && has_engine_type_not( fuel_type_muscle, true ) ) { engine_on = true; } @@ -1107,7 +1108,7 @@ bool vehicle::has_security_working() const bool found_security = false; if( fuel_left( fuel_type_battery ) > 0 ) { for( int s : speciality ) { - if( part_flag( s, flag_SECURITY ) && parts[ s ].is_available() ) { + if( part_flag( s, "SECURITY" ) && parts[ s ].is_available() ) { found_security = true; break; } @@ -2006,7 +2007,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) const tripoint part_loc = global_part_pos3( p ); // Unboard any entities standing on removed boardable parts - if( part_flag( p, flag_BOARDABLE ) && parts[p].has_flag( vehicle_part::passenger_flag ) ) { + if( part_flag( p, "BOARDABLE" ) && parts[p].has_flag( vehicle_part::passenger_flag ) ) { handler.unboard( part_loc ); } @@ -2043,7 +2044,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) } // Update current engine configuration if needed - if( part_flag( p, flag_ENGINE ) && engines.size() > 1 ) { + if( part_flag( p, "ENGINE" ) && engines.size() > 1 ) { bool any_engine_on = false; for( auto &e : engines ) { @@ -2065,7 +2066,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) const auto lz_iter = loot_zones.find( parts[p].mount ); const bool no_zone = lz_iter != loot_zones.end(); - if( no_zone && part_flag( p, flag_CARGO ) ) { + if( no_zone && part_flag( p, "CARGO" ) ) { // Using the key here (instead of the iterator) will remove all zones on // this mount points regardless of how many there are loot_zones.erase( parts[p].mount ); @@ -2347,7 +2348,7 @@ bool vehicle::find_and_split_vehicles( int exclude ) void vehicle::relocate_passengers( const std::vector &passengers ) { - const auto boardables = get_avail_parts( flag_BOARDABLE ); + const auto boardables = get_avail_parts( "BOARDABLE" ); for( player *passenger : passengers ) { for( const vpart_reference &vp : boardables ) { if( vp.part().passenger_id == passenger->getID() ) { @@ -2437,7 +2438,7 @@ bool vehicle::split_vehicles( const std::vector> &new_vehs, player *passenger = nullptr; // Unboard any entities standing on any transferred part - if( part_flag( mov_part, flag_BOARDABLE ) ) { + if( part_flag( mov_part, "BOARDABLE" ) ) { passenger = get_passenger( mov_part ); if( passenger ) { passengers.push_back( passenger ); @@ -2791,7 +2792,7 @@ int vehicle::next_part_to_close( int p, bool outside ) const if( part_flag( *part_it, VPFLAG_OPENABLE ) && parts[ *part_it ].is_available() && parts[*part_it].open == 1 - && ( !outside || !part_flag( *part_it, flag_OPENCLOSE_INSIDE ) ) ) { + && ( !outside || !part_flag( *part_it, "OPENCLOSE_INSIDE" ) ) ) { return *part_it; } } @@ -2805,7 +2806,7 @@ int vehicle::next_part_to_open( int p, bool outside ) const // We want forwards, since we open the innermost thing first (curtains), and then the innermost thing (door) for( auto &elem : parts_here ) { if( part_flag( elem, VPFLAG_OPENABLE ) && parts[ elem ].is_available() && parts[elem].open == 0 && - ( !outside || !part_flag( elem, flag_OPENCLOSE_INSIDE ) ) ) { + ( !outside || !part_flag( elem, "OPENCLOSE_INSIDE" ) ) ) { return elem; } } @@ -3114,7 +3115,7 @@ int vehicle::roof_at_part( const int part ) const { std::vector parts_in_square = parts_at_relative( parts[part].mount, true ); for( const int p : parts_in_square ) { - if( part_info( p ).location == "on_roof" || part_flag( p, flag_ROOF ) ) { + if( part_info( p ).location == "on_roof" || part_flag( p, "ROOF" ) ) { return p; } } @@ -3768,7 +3769,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) double muffle = 1.0; double m = 0.0; int exhaust_part = -1; - for( const vpart_reference &vp : get_avail_parts( flag_MUFFLER ) ) { + for( const vpart_reference &vp : get_avail_parts( "MUFFLER" ) ) { m = 1.0 - ( 1.0 - vp.info().bonus / 100.0 ) * vp.part().health_percent(); if( m < muffle ) { muffle = m; @@ -5628,8 +5629,7 @@ void vehicle::remove_remote_part( int part_num ) int remote_partnum = veh->loose_parts[j]; auto remote_part = &veh->parts[remote_partnum]; - if( veh->part_flag( remote_partnum, flag_POWER_TRANSFER ) && - remote_part->target.first == local_abs ) { + if( veh->part_flag( remote_partnum, "POWER_TRANSFER" ) && remote_part->target.first == local_abs ) { veh->remove_part( remote_partnum ); return; } @@ -5643,7 +5643,7 @@ void vehicle::shed_loose_parts() // it will stay empty. while( !loose_parts.empty() ) { const int elem = loose_parts.front(); - if( part_flag( elem, flag_POWER_TRANSFER ) ) { + if( part_flag( elem, "POWER_TRANSFER" ) ) { remove_remote_part( elem ); } @@ -5694,12 +5694,12 @@ void vehicle::refresh_insides() bool cover = false; for( auto &j : parts_n3ar ) { // another roof -- cover - if( part_flag( j, flag_ROOF ) && parts[ j ].is_available() ) { + if( part_flag( j, "ROOF" ) && parts[ j ].is_available() ) { cover = true; break; - } else if( part_flag( j, flag_OBSTACLE ) && parts[ j ].is_available() ) { + } else if( part_flag( j, "OBSTACLE" ) && parts[ j ].is_available() ) { // found an obstacle, like board or windshield or door - if( parts[j].inside || ( part_flag( j, flag_OPENABLE ) && parts[j].open ) ) { + if( parts[j].inside || ( part_flag( j, "OPENABLE" ) && parts[j].open ) ) { // door and it's open -- can't cover continue; } @@ -5748,8 +5748,8 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) if( !aimed ) { bool found_obs = false; for( auto &i : pl ) { - if( part_flag( i, flag_OBSTACLE ) && - ( !part_flag( i, flag_OPENABLE ) || !parts[i].open ) ) { + if( part_flag( i, "OBSTACLE" ) && + ( !part_flag( i, "OPENABLE" ) || !parts[i].open ) ) { found_obs = true; break; } @@ -5763,12 +5763,12 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) int target_part = random_entry( pl ); // door motor mechanism is protected by closed doors - if( part_flag( target_part, flag_DOOR_MOTOR ) ) { + if( part_flag( target_part, "DOOR_MOTOR" ) ) { // find the most strong openable that is not open int strongest_door_part = -1; int strongest_door_durability = INT_MIN; for( int part : pl ) { - if( part_flag( part, flag_OPENABLE ) && !parts[part].open ) { + if( part_flag( part, "OPENABLE" ) && !parts[part].open ) { int door_durability = part_info( part ).durability; if( door_durability > strongest_door_durability ) { strongest_door_part = part; @@ -5793,8 +5793,7 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) // Covered by armor -- hit both armor and part, but reduce damage by armor's reduction int protection = part_info( armor_part ).damage_reduction[ type ]; // Parts on roof aren't protected - bool overhead = part_flag( target_part, flag_ROOF ) || - part_info( target_part ).location == "on_roof"; + bool overhead = part_flag( target_part, "ROOF" ) || part_info( target_part ).location == "on_roof"; // Calling damage_direct may remove the damaged part // completely, therefore the other index (target_part) becomes // wrong if target_part > armor_part. @@ -6038,7 +6037,7 @@ int vehicle::damage_direct( int p, int dmg, damage_type type ) if( parts[p].is_fuel_store() ) { explode_fuel( p, type ); - } else if( parts[ p ].is_broken() && part_flag( p, flag_UNMOUNT_ON_DAMAGE ) ) { + } else if( parts[ p ].is_broken() && part_flag( p, "UNMOUNT_ON_DAMAGE" ) ) { g->m.spawn_item( global_part_pos3( p ), part_info( p ).item, 1, 0, calendar::turn ); monster *mon = get_pet( p ); if( mon != nullptr && mon->has_effect( effect_harnessed ) ) { diff --git a/src/vehicle_display.cpp b/src/vehicle_display.cpp index 0a619ecf315fc..87d03854a956a 100644 --- a/src/vehicle_display.cpp +++ b/src/vehicle_display.cpp @@ -20,8 +20,9 @@ #include "units.h" #include "color.h" #include "optional.h" -#include "cata_string_consts.h" +static const std::string part_location_structure( "structure" ); +static const itype_id fuel_type_muscle( "muscle" ); std::string vehicle::disp_name() const { @@ -170,7 +171,7 @@ int vehicle::print_part_list( const catacurses::window &win, int y1, const int m } } - if( part_flag( pl[i], flag_CARGO ) ) { + if( part_flag( pl[i], "CARGO" ) ) { //~ used/total volume of a cargo vehicle part partname += string_format( _( " (vol: %s/%s %s)" ), format_volume( stored_volume( pl[i] ) ), @@ -178,7 +179,7 @@ int vehicle::print_part_list( const catacurses::window &win, int y1, const int m volume_units_abbr() ); } - bool armor = part_flag( pl[i], flag_ARMOR ); + bool armor = part_flag( pl[i], "ARMOR" ); std::string left_sym; std::string right_sym; if( armor ) { diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index fe75bf33e5588..82d2da1dd839f 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -652,7 +652,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, // No blood from hallucinations if( critter != nullptr && !critter->is_hallucination() ) { - if( part_flag( ret.part, flag_SHARP ) ) { + if( part_flag( ret.part, "SHARP" ) ) { parts[ret.part].blood += ( 20 + dam ) * 5; } else if( dam > rng( 10, 30 ) ) { parts[ret.part].blood += ( 10 + dam / 2 ) * 5; @@ -669,7 +669,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, if( ph != nullptr ) { ph->hitall( dam, 40, driver ); } else { - const int armor = part_flag( ret.part, flag_SHARP ) ? + const int armor = part_flag( ret.part, "SHARP" ) ? critter->get_armor_cut( bp_torso ) : critter->get_armor_bash( bp_torso ); dam = std::max( 0, dam - armor ); @@ -727,7 +727,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, } } - if( part_flag( ret.part, flag_SHARP ) ) { + if( part_flag( ret.part, "SHARP" ) ) { critter->bleed(); } else { sounds::sound( p, 20, sounds::sound_t::combat, snd, false, "smash_success", "hit_vehicle" ); diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index f09462cf799c1..c6e90526023e3 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -114,7 +114,7 @@ void vehicle::add_toggle_to_opts( std::vector &options, void vehicle::control_doors() { - const auto door_motors = get_avail_parts( flag_DOOR_MOTOR ); + const auto door_motors = get_avail_parts( "DOOR_MOTOR" ); // Indices of doors std::vector< int > doors_with_motors; // Locations used to display the doors @@ -174,7 +174,7 @@ void vehicle::control_doors() if( open ) { int part = next_part_to_open( motor ); if( part != -1 ) { - if( !part_flag( part, flag_CURTAIN ) && option == OPENCURTAINS ) { + if( !part_flag( part, "CURTAIN" ) && option == OPENCURTAINS ) { continue; } open_or_close( part, open ); @@ -188,7 +188,7 @@ void vehicle::control_doors() } else { int part = next_part_to_close( motor ); if( part != -1 ) { - if( part_flag( part, flag_CURTAIN ) && option == CLOSEDOORS ) { + if( part_flag( part, "CURTAIN" ) && option == CLOSEDOORS ) { continue; } open_or_close( part, open ); @@ -447,7 +447,7 @@ void vehicle::smash_security_system() int s = -1; int c = -1; for( int p : speciality ) { - if( part_flag( p, flag_SECURITY ) && !parts[ p ].is_broken() ) { + if( part_flag( p, "SECURITY" ) && !parts[ p ].is_broken() ) { s = p; c = part_with_feature( s, "CONTROLS", true ); break; @@ -1057,10 +1057,10 @@ void vehicle::honk_horn() const bool no_power = !fuel_left( fuel_type_battery, true ); bool honked = false; - for( const vpart_reference &vp : get_avail_parts( flag_HORN ) ) { + for( const vpart_reference &vp : get_avail_parts( "HORN" ) ) { //Only bicycle horn doesn't need electricity to work const vpart_info &horn_type = vp.info(); - if( ( horn_type.get_id() != vpart_horn_bicycle ) && no_power ) { + if( ( horn_type.get_id() != vpart_id( "horn_bicycle" ) ) && no_power ) { continue; } if( !honked ) { @@ -1138,7 +1138,7 @@ void vehicle::beeper_sound() } const bool odd_turn = calendar::once_every( 2_turns ); - for( const vpart_reference &vp : get_avail_parts( flag_BEEPER ) ) { + for( const vpart_reference &vp : get_avail_parts( "BEEPER" ) ) { if( ( odd_turn && vp.has_feature( VPFLAG_EVENTURN ) ) || ( !odd_turn && vp.has_feature( VPFLAG_ODDTURN ) ) ) { continue; @@ -1716,7 +1716,7 @@ void vehicle::use_harness( int part, const tripoint &pos ) } else if( !m.has_flag( MF_PET_MOUNTABLE ) && !m.has_flag( MF_PET_HARNESSABLE ) ) { add_msg( m_info, _( "This creature cannot be harnessed." ) ); return; - } else if( !part_flag( part, Harness_Bodytype ) && !part_flag( part, flag_HARNESS_any ) ) { + } else if( !part_flag( part, Harness_Bodytype ) && !part_flag( part, "HARNESS_any" ) ) { add_msg( m_info, _( "The harness is not adapted for this creature morphology." ) ); return; } diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 7e611734e6993..3c55d4561e34e 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -309,6 +309,8 @@ TEST_CASE( "npc-movement" ) const ter_id t_floor( "t_floor" ); const furn_id f_rubble( "f_rubble" ); const furn_id f_null( "f_null" ); + const vpart_id vpart_frame_vertical( "frame_vertical" ); + const vpart_id vpart_seat( "seat" ); g->place_player( tripoint( 60, 60, 0 ) ); diff --git a/tests/vehicle_drag_test.cpp b/tests/vehicle_drag_test.cpp index 8a67870ca7316..0968ca6b5ed21 100644 --- a/tests/vehicle_drag_test.cpp +++ b/tests/vehicle_drag_test.cpp @@ -18,10 +18,11 @@ #include "type_id.h" #include "point.h" #include "vpart_position.h" -#include "cata_string_consts.h" using efficiency_stat = statistics; +const efftype_id effect_blind( "blind" ); + static void clear_game_drag( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power @@ -59,7 +60,7 @@ static void clear_game_drag( const ter_id &terrain ) static vehicle *setup_drag_test( const vproto_id &veh_id ) { - clear_game_drag( ter_pavement ); + clear_game_drag( ter_id( "t_pavement" ) ); const tripoint map_starting_point( 60, 60, 0 ); vehicle *veh_ptr = g->m.add_vehicle( veh_id, map_starting_point, -90, 0, 0 ); @@ -76,7 +77,7 @@ static vehicle *setup_drag_test( const vproto_id &veh_id ) veh_ptr->toggle_specific_part( vp.part_index(), true ); } // close the doors - const auto doors = veh_ptr->get_avail_parts( flag_OPENABLE ); + const auto doors = veh_ptr->get_avail_parts( "OPENABLE" ); for( const vpart_reference vp : doors ) { const size_t door = vp.part_index(); veh_ptr->close( door ); diff --git a/tests/vehicle_efficiency_test.cpp b/tests/vehicle_efficiency_test.cpp index 4b3eabf3f3053..ef9b7b2a86e53 100644 --- a/tests/vehicle_efficiency_test.cpp +++ b/tests/vehicle_efficiency_test.cpp @@ -32,10 +32,11 @@ #include "type_id.h" #include "point.h" #include "vpart_position.h" -#include "cata_string_consts.h" using efficiency_stat = statistics; +const efftype_id effect_blind( "blind" ); + static void clear_game( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power @@ -85,7 +86,7 @@ static std::map set_vehicle_fuel( vehicle &v, const float veh_fue } // We ignore battery when setting fuel because it uses designated "tanks" - actually_used.erase( fuel_type_battery ); + actually_used.erase( "battery" ); // Currently only one liquid fuel supported REQUIRE( actually_used.size() <= 1 ); @@ -104,8 +105,8 @@ static std::map set_vehicle_fuel( vehicle &v, const float veh_fue vehicle_part &pt = vp.part(); if( pt.is_battery() ) { - pt.ammo_set( fuel_type_battery, pt.ammo_capacity() * veh_fuel_mult ); - ret[ fuel_type_battery ] += pt.ammo_capacity() * veh_fuel_mult; + pt.ammo_set( "battery", pt.ammo_capacity() * veh_fuel_mult ); + ret[ "battery" ] += pt.ammo_capacity() * veh_fuel_mult; } else if( pt.is_tank() && liquid_fuel != "null" ) { float qty = pt.ammo_capacity() * veh_fuel_mult; qty *= std::max( item::find_type( liquid_fuel )->stack_size, 1 ); @@ -118,7 +119,7 @@ static std::map set_vehicle_fuel( vehicle &v, const float veh_fue } // We re-add battery because we want it accounted for, just not in the section above - actually_used.insert( fuel_type_battery ); + actually_used.insert( "battery" ); for( auto iter = ret.begin(); iter != ret.end(); ) { if( iter->second <= 0 || actually_used.count( iter->first ) == 0 ) { iter = ret.erase( iter ); @@ -198,7 +199,7 @@ static int test_efficiency( const vproto_id &veh_id, int &expected_mass, veh_ptr->get_items( vp.part_index() ).clear(); vp.part().ammo_consume( vp.part().ammo_remaining(), vp.pos() ); } - for( const vpart_reference vp : veh.get_avail_parts( flag_OPENABLE ) ) { + for( const vpart_reference vp : veh.get_avail_parts( "OPENABLE" ) ) { veh.close( vp.part_index() ); } @@ -354,29 +355,29 @@ static void test_vehicle( const int pavement_target_smooth_stops = 0, const int dirt_target_smooth_stops = 0 ) { SECTION( type + " on pavement" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_pavement, -1, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_pavement" ), -1, pavement_target ); } SECTION( type + " on dirt" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_dirt, -1, dirt_target ); + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_dirt" ), -1, dirt_target ); } SECTION( type + " on pavement, full stop every 5 turns" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_pavement, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_pavement" ), 5, pavement_target_w_stops ); } SECTION( type + " on dirt, full stop every 5 turns" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_dirt, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_dirt" ), 5, dirt_target_w_stops ); } if( pavement_target_smooth_stops > 0 ) { SECTION( type + " on pavement, alternating 5 turns of acceleration and 5 turns of decceleration" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_pavement, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_pavement" ), 5, pavement_target_smooth_stops, true ); } } if( dirt_target_smooth_stops > 0 ) { SECTION( type + " on dirt, alternating 5 turns of acceleration and 5 turns of decceleration" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_dirt, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_dirt" ), 5, dirt_target_smooth_stops, true ); } } diff --git a/tests/vehicle_part_test.cpp b/tests/vehicle_part_test.cpp index 380a211cc17aa..c8fedbc139e1c 100644 --- a/tests/vehicle_part_test.cpp +++ b/tests/vehicle_part_test.cpp @@ -1,12 +1,11 @@ #include "catch/catch.hpp" #include "veh_type.h" -#include "cata_string_consts.h" TEST_CASE( "verify_copy_from_gets_damage_reduction", "[vehicle]" ) { // Picking halfboard_horizontal as a vpart which is likely to remain // defined via copy-from, and which should have non-zero damage reduction. - const vpart_info &vp = vpart_halfboard_horizontal.obj(); + const vpart_info &vp = vpart_id( "halfboard_horizontal" ).obj(); CHECK( vp.damage_reduction[DT_BASH] != 0 ); } diff --git a/tests/vehicle_turrets_test.cpp b/tests/vehicle_turrets_test.cpp index 7bbc608b983cc..0bd67ad94903d 100644 --- a/tests/vehicle_turrets_test.cpp +++ b/tests/vehicle_turrets_test.cpp @@ -70,12 +70,12 @@ TEST_CASE( "vehicle_turret", "[vehicle] [gun] [magazine] [.]" ) const int idx = veh->install_part( point_zero, e->get_id(), true ); REQUIRE( idx >= 0 ); - REQUIRE( veh->install_part( point_zero, vpart_storage_battery, true ) >= 0 ); + REQUIRE( veh->install_part( point_zero, vpart_id( "storage_battery" ), true ) >= 0 ); veh->charge_battery( 10000 ); auto ammo = ammotype( veh->turret_query( veh->parts[idx] ).base()->ammo_default() ); - if( veh->part_flag( idx, flag_USE_TANKS ) ) { + if( veh->part_flag( idx, "USE_TANKS" ) ) { auto *tank = biggest_tank( ammo ); REQUIRE( tank ); INFO( tank->get_id().str() );