diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 11aedadcecc1b..bf1a246fff7b7 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -395,7 +395,7 @@ void aim_activity_actor::do_turn( player_activity &act, Character &who ) avatar &you = get_avatar(); item_location weapon = get_weapon(); - if( !weapon || !avatar_action::can_fire_weapon( you, get_map(), *weapon ) ) { + if( !weapon || !avatar_action::can_fire_weapon( *weapon ) ) { aborted = true; act.moves_left = 0; return; @@ -417,7 +417,7 @@ void aim_activity_actor::do_turn( player_activity &act, Character &who ) } g->temp_exit_fullscreen(); - target_handler::trajectory trajectory = target_handler::mode_fire( you, *this ); + target_handler::trajectory trajectory = target_handler::mode_fire( *this ); g->reenter_fullscreen(); if( aborted ) { diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index f9e8f34604022..868342588b8c8 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2802,29 +2802,24 @@ void activity_handlers::eat_menu_do_turn( player_activity *, Character *you ) you->cancel_activity(); return; } - - avatar &player_character = get_avatar(); - avatar_action::eat_or_use( player_character, game_menus::inv::consume() ); + avatar_action::eat_or_use( game_menus::inv::consume() ); } void activity_handlers::consume_food_menu_do_turn( player_activity *, Character * ) { - avatar &player_character = get_avatar(); item_location loc = game_menus::inv::consume_food(); - avatar_action::eat( player_character, loc ); + avatar_action::eat( loc ); } void activity_handlers::consume_drink_menu_do_turn( player_activity *, Character * ) { - avatar &player_character = get_avatar(); item_location loc = game_menus::inv::consume_drink(); - avatar_action::eat( player_character, loc ); + avatar_action::eat( loc ); } void activity_handlers::consume_meds_menu_do_turn( player_activity *, Character * ) { - avatar &player_character = get_avatar(); - avatar_action::eat_or_use( player_character, game_menus::inv::consume_meds() ); + avatar_action::eat_or_use( game_menus::inv::consume_meds() ); } void activity_handlers::move_loot_do_turn( player_activity *act, Character *you ) diff --git a/src/avatar.cpp b/src/avatar.cpp index 9a1a635ed4697..a7b598e64dab4 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -221,7 +221,7 @@ void avatar::longpull( const std::string &name ) { item wtmp( itype_mut_longpull ); g->temp_exit_fullscreen(); - target_handler::trajectory traj = target_handler::mode_throw( *this, wtmp, false ); + target_handler::trajectory traj = target_handler::mode_throw( wtmp, false ); g->reenter_fullscreen(); if( traj.empty() ) { return; // cancel diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 6abeb45efaac7..bd4ba65faed8e 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -176,8 +176,10 @@ static bool check_water_affect_items( avatar &you ) return true; } -bool avatar_action::move( avatar &you, map &m, const tripoint &d ) +bool avatar_action::move( const tripoint &d ) { + avatar &you = get_avatar(); + map &m = get_map(); bool in_shell = you.has_active_mutation( trait_SHELL2 ) || you.has_active_mutation( trait_SHELL3 ); if( ( !g->check_safe_mode_allowed() ) || in_shell ) { @@ -483,7 +485,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) add_msg( m_info, _( "%s to dive underwater." ), press_x( ACTION_MOVE_DOWN ) ); } - avatar_action::swim( get_map(), get_avatar(), dest_loc.raw() ); + avatar_action::swim( dest_loc.raw() ); } g->on_move_effects(); @@ -571,63 +573,10 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) return false; } -bool avatar_action::ramp_move( avatar &you, map &m, const tripoint &dest_loc ) -{ - if( dest_loc.z != you.posz() ) { - // No recursive ramp_moves - return false; - } - - // We're moving onto a tile with no support, check if it has a ramp below - if( !m.has_floor_or_support( dest_loc ) ) { - tripoint_bub_ms below( point_bub_ms( dest_loc.xy() ), dest_loc.z - 1 ); - if( m.has_flag( ter_furn_flag::TFLAG_RAMP, below ) ) { - // But we're moving onto one from above - const tripoint dp = dest_loc - you.pos(); - move( you, m, tripoint( dp.xy(), -1 ) ); - // No penalty for misaligned stairs here - // Also cheaper than climbing up - return true; - } - - return false; - } - - if( !m.has_flag( ter_furn_flag::TFLAG_RAMP, you.pos_bub() ) || - m.passable( dest_loc ) ) { - return false; - } - - // Try to find an aligned end of the ramp that will make our climb faster - // Basically, finish walking on the stairs instead of pulling self up by hand - bool aligned_ramps = false; - for( const tripoint &pt : m.points_in_radius( you.pos(), 1 ) ) { - if( rl_dist( pt, dest_loc ) < 2 && m.has_flag( ter_furn_flag::TFLAG_RAMP_END, pt ) ) { - aligned_ramps = true; - break; - } - } - - const tripoint above_u( you.posx(), you.posy(), you.posz() + 1 ); - if( m.has_floor_or_support( above_u ) ) { - add_msg( m_warning, _( "You can't climb here - there's a ceiling above." ) ); - return false; - } - - const tripoint dp = dest_loc - you.pos(); - const tripoint old_pos = you.pos(); - move( you, m, tripoint( dp.xy(), 1 ) ); - // We can't just take the result of the above function here - if( you.pos() != old_pos ) { - const double total_move_cost = aligned_ramps ? 0.5 : 1.0; - you.mod_moves( -you.get_speed() * total_move_cost ); - } - - return true; -} - -void avatar_action::swim( map &m, avatar &you, const tripoint &p ) +void avatar_action::swim( const tripoint &p ) { + avatar &you = get_avatar(); + map &m = get_map(); if( !m.has_flag( ter_furn_flag::TFLAG_SWIMMABLE, p ) ) { dbg( D_ERROR ) << "game:plswim: Tried to swim in " << m.tername( p ) << "!"; @@ -728,8 +677,9 @@ static float rate_critter( const Creature &c ) return m->type->difficulty; } -void avatar_action::autoattack( avatar &you, map &m ) +void avatar_action::autoattack() { + avatar &you = get_avatar(); const item_location weapon = you.get_wielded_item(); int reach = weapon ? weapon->reach_range( you ) : 1; std::vector critters = you.get_targetable_creatures( reach, true ); @@ -758,7 +708,7 @@ void avatar_action::autoattack( avatar &you, map &m ) const tripoint diff = best.pos() - you.pos(); if( std::abs( diff.x ) <= 1 && std::abs( diff.y ) <= 1 && diff.z == 0 ) { - move( you, m, tripoint( diff.xy(), 0 ) ); + move( tripoint( diff.xy(), 0 ) ); return; } @@ -766,23 +716,23 @@ void avatar_action::autoattack( avatar &you, map &m ) } // TODO: Move data/functions related to targeting out of game class -bool avatar_action::can_fire_weapon( avatar &you, const map &m, const item &weapon ) +bool avatar_action::can_fire_weapon( const item &weapon ) { if( !weapon.is_gun() ) { debugmsg( "Expected item to be a gun" ); return false; } - if( !you.try_break_relax_gas( _( "Your eyes steel, and you raise your weapon!" ), - _( "You can't fire your weapon, it's too heavy…" ) ) ) { + if( !get_avatar().try_break_relax_gas( _( "Your eyes steel, and you raise your weapon!" ), + _( "You can't fire your weapon, it's too heavy…" ) ) ) { return false; } std::vector messages; for( const std::pair &mode_map : weapon.gun_all_modes() ) { - bool check_common = gunmode_checks_common( you, m, messages, mode_map.second ); - bool check_weapon = gunmode_checks_weapon( you, m, messages, mode_map.second ); + bool check_common = gunmode_checks_common( messages, mode_map.second ); + bool check_weapon = gunmode_checks_weapon( messages, mode_map.second ); bool can_use_mode = check_common && check_weapon; if( can_use_mode ) { return true; @@ -795,8 +745,9 @@ bool avatar_action::can_fire_weapon( avatar &you, const map &m, const item &weap return false; } -void avatar_action::fire_wielded_weapon( avatar &you ) +void avatar_action::fire_wielded_weapon() { + avatar &you = get_avatar(); const item_location weapon = you.get_wielded_item(); if( !weapon ) { @@ -825,12 +776,12 @@ void avatar_action::fire_ranged_mutation( Character &you, const item &fake_gun ) you.assign_activity( aim_activity_actor::use_mutation( fake_gun ) ); } -void avatar_action::fire_ranged_bionic( avatar &you, const item &fake_gun ) +void avatar_action::fire_ranged_bionic( const item &fake_gun ) { - you.assign_activity( aim_activity_actor::use_bionic( fake_gun ) ); + get_avatar().assign_activity( aim_activity_actor::use_bionic( fake_gun ) ); } -bool avatar_action::fire_turret_manual( avatar &you, map &m, turret_data &turret ) +bool avatar_action::fire_turret_manual( turret_data &turret ) { if( !turret.base()->is_gun() ) { debugmsg( "Expected turret base to be a gun." ); @@ -855,8 +806,8 @@ bool avatar_action::fire_turret_manual( avatar &you, map &m, turret_data &turret std::vector messages; const std::map gunmodes = turret.base()->gun_all_modes(); if( !std::any_of( gunmodes.begin(), gunmodes.end(), - [&you, &m, &messages]( const std::pair &p ) { - return gunmode_checks_common( you, m, messages, p.second ); + [&messages]( const std::pair &p ) { + return gunmode_checks_common( messages, p.second ); } ) ) { // no gunmode is usable, dump reason messages why not for( const std::string &msg : messages ) { @@ -867,18 +818,18 @@ bool avatar_action::fire_turret_manual( avatar &you, map &m, turret_data &turret // all checks passed - start aiming g->temp_exit_fullscreen(); - target_handler::trajectory trajectory = target_handler::mode_turret_manual( you, turret ); + target_handler::trajectory trajectory = target_handler::mode_turret_manual( turret ); if( !trajectory.empty() ) { - turret.fire( you, trajectory.back() ); + turret.fire( get_avatar(), trajectory.back() ); } g->reenter_fullscreen(); return true; } -void avatar_action::mend( avatar &you, item_location loc ) +void avatar_action::mend( item_location loc ) { - + avatar &you = get_avatar(); if( you.fine_detail_vision_mod() > 4 ) { add_msg( m_bad, _( "It's too dark to work on mending this." ) ); return; @@ -898,8 +849,9 @@ void avatar_action::mend( avatar &you, item_location loc ) } } -bool avatar_action::eat_here( avatar &you ) +bool avatar_action::eat_here() { + avatar &you = get_avatar(); map &here = get_map(); if( ( you.has_active_mutation( trait_RUMINANT ) || you.has_active_mutation( trait_GRAZER ) ) && ( here.has_flag( ter_furn_flag::TFLAG_SHRUB, you.pos_bub() ) && @@ -959,22 +911,24 @@ bool avatar_action::eat_here( avatar &you ) return false; } -void avatar_action::eat( avatar &you, item_location &loc ) +void avatar_action::eat( item_location &loc ) { + avatar &you = get_avatar(); std::string filter; if( !you.activity.str_values.empty() ) { filter = you.activity.str_values.back(); } - avatar_action::eat( you, loc, you.activity.values, you.activity.targets, filter, + avatar_action::eat( loc, you.activity.values, you.activity.targets, filter, you.activity.id() ); } -void avatar_action::eat( avatar &you, item_location &loc, +void avatar_action::eat( item_location &loc, const std::vector &consume_menu_selections, const std::vector &consume_menu_selected_items, const std::string &consume_menu_filter, activity_id type ) { + avatar &you = get_avatar(); if( !loc ) { you.cancel_activity(); add_msg( _( "Never mind." ) ); @@ -986,18 +940,19 @@ void avatar_action::eat( avatar &you, item_location &loc, you.last_item = item( *loc ).typeId(); } -void avatar_action::eat_or_use( avatar &you, item_location loc ) +void avatar_action::eat_or_use( item_location loc ) { if( loc && loc->is_medical_tool() ) { - avatar_action::use_item( you, loc, "heal" ); + avatar_action::use_item( loc, "heal" ); } else { - avatar_action::eat( you, loc ); + avatar_action::eat( loc ); } } -void avatar_action::plthrow( avatar &you, item_location loc, +void avatar_action::plthrow( item_location loc, const std::optional &blind_throw_from_pos ) { + avatar &you = get_avatar(); bool in_shell = you.has_active_mutation( trait_SHELL2 ) || you.has_active_mutation( trait_SHELL3 ); if( in_shell ) { @@ -1084,7 +1039,7 @@ void avatar_action::plthrow( avatar &you, item_location loc, g->temp_exit_fullscreen(); item_location weapon = you.get_wielded_item(); - target_handler::trajectory trajectory = target_handler::mode_throw( you, *weapon, + target_handler::trajectory trajectory = target_handler::mode_throw( *weapon, blind_throw_from_pos.has_value() ); // If we previously shifted our position, put ourselves back now that we've picked our target. @@ -1117,14 +1072,15 @@ static void update_lum( item_location loc, bool add ) } } -void avatar_action::use_item( avatar &you ) +void avatar_action::use_item() { item_location loc; - avatar_action::use_item( you, loc ); + avatar_action::use_item( loc ); } -void avatar_action::use_item( avatar &you, item_location &loc, std::string const &method ) +void avatar_action::use_item( item_location &loc, std::string const &method ) { + avatar &you = get_avatar(); if( you.has_effect( effect_incorporeal ) ) { you.add_msg_if_player( m_bad, _( "You can't use anything while incorporeal." ) ); return; @@ -1227,8 +1183,9 @@ void avatar_action::use_item( avatar &you, item_location &loc, std::string const // Opens up a menu to Unload a container, gun, or tool // If it's a gun, some gunmods can also be loaded -void avatar_action::unload( avatar &you ) +void avatar_action::unload() { + avatar &you = get_avatar(); std::pair ret = game_menus::inv::unload( you ); if( !ret.first ) { add_msg( _( "Never mind." ) ); diff --git a/src/avatar_action.h b/src/avatar_action.h index 49355c6d0fc92..ce1ccb137f61c 100644 --- a/src/avatar_action.h +++ b/src/avatar_action.h @@ -10,59 +10,50 @@ #include "point.h" class Character; -class avatar; class item; class item_location; -class map; class turret_data; namespace avatar_action { /** Eat food or fuel 'E' (or 'a') */ -void eat( avatar &you, item_location &loc ); -void eat( avatar &you, item_location &loc, +void eat( item_location &loc ); +void eat( item_location &loc, const std::vector &consume_menu_selections, const std::vector &consume_menu_selected_items, const std::string &consume_menu_filter, activity_id type ); // special rules for eating: grazing etc // returns false if no rules are needed -bool eat_here( avatar &you ); -void eat_or_use( avatar &you, item_location loc ); +bool eat_here(); +void eat_or_use( item_location loc ); // Standard movement; handles attacks, traps, &c. Returns false if auto move // should be canceled -bool move( avatar &you, map &m, const tripoint &d ); -inline bool move( avatar &you, map &m, const point &d ) -{ - return move( you, m, tripoint( d, 0 ) ); -} - -// Handle moving from a ramp -bool ramp_move( avatar &you, map &m, const tripoint &dest ); +bool move( const tripoint &d ); /** Handles swimming by the player. Called by avatar_action::move(). */ -void swim( map &m, avatar &you, const tripoint &p ); +void swim( const tripoint &p ); -void autoattack( avatar &you, map &m ); +void autoattack(); -void mend( avatar &you, item_location loc ); +void mend( item_location loc ); /** * Checks if the weapon is valid and if the player meets certain conditions for firing it. * Used for validating ACT_AIM and turret weapon * @return True if all conditions are true, otherwise false. */ -bool can_fire_weapon( avatar &you, const map &m, const item &weapon ); +bool can_fire_weapon( const item &weapon ); /** Checks if the wielded weapon is a gun and can be fired then starts interactive aiming */ -void fire_wielded_weapon( avatar &you ); +void fire_wielded_weapon(); /** Stores fake gun specified by the mutation and starts interactive aiming */ void fire_ranged_mutation( Character &you, const item &fake_gun ); /** Stores fake gun specified by the bionic and starts interactive aiming */ -void fire_ranged_bionic( avatar &you, const item &fake_gun ); +void fire_ranged_bionic( const item &fake_gun ); /** * Checks if the player can manually (with their 2 hands, not via vehicle controls) @@ -70,17 +61,21 @@ void fire_ranged_bionic( avatar &you, const item &fake_gun ); * Assumes that the turret is on player position. * @return true if attempt to fire was successful (aim then cancel is also considered success) */ -bool fire_turret_manual( avatar &you, map &m, turret_data &turret ); +bool fire_turret_manual( turret_data &turret ); // Throw an item 't' -void plthrow( avatar &you, item_location loc, +void plthrow( item_location loc, const std::optional &blind_throw_from_pos = std::nullopt ); -void unload( avatar &you ); +/** + * Opens up a menu to Unload a container, gun, or tool + * If it's a gun, some gunmods can also be loaded + */ +void unload(); // Use item; also tries E,R,W 'a' -void use_item( avatar &you, item_location &loc, std::string const &method = {} ); -void use_item( avatar &you ); +void use_item( item_location &loc, std::string const &method = {} ); +void use_item(); /** Check if avatar is stealing a weapon. */ bool check_stealing( Character &who, item &weapon ); diff --git a/src/bionics.cpp b/src/bionics.cpp index 51a0e640766fd..b5fbe299ce2a4 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -812,7 +812,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics if( close_bionics_ui ) { *close_bionics_ui = true; } - avatar_action::fire_ranged_bionic( player_character, bio.get_weapon() ); + avatar_action::fire_ranged_bionic( bio.get_weapon() ); } else if( bio.info().has_flag( json_flag_BIONIC_WEAPON ) ) { if( !bio.has_weapon() ) { debugmsg( "tried to activate weapon bionic \"%s\" without fake_weapon", diff --git a/src/character.cpp b/src/character.cpp index 707d1f6f3ba51..c7e239bbd5e44 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -12636,7 +12636,7 @@ void Character::knock_back_to( const tripoint &to ) if( here.has_flag( ter_furn_flag::TFLAG_LIQUID, to ) && here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, to ) ) { if( !is_npc() ) { - avatar_action::swim( here, get_avatar(), to ); + avatar_action::swim( to ); } // TODO: NPCs can't swim! } else if( here.impassable( to ) ) { // Wait, it's a wall diff --git a/src/condition.cpp b/src/condition.cpp index ff4c9a56a5892..bfb4b00e79376 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -1637,7 +1637,6 @@ conditional_t::func f_query_tile( const JsonObject &jo, std::string_view member, std::optional loc; Character *ch = d.actor( is_npc )->get_character(); if( ch && ch->as_avatar() ) { - avatar *you = ch->as_avatar(); if( type == "anywhere" ) { if( !message.empty() ) { static_popup popup; @@ -1653,7 +1652,7 @@ conditional_t::func f_query_tile( const JsonObject &jo, std::string_view member, popup.on_top( true ); popup.message( "%s", message ); } - target_handler::trajectory traj = target_handler::mode_select_only( *you, range.evaluate( d ) ); + target_handler::trajectory traj = target_handler::mode_select_only( range.evaluate( d ) ); if( !traj.empty() ) { loc = traj.back(); } diff --git a/src/game.cpp b/src/game.cpp index 8c0108ad64ba9..9b92399e7d225 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2262,11 +2262,11 @@ int game::inventory_item_menu( item_location locThisItem, if( locThisItem.get_item()->type->has_use() && !locThisItem.get_item()->item_has_uses_recursive( true ) ) { // NOLINT(bugprone-branch-clone) // Item has uses and none of its contents (if any) has uses. - avatar_action::use_item( u, locThisItem ); + avatar_action::use_item( locThisItem ); } else if( locThisItem.get_item()->item_has_uses_recursive() ) { game::item_action_menu( locThisItem ); } else if( locThisItem.get_item()->has_relic_activation() ) { - avatar_action::use_item( u, locThisItem ); + avatar_action::use_item( locThisItem ); } else { add_msg( m_info, _( "You can't use a %s there." ), locThisItem->tname() ); break; @@ -2276,9 +2276,9 @@ int game::inventory_item_menu( item_location locThisItem, } case 'E': if( !locThisItem.get_item()->is_container() ) { - avatar_action::eat( u, locThisItem ); + avatar_action::eat( locThisItem ); } else { - avatar_action::eat_or_use( u, game_menus::inv::consume( locThisItem ) ); + avatar_action::eat_or_use( game_menus::inv::consume( locThisItem ) ); } break; case 'W': { @@ -2301,7 +2301,7 @@ int game::inventory_item_menu( item_location locThisItem, case 't': { contents_change_handler handler; handler.unseal_pocket_containing( locThisItem ); - avatar_action::plthrow( u, locThisItem ); + avatar_action::plthrow( locThisItem ); handler.handle_by( u ); break; } @@ -2324,7 +2324,7 @@ int game::inventory_item_menu( item_location locThisItem, reload( locThisItem, true ); break; case 'm': - avatar_action::mend( u, locThisItem ); + avatar_action::mend( locThisItem ); break; case 'R': u.read( locThisItem ); @@ -4863,7 +4863,7 @@ void game::knockback( std::vector &traj, int stun, int dam_mult ) break; } if( m.has_flag( ter_furn_flag::TFLAG_LIQUID, u.pos_bub() ) && force_remaining == 0 ) { - avatar_action::swim( m, u, u.pos() ); + avatar_action::swim( u.pos() ); } else { u.setpos( traj[i] ); } @@ -6136,7 +6136,7 @@ void game::peek( const tripoint &p ) if( result.peek_action && *result.peek_action == PA_BLIND_THROW ) { item_location loc; - avatar_action::plthrow( u, loc, p ); + avatar_action::plthrow( loc, p ); } m.invalidate_map_cache( p.z ); m.invalidate_visibility_cache(); @@ -8144,7 +8144,7 @@ void game::list_items_monsters() } if( ret == game::vmenu_ret::FIRE ) { - avatar_action::fire_wielded_weapon( u ); + avatar_action::fire_wielded_weapon(); } reenter_fullscreen(); } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 0b1f87bd7bdd7..5ae0c97bab80a 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -1668,7 +1668,7 @@ static void reach_attack( avatar &you ) { g->temp_exit_fullscreen(); - target_handler::trajectory traj = target_handler::mode_reach( you, you.get_wielded_item() ); + target_handler::trajectory traj = target_handler::mode_reach( you.get_wielded_item() ); if( !traj.empty() ) { you.reach_attack( traj.back() ); @@ -1698,13 +1698,13 @@ static void fire() } // try firing gun if( weapon && weapon->is_gun() && !weapon->gun_current_mode().melee() ) { - avatar_action::fire_wielded_weapon( you ); + avatar_action::fire_wielded_weapon(); return; } // try firing turrets if( const optional_vpart_position ovp = here.veh_at( you.pos_bub() ) ) { if( turret_data turret_here = ovp->vehicle().turret_query( you.pos() ) ) { - if( avatar_action::fire_turret_manual( you, here, turret_here ) ) { + if( avatar_action::fire_turret_manual( turret_here ) ) { return; } } else if( ovp.part_with_feature( VPFLAG_CONTROLS, true ) ) { @@ -1892,20 +1892,19 @@ void game::open_consume_item_menu() as_m.entries.emplace_back( 2, true, 'm', _( "Medication" ) ); as_m.query(); - avatar &player_character = get_avatar(); switch( as_m.ret ) { case 0: { item_location loc = game_menus::inv::consume_food(); - avatar_action::eat( player_character, loc ); + avatar_action::eat( loc ); break; } case 1: { item_location loc = game_menus::inv::consume_drink(); - avatar_action::eat( player_character, loc ); + avatar_action::eat( loc ); break; } case 2: - avatar_action::eat_or_use( player_character, game_menus::inv::consume_meds() ); + avatar_action::eat_or_use( game_menus::inv::consume_meds() ); break; default: break; @@ -2273,7 +2272,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, } dest_delta = dest_next; } - if( !avatar_action::move( player_character, m, dest_delta ) ) { + if( !avatar_action::move( tripoint( dest_delta, 0 ) ) ) { // auto-move should be canceled due to a failed move or obstacle player_character.abort_automove(); } @@ -2472,7 +2471,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, case ACTION_USE: // Shell-users are presumed to be able to mess with their inventories, etc // while in the shell. Eating, gear-changing, and item use are OK. - avatar_action::use_item( player_character ); + avatar_action::use_item(); break; case ACTION_USE_WIELDED: @@ -2488,13 +2487,13 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_EAT: - if( !avatar_action::eat_here( player_character ) ) { - avatar_action::eat_or_use( player_character, game_menus::inv::consume() ); + if( !avatar_action::eat_here() ) { + avatar_action::eat_or_use( game_menus::inv::consume() ); } break; case ACTION_OPEN_CONSUME: - if( !avatar_action::eat_here( player_character ) ) { + if( !avatar_action::eat_here() ) { open_consume_item_menu(); } break; @@ -2525,16 +2524,16 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_UNLOAD: - avatar_action::unload( player_character ); + avatar_action::unload(); break; case ACTION_MEND: - avatar_action::mend( player_character, item_location() ); + avatar_action::mend( item_location() ); break; case ACTION_THROW: { item_location loc; - avatar_action::plthrow( player_character, loc ); + avatar_action::plthrow( loc ); break; } @@ -2550,7 +2549,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, if( weapon ) { gun_mode_id original_mode = weapon->gun_get_mode_id(); if( weapon->gun_set_mode( gun_mode_AUTO ) ) { - avatar_action::fire_wielded_weapon( player_character ); + avatar_action::fire_wielded_weapon(); weapon->gun_set_mode( original_mode ); } } @@ -2992,7 +2991,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_AUTOATTACK: - avatar_action::autoattack( player_character, m ); + avatar_action::autoattack(); break; default: diff --git a/src/iuse.cpp b/src/iuse.cpp index 03a96bbc515ff..e04ce97b8b697 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2232,7 +2232,7 @@ class exosuit_interact return to_moves( 5_seconds ); } else if( ret == 2 ) { if( !!loc_it ) { - avatar_action::use_item( get_avatar(), loc_it ); + avatar_action::use_item( loc_it ); } return 0; } else if( ret == 3 ) { diff --git a/src/magic.cpp b/src/magic.cpp index 5927644c5a2c7..fcf3da3f8e66e 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -820,9 +820,7 @@ std::optional spell::select_target( Creature *source ) if( source->is_avatar() ) { do { avatar &source_avatar = *source->as_avatar(); - std::vector trajectory = target_handler::mode_spell( source_avatar, *this, - true, - true ); + std::vector trajectory = target_handler::mode_spell( *this, true, true ); if( !trajectory.empty() ) { target = trajectory.back(); target_is_valid = is_valid_target( source_avatar, target ); diff --git a/src/medical_ui.cpp b/src/medical_ui.cpp index ef8a5e1d6ed98..c86fa823ae5bb 100644 --- a/src/medical_ui.cpp +++ b/src/medical_ui.cpp @@ -963,9 +963,8 @@ void Character::disp_medical() } info_scroll_position = 0; } else if( action == "APPLY" ) { - avatar *a = this->as_avatar(); - if( a ) { - avatar_action::use_item( *a ); + if( this->as_avatar() ) { + avatar_action::use_item(); } else { popup( _( "Applying not implemented for NPCs." ) ); } diff --git a/src/ranged.cpp b/src/ranged.cpp index 28a5152f6c24a..5f95755e81394 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -447,73 +447,73 @@ class target_ui void on_target_accepted( bool harmful ) const; }; -target_handler::trajectory target_handler::mode_select_only( avatar &you, int range ) +target_handler::trajectory target_handler::mode_select_only( int range ) { target_ui ui = target_ui(); - ui.you = &you; + ui.you = &get_avatar(); ui.mode = target_ui::TargetMode::SelectOnly; ui.range = range; - restore_on_out_of_scope view_offset_prev( you.view_offset ); + restore_on_out_of_scope view_offset_prev( ui.you->view_offset ); return ui.run(); } -target_handler::trajectory target_handler::mode_fire( avatar &you, aim_activity_actor &activity ) +target_handler::trajectory target_handler::mode_fire( aim_activity_actor &activity ) { target_ui ui = target_ui(); - ui.you = &you; + ui.you = &get_avatar(); ui.mode = target_ui::TargetMode::Fire; ui.activity = &activity; ui.relevant = &*activity.get_weapon(); gun_mode gun = ui.relevant->gun_current_mode(); - ui.range = gun.target->gun_range( &you ); + ui.range = gun.target->gun_range( ui.you ); ui.ammo = gun->ammo_data(); return ui.run(); } -target_handler::trajectory target_handler::mode_throw( avatar &you, item &relevant, - bool blind_throwing ) +target_handler::trajectory target_handler::mode_throw( item &relevant, bool blind_throwing ) { target_ui ui = target_ui(); - ui.you = &you; + ui.you = &get_avatar(); ui.mode = blind_throwing ? target_ui::TargetMode::ThrowBlind : target_ui::TargetMode::Throw; ui.relevant = &relevant; - ui.range = you.throw_range( relevant ); + ui.range = ui.you->throw_range( relevant ); - restore_on_out_of_scope view_offset_prev( you.view_offset ); + restore_on_out_of_scope view_offset_prev( ui.you->view_offset ); return ui.run(); } -target_handler::trajectory target_handler::mode_reach( avatar &you, item_location weapon ) +target_handler::trajectory target_handler::mode_reach( item_location weapon ) { target_ui ui = target_ui(); - ui.you = &you; + ui.you = &get_avatar(); ui.mode = target_ui::TargetMode::Reach; ui.relevant = weapon.get_item(); - ui.range = weapon ? weapon->current_reach_range( you ) : 1; + ui.range = weapon ? weapon->current_reach_range( *ui.you ) : 1; - restore_on_out_of_scope view_offset_prev( you.view_offset ); + restore_on_out_of_scope view_offset_prev( ui.you->view_offset ); return ui.run(); } -target_handler::trajectory target_handler::mode_turret_manual( avatar &you, turret_data &turret ) +target_handler::trajectory target_handler::mode_turret_manual( turret_data &turret ) { target_ui ui = target_ui(); - ui.you = &you; + ui.you = &get_avatar(); ui.mode = target_ui::TargetMode::TurretManual; ui.turret = &turret; ui.relevant = &*turret.base(); ui.range = turret.range(); ui.ammo = turret.ammo_data(); - restore_on_out_of_scope view_offset_prev( you.view_offset ); + restore_on_out_of_scope view_offset_prev( ui.you->view_offset ); return ui.run(); } -target_handler::trajectory target_handler::mode_turrets( avatar &you, vehicle &veh, +target_handler::trajectory target_handler::mode_turrets( vehicle &veh, const std::vector &turrets ) { + avatar &you = get_avatar(); // Find radius of a circle centered at u encompassing all points turrets can aim at // FIXME: this calculation is fine for square distances, but results in an underestimation // when used with real circles @@ -541,18 +541,17 @@ target_handler::trajectory target_handler::mode_turrets( avatar &you, vehicle &v return ui.run(); } -target_handler::trajectory target_handler::mode_spell( avatar &you, spell &casting, bool no_fail, - bool no_mana ) +target_handler::trajectory target_handler::mode_spell( spell &casting, bool no_fail, bool no_mana ) { target_ui ui = target_ui(); - ui.you = &you; + ui.you = &get_avatar(); ui.mode = target_ui::TargetMode::Spell; ui.casting = &casting; - ui.range = casting.range( you ); + ui.range = casting.range( *ui.you ); ui.no_fail = no_fail; ui.no_mana = no_mana; - restore_on_out_of_scope view_offset_prev( you.view_offset ); + restore_on_out_of_scope view_offset_prev( ui.you->view_offset ); return ui.run(); } @@ -3210,14 +3209,14 @@ void target_ui::update_status() // None of the turrets are in range status = Status::OutOfRange; } else if( mode == TargetMode::Fire && - ( !gunmode_checks_common( *you, get_map(), msgbuf, relevant->gun_current_mode() ) || - !gunmode_checks_weapon( *you, get_map(), msgbuf, relevant->gun_current_mode() ) ) + ( !gunmode_checks_common( msgbuf, relevant->gun_current_mode() ) || + !gunmode_checks_weapon( msgbuf, relevant->gun_current_mode() ) ) ) { // NOLINT(bugprone-branch-clone) // Selected gun mode is empty // TODO: it might be some other error, but that's highly unlikely to happen, so a catch-all 'Out of ammo' is fine status = Status::OutOfAmmo; } else if( mode == TargetMode::TurretManual && ( turret->query() != turret_data::status::ready || - !gunmode_checks_common( *you, get_map(), msgbuf, relevant->gun_current_mode() ) ) ) { + !gunmode_checks_common( msgbuf, relevant->gun_current_mode() ) ) ) { status = Status::OutOfAmmo; } else if( ( src == dst ) && !( mode == TargetMode::Spell && casting->is_valid_target( spell_target::self ) ) ) { @@ -4168,9 +4167,9 @@ void target_ui::on_target_accepted( bool harmful ) const } } -bool gunmode_checks_common( avatar &you, const map &m, std::vector &messages, - const gun_mode &gmode ) +bool gunmode_checks_common( std::vector &messages, const gun_mode &gmode ) { + avatar &you = get_avatar(); bool result = true; if( you.has_trait( trait_BRAWLER ) ) { messages.push_back( string_format( _( "Pfft. You are a brawler; using this %s is beneath you." ), @@ -4185,7 +4184,7 @@ bool gunmode_checks_common( avatar &you, const map &m, std::vector result = false; } - const optional_vpart_position vp = m.veh_at( you.pos_bub() ); + const optional_vpart_position vp = get_map().veh_at( you.pos_bub() ); if( vp && vp->vehicle().player_in_control( you ) && ( gmode->is_two_handed( you ) || gmode->has_flag( flag_FIRE_TWOHAND ) ) ) { messages.push_back( string_format( _( "You can't fire your %s while driving." ), @@ -4203,9 +4202,10 @@ bool gunmode_checks_common( avatar &you, const map &m, std::vector return result; } -bool gunmode_checks_weapon( avatar &you, const map &m, std::vector &messages, - const gun_mode &gmode ) +bool gunmode_checks_weapon( std::vector &messages, const gun_mode &gmode ) { + avatar &you = get_avatar(); + const map &m = get_map(); bool result = true; if( !gmode->ammo_sufficient( &you ) && !gmode->has_flag( flag_RELOAD_AND_SHOOT ) ) { diff --git a/src/ranged.h b/src/ranged.h index a93fc5a670d4f..2df15268c3f85 100644 --- a/src/ranged.h +++ b/src/ranged.h @@ -9,12 +9,10 @@ #include "point.h" class aim_activity_actor; -class avatar; class Character; class gun_mode; class item; class item_location; -class map; class spell; class turret_data; class vehicle; @@ -29,27 +27,27 @@ namespace target_handler using trajectory = std::vector; /** Generic target select without fire something */ -trajectory mode_select_only( avatar &you, int range ); +trajectory mode_select_only( int range ); /** * Firing ranged weapon. This mode allows spending moves on aiming. */ -trajectory mode_fire( avatar &you, aim_activity_actor &activity ); +trajectory mode_fire( aim_activity_actor &activity ); /** Throwing item */ -trajectory mode_throw( avatar &you, item &relevant, bool blind_throwing ); +trajectory mode_throw( item &relevant, bool blind_throwing ); /** Reach attacking */ -trajectory mode_reach( avatar &you, item_location weapon ); +trajectory mode_reach( item_location weapon ); /** Manually firing vehicle turret */ -trajectory mode_turret_manual( avatar &you, turret_data &turret ); +trajectory mode_turret_manual( turret_data &turret ); /** Selecting target for turrets (when using vehicle controls) */ -trajectory mode_turrets( avatar &you, vehicle &veh, const std::vector &turrets ); +trajectory mode_turrets( vehicle &veh, const std::vector &turrets ); /** Casting a spell */ -trajectory mode_spell( avatar &you, spell &casting, bool no_fail, bool no_mana ); +trajectory mode_spell( spell &casting, bool no_fail, bool no_mana ); } // namespace target_handler void practice_archery_proficiency( Character &p, const item &relevant ); @@ -61,16 +59,14 @@ int range_with_even_chance_of_good_hit( int dispersion ); * @param messages Used to store messages describing failed checks * @return True if all conditions are true */ -bool gunmode_checks_common( avatar &you, const map &m, std::vector &messages, - const gun_mode &gmode ); +bool gunmode_checks_common( std::vector &messages, const gun_mode &gmode ); /** * Various checks for gunmode when firing a weapon * @param messages Used to store messages describing failed checks * @return True if all conditions are true */ -bool gunmode_checks_weapon( avatar &you, const map &m, std::vector &messages, - const gun_mode &gmode ); +bool gunmode_checks_weapon( std::vector &messages, const gun_mode &gmode ); int throw_cost( const Character &c, const item &to_throw ); diff --git a/src/timed_event.cpp b/src/timed_event.cpp index 5019fda18df48..cfc75a369f725 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -256,7 +256,7 @@ void timed_event::actualize() get_memorial().add( pgettext( "memorial_male", "Water level reached the ceiling." ), pgettext( "memorial_female", "Water level reached the ceiling." ) ); - avatar_action::swim( here, player_character, player_character.pos() ); + avatar_action::swim( player_character.pos() ); } } // flood_buf is filled with correct tiles; now copy them back to here diff --git a/src/turret.cpp b/src/turret.cpp index 3b70b7e93e270..fc58027fa8092 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -417,8 +417,7 @@ bool vehicle::turrets_aim( std::vector &turrets ) } // Get target - target_handler::trajectory trajectory = target_handler::mode_turrets( player_character, *this, - turrets ); + target_handler::trajectory trajectory = target_handler::mode_turrets( *this, turrets ); bool got_target = !trajectory.empty(); if( got_target ) { diff --git a/tests/gates_test.cpp b/tests/gates_test.cpp index ee531245dd5a8..03a34fbd2af9b 100644 --- a/tests/gates_test.cpp +++ b/tests/gates_test.cpp @@ -165,7 +165,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE( here.ter_set( pos, ter_t_door_c ) ); REQUIRE( here.ter( pos ).obj().id == ter_t_door_c->id ); - REQUIRE( avatar_action::move( they, here, tripoint_east ) ); + REQUIRE( avatar_action::move( tripoint_east ) ); THEN( "avatar should spend move points" ) { CHECK( they.get_moves() == -open_move_cost ); @@ -175,7 +175,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE( here.ter_set( pos, ter_t_door_locked ) ); REQUIRE( here.ter( pos ).obj().id == ter_t_door_locked->id ); - REQUIRE_FALSE( avatar_action::move( they, here, tripoint_east ) ); + REQUIRE_FALSE( avatar_action::move( tripoint_east ) ); THEN( "avatar should not spend move points" ) { CHECK( they.get_moves() == 0 ); @@ -188,7 +188,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE( here.ter_set( pos, ter_t_window_no_curtains ) ); REQUIRE( here.ter( pos ).obj().id == ter_t_window_no_curtains->id ); - REQUIRE_FALSE( avatar_action::move( they, here, tripoint_east ) ); + REQUIRE_FALSE( avatar_action::move( tripoint_east ) ); THEN( "avatar should spend move points" ) { CHECK( they.get_moves() == 0 ); @@ -227,7 +227,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE( here.ter_set( pos, ter_t_window_no_curtains ) ); REQUIRE( here.ter( pos ).obj().id == ter_t_window_no_curtains->id ); - REQUIRE( avatar_action::move( they, here, tripoint_east ) ); + REQUIRE( avatar_action::move( tripoint_east ) ); THEN( "avatar should spend move points" ) { CHECK( they.get_moves() == -open_move_cost ); diff --git a/tests/item_test.cpp b/tests/item_test.cpp index bd07b6480e413..ccdb99878054a 100644 --- a/tests/item_test.cpp +++ b/tests/item_test.cpp @@ -866,7 +866,7 @@ TEST_CASE( "module_inheritance", "[item][armor]" ) guy.wear_item( hat_hard ); item_location worn_hat = guy.worn.top_items_loc( guy ).front(); item_location worn_muffs( worn_hat, &worn_hat->only_item() ); - avatar_action::use_item( guy, worn_muffs, "transform" ); + avatar_action::use_item( worn_muffs, "transform" ); CHECK( worn_hat->has_flag( json_flag_DEAF ) ); } diff --git a/tests/move_cost_test.cpp b/tests/move_cost_test.cpp index b851f39ac01f6..cfe714a28b0c3 100644 --- a/tests/move_cost_test.cpp +++ b/tests/move_cost_test.cpp @@ -216,7 +216,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -100 ); } } @@ -225,7 +225,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -200 ); } } @@ -234,7 +234,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 600 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -600 ); } } @@ -251,7 +251,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -100 ); } } @@ -260,7 +260,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -200 ); } } @@ -269,7 +269,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 660 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -660 ); } } @@ -285,7 +285,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 154 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -154 ); } } @@ -294,7 +294,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 309 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -309 ); } } @@ -303,7 +303,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 932 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -932 ); } } @@ -321,7 +321,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -100 ); } } @@ -330,7 +330,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -200 ); } } @@ -339,7 +339,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 803 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -803 ); } } @@ -357,7 +357,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -100 ); } } @@ -366,7 +366,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -200 ); } } @@ -375,7 +375,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 818 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -818 ); } } @@ -392,7 +392,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 154 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -154 ); } } @@ -401,7 +401,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 309 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -309 ); } } @@ -410,7 +410,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1246 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -1246 ); } } @@ -430,7 +430,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1000 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -1000 ); } } @@ -450,7 +450,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1179 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -1179 ); } } @@ -469,7 +469,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1561 ); - avatar_action::move( u, get_map(), point_south ); + avatar_action::move( tripoint_south ); CHECK( u.get_moves() == -1561 ); } } diff --git a/tests/water_movement_test.cpp b/tests/water_movement_test.cpp index 25da7932211b5..d8509996853be 100644 --- a/tests/water_movement_test.cpp +++ b/tests/water_movement_test.cpp @@ -260,7 +260,6 @@ struct swim_scenario { static int swimming_steps( avatar &swimmer ) { - map &here = get_map(); const tripoint left = swimmer.pos(); const tripoint right = left + tripoint_east; int steps = 0; @@ -272,10 +271,10 @@ static int swimming_steps( avatar &swimmer ) while( swimmer.get_stamina() > 0 && !swimmer.has_effect( effect_winded ) && steps < STOP_STEPS ) { if( steps % 2 == 0 ) { REQUIRE( swimmer.pos() == left ); - REQUIRE( avatar_action::move( swimmer, here, tripoint_east ) ); + REQUIRE( avatar_action::move( tripoint_east ) ); } else { REQUIRE( swimmer.pos() == right ); - REQUIRE( avatar_action::move( swimmer, here, tripoint_west ) ); + REQUIRE( avatar_action::move( tripoint_west ) ); } ++steps; REQUIRE( swimmer.get_moves() < last_moves );