From afb794bbc5535b0391f4e066c3e662dae39cb67e Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sun, 3 Nov 2024 15:08:15 +0100 Subject: [PATCH 1/5] typified a bit of vehicle.h and dependents --- src/activity_item_handling.cpp | 6 +- src/avatar.cpp | 2 +- src/cata_tiles.cpp | 8 +- src/character.cpp | 2 +- src/construction.cpp | 3 +- src/creature.cpp | 8 +- src/game.cpp | 10 +- src/grab.cpp | 8 +- src/handle_action.cpp | 6 +- src/handle_liquid.cpp | 6 +- src/iexamine.cpp | 3 +- src/item.cpp | 12 +- src/item_location.cpp | 4 +- src/iuse.cpp | 8 +- src/map.cpp | 56 +++--- src/map_extras.cpp | 14 +- src/mapgen.cpp | 4 +- src/npc.cpp | 2 +- src/ranged.cpp | 12 +- src/savegame_json.cpp | 40 ++-- src/sounds.cpp | 12 +- src/turret.cpp | 26 +-- src/veh_appliance.cpp | 12 +- src/veh_interact.cpp | 26 +-- src/veh_shape.cpp | 4 +- src/veh_type.cpp | 4 +- src/vehicle.cpp | 307 ++++++++++++------------------ src/vehicle.h | 132 ++++++------- src/vehicle_autodrive.cpp | 14 +- src/vehicle_move.cpp | 103 +++++----- src/vehicle_part.cpp | 5 +- src/vehicle_use.cpp | 55 +++--- tests/crafting_test.cpp | 4 +- tests/npc_test.cpp | 4 +- tests/vehicle_efficiency_test.cpp | 2 +- tests/vehicle_fake_part_test.cpp | 16 +- tests/vehicle_power_test.cpp | 12 +- tests/vehicle_ramp_test.cpp | 18 +- tests/vehicle_split_test.cpp | 14 +- tests/vehicle_test.cpp | 14 +- tests/vehicle_turrets_test.cpp | 4 +- tests/vision_test.cpp | 4 +- 42 files changed, 458 insertions(+), 548 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 24758ccbfd807..aa766b67524a7 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -586,7 +586,7 @@ static bool vehicle_activity( Character &you, const tripoint_bub_ms &src_loc, in // so , NPCs can remove the last part on a position, then there is no vehicle there anymore, // for someone else who stored that position at the start of their activity. // so we may need to go looking a bit further afield to find it , at activities end. - for( const tripoint &pt : veh->get_points( true ) ) { + for( const tripoint_bub_ms &pt : veh->get_points( true ) ) { you.activity.coord_set.insert( here.getglobal( pt ).raw() ); } // values[0] @@ -1056,7 +1056,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara // find out if there is a vehicle part here we can remove. // TODO: fix point types std::vector parts = - veh->get_parts_at( src_loc.raw(), "", part_status_flag::any ); + veh->get_parts_at( src_loc, "", part_status_flag::any ); for( vehicle_part *part_elem : parts ) { const int vpindex = veh->index_of_part( part_elem, true ); // if part is not on this vehicle, or if its attached to another part that needs to be removed first. @@ -1101,7 +1101,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara } else if( act == ACT_VEHICLE_REPAIR ) { // find out if there is a vehicle part here we can repair. // TODO: fix point types - std::vector parts = veh->get_parts_at( src_loc.raw(), "", part_status_flag::any ); + std::vector parts = veh->get_parts_at( src_loc, "", part_status_flag::any ); for( vehicle_part *part_elem : parts ) { const vpart_info &vpinfo = part_elem->info(); int vpindex = veh->index_of_part( part_elem, true ); diff --git a/src/avatar.cpp b/src/avatar.cpp index 317ce4c1911ce..1915de0bd29c4 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -688,7 +688,7 @@ void avatar::grab( object_type grab_type_new, const tripoint_rel_ms &grab_point_ map &m = get_map(); if( gtype == object_type::VEHICLE ) { if( const optional_vpart_position ovp = m.veh_at( pos_bub() + gpoint ) ) { - for( const tripoint &target : ovp->vehicle().get_points() ) { + for( const tripoint_bub_ms &target : ovp->vehicle().get_points() ) { if( erase ) { memorize_clear_decoration( m.getglobal( target ), /* prefix = */ "vp_" ); } diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index cfb17a3374783..e27c6d411ab71 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1429,12 +1429,12 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( g->display_overlay_state( ACTION_DISPLAY_VEHICLE_AI ) ) { for( const wrapped_vehicle &elem : here.get_vehicles() ) { const vehicle &veh = *elem.v; - const point veh_pos = veh.global_pos3().xy(); + const point_bub_ms veh_pos = veh.pos_bub().xy(); for( const auto &overlay_data : veh.get_debug_overlay_data() ) { - const point pt = veh_pos + std::get<0>( overlay_data ); + const point_bub_ms pt = veh_pos + std::get<0>( overlay_data ); const int color = std::get<1>( overlay_data ); const std::string &text = std::get<2>( overlay_data ); - overlay_strings.emplace( player_to_screen( pt ), + overlay_strings.emplace( player_to_screen( pt.raw() ), formatted_text( text, color, text_alignment::left ) ); } @@ -3940,7 +3940,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, avatar &you = get_avatar(); if( !veh.forward_velocity() && !veh.player_in_control( you ) && !( you.get_grab_type() == object_type::VEHICLE - && veh.get_points().count( ( you.pos_bub() + you.grab_point ).raw() ) ) + && veh.get_points().count( ( you.pos_bub() + you.grab_point ) ) ) && here.memory_cache_dec_is_dirty( p ) ) { you.memorize_decoration( here.getglobal( p ), vd.get_tileset_id(), subtile, rotation ); } diff --git a/src/character.cpp b/src/character.cpp index f685efce7645f..59c9393de9cbf 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -11106,7 +11106,7 @@ void Character::stagger() const optional_vpart_position vp_there = here.veh_at( dest ); if( vp_there ) { vehicle &veh = vp_there->vehicle(); - if( veh.enclosed_at( dest.raw() ) ) { + if( veh.enclosed_at( dest ) ) { blocked = true; } } diff --git a/src/construction.cpp b/src/construction.cpp index 4125f530ecd24..021b3f561202b 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1733,7 +1733,8 @@ void construct::done_vehicle( const tripoint_bub_ms &p, Character & ) const item &base = components.front(); veh->name = name; - const int partnum = veh->install_part( point_zero, vpart_from_item( base.typeId() ), item( base ) ); + const int partnum = veh->install_part( point_rel_ms_zero, vpart_from_item( base.typeId() ), + item( base ) ); veh->part( partnum ).set_flag( vp_flag::unsalvageable_flag ); // Update the vehicle cache immediately, diff --git a/src/creature.cpp b/src/creature.cpp index ba3e3c57161e6..52c061b16742f 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -245,7 +245,7 @@ bool Creature::will_be_cramped_in_vehicle_tile( const tripoint_abs_ms &loc ) con } if( capacity > 0_ml ) { // First, we'll try to squeeze in. Open-topped vehicle parts have more room to step over cargo. - if( !veh.enclosed_at( here.bub_from_abs( loc ).raw() ) ) { + if( !veh.enclosed_at( here.bub_from_abs( loc ) ) ) { free_cargo *= 1.2; } const creature_size size = get_size(); @@ -630,10 +630,10 @@ bool Creature::sees( const tripoint_bub_ms &t, bool is_avatar, int range_mod ) c // Helper function to check if potential area of effect of a weapon overlaps vehicle // Maybe TODO: If this is too slow, precalculate a bounding box and clip the tested area to it -static bool overlaps_vehicle( const std::set &veh_area, const tripoint &pos, +static bool overlaps_vehicle( const std::set &veh_area, const tripoint_bub_ms &pos, const int area ) { - for( const tripoint &tmp : tripoint_range( pos - tripoint( area, area, 0 ), + for( const tripoint_bub_ms &tmp : tripoint_range( pos - tripoint( area, area, 0 ), pos + tripoint( area - 1, area - 1, 0 ) ) ) { if( veh_area.count( tmp ) > 0 ) { return true; @@ -775,7 +775,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area continue; // Handle this late so that boo_hoo++ can happen } // Expensive check for proximity to vehicle - if( self_area_iff && overlaps_vehicle( in_veh->get_points(), m->pos(), area ) ) { + if( self_area_iff && overlaps_vehicle( in_veh->get_points(), tripoint_bub_ms( m->pos() ), area ) ) { continue; } diff --git a/src/game.cpp b/src/game.cpp index e193b771d298b..a26923790866a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2716,8 +2716,8 @@ void game::setremoteveh( vehicle *veh ) } std::stringstream remote_veh_string; - const tripoint vehpos = veh->global_pos3(); - remote_veh_string << vehpos.x << ' ' << vehpos.y << ' ' << vehpos.z; + const tripoint_bub_ms vehpos = veh->pos_bub(); + remote_veh_string << vehpos.x() << ' ' << vehpos.y() << ' ' << vehpos.z(); u.set_value( "remote_controlling_vehicle", remote_veh_string.str() ); } @@ -5576,7 +5576,7 @@ void game::control_vehicle() { if( vehicle *remote_veh = remoteveh() ) { // remote controls have priority for( const vpart_reference &vpr : remote_veh->get_avail_parts( "REMOTE_CONTROLS" ) ) { - remote_veh->interact_with( vpr.pos() ); + remote_veh->interact_with( vpr.pos_bub() ); return; } } @@ -5690,7 +5690,7 @@ void game::control_vehicle() if( veh ) { // If we reached here, we gained control of a vehicle. // Clear the map memory for the area covered by the vehicle to eliminate ghost vehicles. - for( const tripoint &target : veh->get_points() ) { + for( const tripoint_bub_ms &target : veh->get_points() ) { u.memorize_clear_decoration( m.getglobal( target ), "vp_" ); m.memory_cache_dec_set_dirty( target, true ); } @@ -10025,7 +10025,7 @@ void game::reload_weapon( bool try_everything ) // If we make it here and haven't found anything to reload, start looking elsewhere. const optional_vpart_position ovp = m.veh_at( u.pos_bub() ); if( ovp ) { - const turret_data turret = ovp->vehicle().turret_query( ovp->pos() ); + const turret_data turret = ovp->vehicle().turret_query( ovp->pos_bub() ); if( turret.can_reload() ) { item::reload_option opt = u.select_ammo( turret.base(), true ); if( opt ) { diff --git a/src/grab.cpp b/src/grab.cpp index d92fed314076d..43729ceeceb57 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -148,7 +148,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) if( str_req <= str ) { if( str_req == max_str_req ) { //if vehicle has no wheels, make a noise. - sounds::sound( grabbed_vehicle->global_pos3(), str_req * 2, sounds::sound_t::movement, + sounds::sound( grabbed_vehicle->pos_bub(), str_req * 2, sounds::sound_t::movement, _( "a scraping noise." ), true, "misc", "scraping" ); } //calculate exertion factor and movement penalty @@ -217,7 +217,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) precalc_dir = mdir.dir(); } grabbed_vehicle->precalc_mounts( 1, precalc_dir, grabbed_vehicle->pivot_point() ); - grabbed_vehicle->pos -= grabbed_vehicle->pivot_displacement(); + grabbed_vehicle->pos -= grabbed_vehicle->pivot_displacement().raw(); // Grabbed part has to stay at distance 1 to the player // and in roughly the same direction. @@ -257,7 +257,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) const tripoint player_prev = u.pos(); u.setpos( tripoint_zero ); std::vector colls; - failed = grabbed_vehicle->collision( colls, actual_dir.raw(), true ); + failed = grabbed_vehicle->collision( colls, actual_dir, true ); u.setpos( player_prev ); if( !colls.empty() ) { blocker_name = colls.front().target_name; @@ -308,7 +308,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) for( int p : wheel_indices ) { if( one_in( 2 ) ) { vehicle_part &vp_wheel = grabbed_vehicle->part( p ); - tripoint wheel_p = grabbed_vehicle->global_part_pos3( vp_wheel ); + tripoint_bub_ms wheel_p = grabbed_vehicle->bub_part_pos( vp_wheel ); grabbed_vehicle->handle_trap( wheel_p, vp_wheel ); } } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index c7e264c2a9566..56c5555147097 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -567,7 +567,7 @@ static void pldrive( const tripoint &p ) return; } } - veh->pldrive( get_avatar(), p.xy(), p.z ); + veh->pldrive( get_avatar(), p.x, p.y, p.z ); } static void pldrive( point d ) @@ -762,7 +762,7 @@ static void grab() //solid vehicles can't be grabbed while boarded const optional_vpart_position vp_boarded = here.veh_at( you.pos_bub() ); if( vp_boarded ) { - const std::set grabbed_veh_points = vp->vehicle().get_points(); + const std::set grabbed_veh_points = vp->vehicle().get_points(); if( &vp_boarded->vehicle() == &vp->vehicle() && !empty( vp->vehicle().get_avail_parts( VPFLAG_OBSTACLE ) ) ) { add_msg( m_info, _( "You can't move the %s while you're boarding it." ), veh_name ); @@ -1767,7 +1767,7 @@ static void fire() } // try firing turrets if( const optional_vpart_position ovp = here.veh_at( you.pos_bub() ) ) { - if( turret_data turret_here = ovp->vehicle().turret_query( you.pos() ) ) { + if( turret_data turret_here = ovp->vehicle().turret_query( you.pos_bub() ) ) { if( avatar_action::fire_turret_manual( you, here, turret_here ) ) { return; } diff --git a/src/handle_liquid.cpp b/src/handle_liquid.cpp index 11f11fe5f62c6..1682aa2a9fcb4 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -54,9 +54,9 @@ static void serialize_liquid_source( player_activity &act, const vehicle &veh, c act.values.push_back( static_cast( liquid_source_type::VEHICLE ) ); act.values.push_back( part_num ); if( part_num != -1 ) { - act.coords.push_back( veh.global_part_pos3( part_num ) ); + act.coords.push_back( veh.bub_part_pos( part_num ).raw() ); } else { - act.coords.push_back( veh.global_pos3() ); + act.coords.push_back( veh.pos_bub().raw() ); } act.str_values.push_back( serialize( liquid ) ); } @@ -84,7 +84,7 @@ static void serialize_liquid_target( player_activity &act, const vpart_reference { act.values.push_back( static_cast( liquid_target_type::VEHICLE ) ); act.values.push_back( 0 ); // dummy - act.coords.push_back( vp.vehicle().global_part_pos3( 0 ) ); + act.coords.push_back( vp.vehicle().bub_part_pos( 0 ).raw() ); act.values.push_back( vp.part_index() ); // tank part index } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 74b04284c5873..77a5b6fa391e2 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1365,7 +1365,8 @@ void iexamine::elevator( Character &you, const tripoint_bub_ms &examp ) } for( vehicle *v : vehs.v ) { - tripoint_bub_ms const p = tripoint_bub_ms( _rotate_point_sm( { v->global_pos3().xy(), movez }, erot, + tripoint_bub_ms const p = tripoint_bub_ms( _rotate_point_sm( { v->pos_bub().xy().raw(), movez}, + erot, sm_orig.raw() ) ); here.displace_vehicle( *v, p - v->pos_bub() ); v->turn( erot * 90_degrees ); diff --git a/src/item.cpp b/src/item.cpp index 8a22634264113..523ec5abc901a 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -13681,12 +13681,12 @@ ret_val item::link_to( vehicle &veh, const point_rel_ms &mount, link_state } // Prepare target tripoints for the cable parts that'll be added to the selected/previous vehicles - const std::pair prev_part_target = std::make_pair( - ( veh.global_square_location() + veh.coord_translate( mount ) ).raw(), - veh.global_square_location().raw() ); - const std::pair sel_part_target = std::make_pair( - ( link().t_abs_pos + prev_veh->coord_translate( link().t_mount ) ).raw(), - link().t_abs_pos.raw() ); + const std::pair prev_part_target = std::make_pair( + veh.global_square_location() + veh.coord_translate( mount ), + veh.global_square_location() ); + const std::pair sel_part_target = std::make_pair( + link().t_abs_pos + prev_veh->coord_translate( link().t_mount ), + link().t_abs_pos ); for( const vpart_reference &vpr : prev_veh->get_any_parts( VPFLAG_POWER_TRANSFER ) ) { if( vpr.part().target.first == prev_part_target.first && diff --git a/src/item_location.cpp b/src/item_location.cpp index b4ed5a80fd490..ba2ab9b8fb0d8 100644 --- a/src/item_location.cpp +++ b/src/item_location.cpp @@ -485,7 +485,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl } tripoint position() const override { - return cur.veh.global_part_pos3( cur.part ); + return cur.veh.bub_part_pos( cur.part ).raw(); } Character *carrier() const override { @@ -534,7 +534,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl item *obj = target(); int mv = ch.item_handling_cost( *obj, true, VEHICLE_HANDLING_PENALTY, qty ); - mv += 100 * rl_dist( ch.pos(), cur.veh.global_part_pos3( cur.part ) ); + mv += 100 * rl_dist( ch.pos_bub(), cur.veh.bub_part_pos( cur.part ) ); // TODO: handle unpacking costs diff --git a/src/iuse.cpp b/src/iuse.cpp index afdd3d6850ab6..b6bff01b38bd0 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -7356,7 +7356,7 @@ static vehicle *pickveh( const tripoint ¢er, bool advanced ) for( wrapped_vehicle &veh : get_map().get_vehicles() ) { vehicle *&v = veh.v; - if( rl_dist( center, v->global_pos3() ) < 40 && + if( rl_dist( center, v->pos_bub().raw() ) < 40 && v->fuel_left( itype_battery ) > 0 && ( !empty( v->get_avail_parts( advctrl ) ) || ( !advanced && !empty( v->get_avail_parts( ctrl ) ) ) ) ) { @@ -7366,7 +7366,7 @@ static vehicle *pickveh( const tripoint ¢er, bool advanced ) std::vector locations; for( int i = 0; i < static_cast( vehs.size() ); i++ ) { vehicle *veh = vehs[i]; - locations.push_back( veh->global_pos3() ); + locations.push_back( veh->pos_bub().raw() ); pmenu.addentry( i, true, MENU_AUTOASSIGN, veh->name ); } @@ -7461,9 +7461,9 @@ std::optional iuse::remoteveh( Character *p, item *it, const tripoint &pos const auto electronics_parts = veh->get_avail_parts( "CTRL_ELECTRONIC" ); // Revert to original behavior if we can't find remote controls. if( empty( rctrl_parts ) ) { - veh->interact_with( electronics_parts.begin()->pos() ); + veh->interact_with( electronics_parts.begin()->pos_bub() ); } else { - veh->interact_with( rctrl_parts.begin()->pos() ); + veh->interact_with( rctrl_parts.begin()->pos_bub() ); } } diff --git a/src/map.cpp b/src/map.cpp index 2047ce75ff0a5..b7d493c543ec6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -389,7 +389,7 @@ void map::memory_cache_ter_set_dirty( const tripoint_bub_ms &p, bool value ) con void map::memory_clear_vehicle_points( const vehicle &veh ) const { avatar &player_character = get_avatar(); - for( const tripoint &p : veh.get_points() ) { + for( const tripoint_bub_ms &p : veh.get_points() ) { if( !inbounds( p ) ) { continue; } @@ -625,7 +625,7 @@ std::unique_ptr map::detach_vehicle( vehicle *veh ) level_cache &ch = get_cache( z ); for( size_t i = 0; i < current_submap->vehicles.size(); i++ ) { if( current_submap->vehicles[i].get() == veh ) { - for( const tripoint &pt : veh->get_points() ) { + for( const tripoint_bub_ms &pt : veh->get_points() ) { if( inbounds( pt ) ) { memory_cache_dec_set_dirty( pt, true ); } @@ -669,7 +669,7 @@ void map::vehmove() VehicleList vehicle_list; int minz = zlevels ? -OVERMAP_DEPTH : abs_sub.z(); int maxz = zlevels ? OVERMAP_HEIGHT : abs_sub.z(); - const tripoint_bub_ms player_pos = get_player_character().pos_bub(); + const tripoint_abs_ms player_pos = get_player_character().get_location(); for( int zlev = minz; zlev <= maxz; ++zlev ) { level_cache *cache_lazy = get_cache_lazy( zlev ); if( !cache_lazy ) { @@ -678,7 +678,7 @@ void map::vehmove() level_cache &cache = *cache_lazy; for( vehicle *veh : cache.vehicle_list ) { if( veh->is_following ) { - veh->drive_to_local_target( getglobal( player_pos ).raw(), true ); + veh->drive_to_local_target( player_pos, true ); } else if( veh->is_patrolling ) { veh->autopilot_patrol(); } @@ -770,7 +770,7 @@ bool map::vehproceed( VehicleList &vehicle_list ) static bool sees_veh( const Creature &c, vehicle &veh, bool force_recalc ) { const auto &veh_points = veh.get_points( force_recalc ); - return std::any_of( veh_points.begin(), veh_points.end(), [&c]( const tripoint & pt ) { + return std::any_of( veh_points.begin(), veh_points.end(), [&c]( const tripoint_bub_ms & pt ) { return c.sees( pt ); } ); } @@ -835,7 +835,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler size_t collision_attempts = 10; do { collisions.clear(); - veh.collision( collisions, dp1.raw(), false ); + veh.collision( collisions, dp1, false ); // Vehicle collisions std::map > veh_collisions; @@ -896,7 +896,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler veh.stop_autodriving(); const int volume = std::min( 100, std::sqrt( impulse ) ); // TODO: Center the sound at weighted (by impulse) average of collisions - sounds::sound( veh.global_pos3(), volume, sounds::sound_t::combat, _( "crash!" ), + sounds::sound( veh.pos_bub(), volume, sounds::sound_t::combat, _( "crash!" ), false, "smash_success", "hit_vehicle" ); } @@ -909,7 +909,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler if( !vertical && !veh.valid_wheel_config() && !( veh.is_watercraft() && veh.can_float() ) && !veh.is_flying_in_air() && dp.z() == 0 ) { veh.velocity -= std::clamp( veh.velocity, -2000, 2000 ); // extra drag - for( const tripoint &p : veh.get_points() ) { + for( const tripoint_bub_ms &p : veh.get_points() ) { const ter_id &pter = ter( p ); if( pter == ter_t_dirt || pter == ter_t_grass ) { ter_set( p, ter_t_dirtmound ); @@ -983,7 +983,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler "environment", "splash" ); } - veh.handle_trap( wheel_p.raw(), vp_wheel ); + veh.handle_trap( wheel_p, vp_wheel ); // dont use vp_wheel or vp_wheel_idx below this - handle_trap might've removed it from parts if( !has_flag( ter_furn_flag::TFLAG_SEALED, wheel_p ) ) { @@ -1076,16 +1076,16 @@ float map::vehicle_vehicle_collision( vehicle &veh, vehicle &veh2, 0.5 * m2 * velo_veh2.magnitude() * velo_veh2.magnitude(); // Collision_axis - point cof1 = veh .rotated_center_of_mass(); - point cof2 = veh2.rotated_center_of_mass(); - int &x_cof1 = cof1.x; - int &y_cof1 = cof1.y; - int &x_cof2 = cof2.x; - int &y_cof2 = cof2.y; + point_rel_ms cof1 = veh .rotated_center_of_mass(); + point_rel_ms cof2 = veh2.rotated_center_of_mass(); + int &x_cof1 = cof1.x(); + int &y_cof1 = cof1.y(); + int &x_cof2 = cof2.x(); + int &y_cof2 = cof2.y(); rl_vec2d collision_axis_y; - collision_axis_y.x = ( veh.global_pos3().x + x_cof1 ) - ( veh2.global_pos3().x + x_cof2 ); - collision_axis_y.y = ( veh.global_pos3().y + y_cof1 ) - ( veh2.global_pos3().y + y_cof2 ); + collision_axis_y.x = ( veh.pos_bub().x() + x_cof1 ) - ( veh2.pos_bub().x() + x_cof2 ); + collision_axis_y.y = ( veh.pos_bub().y() + y_cof1 ) - ( veh2.pos_bub().y() + y_cof2 ); collision_axis_y = collision_axis_y.normalized(); rl_vec2d collision_axis_x = collision_axis_y.rotated( M_PI / 2 ); // imp? & delta? & final? reworked: @@ -1324,7 +1324,7 @@ VehicleList map::get_vehicles( const tripoint_bub_ms &start, const tripoint_bub_ elem->sm_pos.z = cz; wrapped_vehicle w; w.v = elem.get(); - w.pos = w.v->global_pos3(); + w.pos = w.v->pos_bub().raw(); vehs.push_back( w ); } } @@ -1608,7 +1608,7 @@ bool map::displace_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const bool if( src_submap != dst_submap ) { dst_submap->ensure_nonuniform(); - veh.set_submap_moved( tripoint( dst.x() / SEEX, dst.y() / SEEY, dst.z() ) ); + veh.set_submap_moved( { dst.x() / SEEX, dst.y() / SEEY, dst.z() } ); auto src_submap_veh_it = src_submap->vehicles.begin() + our_i; dst_submap->vehicles.push_back( std::move( *src_submap_veh_it ) ); src_submap->vehicles.erase( src_submap_veh_it ); @@ -5860,8 +5860,8 @@ void map::process_items() level_cache &cache = access_cache( gz ); std::set submaps_with_vehicles; for( vehicle *this_vehicle : cache.vehicle_list ) { - tripoint pos = this_vehicle->global_pos3(); - submaps_with_vehicles.emplace( pos.x / SEEX, pos.y / SEEY, pos.z ); + tripoint_bub_ms pos = this_vehicle->pos_bub(); + submaps_with_vehicles.emplace( pos.x() / SEEX, pos.y() / SEEY, pos.z() ); } for( const tripoint &pos : submaps_with_vehicles ) { submap *const current_submap = get_submap_at_grid( tripoint_rel_sm( pos ) ); @@ -7541,7 +7541,7 @@ bool map::draw_maptile( const catacurses::window &w, const tripoint_bub_ms &p, if( !veh->forward_velocity() && !veh->player_in_control( player_character ) && !( player_character.get_grab_type() == object_type::VEHICLE && veh->get_points().count( ( player_character.pos_bub() + - player_character.grab_point ).raw() ) ) ) { + player_character.grab_point ) ) ) ) { memory_sym = sym; } } @@ -9915,25 +9915,25 @@ static void vehicle_caching_internal( level_cache &zch, const vpart_reference &v auto &floor_cache = zch.floor_cache; const size_t part = vp.part_index(); - const tripoint part_pos = v->global_part_pos3( vp.part() ); + const tripoint_bub_ms part_pos = v->bub_part_pos( vp.part() ); bool vehicle_is_opaque = vp.has_feature( VPFLAG_OPAQUE ) && !vp.part().is_broken(); if( vehicle_is_opaque ) { int dpart = v->part_with_feature( part, VPFLAG_OPENABLE, true ); if( dpart < 0 || !v->part( dpart ).open ) { - transparency_cache[part_pos.x][part_pos.y] = LIGHT_TRANSPARENCY_SOLID; + transparency_cache[part_pos.x()][part_pos.y()] = LIGHT_TRANSPARENCY_SOLID; } else { vehicle_is_opaque = false; } } if( vehicle_is_opaque || vp.is_inside() ) { - outside_cache[part_pos.x][part_pos.y] = false; + outside_cache[part_pos.x()][part_pos.y()] = false; } if( vp.has_feature( VPFLAG_BOARDABLE ) && !vp.part().is_broken() ) { - floor_cache[part_pos.x][part_pos.y] = true; + floor_cache[part_pos.x()][part_pos.y()] = true; } } @@ -9941,8 +9941,8 @@ static void vehicle_caching_internal_above( level_cache &zch_above, const vpart_ vehicle *v ) { if( vp.has_feature( VPFLAG_ROOF ) || vp.has_feature( VPFLAG_OPAQUE ) ) { - const tripoint part_pos = v->global_part_pos3( vp.part() ); - zch_above.floor_cache[part_pos.x][part_pos.y] = true; + const tripoint_bub_ms part_pos = v->bub_part_pos( vp.part() ); + zch_above.floor_cache[part_pos.x()][part_pos.y()] = true; } } diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 6b4305c990c44..235f97c52461c 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -445,10 +445,10 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) break; } if( !one_in( 4 ) ) { - wreckage->smash( m, 0.8f, 1.2f, 1.0f, point( dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 ), 6 + dice( 1, + wreckage->smash( m, 0.8f, 1.2f, 1.0f, { dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 }, 6 + dice( 1, 10 ) ); } else { - wreckage->smash( m, 0.1f, 0.9f, 1.0f, point( dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 ), 6 + dice( 1, + wreckage->smash( m, 0.1f, 0.9f, 1.0f, { dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 }, 6 + dice( 1, 10 ) ); } } @@ -1360,7 +1360,7 @@ static void burned_ground_parser( map &m, const tripoint &loc ) } else { tripoint_abs_omt pos = project_to( m.getglobal( loc ) ); oter_id terrain_type = overmap_buffer.ter( pos ); - tripoint veh_origin = vehicle.v->global_pos3(); + tripoint_bub_ms veh_origin = vehicle.v->pos_bub(); debugmsg( "burned_ground_parser: Vehicle %s (origin %s; rotation (%f,%f)) has " "out of bounds part at %s in terrain_type %s\n", vehicle.v->name, veh_origin.to_string(), @@ -1505,18 +1505,18 @@ static bool mx_burned_ground( map &m, const tripoint &abs_sub ) } VehicleList vehs = m.get_vehicles(); std::vector vehicles; - std::vector points; + std::vector points; for( wrapped_vehicle vehicle : vehs ) { vehicles.push_back( vehicle.v ); - std::set occupied = vehicle.v->get_points(); - for( const tripoint &t : occupied ) { + std::set occupied = vehicle.v->get_points(); + for( const tripoint_bub_ms &t : occupied ) { points.push_back( t ); } } for( vehicle *vrem : vehicles ) { m.destroy_vehicle( vrem ); } - for( const tripoint &tri : points ) { + for( const tripoint_bub_ms &tri : points ) { m.furn_set( tri, furn_f_wreckage ); } diff --git a/src/mapgen.cpp b/src/mapgen.cpp index b3a344224c59f..754e0b92f9ad6 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -6994,7 +6994,7 @@ vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, cons veh->turn_dir = dir; // for backwards compatibility, we always spawn with a pivot point of (0,0) so // that the mount at (0,0) is located at the spawn position. - veh->precalc_mounts( 0, dir, point() ); + veh->precalc_mounts( 0, dir, point_rel_ms_zero ); std::unique_ptr placed_vehicle_up = add_vehicle_to_map( std::move( veh ), merge_wrecks ); @@ -7087,7 +7087,7 @@ std::unique_ptr map::add_vehicle_to_map( */ std::unique_ptr handler_ptr; bool did_merge = false; - for( const tripoint &map_pos : first_veh->get_points( true ) ) { + for( const tripoint_bub_ms &map_pos : first_veh->get_points( true ) ) { std::vector parts_to_move = veh_to_add->get_parts_at( map_pos, "", part_status_flag::any ); if( !parts_to_move.empty() ) { diff --git a/src/npc.cpp b/src/npc.cpp index 032b24d567a0b..19f92aa9bcd5d 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1761,7 +1761,7 @@ float npc::vehicle_danger( int radius ) const const wrapped_vehicle &wrapped_veh = vehicles[i]; if( wrapped_veh.v->is_moving() ) { const auto &points_to_check = wrapped_veh.v->immediate_path(); - point p( get_map().getglobal( pos_bub() ).xy().raw() ); + point_abs_ms p( get_map().getglobal( pos_bub() ).xy() ); if( points_to_check.find( p ) != points_to_check.end() ) { danger = i; } diff --git a/src/ranged.cpp b/src/ranged.cpp index d7c5fc276bc67..8fddfdef1fe50 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -521,13 +521,13 @@ target_handler::trajectory target_handler::mode_turrets( avatar &you, vehicle &v int range_total = 0; for( vehicle_part *t : turrets ) { int range = veh.turret_query( *t ).range(); - tripoint pos = veh.global_part_pos3( *t ); + tripoint_bub_ms pos = veh.bub_part_pos( *t ); int res = 0; - res = std::max( res, rl_dist( you.pos(), pos + point( range, 0 ) ) ); - res = std::max( res, rl_dist( you.pos(), pos + point( -range, 0 ) ) ); - res = std::max( res, rl_dist( you.pos(), pos + point( 0, range ) ) ); - res = std::max( res, rl_dist( you.pos(), pos + point( 0, -range ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( range, 0 ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( -range, 0 ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( 0, range ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( 0, -range ) ) ); range_total = std::max( range_total, res ); } @@ -998,7 +998,7 @@ int Character::fire_gun( const tripoint_bub_ms &target, int shots, item &gun, it bool bipod = here.has_flag_ter_or_furn( ter_furn_flag::TFLAG_MOUNTABLE, pos_bub() ) || is_prone(); if( !bipod ) { if( const optional_vpart_position vp = here.veh_at( pos_bub() ) ) { - bipod = vp->vehicle().has_part( pos(), "MOUNTABLE" ); + bipod = vp->vehicle().has_part( pos_bub(), "MOUNTABLE" ); } } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 5cc9bd9c3673a..323e0f4ffb473 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -3189,12 +3189,12 @@ void vehicle_part::deserialize( const JsonObject &data ) data.read( "items", items ); data.read( "tools", tools ); data.read( "salvageable", salvageable ); - data.read( "target_first_x", target.first.x ); - data.read( "target_first_y", target.first.y ); - data.read( "target_first_z", target.first.z ); - data.read( "target_second_x", target.second.x ); - data.read( "target_second_y", target.second.y ); - data.read( "target_second_z", target.second.z ); + data.read( "target_first_x", target.first.x() ); + data.read( "target_first_y", target.first.y() ); + data.read( "target_first_z", target.first.z() ); + data.read( "target_second_x", target.second.x() ); + data.read( "target_second_y", target.second.y() ); + data.read( "target_second_z", target.second.z() ); data.read( "ammo_pref", ammo_pref ); data.read( "locked", locked ); data.read( "last_disconnected", last_disconnected ); @@ -3240,15 +3240,15 @@ void vehicle_part::serialize( JsonOut &json ) const json.member( "items", items ); json.member( "tools", tools ); json.member( "salvageable", salvageable ); - if( target.first != tripoint_min ) { - json.member( "target_first_x", target.first.x ); - json.member( "target_first_y", target.first.y ); - json.member( "target_first_z", target.first.z ); + if( target.first != tripoint_abs_ms_min ) { + json.member( "target_first_x", target.first.x() ); + json.member( "target_first_y", target.first.y() ); + json.member( "target_first_z", target.first.z() ); } - if( target.second != tripoint_min ) { - json.member( "target_second_x", target.second.x ); - json.member( "target_second_y", target.second.y ); - json.member( "target_second_z", target.second.z ); + if( target.second != tripoint_abs_ms_min ) { + json.member( "target_second_x", target.second.x() ); + json.member( "target_second_y", target.second.y() ); + json.member( "target_second_z", target.second.z() ); } json.member( "ammo_pref", ammo_pref ); json.member( "locked", locked ); @@ -3283,16 +3283,16 @@ void vehicle_part::carried_part_data::serialize( JsonOut &json ) const void label::deserialize( const JsonObject &data ) { data.allow_omitted_members(); - data.read( "x", x ); - data.read( "y", y ); + data.read( "x", x() ); + data.read( "y", y() ); data.read( "text", text ); } void label::serialize( JsonOut &json ) const { json.start_object(); - json.member( "x", x ); - json.member( "y", y ); + json.member( "x", x() ); + json.member( "y", y() ); json.member( "text", text ); json.end_object(); } @@ -3475,11 +3475,11 @@ void vehicle::serialize( JsonOut &json ) const json.end_object(); } json.end_array(); - tripoint other_tow_temp_point; + tripoint_bub_ms other_tow_temp_point; if( is_towed() ) { vehicle *tower = tow_data.get_towed_by(); if( tower ) { - other_tow_temp_point = tower->global_part_pos3( tower->get_tow_part() ); + other_tow_temp_point = tower->bub_part_pos( tower->get_tow_part() ); } } json.member( "other_tow_point", other_tow_temp_point ); diff --git a/src/sounds.cpp b/src/sounds.cpp index bda94b3341216..b5b33c2d75320 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1063,10 +1063,10 @@ void sfx::do_vehicle_exterior_engine_sfx() for( wrapped_vehicle vehicle : vehs ) { if( vehicle.v->vehicle_noise > 0 && vehicle.v->vehicle_noise - - sound_distance( player_character.pos(), vehicle.v->global_pos3() ) > noise_factor ) { + sound_distance( player_character.pos_bub().raw(), vehicle.v->pos_bub().raw() ) > noise_factor ) { - noise_factor = vehicle.v->vehicle_noise - sound_distance( player_character.pos(), - vehicle.v->global_pos3() ); + noise_factor = vehicle.v->vehicle_noise - sound_distance( player_character.pos_bub().raw(), + vehicle.v->pos_bub().raw() ); veh = vehicle.v; } } @@ -1105,7 +1105,7 @@ void sfx::do_vehicle_exterior_engine_sfx() if( is_channel_playing( ch ) ) { if( engine_external_id_and_variant == id_and_variant ) { - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->global_pos3() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "PLAYING exterior_engine_sound, vol: ex:%d true:%d", vol, Mix_Volume( ch_int, -1 ) ); @@ -1115,7 +1115,7 @@ void sfx::do_vehicle_exterior_engine_sfx() add_msg_debug( debugmode::DF_SOUND, "STOP exterior_engine_sound, change id/var" ); play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, 128, ch, 0 ); - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->global_pos3() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "START exterior_engine_sound %s %s vol: %d", id_and_variant.first, @@ -1126,7 +1126,7 @@ void sfx::do_vehicle_exterior_engine_sfx() play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, 128, ch, 0 ); add_msg_debug( debugmode::DF_SOUND, "Vol: %d %d", vol, Mix_Volume( ch_int, -1 ) ); - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->global_pos3() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); add_msg_debug( debugmode::DF_SOUND, "Vol: %d %d", vol, Mix_Volume( ch_int, -1 ) ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "START exterior_engine_sound NEW %s %s vol: ex:%d true:%d", diff --git a/src/turret.cpp b/src/turret.cpp index 6cd40f456138a..da3f36186cbad 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -48,13 +48,13 @@ std::vector vehicle::turrets() return res; } -std::vector vehicle::turrets( const tripoint &target ) +std::vector vehicle::turrets( const tripoint_bub_ms &target ) { std::vector res = turrets(); // exclude turrets not ready to fire or where target is out of range res.erase( std::remove_if( res.begin(), res.end(), [&]( vehicle_part * e ) { return turret_query( *e ).query() != turret_data::status::ready || - rl_dist( global_part_pos3( *e ), target ) > e->base.gun_range(); + rl_dist( bub_part_pos( *e ), target ) > e->base.gun_range(); } ), res.end() ); return res; } @@ -67,7 +67,7 @@ turret_data vehicle::turret_query( vehicle_part &pt ) return turret_data( this, &pt ); } -turret_data vehicle::turret_query( const tripoint &pos ) +turret_data vehicle::turret_query( const tripoint_bub_ms &pos ) { auto res = get_parts_at( pos, "TURRET", part_status_flag::any ); return !res.empty() ? turret_query( *res.front() ) : turret_data(); @@ -392,7 +392,7 @@ int vehicle::turrets_aim_and_fire( std::vector &turrets ) if( has_target ) { turret_data turret = turret_query( *t ); npc &cpu = t->get_targeting_npc( *this ); - shots += turret.fire( cpu, tripoint_bub_ms( t->target.second ) ); + shots += turret.fire( cpu, get_map().bub_from_abs( t->target.second ) ); t->reset_target( bub_part_pos( *t ) ); } } @@ -433,7 +433,7 @@ bool vehicle::turrets_aim( std::vector &turrets ) // Set target for any turret in range for( vehicle_part *t : turrets ) { if( turret_query( *t ).in_range( target ) ) { - t->target.second = target.raw(); + t->target.second = get_map().getglobal( target ); } } @@ -465,7 +465,7 @@ void vehicle::turrets_set_targeting() for( vehicle_part &p : parts ) { if( p.is_turret() ) { turrets.push_back( &p ); - locations.push_back( global_part_pos3( p ) ); + locations.push_back( bub_part_pos( p ).raw() ); } } @@ -480,9 +480,9 @@ void vehicle::turrets_set_targeting() menu.fselected = sel; for( vehicle_part *&p : turrets ) { - menu.addentry( -1, has_part( global_part_pos3( *p ), "TURRET_CONTROLS" ), MENU_AUTOASSIGN, + menu.addentry( -1, has_part( bub_part_pos( *p ), "TURRET_CONTROLS" ), MENU_AUTOASSIGN, "%s [%s]", p->name(), p->enabled ? - _( "auto -> manual" ) : has_part( global_part_pos3( *p ), "TURRET_CONTROLS" ) ? + _( "auto -> manual" ) : has_part( bub_part_pos( *p ), "TURRET_CONTROLS" ) ? _( "manual -> auto" ) : _( "manual (turret control unit required for auto mode)" ) ); } @@ -520,7 +520,7 @@ void vehicle::turrets_set_mode() for( vehicle_part &p : parts ) { if( p.base.is_gun() ) { turrets.push_back( &p ); - locations.push_back( global_part_pos3( p ) ); + locations.push_back( bub_part_pos( p ).raw() ); } } @@ -570,7 +570,7 @@ npc &vehicle_part::get_targeting_npc( vehicle &veh ) brain.name = string_format( _( "The %s turret" ), get_base().tname( 1 ) ); brain.set_skill_level( get_base().gun_skill(), 8 ); } - cpu.brain->setpos( veh.global_part_pos3( *this ) ); + cpu.brain->setpos( veh.bub_part_pos( *this ) ); cpu.brain->recalc_sight_limits(); return *cpu.brain; } @@ -649,11 +649,11 @@ int vehicle::automatic_fire_turret( vehicle_part &pt ) return shots; } - target.second = auto_target->pos(); + target.second = auto_target->get_location(); } else { // Target is already set, make sure we didn't move after aiming (it's a bug if we did). - if( pos.raw() != target.first ) { + if( pos != get_map().bub_from_abs( target.first ) ) { target.second = target.first; debugmsg( "%s moved after aiming but before it could fire.", cpu.get_name() ); return shots; @@ -661,7 +661,7 @@ int vehicle::automatic_fire_turret( vehicle_part &pt ) } // Get the turret's target and reset it - tripoint_bub_ms targ( target.second ); + tripoint_bub_ms targ( get_map().bub_from_abs( target.second ) ); pt.reset_target( pos ); shots = gun.fire( cpu, targ ); diff --git a/src/veh_appliance.cpp b/src/veh_appliance.cpp index 97ffc2aecb94f..65991912862e9 100644 --- a/src/veh_appliance.cpp +++ b/src/veh_appliance.cpp @@ -76,9 +76,9 @@ bool place_appliance( const tripoint_bub_ms &p, const vpart_id &vpart, // transform the deploying item into what it *should* be before storing it copied.convert( vpinfo.base_item ); } - partnum = veh->install_part( point_zero, vpart, std::move( copied ) ); + partnum = veh->install_part( point_rel_ms_zero, vpart, std::move( copied ) ); } else { - partnum = veh->install_part( point_zero, vpart ); + partnum = veh->install_part( point_rel_ms_zero, vpart ); } if( partnum == -1 ) { // unrecoverable, failed to be installed somehow @@ -112,7 +112,7 @@ bool place_appliance( const tripoint_bub_ms &p, const vpart_id &vpart, continue; } if( connected_vehicles.find( &veh_target ) == connected_vehicles.end() ) { - veh->connect( p.raw(), trip.raw() ); + veh->connect( p, trip ); connected_vehicles.insert( &veh_target ); } } @@ -403,7 +403,7 @@ void veh_app_interact::refill() act.str_values.push_back( pt->info().id.str() ); const point_rel_ms q = veh->coord_translate( pt->mount ); map &here = get_map(); - for( const tripoint &p : veh->get_points( true ) ) { + for( const tripoint_bub_ms &p : veh->get_points( true ) ) { act.coord_set.insert( here.getglobal( p ).raw() ); } act.values.push_back( here.getglobal( veh->pos_bub() ).x() + q.x() ); @@ -492,7 +492,7 @@ void veh_app_interact::remove() } else if( query_yn( _( "Are you sure you want to take down the %s?" ), veh->name ) ) { act = player_activity( ACT_VEHICLE, to_moves( time ), static_cast( 'O' ) ); act.str_values.push_back( vpinfo.id.str() ); - for( const tripoint &p : veh->get_points( true ) ) { + for( const tripoint_bub_ms &p : veh->get_points( true ) ) { act.coord_set.insert( here.getglobal( p ).raw() ); } const tripoint a_point_abs( here.getglobal( a_point_bub ).raw() ); @@ -526,7 +526,7 @@ void veh_app_interact::disconnect() void veh_app_interact::plug() { const int part = veh->part_at( veh->coord_translate( a_point ) ); - const tripoint pos = veh->global_part_pos3( part ); + const tripoint_bub_ms pos = veh->bub_part_pos( part ); item cord( "power_cord" ); cord.link_to( *veh, a_point, link_state::automatic ); if( cord.get_use( "link_up" ) ) { diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 44a4b8844fbed..f3c841423f0bb 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -177,7 +177,7 @@ player_activity veh_interact::serialize_activity() const point_rel_ms q = veh->coord_translate( pt ? pt->mount : veh->part( 0 ).mount ); const vehicle_part *vpt = pt ? pt : &veh->part( 0 ); map &here = get_map(); - for( const tripoint &p : veh->get_points( true ) ) { + for( const tripoint_bub_ms &p : veh->get_points( true ) ) { res.coord_set.insert( here.getglobal( p ).raw() ); } res.values.push_back( here.getglobal( veh->pos_bub() ).x() + q.x() ); // values[0] @@ -2316,15 +2316,15 @@ void veh_interact::display_veh() if( debug_mode ) { // show CoM, pivot in debug mode - const point &pivot = veh->pivot_point(); - const point &com = veh->local_center_of_mass(); + const point_rel_ms &pivot = veh->pivot_point(); + const point_rel_ms &com = veh->local_center_of_mass(); - mvwprintz( w_disp, point_zero, c_green, "CoM %d,%d", com.x, com.y ); + mvwprintz( w_disp, point_zero, c_green, "CoM %d,%d", com.x(), com.y() ); // NOLINTNEXTLINE(cata-use-named-point-constants) - mvwprintz( w_disp, point( 0, 1 ), c_red, "Pivot %d,%d", pivot.x, pivot.y ); + mvwprintz( w_disp, point( 0, 1 ), c_red, "Pivot %d,%d", pivot.x(), pivot.y() ); - const point com_s = ( com + dd ).rotate( 3 ) + h_size; - const point pivot_s = ( pivot + dd ).rotate( 3 ) + h_size; + const point com_s = ( com.raw() + dd ).rotate( 3 ) + h_size; + const point pivot_s = ( pivot.raw() + dd ).rotate( 3 ) + h_size; for( int x = 0; x < getmaxx( w_disp ); ++x ) { if( x <= com_s.x ) { @@ -3088,7 +3088,7 @@ void veh_interact::complete_vehicle( Character &you ) } vehicle &veh = ovp->vehicle(); - const point d( you.activity.values[4], you.activity.values[5] ); + const point_rel_ms d( you.activity.values[4], you.activity.values[5] ); const vpart_id part_id( you.activity.str_values[0] ); const vpart_info &vpinfo = part_id.obj(); @@ -3136,7 +3136,7 @@ void veh_interact::complete_vehicle( Character &you ) const int partnum = veh.install_part( d, part_id, std::move( base ), installed_with ); if( partnum < 0 ) { debugmsg( "complete_vehicle install part fails dx=%d dy=%d id=%s", - d.x, d.y, part_id.c_str() ); + d.x(), d.y(), part_id.c_str() ); break; } ::vehicle_part &vp_new = veh.part( partnum ); @@ -3146,15 +3146,15 @@ void veh_interact::complete_vehicle( Character &you ) // Need map-relative coordinates to compare to output of look_around. // Need to call coord_translate() directly since it's a new part. - const point q = veh.coord_translate( d ); + const point_rel_ms q = veh.coord_translate( d ); if( vpinfo.has_flag( VPFLAG_CONE_LIGHT ) || vpinfo.has_flag( VPFLAG_WIDE_CONE_LIGHT ) || vpinfo.has_flag( VPFLAG_HALF_CIRCLE_LIGHT ) ) { - orient_part( &veh, vpinfo, partnum, q ); + orient_part( &veh, vpinfo, partnum, q.raw() ); } - const tripoint_bub_ms vehp = veh.pos_bub() + tripoint( q, 0 ); + const tripoint_bub_ms vehp = veh.pos_bub() + tripoint_rel_ms( q, 0 ); // TODO: allow boarding for non-players as well. Character *const pl = get_creature_tracker().creature_at( vehp ); if( vpinfo.has_flag( VPFLAG_BOARDABLE ) && pl ) { @@ -3341,7 +3341,7 @@ void veh_interact::complete_vehicle( Character &you ) veh.part_removal_cleanup(); // Ensure the position, pivot, and precalc points are up-to-date veh.pos -= veh.pivot_anchor[0]; - veh.precalc_mounts( 0, veh.turn_dir, point() ); + veh.precalc_mounts( 0, veh.turn_dir, point_rel_ms_zero ); here.rebuild_vehicle_level_caches(); if( auto newpart = here.veh_at( act_pos ).part_with_feature( VPFLAG_APPLIANCE, false ) ) { diff --git a/src/veh_shape.cpp b/src/veh_shape.cpp index 3849c9a083204..2ed598abd7cfb 100644 --- a/src/veh_shape.cpp +++ b/src/veh_shape.cpp @@ -28,7 +28,7 @@ player_activity veh_shape::start( const tripoint_bub_ms &pos ) if( !set_cursor_pos( pos ) ) { debugmsg( "failed to set cursor at given part" ); - set_cursor_pos( tripoint_bub_ms( veh.global_part_pos3( 0 ) ) ); + set_cursor_pos( veh.bub_part_pos( 0 ) ); } const auto target_ui_cb = make_shared_fast( @@ -141,7 +141,7 @@ void veh_shape::change_part_shape( vpart_reference vpr ) const .keep_menu_open() .skip_locked_check() .skip_theft_check() - .location( veh.global_part_pos3( part ) ) + .location( veh.bub_part_pos( part ).raw() ) .select( part.variant == vvid ) .desc( _( "Confirm to save or exit to revert" ) ) .symbol( vv.get_symbol_curses( 0_degrees, false ) ) diff --git a/src/veh_type.cpp b/src/veh_type.cpp index 19c744a8277ec..b3a0c3823ba98 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -1420,11 +1420,11 @@ void vehicle_prototype::save_vehicle_as_prototype( const vehicle &veh, JsonOut & for( int x = mount_max_x; x >= mount_min_x; x-- ) { std::string row; for( int y = mount_min_y; y <= mount_max_y; y++ ) { - if( veh.part_displayed_at( point( x, y ), false, true, true ) == -1 ) { + if( veh.part_displayed_at( point_rel_ms( x, y ), false, true, true ) == -1 ) { row += " "; continue; } - const vpart_display &c = veh.get_display_of_tile( point( x, y ), false, false, true, true ); + const vpart_display &c = veh.get_display_of_tile( point_rel_ms( x, y ), false, false, true, true ); row += utf32_to_utf8( c.symbol ); } json.write( row ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 993d680e45e28..334e04f1a29fa 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -649,13 +649,13 @@ void vehicle::autopilot_patrol() */ map &here = get_map(); // if we are close to a waypoint, then return to come back to this function next turn. - if( autodrive_local_target != tripoint_zero ) { - if( rl_dist( global_square_location().raw(), autodrive_local_target ) <= 3 ) { - autodrive_local_target = tripoint_zero; + if( autodrive_local_target != tripoint_abs_ms_zero ) { + if( rl_dist( global_square_location(), autodrive_local_target ) <= 3 ) { + autodrive_local_target = tripoint_abs_ms_zero; return; } - if( !here.inbounds( here.bub_from_abs( tripoint_abs_ms( autodrive_local_target ) ) ) ) { - autodrive_local_target = tripoint_zero; + if( !here.inbounds( here.bub_from_abs( autodrive_local_target ) ) ) { + autodrive_local_target = tripoint_abs_ms_zero; is_patrolling = false; return; } @@ -697,13 +697,13 @@ void vehicle::autopilot_patrol() chosen_tri = max_tri; } // TODO: fix point types - autodrive_local_target = chosen_tri.raw(); + autodrive_local_target = chosen_tri; drive_to_local_target( autodrive_local_target, false ); } -std::set vehicle::immediate_path( const units::angle &rotate ) +std::set vehicle::immediate_path( const units::angle &rotate ) { - std::set points_to_check; + std::set points_to_check; const int distance_to_check = 10 + ( velocity / 800 ); units::angle adjusted_angle = normalize( face.dir() + rotate ); // clamp to multiples of 15. @@ -719,7 +719,7 @@ std::set vehicle::immediate_path( const units::angle &rotate ) for( int i = 0; i < distance_to_check; ++i ) { collision_vector.advance( i ); point_abs_ms point_to_add = elem + point( collision_vector.dx(), collision_vector.dy() ); - points_to_check.emplace( point_to_add.raw() ); + points_to_check.emplace( point_to_add ); } } collision_check_points = points_to_check; @@ -749,11 +749,11 @@ static int get_turn_from_angle( const units::angle &angle, const tripoint &vehpo return 0; } -void vehicle::drive_to_local_target( const tripoint &target, bool follow_protocol ) +void vehicle::drive_to_local_target( const tripoint_abs_ms &target, bool follow_protocol ) { Character &player_character = get_player_character(); if( follow_protocol && player_character.in_vehicle ) { - sounds::sound( global_pos3(), 30, sounds::sound_t::alert, + sounds::sound( pos_bub(), 30, sounds::sound_t::alert, string_format( _( "the %s emitting a beep and saying \"Autonomous driving protocols suspended!\"" ), name ) ); stop_autodriving(); @@ -767,14 +767,14 @@ void vehicle::drive_to_local_target( const tripoint &target, bool follow_protoco bool stop = precollision_check( angle, here, follow_protocol ); if( stop ) { if( autopilot_on ) { - sounds::sound( global_pos3(), 30, sounds::sound_t::alert, + sounds::sound( pos_bub(), 30, sounds::sound_t::alert, string_format( _( "the %s emitting a beep and saying \"Obstacle detected!\"" ), name ) ); } stop_autodriving(); return; } - int turn_x = get_turn_from_angle( angle, vehpos.raw(), target ); + int turn_x = get_turn_from_angle( angle, vehpos.raw(), target.raw() ); int accel_y = 0; // best to cruise around at a safe velocity or 40mph, whichever is lowest // accelerate when it doesn't need to turn. @@ -808,7 +808,7 @@ void vehicle::drive_to_local_target( const tripoint &target, bool follow_protoco accel_y = 1; } } - selfdrive( point( turn_x, accel_y ) ); + selfdrive( turn_x, accel_y ); } bool vehicle::precollision_check( units::angle &angle, map &here, bool follow_protocol ) @@ -819,10 +819,10 @@ bool vehicle::precollision_check( units::angle &angle, map &here, bool follow_pr Character &player_character = get_player_character(); // now we got the angle to the target, we can work out when we are heading towards disaster. // Check the tileray in the direction we need to head towards. - std::set points_to_check = immediate_path( angle ); + std::set points_to_check = immediate_path( angle ); bool stop = false; creature_tracker &creatures = get_creature_tracker(); - for( const point &pt_elem : points_to_check ) { + for( const point_abs_ms &pt_elem : points_to_check ) { point_bub_ms elem = here.bub_from_abs( point_abs_ms( pt_elem ) ); if( stop ) { break; @@ -864,12 +864,12 @@ bool vehicle::precollision_check( units::angle &angle, map &here, bool follow_pr return stop; } -units::angle vehicle::get_angle_from_targ( const tripoint &targ ) const +units::angle vehicle::get_angle_from_targ( const tripoint_abs_ms &targ ) const { - tripoint vehpos = global_square_location().raw(); + tripoint_abs_ms vehpos = global_square_location(); rl_vec2d facevec = face_vec(); - point rel_pos_target = targ.xy() - vehpos.xy(); - rl_vec2d targetvec = rl_vec2d( rel_pos_target.x, rel_pos_target.y ); + point_rel_ms rel_pos_target = targ.xy() - vehpos.xy(); + rl_vec2d targetvec = rl_vec2d( rel_pos_target.x(), rel_pos_target.y() ); // cross product double crossy = ( facevec.x * targetvec.y ) - ( targetvec.x * facevec.y ); // dot product. @@ -885,7 +885,7 @@ units::angle vehicle::get_angle_from_targ( const tripoint &targ ) const * was the collision point. */ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_max, - float percent_of_parts_to_affect, point damage_origin, float damage_size ) + float percent_of_parts_to_affect, point_rel_ms damage_origin, float damage_size ) { for( vehicle_part &part : parts ) { //Skip any parts already mashed up or removed. @@ -915,9 +915,9 @@ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_ma int roll = dice( 1, 1000 ); int pct_af = ( percent_of_parts_to_affect * 1000.0f ); if( roll < pct_af ) { - double dist = damage_size == 0.0f ? 1.0f : - clamp( 1.0f - trig_dist( damage_origin, part.precalc[0].xy().raw() ) / - damage_size, 0.0f, 1.0f ); + double dist = damage_size == 0.0f ? 1.0f : + clamp( 1.0f - trig_dist( damage_origin, part.precalc[0].xy() ) / + damage_size, 0.0f, 1.0f ); //Everywhere else, drop by 10-120% of max HP (anything over 100 = broken) const float roll = rng_float( hp_percent_loss_min * dist, hp_percent_loss_max * dist ); if( mod_hp( part, -part.info().durability * roll ) ) { @@ -929,13 +929,13 @@ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_ma std::unique_ptr handler_ptr; // clear out any duplicated locations for( int p = static_cast( parts.size() ) - 1; p >= 0; p-- ) { - vehicle_part &part = parts[ p ]; + vehicle_part &part = parts[p]; if( part.removed ) { continue; } std::vector parts_here = parts_at_relative( part.mount, true ); - for( int other_i = static_cast( parts_here.size() ) - 1; other_i >= 0; other_i -- ) { - int other_p = parts_here[ other_i ]; + for( int other_i = static_cast( parts_here.size() ) - 1; other_i >= 0; other_i-- ) { + int other_p = parts_here[other_i]; if( p == other_p ) { continue; } @@ -1090,7 +1090,7 @@ void vehicle::backfire( const vehicle_part &vp ) const // single space after the exclamation mark because it does not end the sentence //~ backfire sound const std::string text = _( "a loud BANG! from the %s" ); // NOLINT(cata-text-style); - const tripoint pos = global_part_pos3( vp ); + const tripoint_bub_ms pos = bub_part_pos( vp ); const int volume = 40 + units::to_watt( part_vpower_w( vp, true ) ) / 10000; sounds::sound( pos, volume, sounds::sound_t::movement, string_format( text, vp.name() ), true, "vehicle", "engine_backfire" ); @@ -1483,12 +1483,12 @@ bool vehicle::is_appliance() const int vehicle::install_part( const point &dp, const vpart_id &type ) { - return install_part( dp, type, item( type.obj().base_item ) ); + return install_part( point_rel_ms( dp ), type, item( type.obj().base_item ) ); } -int vehicle::install_part( const point &dp, const vpart_id &type, item &&base ) +int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type ) { - return install_part( dp, vehicle_part( type, std::move( base ) ) ); + return install_part( dp, type, item( type.obj().base_item ) ); } int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type, item &&base ) @@ -1496,7 +1496,7 @@ int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type, item && return install_part( dp, vehicle_part( type, std::move( base ) ) ); } -int vehicle::install_part( const point &dp, const vpart_id &type, item &&base, +int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type, item &&base, std::vector &installed_with ) { return install_part( dp, vehicle_part( type, std::move( base ), installed_with ) ); @@ -2023,6 +2023,11 @@ bool vehicle::merge_appliance_into_grid( vehicle &veh_target ) } void vehicle::separate_from_grid( const point mount ) +{ + vehicle::separate_from_grid( point_rel_ms( mount ) ); +} + +void vehicle::separate_from_grid( const point_rel_ms mount ) { // Disconnect items and power cords unlink_cables( mount, get_player_character(), true, true, true ); @@ -2042,7 +2047,7 @@ void vehicle::separate_from_grid( const point mount ) const std::string part_name = part( idx ).name(); std::vector> split_indices( { { idx } } ); const std::vector null_vehicles( 2, nullptr ); - const std::vector> null_mounts( 2, std::vector() ); + const std::vector> null_mounts( 2, std::vector() ); if( !split_vehicles( here, split_indices, null_vehicles, null_mounts ) ) { debugmsg( "unable to split %s from power grid", part( idx ).name( false ) ); return; @@ -2054,7 +2059,7 @@ void vehicle::separate_from_grid( const point mount ) // Ensure the position, pivot, and precalc points are up-to-date. shift_if_needed( get_map() ); pos -= pivot_anchor[0]; - precalc_mounts( 0, turn_dir, point() ); + precalc_mounts( 0, turn_dir, point_rel_ms_zero ); add_msg( _( "You separate the %s from the power grid" ), part_name ); @@ -2192,7 +2197,7 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) handler.removed( *this, vp_idx ); const point_rel_ms &vp_mount = vp.mount; - const auto iter = labels.find( label( vp_mount.raw() ) ); + const auto iter = labels.find( label( vp_mount ) ); if( iter != labels.end() && parts_at_relative( vp_mount, false ).empty() ) { labels.erase( iter ); } @@ -2307,7 +2312,7 @@ bool vehicle::remove_carried_vehicle( const std::vector &carried_parts, return false; } - std::vector new_mounts; + std::vector new_mounts; new_vehicle->name = carried_pivot->veh_name; new_vehicle->owner = owner; new_vehicle->old_owner = old_owner; @@ -2333,7 +2338,7 @@ bool vehicle::remove_carried_vehicle( const std::vector &carried_parts, } } } - new_mounts.push_back( mount.xy().raw() ); + new_mounts.push_back( mount.xy() ); } for( const int &rack_part : racks ) { @@ -2458,7 +2463,8 @@ bool vehicle::find_and_split_vehicles( map &here, std::set exclude ) if( !all_vehicles.empty() ) { const std::vector null_vehicles( all_vehicles.size(), nullptr ); - const std::vector> null_mounts( all_vehicles.size(), std::vector() ); + const std::vector> null_mounts( all_vehicles.size(), + std::vector() ); std::vector mark_wreckage { this }; if( split_vehicles( here, all_vehicles, null_vehicles, null_mounts, &mark_wreckage ) ) { for( vehicle *veh : mark_wreckage ) { @@ -2466,7 +2472,7 @@ bool vehicle::find_and_split_vehicles( map &here, std::set exclude ) veh->add_tag( "wreckage" ); // wreckages don't get fake parts added } } - shift_parts( here, point_zero ); // update the active cache + shift_parts( here, point_rel_ms_zero ); // update the active cache return true; } } @@ -2485,26 +2491,6 @@ void vehicle::relocate_passengers( const std::vector &passengers ) } } -bool vehicle::split_vehicles( map &here, - const std::vector> &new_vehs, - const std::vector &new_vehicles, - const std::vector> &new_mounts, - std::vector *added_vehicles ) -{ - std::vector> temp; - for( const std::vector &sub : new_mounts ) { - std::vector temp2; - temp2.reserve( sub.size() ); - for( const point pt : sub ) { - const point_rel_ms temp3{pt}; - temp2.emplace_back( temp3 ); - } - temp.emplace_back( temp2 ); - } - - return vehicle::split_vehicles( here, new_vehs, new_vehicles, temp, added_vehicles ); -} - bool vehicle::split_vehicles( map &here, const std::vector> &new_vehs, const std::vector &new_vehicles, @@ -2616,11 +2602,11 @@ bool vehicle::split_vehicles( map &here, new_vehicle->parts.back().mount = new_mount; // remove labels associated with the mov_part - const auto iter = labels.find( label( cur_mount.raw() ) ); + const auto iter = labels.find( label( cur_mount ) ); if( iter != labels.end() ) { std::string label_str = iter->text; labels.erase( iter ); - new_labels.insert( label( new_mount.raw(), label_str ) ); + new_labels.insert( label( new_mount, label_str ) ); } // Prepare the zones to be moved to the new vehicle const std::pair::iterator, std::unordered_multimap::iterator> @@ -2672,7 +2658,7 @@ bool vehicle::split_vehicles( map &here, } // update the precalc points - new_vehicle->precalc_mounts( 0, new_vehicle->turn_dir, point() ); + new_vehicle->precalc_mounts( 0, new_vehicle->turn_dir, point_rel_ms_zero ); new_vehicle->precalc_mounts( 1, new_vehicle->skidding ? new_vehicle->turn_dir : new_vehicle->face.dir(), new_vehicle->pivot_point() ); @@ -2949,12 +2935,6 @@ int vehicle::part_with_feature( int part, vpart_bitflags flag, bool unbroken, return -1; } -int vehicle::part_with_feature( const point &pt, vpart_bitflags f, bool unbroken, - bool include_fake ) const -{ - return vehicle::part_with_feature( point_rel_ms( pt ), f, unbroken, include_fake ); -} - int vehicle::part_with_feature( const point_rel_ms &pt, vpart_bitflags f, bool unbroken, bool include_fake ) const { @@ -2995,6 +2975,11 @@ int vehicle::avail_part_with_feature( int part, vpart_bitflags flag ) const } int vehicle::avail_part_with_feature( const point &pt, const std::string &flag ) const +{ + return vehicle::avail_part_with_feature( point_rel_ms( pt ), flag ); +} + +int vehicle::avail_part_with_feature( const point_rel_ms &pt, const std::string &flag ) const { const int part_a = part_with_feature( pt, flag, true ); if( ( part_a >= 0 ) && this->part( part_a ).is_available() ) { @@ -3034,10 +3019,15 @@ bool vehicle::has_part( const std::string &flag, bool enabled ) const bool vehicle::has_part( const tripoint &pos, const std::string &flag, bool enabled ) const { - const tripoint relative_pos = pos - global_pos3(); + return vehicle::has_part( tripoint_bub_ms( pos ), flag, enabled ); +} + +bool vehicle::has_part( const tripoint_bub_ms &pos, const std::string &flag, bool enabled ) const +{ + const tripoint_rel_ms relative_pos = pos - pos_bub(); for( const vpart_reference &vpr : get_all_parts() ) { - if( vpr.part().precalc[0].raw() != relative_pos ) { + if( vpr.part().precalc[0] != relative_pos ) { continue; } if( !vpr.part().removed && ( !enabled || vpr.part().enabled ) && !vpr.part().is_broken() && @@ -3051,12 +3041,19 @@ bool vehicle::has_part( const tripoint &pos, const std::string &flag, bool enabl // NOLINTNEXTLINE(readability-make-member-function-const) std::vector vehicle::get_parts_at( const tripoint &pos, const std::string &flag, const part_status_flag condition ) +{ + return vehicle::get_parts_at( tripoint_bub_ms( pos ), flag, condition ); +} + +std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, + const std::string &flag, + const part_status_flag condition ) { // TODO: provide access to fake parts via argument ? - const tripoint relative_pos = pos - global_pos3(); + const tripoint_rel_ms relative_pos = pos - pos_bub(); std::vector res; for( const vpart_reference &vpr : get_all_parts() ) { - if( vpr.part().precalc[ 0 ].raw() != relative_pos ) { + if( vpr.part().precalc[0] != relative_pos ) { continue; } if( !vpr.part().removed && @@ -3069,21 +3066,14 @@ std::vector vehicle::get_parts_at( const tripoint &pos, const st return res; } -std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, - const std::string &flag, - const part_status_flag condition ) -{ - return vehicle::get_parts_at( pos.raw(), flag, condition ); -} - -std::vector vehicle::get_parts_at( const tripoint &pos, +std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, const std::string &flag, const part_status_flag condition ) const { - const tripoint relative_pos = pos - global_pos3(); + const tripoint_rel_ms relative_pos = pos - pos_bub(); std::vector res; for( const vpart_reference &vpr : get_all_parts() ) { - if( vpr.part().precalc[ 0 ].raw() != relative_pos ) { + if( vpr.part().precalc[ 0 ] != relative_pos ) { continue; } if( !vpr.part().removed && @@ -3098,7 +3088,7 @@ std::vector vehicle::get_parts_at( const tripoint &pos, std::optional vpart_position::get_label() const { - const auto it = vehicle().labels.find( label( mount() ) ); + const auto it = vehicle().labels.find( label( mount_pos() ) ); if( it == vehicle().labels.end() ) { return std::nullopt; } @@ -3112,13 +3102,13 @@ std::optional vpart_position::get_label() const void vpart_position::set_label( const std::string &text ) const { std::set