diff --git a/src/bionics.cpp b/src/bionics.cpp index 48b680bf8ef27..e8acb46911b37 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -1693,13 +1693,10 @@ void Character::process_bionic( bionic &bio ) mod_power_level( -trigger_cost ); } } else if( bio.id == bio_gills ) { - const units::energy trigger_cost = bio.info().power_trigger / 8; - if( has_effect( effect_asthma ) && get_power_level() >= trigger_cost ) { + if( has_effect( effect_asthma ) ) { add_msg_if_player( m_good, - _( "Your %s activates and you feel your throat open up and air filling your lungs!" ), - bio.info().name ); + _( "You feel your throat open up and air filling your lungs!" ) ); remove_effect( effect_asthma ); - mod_power_level( -trigger_cost ); } } else if( bio.id == bio_evap ) { if( is_underwater() ) { diff --git a/src/cata_imgui.cpp b/src/cata_imgui.cpp index ae7b31986a385..4f6679a8ebab3 100644 --- a/src/cata_imgui.cpp +++ b/src/cata_imgui.cpp @@ -332,8 +332,6 @@ static void AddGlyphRangesFromCLDR( ImFontGlyphRangesBuilder *b, const std::stri AddGlyphRangesFromCLDRForPL( b ); } else if( lang == "pt_BR" ) { AddGlyphRangesFromCLDRForPT( b ); - } else if( lang == "pt_PT" ) { - AddGlyphRangesFromCLDRForPT( b ); } else if( lang == "ru" ) { AddGlyphRangesFromCLDRForRU( b ); } else if( lang == "sr" ) { diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index a8a75c0b4ecf7..518b3697dfbc8 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -149,7 +149,8 @@ pixel_minimap_mode pixel_minimap_mode_from_string( const std::string &mode ) return pixel_minimap_mode::solid; } -auto simple_point_hash = []( const auto &p ) +// Generic function for hashing points. Untype them to use them. +auto simple_point_hash = []( const point &p ) { return p.x + p.y * 65536; }; @@ -2790,7 +2791,7 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG case TILE_CATEGORY::FIELD: case TILE_CATEGORY::LIGHTING: // stationary map tiles, seed based on map coordinates - seed = simple_point_hash( here.getglobal( pos ).raw() ); + seed = simple_point_hash( here.getglobal( pos ).raw().xy() ); break; case TILE_CATEGORY::VEHICLE_PART: // vehicle parts, seed based on coordinates within the vehicle @@ -2808,7 +2809,7 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG } else { const optional_vpart_position vp = here.veh_at( pos ); if( vp ) { - seed = simple_point_hash( vp->mount() ); + seed = simple_point_hash( vp->mount_pos().raw() ); } } } @@ -2822,7 +2823,7 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG if( fid.is_valid() ) { const furn_t &f = fid.obj(); if( !f.is_movable() ) { - seed = simple_point_hash( here.getglobal( pos ).raw() ); + seed = simple_point_hash( here.getglobal( pos ).raw().xy() ); } } } @@ -2831,14 +2832,14 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG case TILE_CATEGORY::OVERMAP_TERRAIN: case TILE_CATEGORY::OVERMAP_VISION_LEVEL: case TILE_CATEGORY::MAP_EXTRA: - seed = simple_point_hash( pos ); + seed = simple_point_hash( pos.xy() ); break; case TILE_CATEGORY::NONE: // graffiti if( found_id == "graffiti" ) { seed = std::hash {}( here.graffiti_at( pos ) ); } else if( string_starts_with( found_id, "graffiti" ) ) { - seed = simple_point_hash( here.getglobal( pos ).raw() ); + seed = simple_point_hash( here.getglobal( pos ).raw().xy() ); } break; case TILE_CATEGORY::ITEM: @@ -3654,7 +3655,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int // get the sprite to draw // roll is based on the maptile seed to keep visuals consistent - int roll = simple_point_hash( p ) % layer_var.total_weight; + int roll = simple_point_hash( p.xy() ) % layer_var.total_weight; std::string sprite_to_draw; for( const auto &sprite_list : layer_var.sprite ) { roll = roll - sprite_list.second; @@ -3682,7 +3683,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int // get the sprite to draw // roll is based on the maptile seed to keep visuals consistent - int roll = simple_point_hash( p ) % layer_var.total_weight; + int roll = simple_point_hash( p.xy() ) % layer_var.total_weight; std::string sprite_to_draw; for( const auto &sprite_list : layer_var.sprite ) { roll = roll - sprite_list.second; @@ -3934,7 +3935,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, const optional_vpart_position ovp = here.veh_at( p ); if( ovp && !invisible[0] ) { const vehicle &veh = ovp->vehicle(); - const vpart_display vd = veh.get_display_of_tile( ovp->mount() ); + const vpart_display vd = veh.get_display_of_tile( ovp->mount_pos() ); if( !vd.id.is_null() ) { const int subtile = vd.is_open ? open_ : vd.is_broken ? broken : 0; const int rotation = angle_to_dir4( 270_degrees - veh.face.dir() ); diff --git a/src/character.cpp b/src/character.cpp index 51d68f0b5a918..2b9268d8322f7 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3085,7 +3085,7 @@ std::vector Character::nearby( const } ); } - for( const vehicle_cursor &cur : vehicle_selector( pos(), radius ) ) { + for( const vehicle_cursor &cur : vehicle_selector( pos_bub(), radius ) ) { cur.visit_items( [&]( const item * e, const item * parent ) { if( func( e, parent ) ) { res.emplace_back( cur, const_cast( e ) ); @@ -3214,7 +3214,7 @@ units::mass Character::best_nearby_lifting_assist( const tripoint &world_pos ) c } int lift_quality = std::max( { this->max_quality( qual_LIFT ), mech_lift, map_selector( this->pos_bub(), PICKUP_RANGE ).max_quality( qual_LIFT ), - vehicle_selector( world_pos, 4, true, true ).max_quality( qual_LIFT ) + vehicle_selector( tripoint_bub_ms( world_pos ), 4, true, true ).max_quality( qual_LIFT ) } ); return lifting_quality_to_mass( lift_quality ); } diff --git a/src/character_guns.cpp b/src/character_guns.cpp index e8b4c9af9fe4a..b55a52cfb1fb3 100644 --- a/src/character_guns.cpp +++ b/src/character_guns.cpp @@ -118,7 +118,7 @@ std::vector Character::find_ammo( const item &obj, bool empty, in for( map_cursor &cursor : map_selector( pos_bub(), radius ) ) { find_ammo_helper( cursor, obj, empty, std::back_inserter( res ), false ); } - for( vehicle_cursor &cursor : vehicle_selector( pos(), radius ) ) { + for( vehicle_cursor &cursor : vehicle_selector( pos_bub(), radius ) ) { find_ammo_helper( cursor, obj, empty, std::back_inserter( res ), false ); } } diff --git a/src/clzones.cpp b/src/clzones.cpp index 26540047c64b8..937a26fe4663e 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -1408,7 +1408,7 @@ void zone_manager::add( const std::string &name, const zone_type_id &type, const return; } - create_vehicle_loot_zone( vp->vehicle(), vp->mount(), new_zone, pmap ); + create_vehicle_loot_zone( vp->vehicle(), vp->mount_pos().raw(), new_zone, pmap ); return; } } @@ -1791,7 +1791,7 @@ void zone_manager::revert_vzones() const tripoint_bub_ms pos = here.bub_from_abs( zone.get_start_point() ); if( const std::optional vp = here.veh_at( pos ).cargo() ) { zone.set_is_vehicle( true ); - vp->vehicle().loot_zones.emplace( vp->mount(), zone ); + vp->vehicle().loot_zones.emplace( vp->mount_pos(), zone ); here.register_vehicle_zone( &vp->vehicle(), here.get_abs_sub().z() ); cache_vzones(); } diff --git a/src/editmap.cpp b/src/editmap.cpp index 41ca28efa817b..48de02bbd657e 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -652,7 +652,7 @@ void editmap::draw_main_ui_overlay() false ); } if( const optional_vpart_position ovp = tmpmap.veh_at( tmp_p ) ) { - const vpart_display vd = ovp->vehicle().get_display_of_tile( ovp->mount() ); + const vpart_display vd = ovp->vehicle().get_display_of_tile( ovp->mount_pos() ); char part_mod = 0; if( vd.is_open ) { part_mod = 1; @@ -660,7 +660,8 @@ void editmap::draw_main_ui_overlay() part_mod = 2; } const units::angle veh_dir = ovp->vehicle().face.dir(); - g->draw_vpart_override( map_p, vpart_id( vd.id ), part_mod, veh_dir, vd.has_cargo, ovp->mount() ); + g->draw_vpart_override( map_p, vpart_id( vd.id ), part_mod, veh_dir, vd.has_cargo, + ovp->mount_pos().raw() ); } else { g->draw_vpart_override( map_p, vpart_id::NULL_ID(), 0, 0_degrees, false, point_zero ); } diff --git a/src/game.cpp b/src/game.cpp index 01192b1e1c59f..44e784063114c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1034,11 +1034,11 @@ bool game::start_game() std::string search = std::string( "helicopter" ); if( name.find( search ) != std::string::npos ) { for( const vpart_reference &vp : v.v->get_any_parts( VPFLAG_CONTROLS ) ) { - const tripoint pos = vp.pos(); + const tripoint_bub_ms pos = vp.pos_bub(); u.setpos( pos ); // Delete the items that would have spawned here from a "corpse" - for( const int sp : v.v->parts_at_relative( vp.mount(), true ) ) { + for( const int sp : v.v->parts_at_relative( vp.mount_pos(), true ) ) { vpart_reference( *v.v, sp ).items().clear(); } @@ -1200,7 +1200,7 @@ vehicle *game::place_vehicle_nearby( point_sm_ms remainder; std::tie( quotient, remainder ) = coords::project_remain( abs_local ); veh->sm_pos = quotient.raw(); - veh->pos = remainder.raw(); + veh->pos = remainder; veh->unlock(); // always spawn unlocked veh->toggle_tracking(); // always spawn tracked @@ -5511,7 +5511,7 @@ void game::save_cyborg( item *cyborg, const tripoint &couch_pos, Character &inst void game::exam_appliance( vehicle &veh, const point &c ) { - player_activity act = veh_app_interact::run( veh, c ); + player_activity act = veh_app_interact::run( veh, point_rel_ms( c ) ); if( act ) { u.set_moves( 0 ); u.assign_activity( act ); @@ -5524,7 +5524,7 @@ void game::exam_vehicle( vehicle &veh, const point &c ) add_msg( m_info, _( "This is your %s" ), veh.name ); return; } - player_activity act = veh_interact::run( veh, c ); + player_activity act = veh_interact::run( veh, point_rel_ms( c ) ); if( act ) { u.set_moves( 0 ); u.assign_activity( act ); @@ -5583,8 +5583,8 @@ void game::control_vehicle() vehicle *veh = nullptr; if( const optional_vpart_position vp = m.veh_at( u.pos_bub() ) ) { veh = &vp->vehicle(); - const int controls_idx = veh->avail_part_with_feature( vp->mount(), "CONTROLS" ); - const int reins_idx = veh->avail_part_with_feature( vp->mount(), "CONTROL_ANIMAL" ); + const int controls_idx = veh->avail_part_with_feature( vp->mount_pos(), "CONTROLS" ); + const int reins_idx = veh->avail_part_with_feature( vp->mount_pos(), "CONTROL_ANIMAL" ); const bool controls_ok = controls_idx >= 0; // controls available to "drive" const bool reins_ok = reins_idx >= 0 // reins + animal available to "drive" && veh->has_engine_type( fuel_type_animal, false ) @@ -6011,7 +6011,7 @@ void game::examine( const tripoint_bub_ms &examp, bool with_pickup ) if( !vp->vehicle().is_appliance() ) { vp->vehicle().interact_with( examp, with_pickup ); } else { - g->exam_appliance( vp->vehicle(), vp->mount() ); + g->exam_appliance( vp->vehicle(), vp->mount_pos().raw() ); } return; } else { @@ -10807,7 +10807,7 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool if( grabbed_vehicle ) { // Vehicle might be at different z level than the grabbed part. - u.grab_point.z() = vp_grab->pos().z - u.posz(); + u.grab_point.z() = vp_grab->pos_bub().z() - u.posz(); } if( pulling ) { diff --git a/src/handle_action.cpp b/src/handle_action.cpp index cff4366343f47..125a5277a0c3b 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -752,7 +752,7 @@ static void grab() return; } get_player_character().pause(); - vp->vehicle().separate_from_grid( vp.value().mount() ); + vp->vehicle().separate_from_grid( vp.value().mount_pos() ); if( const optional_vpart_position &split_vp = here.veh_at( grabp ) ) { veh_name = split_vp->vehicle().name; } else { diff --git a/src/item.cpp b/src/item.cpp index 8e216705754fd..a9b218bb9c6c3 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -13583,7 +13583,7 @@ std::string item::link_name() const ret_val item::link_to( const optional_vpart_position &linked_vp, link_state link_type ) { - return linked_vp ? link_to( linked_vp->vehicle(), linked_vp->mount(), link_type ) : + return linked_vp ? link_to( linked_vp->vehicle(), linked_vp->mount_pos(), link_type ) : ret_val::make_failure(); } @@ -13594,11 +13594,12 @@ ret_val item::link_to( const optional_vpart_position &first_linked_vp, return ret_val::make_failure(); } // Link up the second vehicle first so, if it's a tow cable, the first vehicle will tow the second. - ret_val result = link_to( second_linked_vp->vehicle(), second_linked_vp->mount(), link_type ); + ret_val result = link_to( second_linked_vp->vehicle(), second_linked_vp->mount_pos(), + link_type ); if( !result.success() ) { return result; } - return link_to( first_linked_vp->vehicle(), first_linked_vp->mount(), link_type ); + return link_to( first_linked_vp->vehicle(), first_linked_vp->mount_pos(), link_type ); } ret_val item::link_to( vehicle &veh, const point &mount, link_state link_type ) diff --git a/src/item_location.cpp b/src/item_location.cpp index 76190f63e349e..83710fe4f06d1 100644 --- a/src/item_location.cpp +++ b/src/item_location.cpp @@ -508,7 +508,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl debugmsg( "item in vehicle part without cargo storage" ); } if( ch ) { - res += " " + direction_suffix( ch->pos(), part_pos.pos() ); + res += " " + direction_suffix( ch->pos_bub().raw(), part_pos.pos_bub().raw() ); } return res; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 5a996d5f2060b..5e7c9ee578b33 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -4880,7 +4880,7 @@ std::optional link_up_actor::link_to_veh_app( Character *p, item &it, const auto can_link = [&here, &to_ports]( const tripoint & point ) { const optional_vpart_position ovp = here.veh_at( point ); - return ovp && ovp->vehicle().avail_linkable_part( ovp->mount(), to_ports ) != -1; + return ovp && ovp->vehicle().avail_linkable_part( ovp->mount_pos(), to_ports ) != -1; }; const std::optional pnt_ = choose_adjacent_highlight( _( "Attach the cable where?" ), "", can_link, false, false ); @@ -4923,7 +4923,7 @@ std::optional link_up_actor::link_to_veh_app( Character *p, item &it, } // Get the part name for the connection message, using the vehicle name as a fallback. - const int part_index = sel_vp->vehicle().avail_linkable_part( sel_vp->mount(), to_ports ); + const int part_index = sel_vp->vehicle().avail_linkable_part( sel_vp->mount_pos(), to_ports ); const std::string sel_vp_name = part_index == -1 ? sel_vp->vehicle().name : sel_vp->vehicle().part( part_index ).name( false ); diff --git a/src/map.cpp b/src/map.cpp index 17515049eb394..a971be7320c9f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1253,7 +1253,7 @@ bool map::deregister_vehicle_zone( zone_data &zone ) const const tripoint_bub_ms pos = bub_from_abs( zone.get_start_point() ); if( const std::optional vp = veh_at( pos ).cargo() ) { vehicle &veh = vp->vehicle(); - auto bounds = veh.loot_zones.equal_range( vp->mount() ); + auto bounds = veh.loot_zones.equal_range( vp->mount_pos() ); for( auto it = bounds.first; it != bounds.second; it++ ) { if( &zone == &( it->second ) ) { veh.loot_zones.erase( it ); @@ -1280,7 +1280,7 @@ std::set map::get_moving_vehicle_targets( const Creature &z, in continue; // coarse distance filter, 40 = ~24 * sqrt(2) - rough max diameter of a vehicle } for( const vpart_reference &vpr : v.v->get_all_parts() ) { - const tripoint_bub_ms vppos = static_cast( vpr.pos() ); + const tripoint_bub_ms vppos = vpr.pos_bub(); if( rl_dist( zpos, vppos ) > max_range ) { continue; } @@ -1602,7 +1602,7 @@ bool map::displace_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const bool } veh.shed_loose_parts( trinary::SOME, &dst ); - smzs = veh.advance_precalc_mounts( dst_offset.raw(), src.raw(), dp.raw(), ramp_offset, + smzs = veh.advance_precalc_mounts( dst_offset, src, dp, ramp_offset, adjust_pos, parts_to_move ); veh.update_active_fakes(); @@ -3850,7 +3850,7 @@ bool map::terrain_moppable( const tripoint_bub_ms &p ) // Moppable vehicles ( blood splatter ) if( const optional_vpart_position ovp = veh_at( p ) ) { vehicle *const veh = &ovp->vehicle(); - for( const int elem : veh->parts_at_relative( ovp->mount(), true ) ) { + for( const int elem : veh->parts_at_relative( ovp->mount_pos(), true ) ) { const vehicle_part &vp = veh->part( elem ); if( vp.blood > 0 ) { return true; @@ -3895,7 +3895,7 @@ bool map::mop_spills( const tripoint_bub_ms &p ) if( const optional_vpart_position ovp = veh_at( p ) ) { vehicle *const veh = &ovp->vehicle(); - for( const int elem : veh->parts_at_relative( ovp->mount(), true ) ) { + for( const int elem : veh->parts_at_relative( ovp->mount_pos(), true ) ) { vehicle_part &vp = veh->part( elem ); if( vp.blood > 0 ) { vp.blood = 0; @@ -5998,7 +5998,7 @@ void map::process_items_in_vehicle( vehicle &cur_veh, submap ¤t_submap ) } const auto it = std::find_if( begin( cargo_parts ), end( cargo_parts ), [&]( const vpart_reference & part ) { - return active_item_ref.location.raw() == part.mount(); + return active_item_ref.location == part.mount_pos(); } ); if( it == end( cargo_parts ) ) { @@ -6969,7 +6969,7 @@ void map::add_splatter( const field_type_id &type, const tripoint_bub_ms &where, if( const optional_vpart_position vp = veh_at( where ) ) { vehicle *const veh = &vp->vehicle(); // Might be -1 if all the vehicle's parts at where are marked for removal - const int part = veh->part_displayed_at( vp->mount(), true ); + const int part = veh->part_displayed_at( vp->mount_pos(), true ); if( part != -1 ) { veh->part( part ).blood += 200 * std::min( intensity, 3 ) / 3; return; @@ -7601,7 +7601,7 @@ void map::draw_from_above( const catacurses::window &w, const tripoint_bub_ms &p tercol = curr_furn.color(); } else if( ( veh = veh_at_internal( p, part_below ) ) != nullptr ) { const vpart_position vpp( const_cast( *veh ), part_below ); - const vpart_display vd = veh->get_display_of_tile( vpp.mount(), true, true, true ); + const vpart_display vd = veh->get_display_of_tile( vpp.mount_pos(), true, true, true ); const int roof = veh->roof_at_part( part_below ); sym = vd.symbol_curses; tercol = roof >= 0 || vpp.obstacle_at_part() ? c_light_gray : c_light_gray_cyan; @@ -9019,7 +9019,7 @@ void map::actualize( const tripoint_rel_sm &grid ) // spill out items too large, MIGRATION pockets etc from vehicle parts for( const vpart_reference &vp : veh->get_all_parts() ) { const item &base_const = vp.part().get_base(); - const_cast( base_const ).overflow( vp.pos() ); + const_cast( base_const ).overflow( vp.pos_bub().raw() ); } veh->refresh(); } diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 4c3a8191beebd..22659a2199a62 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -413,7 +413,7 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) } else { m.place_spawns( GROUP_MIL_PASSENGER, 1, pos.xy(), pos.xy(), pos.z(), 1, true ); } - delete_items_at_mount( *wreckage, vp.mount() ); // delete corpse items + delete_items_at_mount( *wreckage, vp.mount_pos().raw() ); // delete corpse items } break; case 4: @@ -427,7 +427,7 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) } else { m.place_spawns( GROUP_MIL_WEAK, 2, pos.xy(), pos.xy(), pos.z(), 1, true ); } - delete_items_at_mount( *wreckage, vp.mount() ); // delete corpse items + delete_items_at_mount( *wreckage, vp.mount_pos().raw() ); // delete corpse items } break; case 6: @@ -435,7 +435,7 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) for( const vpart_reference &vp : wreckage->get_any_parts( VPFLAG_CONTROLS ) ) { const tripoint_bub_ms pos = vp.pos_bub(); m.place_spawns( GROUP_MIL_PILOT, 1, pos.xy(), pos.xy(), pos.z(), 1, true ); - delete_items_at_mount( *wreckage, vp.mount() ); // delete corpse items + delete_items_at_mount( *wreckage, vp.mount_pos().raw() ); // delete corpse items } break; case 7: diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 50c4c71d820e1..3802493ef9535 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -2686,10 +2686,10 @@ static inclusive_rectangle vehicle_bounds( const vehicle_prototype &vp ) cata_assert( !vp.parts.empty() ); for( const vehicle_prototype::part_def &part : vp.parts ) { - min.x = std::min( min.x, part.pos.x ); - max.x = std::max( max.x, part.pos.x ); - min.y = std::min( min.y, part.pos.y ); - max.y = std::max( max.y, part.pos.y ); + min.x = std::min( min.x, part.pos.x() ); + max.x = std::max( max.x, part.pos.x() ); + min.y = std::min( min.y, part.pos.y() ); + max.y = std::max( max.y, part.pos.y() ); } return { min, max }; @@ -6906,7 +6906,7 @@ vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, cons point_sm_ms remainder; std::tie( quotient, remainder ) = coords::project_remain( p_ms ); veh->sm_pos = quotient.raw(); - veh->pos = remainder.raw(); + veh->pos = remainder; veh->init_state( *this, veh_fuel, veh_status ); veh->place_spawn_items(); veh->face.init( dir ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 3b8fbf2f4e9a2..3112f08467ae1 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1785,9 +1785,9 @@ void npc::execute_action( npc_action action ) // Try to find the last destination // This is mount point, not actual position - point last_dest( INT_MIN, INT_MIN ); + point_rel_ms last_dest( INT_MIN, INT_MIN ); if( !path.empty() && veh_pointer_or_null( here.veh_at( path[path.size() - 1] ) ) == veh ) { - last_dest = vp->mount(); + last_dest = vp->mount_pos(); } // Prioritize last found path, then seats @@ -1816,7 +1816,7 @@ void npc::execute_action( npc_action action ) int priority = 0; - if( vp.mount() == last_dest ) { + if( vp.mount_pos() == last_dest ) { // Shares mount point with last known path // We probably wanted to go there in the last turn priority = 4; diff --git a/src/options.cpp b/src/options.cpp index 7aa0961d8df04..33085594d5a14 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1338,7 +1338,7 @@ std::vector options_manager::get_lang_options() { "", to_translation( "System language" ) }, }; - constexpr std::array, 26> language_names = {{ + constexpr std::array, 25> language_names = {{ // Note: language names are in their own language and are *not* translated at all. // Note: Somewhere in Github PR was better link to msdn.microsoft.com with language names. // http://en.wikipedia.org/wiki/List_of_language_names @@ -1361,7 +1361,6 @@ std::vector options_manager::get_lang_options() { "nl", R"(Nederlands)" }, { "pl", R"(Polski)" }, { "pt_BR", R"(Português (Brasil))" }, - { "pt_PT", R"(Português (Portugal))" }, { "ru", R"(Русский)" }, { "sr", R"(Српски)" }, { "tr", R"(Türkçe)" }, @@ -4246,8 +4245,6 @@ void options_manager::update_global_locale() std::locale::global( std::locale( "pl_PL.UTF-8" ) ); } else if( lang == "pt_BR" ) { std::locale::global( std::locale( "pt_BR.UTF-8" ) ); - } else if( lang == "pt_PT" ) { - std::locale::global( std::locale( "pt_PT.UTF-8" ) ); } else if( lang == "ru" ) { std::locale::global( std::locale( "ru_RU.UTF-8" ) ); } else if( lang == "sr" ) { diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index b6abe48d8dff8..51322b21b2c10 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -87,7 +87,7 @@ SDL_Color get_map_color_at( const tripoint &p ) { const map &here = get_map(); if( const optional_vpart_position vp = here.veh_at( p ) ) { - const vpart_display vd = vp->vehicle().get_display_of_tile( vp->mount() ); + const vpart_display vd = vp->vehicle().get_display_of_tile( vp->mount_pos() ); return curses_color_to_SDL( vd.color ); } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index a2c11e559729f..5354c610f7433 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -3322,8 +3322,8 @@ void vehicle::deserialize( const JsonObject &data ) int mdir = 0; data.read( "type", type ); - data.read( "posx", pos.x ); - data.read( "posy", pos.y ); + data.read( "posx", pos.x() ); + data.read( "posy", pos.y() ); data.read( "om_id", om_id ); data.read( "faceDir", fdir ); data.read( "moveDir", mdir ); @@ -3440,8 +3440,8 @@ void vehicle::serialize( JsonOut &json ) const { json.start_object(); json.member( "type", type ); - json.member( "posx", pos.x ); - json.member( "posy", pos.y ); + json.member( "posx", pos.x() ); + json.member( "posy", pos.y() ); json.member( "om_id", om_id ); json.member( "faceDir", std::lround( to_degrees( face.dir() ) ) ); json.member( "moveDir", std::lround( to_degrees( move.dir() ) ) ); diff --git a/src/submap.cpp b/src/submap.cpp index 056a65c8b28eb..9b819f033a905 100644 --- a/src/submap.cpp +++ b/src/submap.cpp @@ -259,9 +259,9 @@ void submap::rotate( int turns ) } for( auto &elem : vehicles ) { - const point_sm_ms new_pos = point_sm_ms( rotate_point( elem->pos ) ); + const point_sm_ms new_pos = point_sm_ms( rotate_point( elem->pos.raw() ) ); - elem->pos = new_pos.raw(); + elem->pos = new_pos; // turn the steering wheel, vehicle::turn does not actually // move the vehicle. elem->turn( turns * 90_degrees ); diff --git a/src/suffer.cpp b/src/suffer.cpp index dd43ba37b7b17..5658887b7c459 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -317,15 +317,9 @@ void suffer::while_underwater( Character &you ) you.oxygen += 12; } if( you.oxygen <= 5 ) { - if( you.has_bionic( bio_gills ) ) { - if( you.get_power_level() >= bio_gills->power_trigger ) { - you.oxygen += 5; - you.mod_power_level( -bio_gills->power_trigger ); - } else { - you.add_msg_if_player( m_bad, - _( "You don't have enough bionic power for activation of your Respirator, so you're drowning!" ) ); - you.apply_damage( nullptr, bodypart_id( "torso" ), rng( 1, 4 ) ); - } + if( you.has_bionic( bio_gills ) && you.get_power_level() >= bio_gills->power_trigger ) { + you.oxygen += 5; + you.mod_power_level( -bio_gills->power_trigger ); } else { you.add_msg_if_player( m_bad, _( "You're drowning!" ) ); you.apply_damage( nullptr, bodypart_id( "torso" ), rng( 1, 4 ) ); diff --git a/src/veh_appliance.cpp b/src/veh_appliance.cpp index 65991912862e9..4411589ec610f 100644 --- a/src/veh_appliance.cpp +++ b/src/veh_appliance.cpp @@ -127,7 +127,7 @@ bool place_appliance( const tripoint_bub_ms &p, const vpart_id &vpart, return true; } -player_activity veh_app_interact::run( vehicle &veh, const point &p ) +player_activity veh_app_interact::run( vehicle &veh, const point_rel_ms &p ) { veh_app_interact ap( veh, p ); ap.app_loop(); @@ -135,7 +135,7 @@ player_activity veh_app_interact::run( vehicle &veh, const point &p ) } // Registers general appliance actions from keybindings -veh_app_interact::veh_app_interact( vehicle &veh, const point &p ) +veh_app_interact::veh_app_interact( vehicle &veh, const point_rel_ms &p ) : a_point( p ), veh( &veh ), ctxt( "APP_INTERACT", keyboard_mode::keycode ) { ctxt.register_directions(); @@ -408,10 +408,10 @@ void veh_app_interact::refill() } act.values.push_back( here.getglobal( veh->pos_bub() ).x() + q.x() ); act.values.push_back( here.getglobal( veh->pos_bub() ).y() + q.y() ); - act.values.push_back( a_point.x ); - act.values.push_back( a_point.y ); - act.values.push_back( -a_point.x ); - act.values.push_back( -a_point.y ); + act.values.push_back( a_point.x() ); + act.values.push_back( a_point.y() ); + act.values.push_back( -a_point.x() ); + act.values.push_back( -a_point.y() ); act.values.push_back( veh->index_of_part( pt ) ); } } @@ -460,7 +460,7 @@ void veh_app_interact::rename() void veh_app_interact::remove() { map &here = get_map(); - const tripoint a_point_bub( veh->mount_to_tripoint( a_point ) ); + const tripoint_bub_ms a_point_bub( veh->mount_to_tripoint( a_point ) ); vehicle_part *vp; if( auto sel_part = here.veh_at( a_point_bub ).part_with_feature( VPFLAG_APPLIANCE, false ) ) { @@ -498,10 +498,10 @@ void veh_app_interact::remove() const tripoint a_point_abs( here.getglobal( a_point_bub ).raw() ); act.values.push_back( a_point_abs.x ); act.values.push_back( a_point_abs.y ); - act.values.push_back( a_point.x ); - act.values.push_back( a_point.y ); - act.values.push_back( -a_point.x ); - act.values.push_back( -a_point.y ); + act.values.push_back( a_point.x() ); + act.values.push_back( a_point.y() ); + act.values.push_back( -a_point.x() ); + act.values.push_back( -a_point.y() ); act.values.push_back( veh->index_of_part( vp ) ); } } @@ -538,7 +538,7 @@ void veh_app_interact::populate_app_actions() { map &here = get_map(); vehicle_part *vp; - const tripoint a_point_bub( veh->mount_to_tripoint( a_point ) ); + const tripoint_bub_ms a_point_bub( veh->mount_to_tripoint( a_point ) ); if( auto sel_part = here.veh_at( a_point_bub ).part_with_feature( VPFLAG_APPLIANCE, false ) ) { vp = &sel_part->part(); } else { @@ -597,7 +597,7 @@ void veh_app_interact::populate_app_actions() /*************** Get part-specific actions ***************/ veh_menu menu( veh, "IF YOU SEE THIS IT IS A BUG" ); - veh->build_interact_menu( menu, veh->mount_to_tripoint( a_point ), false ); + veh->build_interact_menu( menu, veh->mount_to_tripoint( a_point ).raw(), false ); const std::vector items = menu.get_items(); for( size_t i = 0; i < items.size(); i++ ) { const veh_menu_item &it = items[i]; diff --git a/src/veh_appliance.h b/src/veh_appliance.h index 408790bd951d8..bb7e747638545 100644 --- a/src/veh_appliance.h +++ b/src/veh_appliance.h @@ -2,6 +2,8 @@ #ifndef CATA_SRC_VEH_APPLIANCE_H #define CATA_SRC_VEH_APPLIANCE_H +#include "coordinates.h" +#include "coordinate_constants.h" #include "input_context.h" #include "player_activity.h" @@ -37,14 +39,14 @@ class veh_app_interact * @returns An activity to assign to the player (ACT_VEHICLE), * or a null activity if no further action is required. */ - static player_activity run( vehicle &veh, const point &p = point_zero ); + static player_activity run( vehicle &veh, const point_rel_ms &p = point_rel_ms_zero ); private: - explicit veh_app_interact( vehicle &veh, const point &p ); + explicit veh_app_interact( vehicle &veh, const point_rel_ms &p ); ~veh_app_interact() = default; // The player's point of interaction on the appliance. - point a_point = point_zero; + point_rel_ms a_point = point_rel_ms_zero; // The vehicle representing the appliance. vehicle *veh; // An input context to contain registered actions from the APP_INTERACT category. diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index f3c841423f0bb..a74c6e6b4706b 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -136,8 +136,8 @@ player_activity veh_interact::serialize_activity() if( sel_cmd == 'p' ) { if( !parts_here.empty() ) { const vpart_reference part_here( *veh, parts_here[0] ); - const vpart_reference displayed_part( *veh, veh->part_displayed_at( part_here.mount() ) ); - return veh_shape( *veh ).start( tripoint_bub_ms( displayed_part.pos() ) ); + const vpart_reference displayed_part( *veh, veh->part_displayed_at( part_here.mount_pos() ) ); + return veh_shape( *veh ).start( displayed_part.pos_bub() ); } return player_activity(); } @@ -182,10 +182,10 @@ player_activity veh_interact::serialize_activity() } res.values.push_back( here.getglobal( veh->pos_bub() ).x() + q.x() ); // values[0] res.values.push_back( here.getglobal( veh->pos_bub() ).y() + q.y() ); // values[1] - res.values.push_back( dd.x ); // values[2] - res.values.push_back( dd.y ); // values[3] - res.values.push_back( -dd.x ); // values[4] - res.values.push_back( -dd.y ); // values[5] + res.values.push_back( dd.x() ); // values[2] + res.values.push_back( dd.y() ); // values[3] + res.values.push_back( -dd.x() ); // values[4] + res.values.push_back( -dd.y() ); // values[5] res.values.push_back( veh->index_of_part( vpt ) ); // values[6] res.str_values.emplace_back( vp->id.str() ); res.str_values.emplace_back( "" ); // previously stored the part variant, now obsolete @@ -195,7 +195,7 @@ player_activity veh_interact::serialize_activity() } void orient_part( vehicle *veh, const vpart_info &vpinfo, int partnum, - const std::optional &part_placement ) + const std::optional &part_placement ) { avatar &player_character = get_avatar(); @@ -205,8 +205,8 @@ void orient_part( vehicle *veh, const vpart_info &vpinfo, int partnum, tripoint_bub_ms offset = veh->pos_bub(); // Appliances are one tile so the part placement there is always point_zero if( part_placement ) { - point copied_placement = *part_placement ; - offset += copied_placement ; + point_rel_ms copied_placement = *part_placement; + offset = offset + copied_placement; } player_character.view_offset = offset - player_character.pos_bub(); @@ -232,7 +232,7 @@ void orient_part( vehicle *veh, const vpart_info &vpinfo, int partnum, veh->part( partnum ).direction = dir; } -player_activity veh_interact::run( vehicle &veh, const point &p ) +player_activity veh_interact::run( vehicle &veh, const point_rel_ms &p ) { veh_interact vehint( veh, p ); vehint.do_main_loop(); @@ -268,7 +268,7 @@ std::optional veh_interact::select_part( const vehicle &veh, /** * Creates a blank veh_interact window. */ -veh_interact::veh_interact( vehicle &veh, const point &p ) +veh_interact::veh_interact( vehicle &veh, const point_rel_ms &p ) : dd( p ), veh( &veh ), main_context( "VEH_INTERACT", keyboard_mode::keycode ) { main_context.register_directions(); @@ -302,7 +302,7 @@ veh_interact::veh_interact( vehicle &veh, const point &p ) count_durability(); cache_tool_availability(); // Initialize info of selected parts - move_cursor( point_zero ); + move_cursor( point_rel_ms_zero ); } veh_interact::~veh_interact() = default; @@ -513,7 +513,7 @@ void veh_interact::do_main_loop() const std::string action = main_context.handle_input(); msg.reset(); if( const std::optional vec = main_context.get_direction( action ) ) { - move_cursor( vec->xy() ); + move_cursor( point_rel_ms( vec->xy() ) ); } else if( action == "QUIT" ) { finish = true; } else if( action == "INSTALL" ) { @@ -587,13 +587,13 @@ void veh_interact::do_main_loop() } else if( action == "OVERVIEW_UP" ) { move_overview_line( -1 ); } else if( action == "DESC_LIST_DOWN" ) { - move_cursor( point_zero, 1 ); + move_cursor( point_rel_ms_zero, 1 ); } else if( action == "DESC_LIST_UP" ) { - move_cursor( point_zero, -1 ); + move_cursor( point_rel_ms_zero, -1 ); } else if( action == "PAGE_DOWN" ) { - move_cursor( point_zero, description_scroll_lines ); + move_cursor( point_rel_ms_zero, description_scroll_lines ); } else if( action == "PAGE_UP" ) { - move_cursor( point_zero, -description_scroll_lines ); + move_cursor( point_rel_ms_zero, -description_scroll_lines ); } if( sel_cmd != ' ' ) { finish = true; @@ -606,21 +606,21 @@ void veh_interact::cache_tool_availability() Character &player_character = get_player_character(); crafting_inv = &player_character.crafting_inventory(); - cache_tool_availability_update_lifting( player_character.pos() ); + cache_tool_availability_update_lifting( player_character.pos_bub() ); int mech_jack = 0; if( player_character.is_mounted() ) { mech_jack = player_character.mounted_creature->mech_str_addition() + 10; } int max_quality = std::max( { player_character.max_quality( qual_JACK ), mech_jack, map_selector( player_character.pos_bub(), PICKUP_RANGE ).max_quality( qual_JACK ), - vehicle_selector( player_character.pos(), 2, true, *veh ).max_quality( qual_JACK ) + vehicle_selector( player_character.pos_bub(), 2, true, *veh ).max_quality( qual_JACK ) } ); max_jack = lifting_quality_to_mass( max_quality ); } -void veh_interact::cache_tool_availability_update_lifting( const tripoint &world_cursor_pos ) +void veh_interact::cache_tool_availability_update_lifting( const tripoint_bub_ms &world_cursor_pos ) { - max_lift = get_player_character().best_nearby_lifting_assist( world_cursor_pos ); + max_lift = get_player_character().best_nearby_lifting_assist( world_cursor_pos.raw() ); } /** @@ -854,7 +854,7 @@ bool veh_interact::update_part_requirements() } } - if( !axles.empty() && axles.count( -dd.x ) == 0 ) { + if( !axles.empty() && axles.count( -dd.x() ) == 0 ) { // Installing more than one steerable axle is hard // (but adding a wheel to an existing axle isn't) dif_steering = axles.size() + 5; @@ -2154,9 +2154,9 @@ std::pair veh_interact::calc_lift_requirements( const vpart_i * @param d The coordinates, relative to the viewport's 0-point (?) * @return The first vehicle part at the specified coordinates. */ -int veh_interact::part_at( const point &d ) +int veh_interact::part_at( const point_rel_ms &d ) { - const point vd = -dd + d.rotate( 1 ); + const point_rel_ms vd{ -dd + d.rotate( 1 ) }; return veh->part_displayed_at( vd ); } @@ -2190,19 +2190,19 @@ bool veh_interact::can_potentially_install( const vpart_info &vpart ) * @param d How far to move the cursor. * @param dstart_at How far to change the start position for vehicle part descriptions */ -void veh_interact::move_cursor( const point &d, int dstart_at ) +void veh_interact::move_cursor( const point_rel_ms &d, int dstart_at ) { dd += d.rotate( 3 ); - if( d != point_zero ) { + if( d != point_rel_ms_zero ) { start_limit = 0; } else { start_at += dstart_at; } // Update the current active component index to the new position. - cpart = part_at( point_zero ); - const point vd = -dd; - const point q = veh->coord_translate( vd ); + cpart = part_at( point_rel_ms_zero ); + const point_rel_ms vd = -dd; + const point_rel_ms q = veh->coord_translate( vd ); const tripoint_bub_ms vehp = veh->pos_bub() + q; const bool has_critter = get_creature_tracker().creature_at( vehp ); map &here = get_map(); @@ -2252,7 +2252,7 @@ void veh_interact::move_cursor( const point &d, int dstart_at ) } /* Update the lifting quality to be the that is available for this newly selected tile */ - cache_tool_availability_update_lifting( vehp.raw() ); + cache_tool_availability_update_lifting( vehp ); } void veh_interact::display_grid() @@ -2323,26 +2323,26 @@ void veh_interact::display_veh() // NOLINTNEXTLINE(cata-use-named-point-constants) mvwprintz( w_disp, point( 0, 1 ), c_red, "Pivot %d,%d", pivot.x(), pivot.y() ); - const point com_s = ( com.raw() + dd ).rotate( 3 ) + h_size; - const point pivot_s = ( pivot.raw() + dd ).rotate( 3 ) + h_size; + const point_rel_ms com_s = ( com + dd ).rotate( 3 ) + h_size; + const point_rel_ms pivot_s = ( pivot + dd ).rotate( 3 ) + h_size; for( int x = 0; x < getmaxx( w_disp ); ++x ) { - if( x <= com_s.x ) { - mvwputch( w_disp, point( x, com_s.y ), c_green, LINE_OXOX ); + if( x <= com_s.x() ) { + mvwputch( w_disp, point( x, com_s.y() ), c_green, LINE_OXOX ); } - if( x >= pivot_s.x ) { - mvwputch( w_disp, point( x, pivot_s.y ), c_red, LINE_OXOX ); + if( x >= pivot_s.x() ) { + mvwputch( w_disp, point( x, pivot_s.y() ), c_red, LINE_OXOX ); } } for( int y = 0; y < getmaxy( w_disp ); ++y ) { - if( y <= com_s.y ) { - mvwputch( w_disp, point( com_s.x, y ), c_green, LINE_XOXO ); + if( y <= com_s.y() ) { + mvwputch( w_disp, point( com_s.x(), y ), c_green, LINE_XOXO ); } - if( y >= pivot_s.y ) { - mvwputch( w_disp, point( pivot_s.x, y ), c_red, LINE_XOXO ); + if( y >= pivot_s.y() ) { + mvwputch( w_disp, point( pivot_s.x(), y ), c_red, LINE_XOXO ); } } } @@ -2363,10 +2363,10 @@ void veh_interact::display_veh() for( const int structural_part_idx : veh->all_parts_at_location( "structure" ) ) { const vehicle_part &vp = veh->part( structural_part_idx ); const vpart_display vd = veh->get_display_of_tile( vp.mount, false, false ); - const point q = ( vp.mount.raw() + dd ).rotate( 3 ); + const point_rel_ms q = ( vp.mount + dd ).rotate( 3 ); - if( q != point_zero ) { // cursor is not on this part - mvwputch( w_disp, h_size + q, vd.color, vd.symbol_curses ); + if( q != point_rel_ms_zero ) { // cursor is not on this part + mvwputch( w_disp, h_size + q.raw(), vd.color, vd.symbol_curses ); continue; } cpart = structural_part_idx; @@ -3151,7 +3151,7 @@ void veh_interact::complete_vehicle( Character &you ) 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.raw() ); + orient_part( &veh, vpinfo, partnum, q ); } const tripoint_bub_ms vehp = veh.pos_bub() + tripoint_rel_ms( q, 0 ); diff --git a/src/veh_interact.h b/src/veh_interact.h index 24c8d2b105cd9..fda961d637b38 100644 --- a/src/veh_interact.h +++ b/src/veh_interact.h @@ -12,12 +12,13 @@ #include #include "color.h" +#include "coordinates.h" +#include "coordinate_constants.h" #include "cursesdef.h" #include "input_context.h" #include "item_location.h" #include "mapdata.h" #include "player_activity.h" -#include "point.h" #include "type_id.h" #include "units_fwd.h" @@ -51,7 +52,7 @@ class veh_interact using part_selector = std::function; public: - static player_activity run( vehicle &veh, const point &p ); + static player_activity run( vehicle &veh, const point_rel_ms &p ); /** Prompt for a part matching the selector function */ static std::optional select_part( const vehicle &veh, const part_selector &sel, @@ -60,10 +61,10 @@ class veh_interact static void complete_vehicle( Character &you ); private: - explicit veh_interact( vehicle &veh, const point &p = point_zero ); + explicit veh_interact( vehicle &veh, const point_rel_ms &p = point_rel_ms_zero ); ~veh_interact(); - point dd = point_zero; + point_rel_ms dd = point_rel_ms_zero; /* starting offset for vehicle parts description display and max offset for scrolling */ int start_at = 0; int start_limit = 0; @@ -139,8 +140,8 @@ class veh_interact bool format_reqs( std::string &msg, const requirement_data &reqs, const std::map &skills, time_duration time ) const; - int part_at( const point &d ); - void move_cursor( const point &d, int dstart_at = 0 ); + int part_at( const point_rel_ms &d ); + void move_cursor( const point_rel_ms &d, int dstart_at = 0 ); task_reason cant_do( char mode ); bool can_potentially_install( const vpart_info &vpart ); /** Move index (parameter pos) according to input action: @@ -284,7 +285,7 @@ class veh_interact void allocate_windows(); void do_main_loop(); - void cache_tool_availability_update_lifting( const tripoint &world_cursor_pos ); + void cache_tool_availability_update_lifting( const tripoint_bub_ms &world_cursor_pos ); /** Returns true if the vehicle has a jack powerful enough to lift itself installed */ bool can_self_jack(); @@ -293,6 +294,6 @@ class veh_interact void act_vehicle_siphon( vehicle *veh ); void orient_part( vehicle *veh, const vpart_info &vpinfo, int partnum, - const std::optional &part_placement = std::nullopt ); + const std::optional &part_placement = std::nullopt ); #endif // CATA_SRC_VEH_INTERACT_H diff --git a/src/veh_shape.cpp b/src/veh_shape.cpp index 2ed598abd7cfb..35ef9208b2782 100644 --- a/src/veh_shape.cpp +++ b/src/veh_shape.cpp @@ -23,7 +23,7 @@ player_activity veh_shape::start( const tripoint_bub_ms &pos ) cursor_allowed.clear(); for( const vpart_reference &part : veh.get_all_parts() ) { - cursor_allowed.insert( tripoint_bub_ms( part.pos() ) ); + cursor_allowed.insert( part.pos_bub() ); } if( !set_cursor_pos( pos ) ) { diff --git a/src/veh_type.cpp b/src/veh_type.cpp index b3a0c3823ba98..beffc0c46c743 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -1276,7 +1276,7 @@ void vehicle_prototype::load( const JsonObject &jo, std::string_view ) vgroups[vgroup_id( id.str() )].add_vehicle( id, 100 ); optional( jo, was_loaded, "name", name ); - const auto add_part_obj = [&]( const JsonObject & part, point pos ) { + const auto add_part_obj = [&]( const JsonObject & part, point_rel_ms pos ) { const auto [id, variant] = get_vpart_str_variant( part.get_string( "part" ) ); part_def pt; pt.part = vpart_id( id ); @@ -1292,7 +1292,7 @@ void vehicle_prototype::load( const JsonObject &jo, std::string_view ) parts.emplace_back( pt ); }; - const auto add_part_string = [&]( const std::string & part, point pos ) { + const auto add_part_string = [&]( const std::string & part, point_rel_ms pos ) { const auto [id, variant] = get_vpart_str_variant( part ); part_def pt; pt.part = vpart_id( id ); @@ -1307,7 +1307,7 @@ void vehicle_prototype::load( const JsonObject &jo, std::string_view ) } for( JsonObject part : jo.get_array( "parts" ) ) { - point pos = point( part.get_int( "x" ), part.get_int( "y" ) ); + point_rel_ms pos{ part.get_int( "x" ), part.get_int( "y" ) }; if( part.has_string( "part" ) ) { add_part_obj( part, pos ); @@ -1328,13 +1328,13 @@ void vehicle_prototype::load( const JsonObject &jo, std::string_view ) for( JsonObject spawn_info : jo.get_array( "items" ) ) { vehicle_item_spawn next_spawn; - next_spawn.pos.x = spawn_info.get_int( "x" ); - next_spawn.pos.y = spawn_info.get_int( "y" ); + next_spawn.pos.x() = spawn_info.get_int( "x" ); + next_spawn.pos.y() = spawn_info.get_int( "y" ); next_spawn.chance = spawn_info.get_int( "chance" ); if( next_spawn.chance <= 0 || next_spawn.chance > 100 ) { debugmsg( "Invalid spawn chance in %s (%d, %d): %d%%", - name, next_spawn.pos.x, next_spawn.pos.y, next_spawn.chance ); + name, next_spawn.pos.x(), next_spawn.pos.y(), next_spawn.chance ); } // constrain both with_magazine and with_ammo to [0-100] @@ -1371,7 +1371,7 @@ void vehicle_prototype::load( const JsonObject &jo, std::string_view ) zone_type_id zone_type( jzi.get_member( "type" ).get_string() ); std::string name; std::string filter; - point pt( jzi.get_member( "x" ).get_int(), jzi.get_member( "y" ).get_int() ); + point_rel_ms pt( jzi.get_member( "x" ).get_int(), jzi.get_member( "y" ).get_int() ); if( jzi.has_string( "name" ) ) { name = jzi.get_string( "name" ); @@ -1504,8 +1504,8 @@ void vehicle_prototype::save_vehicle_as_prototype( const vehicle &veh, JsonOut & const vehicle_stack &stack = veh.get_items( vp.part() ); if( !stack.empty() ) { json.start_object(); - json.member( "x", vp.mount().x ); - json.member( "y", vp.mount().y ); + json.member( "x", vp.mount_pos().x() ); + json.member( "y", vp.mount_pos().y() ); json.member( "chance", 100 ); json.member( "items" ); json.start_array(); @@ -1522,8 +1522,8 @@ void vehicle_prototype::save_vehicle_as_prototype( const vehicle &veh, JsonOut & json.start_array(); for( auto const &z : veh.loot_zones ) { json.start_object(); - json.member( "x", z.first.x ); - json.member( "y", z.first.y ); + json.member( "x", z.first.x() ); + json.member( "y", z.first.y() ); json.member( "type", z.second.get_type().str() ); json.end_object(); } @@ -1540,7 +1540,7 @@ void vehicles::finalize_prototypes() vehicle_prototype_factory.finalize(); for( const vehicle_prototype &const_proto : vehicles::get_all_prototypes() ) { vehicle_prototype &proto = const_cast( const_proto ); - std::unordered_set cargo_spots; + std::unordered_set cargo_spots; // Calling the constructor with empty vproto_id as parameter // makes constructor bypass copying the (non-existing) blueprint. @@ -1566,7 +1566,7 @@ void vehicles::finalize_prototypes() if( part_idx < 0 ) { debugmsg( "init_vehicles: '%s' part '%s'(%d) can't be installed to %d,%d", blueprint.name, pt.part.c_str(), - blueprint.part_count(), pt.pos.x, pt.pos.y ); + blueprint.part_count(), pt.pos.x(), pt.pos.y() ); } else { vehicle_part &vp = blueprint.part( part_idx ); const vpart_info &vpi = vp.info(); @@ -1657,7 +1657,7 @@ void vehicles::finalize_prototypes() for( vehicle_item_spawn &i : proto.item_spawns ) { if( cargo_spots.count( i.pos ) == 0 ) { debugmsg( "Invalid spawn location (no CARGO vpart) in %s (%d, %d): %d%%", - proto.name, i.pos.x, i.pos.y, i.chance ); + proto.name, i.pos.x(), i.pos.y(), i.chance ); } for( auto &j : i.item_ids ) { if( !item::type_is_defined( j ) ) { diff --git a/src/veh_type.h b/src/veh_type.h index d371fd77c9bce..e471eaaefca71 100644 --- a/src/veh_type.h +++ b/src/veh_type.h @@ -18,8 +18,8 @@ #include "calendar.h" #include "color.h" #include "compatibility.h" +#include "coordinates.h" #include "damage.h" -#include "point.h" #include "requirements.h" #include "translations.h" #include "type_id.h" @@ -465,7 +465,7 @@ class vpart_info }; struct vehicle_item_spawn { - point pos; + point_rel_ms pos; int chance = 0; /** Chance [0-100%] for items to spawn with ammo (plus default magazine if necessary) */ int with_ammo = 0; @@ -484,7 +484,7 @@ struct vehicle_item_spawn { struct vehicle_prototype { public: struct part_def { - point pos; + point_rel_ms pos; vpart_id part; std::string variant; int with_ammo = 0; @@ -498,7 +498,7 @@ struct vehicle_prototype { zone_type_id zone_type; std::string name; std::string filter; - point pt; + point_rel_ms pt; }; vproto_id id; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 4c57be1ff074e..3917b2fb5a99c 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -140,8 +140,8 @@ static const std::string flag_WIRING( "WIRING" ); //~ Name for an array of electronic power grid appliances, like batteries and solar panels static const translation power_grid_name = to_translation( "power grid" ); -static bool is_sm_tile_outside( const tripoint &real_global_pos ); -static bool is_sm_tile_over_water( const tripoint &real_global_pos ); +static bool is_sm_tile_outside( const tripoint_abs_ms &real_global_pos ); +static bool is_sm_tile_over_water( const tripoint_abs_ms &real_global_pos ); static const int MAX_WIRE_VEHICLE_SIZE = 24; @@ -261,7 +261,7 @@ bool vehicle::player_in_control( const Character &p ) const const optional_vpart_position vp = get_map().veh_at( p.pos_bub() ); if( vp && &vp->vehicle() == this && p.controlling_vehicle && - ( ( part_with_feature( vp->mount(), "CONTROL_ANIMAL", true ) >= 0 && + ( ( part_with_feature( vp->mount_pos(), "CONTROL_ANIMAL", true ) >= 0 && has_engine_type( fuel_type_animal, false ) && get_harnessed_animal() ) || ( part_with_feature( vp->part_index(), VPFLAG_CONTROLS, false ) >= 0 ) ) ) { @@ -301,7 +301,7 @@ bool vehicle::remote_controlled( const Character &p ) const } for( const vpart_reference &vp : get_avail_parts( "REMOTE_CONTROLS" ) ) { - if( rl_dist( p.pos(), vp.pos() ) <= 40 ) { + if( rl_dist( p.pos_bub(), vp.pos_bub() ) <= 40 ) { return true; } } @@ -464,7 +464,7 @@ void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status } } - std::optional blood_inside_pos; + std::optional blood_inside_pos; for( const vpart_reference &vp : get_all_parts() ) { const size_t p = vp.part_index(); vehicle_part &pt = vp.part(); @@ -544,7 +544,7 @@ void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status * the "front" of the vehicle (since the driver's seat is at (0, 0). * We'll be generous with the blood, since some may disappear before * the player gets a chance to see the vehicle. */ - if( blood_covered && vp.mount().x > 0 ) { + if( blood_covered && vp.mount_pos().x() > 0 ) { if( one_in( 3 ) ) { //Loads of blood. (200 = completely red vehicle part) pt.blood = rng( 200, 600 ); @@ -558,14 +558,14 @@ void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status // blood is splattered around (blood_inside_pos), // coordinates relative to mount point; the center is always a seat if( blood_inside_pos ) { - const int distSq = std::pow( blood_inside_pos->x - vp.mount().x, 2 ) + - std::pow( blood_inside_pos->y - vp.mount().y, 2 ); + const int distSq = std::pow( blood_inside_pos->x() - vp.mount_pos().x(), 2 ) + + std::pow( blood_inside_pos->y() - vp.mount_pos().y(), 2 ); if( distSq <= 1 ) { pt.blood = rng( 200, 400 ) - distSq * 100; } } else if( vp.has_feature( "SEAT" ) ) { // Set the center of the bloody mess inside - blood_inside_pos.emplace( vp.mount() ); + blood_inside_pos.emplace( vp.mount_pos() ); } } } @@ -726,8 +726,8 @@ std::set vehicle::immediate_path( const units::angle &rotate ) return points_to_check; } -static int get_turn_from_angle( const units::angle &angle, const tripoint &vehpos, - const tripoint &target, bool reverse = false ) +static int get_turn_from_angle( const units::angle &angle, const tripoint_abs_ms &vehpos, + const tripoint_abs_ms &target, bool reverse = false ) { if( angle > 10.0_degrees && angle <= 45.0_degrees ) { return reverse ? 4 : 1; @@ -774,7 +774,7 @@ void vehicle::drive_to_local_target( const tripoint_abs_ms &target, bool follow_ stop_autodriving(); return; } - int turn_x = get_turn_from_angle( angle, vehpos.raw(), target.raw() ); + int turn_x = get_turn_from_angle( angle, vehpos, target ); 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. @@ -787,12 +787,12 @@ void vehicle::drive_to_local_target( const tripoint_abs_ms &target, bool follow_ if( follow_protocol ) { if( ( ( turn_x > 0 || turn_x < 0 ) && velocity > safe_player_follow_speed ) || rl_dist( vehpos, here.getglobal( player_character.pos_bub() ) ) < 7 + ( ( - mount_max.y * 3 ) + 4 ) ) { + mount_max.y() * 3 ) + 4 ) ) { accel_y = 1; } if( ( velocity < std::min( safe_velocity(), safe_player_follow_speed ) && turn_x == 0 && rl_dist( vehpos, here.getglobal( player_character.pos_bub() ) ) > 8 + ( ( - mount_max.y * 3 ) + 4 ) ) || + mount_max.y() * 3 ) + 4 ) ) || velocity < 100 ) { accel_y = -1; } @@ -1174,11 +1174,6 @@ int vehicle::power_to_energy_bat( const units::power power, const time_duration return produced_kj; } -bool vehicle::has_structural_part( const point &dp ) const -{ - return vehicle::has_structural_part( point_rel_ms( dp ) ); -} - bool vehicle::has_structural_part( const point_rel_ms &dp ) const { for( const int elem : parts_at_relative( dp, false ) ) { @@ -1642,7 +1637,7 @@ std::vector vehicle::find_vehicles_to_rack( int rack for( const point &offset : four_cardinal_directions ) { vehicle *veh_matched = nullptr; - std::set parts_matched; + std::set parts_matched; for( const int &rack_part : filtered_rack ) { const tripoint_bub_ms search_pos = bub_part_pos( rack_part ) + offset; const optional_vpart_position ovp = get_map().veh_at( search_pos ); @@ -1654,12 +1649,12 @@ std::vector vehicle::find_vehicles_to_rack( int rack veh_matched = test_veh; parts_matched.clear(); } - parts_matched.insert( search_pos.raw() ); + parts_matched.insert( search_pos ); - std::set test_veh_points; + std::set test_veh_points; for( const vpart_reference &vpr : test_veh->get_all_parts() ) { if( !vpr.part().removed && !vpr.part().is_fake ) { - test_veh_points.insert( vpr.pos() ); + test_veh_points.insert( vpr.pos_bub() ); } } @@ -1783,10 +1778,10 @@ bool vehicle::merge_rackable_vehicle( vehicle *carry_veh, const std::vector int rack_part = 0; // the mount point we are going to add to the vehicle with the rack - point carry_mount; + point_rel_ms carry_mount; // the mount point on the old vehicle (carry_veh) that will be destroyed - point old_mount; + point_rel_ms old_mount; }; remove_fake_parts( /* cleanup = */ false ); invalidate_towing( true ); @@ -1845,8 +1840,8 @@ bool vehicle::merge_rackable_vehicle( vehicle *carry_veh, const std::vector point_rel_ms old_mount = carry_veh->parts[ carry_part ].mount; carry_map.carry_parts_here = carry_veh->parts_at_relative( old_mount, true ); carry_map.rack_part = rack_part; - carry_map.carry_mount = carry_mount.raw(); - carry_map.old_mount = old_mount.raw(); + carry_map.carry_mount = carry_mount; + carry_map.old_mount = old_mount; carry_data.push_back( carry_map ); merged_part = true; break; @@ -1868,9 +1863,9 @@ bool vehicle::merge_rackable_vehicle( vehicle *carry_veh, const std::vector for( const int &carry_part : carry_map.carry_parts_here ) { parts.push_back( carry_veh->parts[ carry_part ] ); vehicle_part &carried_part = parts.back(); - carried_part.mount = point_rel_ms( carry_map.carry_mount ); + carried_part.mount = carry_map.carry_mount; carried_part.carried_stack.push( { - tripoint_rel_ms( carry_map.old_mount.x, carry_map.old_mount.y, 0 ), + tripoint_rel_ms( carry_map.old_mount.x(), carry_map.old_mount.y(), 0 ), relative_dir, carry_veh->name } ); @@ -1889,9 +1884,9 @@ bool vehicle::merge_rackable_vehicle( vehicle *carry_veh, const std::vector parts[ carry_map.rack_part ].set_flag( vp_flag::carrying_flag ); } - const std::pair::iterator, std::unordered_multimap::iterator> - zones_on_point = carry_veh->loot_zones.equal_range( carry_map.old_mount ); - for( std::unordered_multimap::const_iterator it = zones_on_point.first; + const std::pair::iterator, std::unordered_multimap::iterator> + zones_on_point = carry_veh->loot_zones.equal_range( point_rel_ms( carry_map.old_mount ) ); + for( std::unordered_multimap::const_iterator it = zones_on_point.first; it != zones_on_point.second; ++it ) { new_zones.emplace( carry_map.carry_mount, it->second ); } @@ -1899,7 +1894,7 @@ bool vehicle::merge_rackable_vehicle( vehicle *carry_veh, const std::vector for( auto &new_zone : new_zones ) { zone_manager::get_manager().create_vehicle_loot_zone( - *this, new_zone.first, new_zone.second ); + *this, new_zone.first.raw(), new_zone.second ); } // Now that we've added zones to this vehicle, we need to make sure their positions @@ -2114,11 +2109,11 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) // Unboard any entities standing on removed boardable parts if( vpi.has_flag( "BOARDABLE" ) && vp.has_flag( vp_flag::passenger_flag ) ) { - handler.unboard( part_loc.raw() ); + handler.unboard( part_loc ); } for( const item &it : vp.tools ) { - handler.add_item_or_charges( part_loc.raw(), it, false ); + handler.add_item_or_charges( part_loc, it, false ); } // If `p` has flag `parent_flag`, remove child with flag `child_flag` @@ -2130,7 +2125,7 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) return false; } vehicle_part &vp_dep = parts[dep]; - handler.add_item_or_charges( part_loc.raw(), part_to_item( vp_dep ), false ); + handler.add_item_or_charges( part_loc, part_to_item( vp_dep ), false ); remove_part( vp_dep, handler ); return true; }; @@ -2152,7 +2147,7 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) // Release any animal held by the part if( vp.has_flag( vp_flag::animal_flag ) ) { item base = vp.get_base(); - handler.spawn_animal_from_part( base, part_loc.raw() ); + handler.spawn_animal_from_part( base, part_loc ); vp.set_base( std::move( base ) ); vp.remove_flag( vp_flag::animal_flag ); } @@ -2179,13 +2174,13 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) } //Remove loot zone if Cargo was removed. - const auto lz_iter = loot_zones.find( vp.mount.raw() ); + const auto lz_iter = loot_zones.find( vp.mount ); const bool no_zone = lz_iter != loot_zones.end(); if( no_zone && vpi.has_flag( VPFLAG_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( vp.mount.raw() ); + loot_zones.erase( vp.mount ); zones_dirty = true; } vp.removed = true; @@ -2212,7 +2207,7 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) // so we pass true here to cause such points to be clamped to the // valid bounds without printing an error (as would normally // occur). - handler.add_item_or_charges( dest.raw(), i, true ); + handler.add_item_or_charges( dest, i, true ); } } refresh( false ); @@ -2485,7 +2480,7 @@ void vehicle::relocate_passengers( const std::vector &passengers ) for( Character *passenger : passengers ) { for( const vpart_reference &vp : boardables ) { if( vp.part().passenger_id == passenger->getID() ) { - passenger->setpos( vp.pos() ); + passenger->setpos( vp.pos_bub() ); } } } @@ -2609,15 +2604,16 @@ bool vehicle::split_vehicles( map &here, 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> - zones_on_point = loot_zones.equal_range( cur_mount.raw() ); - for( std::unordered_multimap::const_iterator lz_iter = zones_on_point.first; + const std::pair::iterator, std::unordered_multimap::iterator> + zones_on_point = loot_zones.equal_range( cur_mount ); + for( std::unordered_multimap::const_iterator lz_iter = + zones_on_point.first; lz_iter != zones_on_point.second; ++lz_iter ) { new_zones.emplace( new_mount.raw(), lz_iter->second ); } // Erasing on the key removes all the zones from the point at once - loot_zones.erase( cur_mount.raw() ); + loot_zones.erase( cur_mount ); // The zone manager will be updated when we next interact with it through get_vehicle_zones zones_dirty = true; @@ -2634,8 +2630,8 @@ bool vehicle::split_vehicles( map &here, // We want to create the vehicle zones after we've setup the parts // because we need only to move the zone once per mount, not per part. If we move per // part, we will end up with duplicates of the zone per part on the same mount - for( std::pair zone : new_zones ) { - zone_manager::get_manager().create_vehicle_loot_zone( *new_vehicle, zone.first, zone.second ); + for( std::pair zone : new_zones ) { + zone_manager::get_manager().create_vehicle_loot_zone( *new_vehicle, zone.first.raw(), zone.second ); } // create_vehicle_loot_zone marks the vehicle as not dirty but since we got these zones @@ -2688,36 +2684,7 @@ item_group::ItemList vehicle_part::pieces_for_broken_part() const std::vector vehicle::parts_at_relative( const point &dp, const bool use_cache, bool include_fake ) const { - std::vector res; - if( !use_cache ) { - if( include_fake ) { - for( const vpart_reference &vp : get_all_parts_with_fakes() ) { - if( vp.mount() == dp && !vp.part().removed ) { - res.push_back( static_cast( vp.part_index() ) ); - } - } - } else { - for( const vpart_reference &vp : get_all_parts() ) { - if( vp.mount() == dp && !vp.part().removed ) { - res.push_back( static_cast( vp.part_index() ) ); - } - } - } - } else { - const auto &iter = relative_parts.find( dp ); - if( iter != relative_parts.end() ) { - if( include_fake ) { - return iter->second; - } else { - for( const int vp : iter->second ) { - if( !parts.at( vp ).is_fake ) { - res.push_back( vp ); - } - } - } - } - } - return res; + return vehicle::parts_at_relative( point_rel_ms( dp ), use_cache, include_fake ); } std::vector vehicle::parts_at_relative( const point_rel_ms &dp, const bool use_cache, @@ -2739,7 +2706,7 @@ std::vector vehicle::parts_at_relative( const point_rel_ms &dp, const bool } } } else { - const auto &iter = relative_parts.find( dp.raw() ); + const auto &iter = relative_parts.find( dp ); if( iter != relative_parts.end() ) { if( include_fake ) { return iter->second; @@ -2771,7 +2738,7 @@ std::optional vpart_position::obstacle_at_part() const std::optional vpart_position::part_displayed() const { - int part_id = vehicle().part_displayed_at( mount(), true ); + int part_id = vehicle().part_displayed_at( mount_pos(), true ); if( part_id == -1 ) { return std::nullopt; } @@ -2780,7 +2747,7 @@ std::optional vpart_position::part_displayed() const std::optional vpart_position::part_with_tool( const itype_id &tool_type ) const { - for( const int idx : vehicle().parts_at_relative( mount(), false ) ) { + for( const int idx : vehicle().parts_at_relative( mount_pos(), false ) ) { const vpart_reference vp( vehicle(), idx ); if( vp.part().is_broken() ) { continue; @@ -2799,7 +2766,7 @@ std::optional vpart_position::part_with_tool( const itype_id &t std::map vpart_position::get_tools() const { std::map res; - for( const int part_idx : this->vehicle().parts_at_relative( this->mount(), false ) ) { + for( const int part_idx : this->vehicle().parts_at_relative( this->mount_pos(), false ) ) { const vehicle_part &vp = this->vehicle().part( part_idx ); if( vp.is_broken() ) { continue; @@ -2819,7 +2786,7 @@ std::optional vpart_position::cargo() const std::optional vpart_position::part_with_feature( const std::string &f, bool unbroken, bool include_fake ) const { - const int i = vehicle().part_with_feature( mount(), f, unbroken, include_fake ); + const int i = vehicle().part_with_feature( mount_pos(), f, unbroken, include_fake ); if( i < 0 ) { return std::nullopt; } @@ -2839,7 +2806,7 @@ std::optional vpart_position::part_with_feature( const vpart_bi std::optional vpart_position::avail_part_with_feature( const std::string &f ) const { - const int i = vehicle().avail_part_with_feature( mount(), f ); + const int i = vehicle().avail_part_with_feature( mount_pos(), f ); return i >= 0 ? vpart_reference( vehicle(), i ) : std::optional(); } @@ -2908,7 +2875,7 @@ std::vector optional_vpart_position::extended_description() const ret.emplace_back( string_format( _( "%s (%s)" ), v.name, v.owner->name ) ); ret.emplace_back( "--" ); - for( int idx : v.parts_at_relative( value().mount(), true ) ) { + for( int idx : v.parts_at_relative( value().mount_pos(), true ) ) { ret.emplace_back( v.part( idx ).name() ); } @@ -2974,11 +2941,6 @@ int vehicle::avail_part_with_feature( int part, vpart_bitflags flag ) const return -1; } -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 ); @@ -2988,11 +2950,6 @@ int vehicle::avail_part_with_feature( const point_rel_ms &pt, const std::string return -1; } -int vehicle::avail_linkable_part( const point &pt, bool to_ports ) const -{ - return vehicle::avail_linkable_part( point_rel_ms( pt ), to_ports ); -} - int vehicle::avail_linkable_part( const point_rel_ms &pt, bool to_ports ) const { const std::string link_flag = to_ports ? "CABLE_PORTS" : "BATTERY"; @@ -3038,13 +2995,6 @@ bool vehicle::has_part( const tripoint_bub_ms &pos, const std::string &flag, boo return false; } -// 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 ); -} - // NOLINTNEXTLINE(readability-make-member-function-const) std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, const std::string &flag, @@ -3438,12 +3388,6 @@ int vehicle::index_of_part( const vehicle_part *part, bool include_removed ) con * @param roof Include roof parts. * @return The index of the part that will be displayed. */ -int vehicle::part_displayed_at( const point &dp, bool include_fake, bool below_roof, - bool roof ) const -{ - return vehicle::part_displayed_at( point_rel_ms( dp ), include_fake, below_roof, roof ); -} - int vehicle::part_displayed_at( const point_rel_ms &dp, bool include_fake, bool below_roof, bool roof ) const { @@ -3511,15 +3455,6 @@ point_rel_ms vehicle::coord_translate( const point_rel_ms &p ) const return q.xy(); } -void vehicle::coord_translate( const units::angle &dir, const point &pivot, const point &p, - tripoint &q ) const -{ - tileray tdir( dir ); - tdir.advance( p.x - pivot.x ); - q.x = tdir.dx() + tdir.ortho_dx( p.y - pivot.y ); - q.y = tdir.dy() + tdir.ortho_dy( p.y - pivot.y ); -} - void vehicle::coord_translate( const units::angle &dir, const point_rel_ms &pivot, const point_rel_ms &p, tripoint_rel_ms &q ) const @@ -3552,17 +3487,11 @@ tripoint_bub_ms vehicle::mount_to_tripoint( const point_rel_ms &mount ) const tripoint_bub_ms vehicle::mount_to_tripoint( const point_rel_ms &mount, const point_rel_ms &offset ) const { - tripoint mnt_translated; - coord_translate( pivot_rotation[0], pivot_anchor[0], mount.raw() + offset.raw(), mnt_translated ); + tripoint_rel_ms mnt_translated; + coord_translate( pivot_rotation[0], pivot_anchor[0], mount + offset, mnt_translated ); return pos_bub() + mnt_translated; } -void vehicle::precalc_mounts( int idir, const units::angle &dir, - const point &pivot ) -{ - vehicle::precalc_mounts( idir, dir, point_rel_ms( pivot ) ); -} - void vehicle::precalc_mounts( int idir, const units::angle &dir, const point_rel_ms &pivot ) { @@ -3583,7 +3512,7 @@ void vehicle::precalc_mounts( int idir, const units::angle &dir, p.precalc[idir] = q->second; } } - pivot_anchor[idir] = pivot.raw(); + pivot_anchor[idir] = pivot; pivot_rotation[idir] = dir; } @@ -3603,7 +3532,7 @@ std::vector vehicle::get_riders() const std::vector res; creature_tracker &creatures = get_creature_tracker(); for( const vpart_reference &vp : get_avail_parts( VPFLAG_BOARDABLE ) ) { - Creature *rider = creatures.creature_at( vp.pos() ); + Creature *rider = creatures.creature_at( vp.pos_bub() ); if( rider ) { rider_data r; r.prt = vp.part_index(); @@ -3675,7 +3604,7 @@ tripoint_abs_omt vehicle::global_omt_location() const tripoint_bub_ms vehicle::pos_bub() const { - return coords::project_to( tripoint_bub_sm( sm_pos ) ) + pos; + return coords::project_to( tripoint_bub_sm( sm_pos ) ) + rebase_rel( pos ); } tripoint_bub_ms vehicle::bub_part_pos( const int index ) const @@ -3754,7 +3683,7 @@ point_rel_ms vehicle::pivot_displacement() const // rotate the old pivot point around the new pivot point with the old rotation angle tripoint_rel_ms dp; - coord_translate( pivot_rotation[0], pivot_anchor[1], pivot_anchor[0], dp.raw() ); + coord_translate( pivot_rotation[0], pivot_anchor[1], pivot_anchor[0], dp ); return dp.xy(); } @@ -4254,7 +4183,7 @@ void vehicle::spew_field( double joules, int part, field_type_id type, int inten return; } intensity = std::max( joules / 10000, static_cast( intensity ) ); - const tripoint_bub_ms dest = tripoint_bub_ms( exhaust_dest( part ) ); + const tripoint_bub_ms dest = exhaust_dest( part ); get_map().mod_field_intensity( dest, type, intensity ); } @@ -4420,8 +4349,8 @@ double vehicle::coeff_air_drag() const constexpr double rotor_height = 0.6; std::vector structure_indices = all_parts_at_location( part_location_structure ); - int width = mount_max.y - mount_min.y + 1; - int length = mount_max.x - mount_min.x + 1; + int width = mount_max.y() - mount_min.y() + 1; + int length = mount_max.x() - mount_min.x() + 1; // a mess of lambdas to make the next bit slightly easier to read const auto d_exposed = [&]( const vehicle_part & p ) { // if it's not inside, it's a center location, and it doesn't need a roof, it's exposed @@ -4441,10 +4370,10 @@ double vehicle::coeff_air_drag() const } }; const auto d_check_min = [&]( int &value, const vehicle_part & p, bool test ) { - value = std::min( value, test ? p.mount.x() - mount_min.x : maxrow ); + value = std::min( value, test ? p.mount.x() - mount_min.x() : maxrow ); }; const auto d_check_max = [&]( int &value, const vehicle_part & p, bool test ) { - value = std::max( value, test ? p.mount.x() - mount_min.x : minrow ); + value = std::max( value, test ? p.mount.x() - mount_min.x() : minrow ); }; // raycast down each column. the least drag vehicle has halfboard, windshield, seat with roof, @@ -4455,7 +4384,7 @@ double vehicle::coeff_air_drag() const if( parts[ p ].removed || parts[ p ].is_fake ) { continue; } - int col = parts[ p ].mount.y() - mount_min.y; + int col = parts[ p ].mount.y() - mount_min.y(); std::vector parts_at = parts_at_relative( parts[ p ].mount, true ); d_check_min( drag[ col ].pro, parts[ p ], d_protrusion( parts_at ) ); for( int pa_index : parts_at ) { @@ -4770,7 +4699,7 @@ double vehicle::coeff_water_drag() const } double hull_coverage = static_cast( floating.size() ) / structural_part_count; - int tile_width = mount_max.y - mount_min.y + 1; + int tile_width = mount_max.y() - mount_min.y() + 1; double width_m = tile_to_width( tile_width ); // actual area of the hull in m^2 (handles non-rectangular shapes) @@ -5357,7 +5286,7 @@ units::power vehicle::total_solar_epower() const for( const int p : solar_panels ) { const vehicle_part &vp = parts[p]; const tripoint_bub_ms pos = bub_part_pos( vp ); - if( vp.is_unavailable() || !is_sm_tile_outside( here.getglobal( pos ).raw() ) ) { + if( vp.is_unavailable() || !is_sm_tile_outside( here.getglobal( pos ) ) ) { continue; } @@ -5380,7 +5309,7 @@ units::power vehicle::total_wind_epower() const for( const int p : wind_turbines ) { const vehicle_part &vp = parts[p]; const tripoint_bub_ms pos = bub_part_pos( vp ); - if( vp.is_unavailable() || !is_sm_tile_outside( here.getglobal( pos ).raw() ) ) { + if( vp.is_unavailable() || !is_sm_tile_outside( here.getglobal( pos ) ) ) { continue; } @@ -5401,7 +5330,7 @@ units::power vehicle::total_water_wheel_epower() const for( const int p : water_wheels ) { const vehicle_part &vp = parts[p]; const tripoint_bub_ms pos = bub_part_pos( vp ); - if( vp.is_unavailable() || !is_sm_tile_over_water( here.getglobal( pos ).raw() ) ) { + if( vp.is_unavailable() || !is_sm_tile_over_water( here.getglobal( pos ) ) ) { continue; } @@ -5616,8 +5545,7 @@ vehicle *vehicle::find_vehicle( const tripoint_abs_ms &where ) for( const auto &elem : sm->vehicles ) { vehicle *found_veh = elem.get(); - // TODO: fix point types - if( veh_in_sm.raw() == found_veh->pos ) { + if( veh_in_sm == found_veh->pos ) { return found_veh; } } @@ -5643,7 +5571,6 @@ vehicle *vehicle::find_vehicle_using_parts( const tripoint_abs_ms &where ) for( const auto &elem : sm->vehicles ) { vehicle *found_veh = elem.get(); - // TODO: fix point types for( const vpart_reference &vp : found_veh->get_all_parts() ) { point_sm_ms_ib vp_in_sm; tripoint_bub_sm vp_sm; @@ -6260,7 +6187,7 @@ void vehicle::place_spawn_items() for( const vehicle_item_spawn &spawn : type->item_spawns ) { int part = part_with_feature( spawn.pos, "CARGO", false ); if( part < 0 ) { - debugmsg( "No CARGO parts at (%d, %d) of %s!", spawn.pos.x, spawn.pos.y, name ); + debugmsg( "No CARGO parts at (%d, %d) of %s!", spawn.pos.x(), spawn.pos.y(), name ); } else { vehicle_part &vp = parts[part]; const bool broken = vp.is_broken(); @@ -6333,7 +6260,7 @@ void vehicle::place_zones( map &pmap ) const return; } for( vehicle_prototype::zone_def const &d : type->zone_defs ) { - tripoint_abs_ms const pt = pmap.getglobal( tripoint_bub_ms( point_bub_ms( pos + d.pt ), + tripoint_abs_ms const pt = pmap.getglobal( tripoint_bub_ms( rebase_bub( pos.raw() + d.pt ), pmap.get_abs_sub().z() ) ); mapgen_place_zone( pt.raw(), pt.raw(), d.zone_type, get_owner(), d.name, d.filter, &pmap ); } @@ -6458,7 +6385,7 @@ void vehicle::refresh_active_item_cache() auto it = vs.begin(); auto end = vs.end(); for( ; it != end; ++it ) { - active_items.add( *it, point_rel_ms( vp.mount() ) ); + active_items.add( *it, vp.mount_pos() ); } } } @@ -6512,10 +6439,10 @@ void vehicle::refresh( const bool remove_fakes ) } } svpv = { this }; - mount_min.x = 123; - mount_min.y = 123; - mount_max.x = -123; - mount_max.y = -123; + mount_min.x() = 123; + mount_min.y() = 123; + mount_max.x() = -123; + mount_max.y() = -123; int railwheel_xmin = INT_MAX; int railwheel_ymin = INT_MAX; @@ -6537,11 +6464,11 @@ void vehicle::refresh( const bool remove_fakes ) refresh_done = true; // Build map of point -> all parts in that point - const point pt = vp.mount(); - mount_min.x = std::min( mount_min.x, pt.x ); - mount_min.y = std::min( mount_min.y, pt.y ); - mount_max.x = std::max( mount_max.x, pt.x ); - mount_max.y = std::max( mount_max.y, pt.y ); + const point_rel_ms pt{vp.mount_pos()}; + mount_min.x() = std::min( mount_min.x(), pt.x() ); + mount_min.y() = std::min( mount_min.y(), pt.y() ); + mount_max.x() = std::max( mount_max.x(), pt.x() ); + mount_max.y() = std::max( mount_max.y(), pt.y() ); // This will keep the parts at point pt sorted std::vector::iterator vii = std::lower_bound( relative_parts[pt].begin(), @@ -6616,10 +6543,10 @@ void vehicle::refresh( const bool remove_fakes ) all_wheels_on_one_axis = false; } - railwheel_xmin = std::min( railwheel_xmin, pt.x ); - railwheel_ymin = std::min( railwheel_ymin, pt.y ); - railwheel_xmax = std::max( railwheel_xmax, pt.x ); - railwheel_ymax = std::max( railwheel_ymax, pt.y ); + railwheel_xmin = std::min( railwheel_xmin, pt.x() ); + railwheel_ymin = std::min( railwheel_ymin, pt.y() ); + railwheel_xmax = std::max( railwheel_xmax, pt.x() ); + railwheel_ymax = std::max( railwheel_ymax, pt.y() ); } if( ( vpi.has_flag( "STEERABLE" ) && part_with_feature( pt, "STEERABLE", true ) != -1 ) || vpi.has_flag( "TRACKED" ) ) { @@ -6665,12 +6592,12 @@ void vehicle::refresh( const bool remove_fakes ) rail_wheel_bounding_box.p1 = point_rel_ms( railwheel_xmin, railwheel_ymin ); rail_wheel_bounding_box.p2 = point_rel_ms( railwheel_xmax, railwheel_ymax ); - front_left.x = mount_max.x; - front_left.y = mount_min.y; + front_left.x() = mount_max.x(); + front_left.y() = mount_min.y(); front_right = mount_max; if( !refresh_done ) { - mount_min = mount_max = point_zero; + mount_min = mount_max = point_rel_ms_zero; rail_wheel_bounding_box.p1 = point_rel_ms_zero; rail_wheel_bounding_box.p2 = point_rel_ms_zero; } @@ -6696,7 +6623,7 @@ void vehicle::refresh( const bool remove_fakes ) vehicle_part &part_real = parts.at( real_index ); if( part_real.has_fake && static_cast( part_real.fake_part_at ) < parts.size() ) { - relative_parts[ parts[ part_real.fake_part_at ].mount.raw()].push_back( + relative_parts[ parts[ part_real.fake_part_at ].mount].push_back( part_real.fake_part_at ); return; } @@ -6706,7 +6633,7 @@ void vehicle::refresh( const bool remove_fakes ) part_fake.fake_part_to = real_index; part_fake.mount += edge_info.is_left_edge() ? point_north : point_south; if( part_real.info().has_flag( "PROTRUSION" ) ) { - for( const int vp : relative_parts.at( part_real.mount.raw() ) ) { + for( const int vp : relative_parts.at( part_real.mount ) ) { if( parts.at( vp ).is_fake ) { part_fake.fake_protrusion_on = vp; break; @@ -6716,7 +6643,7 @@ void vehicle::refresh( const bool remove_fakes ) int fake_index = parts.size(); part_real.fake_part_at = fake_index; fake_parts.push_back( fake_index ); - relative_parts[ part_fake.mount.raw()].push_back( fake_index ); + relative_parts[ part_fake.mount].push_back( fake_index ); edges.emplace( real_mount, edge_info ); parts.push_back( std::move( part_fake ) ); } @@ -6725,7 +6652,7 @@ void vehicle::refresh( const bool remove_fakes ) // guarantee that the fake parts were removed before being added if( remove_fakes && !has_tag( "wreckage" ) && !is_appliance() ) { // add all the obstacles first - for( const std::pair > &rp : relative_parts ) { + for( const std::pair > &rp : relative_parts ) { add_fake_part( point_rel_ms( rp.first ), "OBSTACLE" ); } // then add protrusions that hanging on top of fake obstacles. @@ -6736,11 +6663,11 @@ void vehicle::refresh( const bool remove_fakes ) } // add fake camera parts so vision isn't blocked by fake parts - for( const std::pair > &rp : relative_parts ) { + for( const std::pair > &rp : relative_parts ) { add_fake_part( point_rel_ms( rp.first ), "CAMERA" ); } // add fake curtains so vision is correctly blocked - for( const std::pair > &rp : relative_parts ) { + for( const std::pair > &rp : relative_parts ) { add_fake_part( point_rel_ms( rp.first ), "CURTAIN" ); } } else { @@ -6749,7 +6676,7 @@ void vehicle::refresh( const bool remove_fakes ) if( parts[fake_index].removed ) { continue; } - point pt = parts[fake_index].mount.raw(); + point_rel_ms pt = parts[fake_index].mount; relative_parts[pt].push_back( fake_index ); } } @@ -6779,25 +6706,25 @@ vpart_edge_info vehicle::get_edge_info( const point_rel_ms &mount ) const int r_index = -1; bool left_side = false; bool right_side = false; - if( relative_parts.find( forward.raw() ) != relative_parts.end() && - !parts.at( relative_parts.at( forward.raw() ).front() ).is_fake ) { - f_index = relative_parts.at( forward.raw() ).front(); - } - if( relative_parts.find( aft.raw() ) != relative_parts.end() && - !parts.at( relative_parts.at( aft.raw() ).front() ).is_fake ) { - a_index = relative_parts.at( aft.raw() ).front(); - } - if( relative_parts.find( left.raw() ) != relative_parts.end() && - !parts.at( relative_parts.at( left.raw() ).front() ).is_fake ) { - l_index = relative_parts.at( left.raw() ).front(); - if( parts.at( relative_parts.at( left.raw() ).front() ).info().has_flag( "PROTRUSION" ) ) { + if( relative_parts.find( forward ) != relative_parts.end() && + !parts.at( relative_parts.at( forward ).front() ).is_fake ) { + f_index = relative_parts.at( forward ).front(); + } + if( relative_parts.find( aft ) != relative_parts.end() && + !parts.at( relative_parts.at( aft ).front() ).is_fake ) { + a_index = relative_parts.at( aft ).front(); + } + if( relative_parts.find( left ) != relative_parts.end() && + !parts.at( relative_parts.at( left ).front() ).is_fake ) { + l_index = relative_parts.at( left ).front(); + if( parts.at( relative_parts.at( left ).front() ).info().has_flag( "PROTRUSION" ) ) { left_side = true; } } - if( relative_parts.find( right.raw() ) != relative_parts.end() && - !parts.at( relative_parts.at( right.raw() ).front() ).is_fake ) { - r_index = relative_parts.at( right.raw() ).front(); - if( parts.at( relative_parts.at( right.raw() ).front() ).info().has_flag( "PROTRUSION" ) ) { + if( relative_parts.find( right ) != relative_parts.end() && + !parts.at( relative_parts.at( right ).front() ).is_fake ) { + r_index = relative_parts.at( right ).front(); + if( parts.at( relative_parts.at( right ).front() ).info().has_flag( "PROTRUSION" ) ) { right_side = true; } } @@ -6979,7 +6906,7 @@ void vehicle::do_towing_move() const bool reverse = towed_veh->tow_data.tow_direction == TOW_BACK; int accel_y = 0; tripoint_abs_ms vehpos = global_square_location(); - int turn_x = get_turn_from_angle( towing_veh_angle, vehpos.raw(), tower_tow_point.raw(), reverse ); + int turn_x = get_turn_from_angle( towing_veh_angle, vehpos, tower_tow_point, reverse ); if( rl_dist( towed_tow_point, tower_tow_point ) < 6 ) { accel_y = reverse ? -1 : 1; } @@ -7087,10 +7014,11 @@ bool vehicle::has_tow_attached() const void vehicle::set_tow_directions() { - const int length = mount_max.x - mount_min.x + 1; + const int length = mount_max.x() - mount_min.x() + 1; const point_rel_ms mount_of_tow = parts[get_tow_part()].mount; - const point_rel_ms normalized_tow_mount = point_rel_ms( std::abs( mount_of_tow.x() - mount_min.x ), - std::abs( mount_of_tow.y() - mount_min.y ) ); + const point_rel_ms normalized_tow_mount = point_rel_ms( std::abs( mount_of_tow.x() - + mount_min.x() ), + std::abs( mount_of_tow.y() - mount_min.y() ) ); if( length >= 3 ) { const int trisect = length / 3; if( normalized_tow_mount.x() <= trisect ) { @@ -7317,13 +7245,6 @@ void vehicle::shed_loose_parts( const trinary shed_cables, const tripoint_bub_ms } } -void vehicle::unlink_cables( const point &mount, Character &remover, - bool unlink_items, bool unlink_tow_cables, bool unlink_power_cords ) -{ - vehicle::unlink_cables( point_rel_ms( mount ), remover, unlink_items, unlink_tow_cables, - unlink_power_cords ); -} - void vehicle::unlink_cables( const point_rel_ms &mount, Character &remover, bool unlink_items, bool unlink_tow_cables, bool unlink_power_cords ) { @@ -7552,11 +7473,6 @@ void vehicle::damage_all( int dmg1, int dmg2, const damage_type_id &type, * (0, 0) part is always present. * @param delta How much to shift along each axis */ -void vehicle::shift_parts( map &here, const point &delta ) -{ - vehicle::shift_parts( here, point_rel_ms( delta ) ); -} - void vehicle::shift_parts( map &here, const point_rel_ms &delta ) { // Don't invalidate the active item cache's location! @@ -7600,7 +7516,7 @@ bool vehicle::shift_if_needed( map &here ) if( vp.info().location == "structure" && !vp.has_feature( "PROTRUSION" ) && !vp.part().removed ) { - shift_parts( here, vp.mount() ); + shift_parts( here, vp.mount_pos() ); refresh(); return true; } @@ -7608,7 +7524,7 @@ bool vehicle::shift_if_needed( map &here ) // There are only parts with PROTRUSION left, choose one of them. for( const vpart_reference &vp : get_all_parts() ) { if( !vp.part().removed ) { - shift_parts( here, vp.mount() ); + shift_parts( here, vp.mount_pos() ); refresh(); return true; } @@ -8049,7 +7965,7 @@ const std::set &vehicle::get_points( const bool force_refresh, occupied_cache_pos = pos_bub(); occupied_cache_direction = face.dir(); occupied_points.clear(); - for( const std::pair> &part_location : relative_parts ) { + for( const std::pair> &part_location : relative_parts ) { if( no_fake && part( part_location.second.front() ).is_fake ) { continue; } @@ -8117,7 +8033,8 @@ std::list vehicle::use_charges( const vpart_position &vp, const itype_id & } if( const std::optional cargo_vp = vp.cargo() ) { - std::list tmp = cargo_vp->items().use_charges( type, quantity, vp.pos(), filter, in_tools ); + std::list tmp = cargo_vp->items().use_charges( type, quantity, vp.pos_bub().raw(), filter, + in_tools ); ret.splice( ret.end(), tmp ); if( quantity <= 0 ) { return ret; @@ -8155,11 +8072,6 @@ bool vpart_position::operator<( const vpart_position &other ) const return std::make_pair( v1, part_index_ ) < std::make_pair( v2, other.part_index_ ); } -point vpart_position::mount() const -{ - return vpart_position::mount_pos().raw(); -} - point_rel_ms vpart_position::mount_pos() const { return vehicle().part( part_index() ).mount; @@ -8169,10 +8081,6 @@ tripoint_bub_ms vpart_position::pos_bub() const { return vehicle().bub_part_pos( part_index() ); } -tripoint vpart_position::pos() const -{ - return pos_bub().raw(); -} bool vpart_reference::has_feature( const std::string &f ) const { @@ -8184,12 +8092,11 @@ bool vpart_reference::has_feature( const vpart_bitflags f ) const return info().has_flag( f ); } -static bool is_sm_tile_over_water( const tripoint &real_global_pos ) +static bool is_sm_tile_over_water( const tripoint_abs_ms &real_global_pos ) { tripoint_abs_sm smp; point_sm_ms_ib p; - // TODO: fix point types - std::tie( smp, p ) = project_remain( tripoint_abs_ms( real_global_pos ) ); + std::tie( smp, p ) = project_remain( real_global_pos ); const submap *sm = MAPBUFFER.lookup_submap( smp ); if( sm == nullptr ) { debugmsg( "is_sm_tile_over_water(): couldn't find submap %s", smp.to_string() ); @@ -8201,17 +8108,15 @@ static bool is_sm_tile_over_water( const tripoint &real_global_pos ) return false; } - // TODO: fix point types return ( sm->get_ter( p ).obj().has_flag( ter_furn_flag::TFLAG_CURRENT ) || sm->get_furn( p ).obj().has_flag( ter_furn_flag::TFLAG_CURRENT ) ); } -static bool is_sm_tile_outside( const tripoint &real_global_pos ) +static bool is_sm_tile_outside( const tripoint_abs_ms &real_global_pos ) { tripoint_abs_sm smp; point_sm_ms_ib p; - // TODO: fix point types - std::tie( smp, p ) = project_remain( tripoint_abs_ms( real_global_pos ) ); + std::tie( smp, p ) = project_remain( real_global_pos ); const submap *sm = MAPBUFFER.lookup_submap( smp ); if( sm == nullptr ) { debugmsg( "is_sm_tile_outside(): couldn't find submap %s", smp.to_string() ); @@ -8223,7 +8128,6 @@ static bool is_sm_tile_outside( const tripoint &real_global_pos ) return false; } - // TODO: fix point types return !( sm->get_ter( p ).obj().has_flag( ter_furn_flag::TFLAG_INDOORS ) || sm->get_furn( p ).obj().has_flag( ter_furn_flag::TFLAG_INDOORS ) ); } @@ -8267,7 +8171,7 @@ void vehicle::update_time( const time_point &update_to ) const vehicle_part &pt = parts[idx]; // we need an unbroken funnel mounted on the exterior of the vehicle - if( pt.is_unavailable() || !is_sm_tile_outside( here.getglobal( bub_part_pos( pt ) ).raw() ) ) { + if( pt.is_unavailable() || !is_sm_tile_outside( here.getglobal( bub_part_pos( pt ) ) ) ) { continue; } @@ -8305,7 +8209,7 @@ void vehicle::update_time( const time_point &update_to ) for( const int p : solar_panels ) { const vehicle_part &vp = parts[p]; const tripoint_bub_ms pos = bub_part_pos( vp ); - if( vp.is_unavailable() || !is_sm_tile_outside( here.getglobal( pos ).raw() ) ) { + if( vp.is_unavailable() || !is_sm_tile_outside( here.getglobal( pos ) ) ) { continue; } epower += part_epower( vp ); @@ -8385,8 +8289,8 @@ void vehicle::calc_mass_center( bool use_precalc ) const xf += vp.part().precalc[0].x() * m_part; yf += vp.part().precalc[0].y() * m_part; } else { - xf += vp.mount().x * m_part; - yf += vp.mount().y * m_part; + xf += vp.mount_pos().x() * m_part; + yf += vp.mount_pos().y() * m_part; } m_total += m_part; @@ -8423,6 +8327,7 @@ bounding_box vehicle::get_bounding_box( bool use_precalc, bool no_fake ) point_rel_ms pt; if( use_precalc ) { const int i_use = 0; + // TODO: Check if this is correct. part_at takes a vehicle relative position, not a bub one... int part_idx = part_at( p.xy().raw() ); if( part_idx < 0 ) { continue; @@ -8505,8 +8410,9 @@ std::vector> vehicle::real_parts() co } return ret; } -std::set vehicle::advance_precalc_mounts( const point &new_pos, const tripoint &src, - const tripoint &dp, int ramp_offset, const bool adjust_pos, +std::set vehicle::advance_precalc_mounts( const point_sm_ms &new_pos, + const tripoint_bub_ms &src, + const tripoint_rel_ms &dp, int ramp_offset, const bool adjust_pos, std::set parts_to_move ) { map &here = get_map(); @@ -8539,20 +8445,20 @@ std::set vehicle::advance_precalc_mounts( const point &new_pos, const tripo for( vehicle_part &prt : parts ) { index += 1; if( prt.is_real_or_active_fake() ) { - here.clear_vehicle_point_from_cache( this, tripoint_bub_ms( src ) + prt.precalc[0] ); + here.clear_vehicle_point_from_cache( this, src + prt.precalc[0] ); } // no parts means this is a normal horizontal or vertical move if( parts_to_move.empty() ) { prt.precalc[0] = prt.precalc[1]; // partial part movement means we're zero-ing out after missing a ramp } else if( adjust_pos && parts_to_move.find( index ) == parts_to_move.end() ) { - prt.precalc[0].z() -= dp.z; + prt.precalc[0].z() -= dp.z(); } else if( !adjust_pos && parts_to_move.find( index ) != parts_to_move.end() ) { - prt.precalc[0].z() += dp.z; + prt.precalc[0].z() += dp.z(); } - if( here.has_flag( ter_furn_flag::TFLAG_RAMP_UP, src + dp + prt.precalc[0].raw() ) ) { + if( here.has_flag( ter_furn_flag::TFLAG_RAMP_UP, src + dp + prt.precalc[0] ) ) { prt.precalc[0].z() += 1; - } else if( here.has_flag( ter_furn_flag::TFLAG_RAMP_DOWN, src + dp + prt.precalc[0].raw() ) ) { + } else if( here.has_flag( ter_furn_flag::TFLAG_RAMP_DOWN, src + dp + prt.precalc[0] ) ) { prt.precalc[0].z() -= 1; } prt.precalc[0].z() -= ramp_offset; @@ -8622,7 +8528,7 @@ bool vehicle::refresh_zones() const int part_idx = part_with_feature( z.first, "CARGO", false ); if( part_idx == -1 ) { debugmsg( "Could not find cargo part at %d,%d on vehicle %s for loot zone. Removing loot zone.", - z.first.x, z.first.y, this->name ); + z.first.x(), z.first.y(), this->name ); // If this loot zone refers to a part that no longer exists at this location, then its unattached somehow. // By continuing here and not adding to new_zones, we effectively remove it @@ -8658,16 +8564,11 @@ std::pair vehicle::get_exhaust_part() const return std::make_pair( exhaust_part, muffle ); } -tripoint vehicle::exhaust_dest( int part ) const -{ - return vehicle::exhaust_dest_bub( part ).raw(); -} - -tripoint_bub_ms vehicle::exhaust_dest_bub( int part ) const +tripoint_bub_ms vehicle::exhaust_dest( int part ) const { point_rel_ms p = parts[part].mount; // Move back from engine/muffler until we find an open space - while( relative_parts.find( p.raw() ) != relative_parts.end() ) { + while( relative_parts.find( p ) != relative_parts.end() ) { p.x() += ( velocity < 0 ? 1 : -1 ); } point_rel_ms q = coord_translate( p ); @@ -8717,14 +8618,14 @@ bool vehicle_part_with_fakes_range::matches( const size_t part ) const } void MapgenRemovePartHandler::add_item_or_charges( - const tripoint &loc, item it, bool permit_oob ) + const tripoint_bub_ms &loc, item it, bool permit_oob ) { if( !m.inbounds( loc ) ) { if( !permit_oob ) { debugmsg( "Tried to put item %s on invalid tile %s during mapgen!", it.tname(), loc.to_string() ); } - tripoint copy = loc; + tripoint_bub_ms copy = loc; m.clip_to_bounds( copy ); cata_assert( m.inbounds( copy ) ); // prevent infinite recursion add_item_or_charges( copy, std::move( it ), false ); diff --git a/src/vehicle.h b/src/vehicle.h index 926f4c9d28bd3..884022fc8d4c1 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -806,8 +806,6 @@ class vpart_display class vehicle { private: - // TODO: Get rid of untyped overload. - bool has_structural_part( const point &dp ) const; bool has_structural_part( const point_rel_ms &dp ) const; bool is_structural_part_removed() const; void open_or_close( int part_index, bool opening ); @@ -1245,8 +1243,6 @@ class vehicle * @param unbroken if true also requires the part to be !is_broken * @returns part index or -1 */ - // TODO: Get rid of untyped overload. - int avail_part_with_feature( const point &pt, const std::string &f ) const; int avail_part_with_feature( const point_rel_ms &pt, const std::string &f ) const; /** * Returns \p p or part index at mount point \p pt which has given \p f flag @@ -1267,8 +1263,6 @@ class vehicle * Either way, will also look for APPLIANCE * @returns part index or -1 */ - // TODO: Get rid of untyped overload. - int avail_linkable_part( const point &pt, bool to_ports ) const; int avail_linkable_part( const point_rel_ms &pt, bool to_ports ) const; /** @@ -1295,9 +1289,6 @@ class vehicle * @param flag if set only flags with this part will be considered * @param condition enum to include unabled, unavailable, and broken parts */ - // TODO: Get rid of untyped overload. - std::vector get_parts_at( const tripoint &pos, const std::string &flag, - part_status_flag condition ); std::vector get_parts_at( const tripoint_bub_ms &pos, const std::string &flag, part_status_flag condition ); std::vector get_parts_at( const tripoint_bub_ms &pos, @@ -1368,9 +1359,6 @@ class vehicle point_rel_ms coord_translate( const point_rel_ms &p ) const; // Translate mount coordinates "p" into tile coordinates "q" using given pivot direction and anchor - // TODO: Get rid of untyped overload. - void coord_translate( const units::angle &dir, const point &pivot, const point &p, - tripoint &q ) const; void coord_translate( const units::angle &dir, const point_rel_ms &pivot, const point_rel_ms &p, tripoint_rel_ms &q ) const; // Translate mount coordinates "p" into tile coordinates "q" using given tileray and anchor @@ -1387,9 +1375,6 @@ class vehicle // TODO: Get rid of untyped overload. int part_at( const point &dp ) const; int part_at( const point_rel_ms &dp ) const; - // TODO: Get rid of untyped overload. - int part_displayed_at( const point &dp, bool include_fake = false, - bool below_roof = true, bool roof = true ) const; int part_displayed_at( const point_rel_ms &dp, bool include_fake = false, bool below_roof = true, bool roof = true ) const; int roof_at_part( int p ) const; @@ -1404,9 +1389,6 @@ class vehicle // @param below_roof if true parts below roof are included // @param roof if true roof parts are included // @returns filled vpart_display struct or default constructed if no part displayed - // TODO: Get rid of untyped overload. - vpart_display get_display_of_tile( const point &dp, bool rotate = true, bool include_fake = true, - bool below_roof = true, bool roof = true ) const; vpart_display get_display_of_tile( const point_rel_ms &dp, bool rotate = true, bool include_fake = true, bool below_roof = true, bool roof = true ) const; @@ -1433,8 +1415,6 @@ class vehicle // Pre-calculate mount points for (idir=0) - current direction or // (idir=1) - next turn direction - // TODO: Get rid of untyped overload. - void precalc_mounts( int idir, const units::angle &dir, const point &pivot ); void precalc_mounts( int idir, const units::angle &dir, const point_rel_ms &pivot ); // get a list of part indices where is a passenger inside @@ -1921,8 +1901,6 @@ class vehicle void damage_all( int dmg1, int dmg2, const damage_type_id &type, const point_rel_ms &impact ); //Shifts the coordinates of all parts and moves the vehicle in the opposite direction. - // TODO: Get rid of untyped overload. - void shift_parts( map &here, const point &delta ); void shift_parts( map &here, const point_rel_ms &delta ); bool shift_if_needed( map &here ); @@ -1943,9 +1921,6 @@ class vehicle * @param unlink_tow_cables If tow cables should be unlinked. * @param unlink_power_cords If power grid cables (power_cord) should be unlinked. */ - // TODO: Get rid of untyped overload. - void unlink_cables( const point &mount, Character &remover, bool unlink_items = false, - bool unlink_tow_cables = false, bool unlink_power_cords = false ); void unlink_cables( const point_rel_ms &mount, Character &remover, bool unlink_items = false, bool unlink_tow_cables = false, bool unlink_power_cords = false ); @@ -2241,8 +2216,8 @@ class vehicle // Updates the internal precalculated mount offsets after the vehicle has been displaced // used in map::displace_vehicle() - std::set advance_precalc_mounts( const point &new_pos, const tripoint &src, - const tripoint &dp, int ramp_offset, + std::set advance_precalc_mounts( const point_sm_ms &new_pos, const tripoint_bub_ms &src, + const tripoint_rel_ms &dp, int ramp_offset, bool adjust_pos, std::set parts_to_move ); // make sure the vehicle is supported across z-levels or on the same z-level bool level_vehicle(); @@ -2286,14 +2261,14 @@ class vehicle */ vproto_id type; // parts_at_relative(dp) is used a lot (to put it mildly) - std::map> relative_parts; // NOLINT(cata-serialize) + std::map> relative_parts; // NOLINT(cata-serialize) std::set