Skip to content

Commit

Permalink
typed tripoints in iexamine functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mqrause committed Sep 29, 2024
1 parent 26de5a1 commit 5ff6c30
Show file tree
Hide file tree
Showing 21 changed files with 349 additions and 367 deletions.
4 changes: 2 additions & 2 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4102,7 +4102,7 @@ void workout_activity_actor::serialize( JsonOut &jsout ) const

std::unique_ptr<activity_actor> workout_activity_actor::deserialize( JsonValue &jsin )
{
workout_activity_actor actor = workout_activity_actor( tripoint_zero );
workout_activity_actor actor{ tripoint_bub_ms() };

JsonObject data = jsin.get_object();

Expand Down Expand Up @@ -4370,7 +4370,7 @@ void harvest_activity_actor::serialize( JsonOut &jsout ) const

std::unique_ptr<activity_actor> harvest_activity_actor::deserialize( JsonValue &jsin )
{
harvest_activity_actor actor( tripoint_zero );
harvest_activity_actor actor{ tripoint_bub_ms() };

JsonObject jsobj = jsin.get_object();
jsobj.read( "target", actor.target );
Expand Down
10 changes: 5 additions & 5 deletions src/activity_actor_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ class try_sleep_activity_actor : public activity_actor
class safecracking_activity_actor : public activity_actor
{
public:
explicit safecracking_activity_actor( const tripoint &safe ) : safe( safe ) {};
explicit safecracking_activity_actor( const tripoint_bub_ms &safe ) : safe( safe ) {};

activity_id get_type() const override {
return activity_id( "ACT_CRACKING" );
Expand All @@ -889,7 +889,7 @@ class safecracking_activity_actor : public activity_actor
static std::unique_ptr<activity_actor> deserialize( JsonValue &jsin );

private:
tripoint safe;
tripoint_bub_ms safe;
int exp_step = 0;

bool can_resume_with_internal( const activity_actor &other,
Expand Down Expand Up @@ -986,7 +986,7 @@ class workout_activity_actor : public activity_actor
int elapsed = 0;

public:
explicit workout_activity_actor( const tripoint &loc ) : location( loc ) {}
explicit workout_activity_actor( const tripoint_bub_ms &loc ) : location( loc ) {}

// can assume different sub-activities
activity_id get_type() const override {
Expand Down Expand Up @@ -1120,7 +1120,7 @@ class stash_activity_actor: public activity_actor
class harvest_activity_actor : public activity_actor
{
public:
explicit harvest_activity_actor( const tripoint &target,
explicit harvest_activity_actor( const tripoint_bub_ms &target,
bool auto_forage = false ) :
target( target ), auto_forage( auto_forage ) {};

Expand All @@ -1140,7 +1140,7 @@ class harvest_activity_actor : public activity_actor
static std::unique_ptr<activity_actor> deserialize( JsonValue &jsin );

private:
tripoint target;
tripoint_bub_ms target;
bool exam_furn = false;
bool nectar = false;
bool auto_forage = false;
Expand Down
10 changes: 5 additions & 5 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1666,8 +1666,8 @@ void activity_handlers::fill_liquid_do_turn( player_activity *act, Character *yo
you->pour_into( act_ref.targets.at( 0 ), liquid, true );
break;
case liquid_target_type::MAP:
if( iexamine::has_keg( act_ref.coords.at( 1 ) ) ) {
iexamine::pour_into_keg( act_ref.coords.at( 1 ), liquid );
if( iexamine::has_keg( tripoint_bub_ms( act_ref.coords.at( 1 ) ) ) ) {
iexamine::pour_into_keg( tripoint_bub_ms( act_ref.coords.at( 1 ) ), liquid );
} else {
here.add_item_or_charges( act_ref.coords.at( 1 ), liquid );
you->add_msg_if_player( _( "You pour %1$s onto the ground." ), liquid.tname() );
Expand Down Expand Up @@ -2893,7 +2893,7 @@ void activity_handlers::armor_layers_do_turn( player_activity *, Character *you

void activity_handlers::atm_do_turn( player_activity *, Character *you )
{
iexamine::atm( *you, you->pos() );
iexamine::atm( *you, you->pos_bub() );
}

// fish-with-rod fish catching function.
Expand Down Expand Up @@ -3569,15 +3569,15 @@ void activity_handlers::fertilize_plot_do_turn( player_activity *act, Character
const auto reject_tile = [&]( const tripoint_bub_ms & tile ) {
check_fertilizer();
// TODO: fix point types
ret_val<void> can_fert = iexamine::can_fertilize( *you, tile.raw(), fertilizer );
ret_val<void> can_fert = iexamine::can_fertilize( *you, tile, fertilizer );
return !can_fert.success();
};

const auto fertilize = [&]( Character & you, const tripoint_bub_ms & tile ) {
check_fertilizer();
if( have_fertilizer() ) {
// TODO: fix point types
iexamine::fertilize_plant( you, tile.raw(), fertilizer );
iexamine::fertilize_plant( you, tile, fertilizer );
if( !have_fertilizer() ) {
add_msg( m_info, _( "You have run out of %s." ), item::nname( fertilizer ) );
}
Expand Down
6 changes: 3 additions & 3 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3002,10 +3002,10 @@ static bool generic_multi_activity_do(
( reason == do_activity_reason::NEEDS_CUT_HARVESTING ) ) &&
here.has_flag_furn( ter_furn_flag::TFLAG_GROWTH_HARVEST, src_loc ) ) {
// TODO: fix point types
iexamine::harvest_plant( you, src_loc.raw(), true );
iexamine::harvest_plant( you, src_loc, true );
} else if( ( reason == do_activity_reason::NEEDS_CLEARING ) &&
here.has_flag_furn( ter_furn_flag::TFLAG_GROWTH_OVERGROWN, src_loc ) ) {
iexamine::clear_overgrown( you, src_loc.raw() );
iexamine::clear_overgrown( you, src_loc );
} else if( reason == do_activity_reason::NEEDS_TILLING &&
here.has_flag( ter_furn_flag::TFLAG_PLOWABLE, src_loc ) &&
you.has_quality( qual_DIG, 1 ) && !here.has_furn( src_loc ) ) {
Expand All @@ -3029,7 +3029,7 @@ static bool generic_multi_activity_do(
continue;
}
// TODO: fix point types
iexamine::plant_seed( you, src_loc.raw(), itype_id( seed ) );
iexamine::plant_seed( you, src_loc, itype_id( seed ) );
you.backlog.emplace_front( act_id );
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10503,7 +10503,7 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool
if( !shifting_furniture && !pushing && is_dangerous_tile( dest_loc ) ) {
std::vector<std::string> harmful_stuff = get_dangerous_tile( dest_loc );
if( harmful_stuff.size() == 1 && harmful_stuff[0] == "ledge" ) {
iexamine::ledge( u, dest_loc );
iexamine::ledge( u, tripoint_bub_ms( dest_loc ) );
return true;
} else if( get_option<std::string>( "DANGEROUS_TERRAIN_WARNING_PROMPT" ) == "ALWAYS" &&
!prompt_dangerous_tile( dest_loc ) ) {
Expand Down Expand Up @@ -10912,7 +10912,7 @@ point game::place_player( const tripoint &dest_loc, bool quick )

const std::string forage_type = get_option<std::string>( "AUTO_FORAGING" );
if( forage_type != "off" ) {
const auto forage = [&]( const tripoint & pos ) {
const auto forage = [&]( const tripoint_bub_ms & pos ) {
const ter_t &xter_t = *m.ter( pos );
const furn_t &xfurn_t = *m.furn( pos );
const bool forage_everything = forage_type == "all";
Expand All @@ -10939,7 +10939,7 @@ point game::place_player( const tripoint &dest_loc, bool quick )
};

for( const direction &elem : adjacentDir ) {
forage( u.pos() + displace_XY( elem ) );
forage( u.pos_bub() + displace_XY( elem ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2732,7 +2732,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character,
break;

case ACTION_WORKOUT:
player_character.assign_activity( workout_activity_actor( player_character.pos() ) );
player_character.assign_activity( workout_activity_actor( player_character.pos_bub() ) );
break;

case ACTION_SUICIDE:
Expand Down
10 changes: 5 additions & 5 deletions src/handle_liquid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,17 @@ static bool get_liquid_target( item &liquid, const item *const source, const int
}
}

for( const tripoint &target_pos : here.points_in_radius( player_character.pos(), 1 ) ) {
for( const tripoint_bub_ms &target_pos : here.points_in_radius( player_character.pos_bub(), 1 ) ) {
if( !iexamine::has_keg( target_pos ) ) {
continue;
}
if( source_pos != nullptr && *source_pos == target_pos ) {
if( source_pos != nullptr && *source_pos == target_pos.raw() ) {
continue;
}
const std::string dir = direction_name( direction_from( player_character.pos(), target_pos ) );
const std::string dir = direction_name( direction_from( player_character.pos_bub(), target_pos ) );
menu.addentry( -1, true, MENU_AUTOASSIGN, _( "Pour into an adjacent keg (%s)" ), dir );
actions.emplace_back( [ &, target_pos]() {
target.pos = target_pos;
target.pos = target_pos.raw();
target.dest_opt = LD_KEG;
} );
}
Expand Down Expand Up @@ -437,7 +437,7 @@ bool perform_liquid_transfer( item &liquid, const tripoint *const source_pos,
serialize_liquid_target( player_character.activity, target.pos );
} else {
if( target.dest_opt == LD_KEG ) {
iexamine::pour_into_keg( target.pos, liquid );
iexamine::pour_into_keg( tripoint_bub_ms( target.pos ), liquid );
} else {
here.add_item_or_charges( target.pos, liquid );
liquid.charges = 0;
Expand Down
Loading

0 comments on commit 5ff6c30

Please sign in to comment.