diff --git a/data/mods/TEST_DATA/appliance.json b/data/mods/TEST_DATA/appliance.json index 914c06e52c01f..3e38cc7d4fd70 100644 --- a/data/mods/TEST_DATA/appliance.json +++ b/data/mods/TEST_DATA/appliance.json @@ -70,7 +70,7 @@ "epower": "0 W", "//": "Epower for POWER_TRANSFER stuff is how much percentage-wise loss there is in transmission", "durability": 120, - "description": "A power cord sticking out of an appliance. You need to plug it in a powered grid for the appliance to work properly.", + "description": "A power cord sticking out of an appliance. You need to plug it into a powered grid for the appliance to work properly.", "item": "test_power_cord", "flags": [ "NO_INSTALL_HIDDEN", "NO_UNINSTALL", "UNMOUNT_ON_DAMAGE", "POWER_TRANSFER" ], "variants": [ { "symbols": "{", "symbols_broken": "s" } ] diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 25ab3f6e6b692..51b02716a512f 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -4822,11 +4822,13 @@ std::optional link_up_actor::link_to_veh_app( Character *p, item &it, prev_part.target.first = here.getabs( pnt ); prev_part.target.second = target_veh->global_square_location().raw(); prev_veh->install_part( vcoords1, std::move( prev_part ) ); + prev_veh->precalc_mounts( 1, prev_veh->pivot_rotation[1], prev_veh->pivot_anchor[1] ); vehicle_part target_part( vpid, item( it ) ); target_part.target.first = here.getabs( prev_veh->mount_to_tripoint( it.link->t_mount ) ); target_part.target.second = prev_veh->global_square_location().raw(); target_veh->install_part( vcoords2, std::move( target_part ) ); + target_veh->precalc_mounts( 1, target_veh->pivot_rotation[1], target_veh->pivot_anchor[1] ); if( p->has_item( it ) ) { //~ %1$s - first vehicle name, %2$s - second vehicle name - %3$s - cable name, @@ -4953,11 +4955,13 @@ std::optional link_up_actor::link_tow_cable( Character *p, item &it, prev_part.target.first = here.getabs( pnt ); prev_part.target.second = target_veh->global_square_location().raw(); prev_veh->install_part( vcoords1, std::move( prev_part ) ); + prev_veh->precalc_mounts( 1, prev_veh->pivot_rotation[1], prev_veh->pivot_anchor[1] ); vehicle_part target_part( vpid, item( it ) ); target_part.target.first = here.getabs( prev_veh->mount_to_tripoint( it.link->t_mount ) ); target_part.target.second = prev_veh->global_square_location().raw(); target_veh->install_part( vcoords2, std::move( target_part ) ); + target_veh->precalc_mounts( 1, target_veh->pivot_rotation[1], target_veh->pivot_anchor[1] ); if( p->has_item( it ) ) { //~ %1$s - first vehicle name, %2$s - second vehicle name - %3$s - tow cable name, diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 48c8e852c9226..cf4f9e62ea042 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -549,6 +549,7 @@ item vehicle::init_cord( const tripoint &pos ) cord.link->t_state = link_state::vehicle_port; cord.link->t_veh_safe = get_safe_reference(); cord.link->t_abs_pos = get_map().getglobal( pos ); + cord.set_link_traits(); return cord; } @@ -587,12 +588,14 @@ void vehicle::connect( const tripoint &source_pos, const tripoint &target_pos ) source_part.target.first = target_global; source_part.target.second = target_veh->global_square_location().raw(); source_veh->install_part( vcoords, std::move( source_part ) ); + source_veh->precalc_mounts( 1, source_veh->pivot_rotation[1], source_veh->pivot_anchor[1] ); vcoords = target_vp->mount(); vehicle_part target_part( vpid, item( cord ) ); target_part.target.first = cord.link->t_abs_pos.raw(); target_part.target.second = source_veh->global_square_location().raw(); target_veh->install_part( vcoords, std::move( target_part ) ); + target_veh->precalc_mounts( 1, target_veh->pivot_rotation[1], target_veh->pivot_anchor[1] ); } double vehicle::engine_cold_factor( const vehicle_part &vp ) const diff --git a/tests/vehicle_test.cpp b/tests/vehicle_test.cpp index 28b4fdb10f242..67c81dfeabf40 100644 --- a/tests/vehicle_test.cpp +++ b/tests/vehicle_test.cpp @@ -432,7 +432,7 @@ static void connect_power_line( const tripoint &src_pos, const tripoint &dst_pos cord.link = cata::make_value(); cord.link->t_state = link_state::vehicle_port; cord.link->t_abs_pos = here.getglobal( src_pos ); - cord.active = true; + cord.set_link_traits(); const optional_vpart_position target_vp = here.veh_at( dst_pos ); const optional_vpart_position source_vp = here.veh_at( src_pos ); @@ -454,12 +454,14 @@ static void connect_power_line( const tripoint &src_pos, const tripoint &dst_pos source_part.target.first = target_global; source_part.target.second = target_veh->global_square_location().raw(); source_veh->install_part( vcoords, std::move( source_part ) ); + source_veh->precalc_mounts( 1, source_veh->pivot_rotation[1], source_veh->pivot_anchor[1] ); vcoords = target_vp->mount(); vehicle_part target_part( vpid, item( cord ) ); target_part.target.first = cord.link->t_abs_pos.raw(); target_part.target.second = source_veh->global_square_location().raw(); target_veh->install_part( vcoords, std::move( target_part ) ); + target_veh->precalc_mounts( 1, target_veh->pivot_rotation[1], target_veh->pivot_anchor[1] ); } TEST_CASE( "power_cable_stretch_disconnect" ) @@ -492,6 +494,7 @@ TEST_CASE( "power_cable_stretch_disconnect" ) REQUIRE( app2.part_count() == 2 ); REQUIRE( app1.part( 1 ).get_base().type->maximum_charges() == 3 ); + REQUIRE( app1.part( 1 ).get_base().max_link_length() == 3 ); const int max_dist = app1.part( 1 ).get_base().type->maximum_charges(); @@ -532,6 +535,7 @@ TEST_CASE( "power_cable_stretch_disconnect" ) REQUIRE( app2.part_count() == 2 ); REQUIRE( app1.part( 1 ).get_base().type->maximum_charges() == 10 ); + REQUIRE( app1.part( 1 ).get_base().max_link_length() == 10 ); const int max_dist = app1.part( 1 ).get_base().type->maximum_charges();