Skip to content

Commit

Permalink
Add resolved_ter_id and resolved_furn_id, and replace some instan…
Browse files Browse the repository at this point in the history
…ces of the `int_id` versions of the above.
  • Loading branch information
prharvey committed Dec 27, 2023
1 parent 49a0e8d commit 462ee91
Show file tree
Hide file tree
Showing 69 changed files with 742 additions and 696 deletions.
80 changes: 40 additions & 40 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,21 +1215,21 @@ void hacksaw_activity_actor::start( player_activity &act, Character &/*who*/ )
int moves_before_quality;

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->hacksaw->valid() ) {
if( !testing ) {
debugmsg( "%s hacksaw is invalid", furn_type.id().str() );
debugmsg( "%s hacksaw is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
}

moves_before_quality = to_moves<int>( furn_type->hacksaw->duration() );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->hacksaw->valid() ) {
if( !testing ) {
debugmsg( "%s hacksaw is invalid", ter_type.id().str() );
debugmsg( "%s hacksaw is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -1295,10 +1295,10 @@ void hacksaw_activity_actor::finish( player_activity &act, Character &who )
const activity_data_common *data;

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->hacksaw->valid() ) {
if( !testing ) {
debugmsg( "%s hacksaw is invalid", furn_type.id().str() );
debugmsg( "%s hacksaw is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
Expand All @@ -1316,10 +1316,10 @@ void hacksaw_activity_actor::finish( player_activity &act, Character &who )
data = static_cast<const activity_data_common *>( &*furn_type->hacksaw );
here.furn_set( target, new_furn );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->hacksaw->valid() ) {
if( !testing ) {
debugmsg( "%s hacksaw is invalid", ter_type.id().str() );
debugmsg( "%s hacksaw is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -2253,21 +2253,21 @@ void boltcutting_activity_actor::start( player_activity &act, Character &/*who*/
const map &here = get_map();

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->boltcut->valid() ) {
if( !testing ) {
debugmsg( "%s boltcut is invalid", furn_type.id().str() );
debugmsg( "%s boltcut is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
}

act.moves_total = to_moves<int>( furn_type->boltcut->duration() );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->boltcut->valid() ) {
if( !testing ) {
debugmsg( "%s boltcut is invalid", ter_type.id().str() );
debugmsg( "%s boltcut is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -2306,10 +2306,10 @@ void boltcutting_activity_actor::finish( player_activity &act, Character &who )
const activity_data_common *data;

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->boltcut->valid() ) {
if( !testing ) {
debugmsg( "%s boltcut is invalid", furn_type.id().str() );
debugmsg( "%s boltcut is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
Expand All @@ -2327,10 +2327,10 @@ void boltcutting_activity_actor::finish( player_activity &act, Character &who )
data = static_cast<const activity_data_common *>( &*furn_type->boltcut );
here.furn_set( target, new_furn );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->boltcut->valid() ) {
if( !testing ) {
debugmsg( "%s boltcut is invalid", ter_type.id().str() );
debugmsg( "%s boltcut is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -2454,8 +2454,8 @@ void lockpick_activity_actor::finish( player_activity &act, Character &who )

map &here = get_map();
const tripoint target = here.getlocal( this->target );
const ter_id ter_type = here.ter( target );
const furn_id furn_type = here.furn( target );
const resolved_ter_id ter_type = here.ter( target );
const resolved_furn_id furn_type = here.furn( target );
optional_vpart_position const veh = here.veh_at( target );
int locked_part = -1;
ter_id new_ter_type;
Expand Down Expand Up @@ -2621,7 +2621,7 @@ std::optional<tripoint> lockpick_activity_actor::select_location( avatar &you )
return target;
}

const ter_id terr_type = get_map().ter( *target );
const resolved_ter_id terr_type = get_map().ter( *target );
if( *target == you.pos() ) {
you.add_msg_if_player( m_info, _( "You pick your nose and your sinuses swing open." ) );
} else if( get_creature_tracker().creature_at<npc>( *target ) ) {
Expand Down Expand Up @@ -3950,7 +3950,7 @@ void harvest_activity_actor::start( player_activity &act, Character &who )
map &here = get_map();

if( here.has_furn( target ) ) {
const furn_id furn = here.furn( target );
const resolved_furn_id furn = here.furn( target );

if( furn->has_examine( iexamine::harvest_furn ) ) {
exam_furn = true;
Expand Down Expand Up @@ -5004,21 +5004,21 @@ void oxytorch_activity_actor::start( player_activity &act, Character &/*who*/ )
const map &here = get_map();

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->oxytorch->valid() ) {
if( !testing ) {
debugmsg( "%s oxytorch is invalid", furn_type.id().str() );
debugmsg( "%s oxytorch is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
}

act.moves_total = to_moves<int>( furn_type->oxytorch->duration() );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->oxytorch->valid() ) {
if( !testing ) {
debugmsg( "%s oxytorch is invalid", ter_type.id().str() );
debugmsg( "%s oxytorch is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -5061,10 +5061,10 @@ void oxytorch_activity_actor::finish( player_activity &act, Character &who )
const activity_data_common *data;

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->oxytorch->valid() ) {
if( !testing ) {
debugmsg( "%s oxytorch is invalid", furn_type.id().str() );
debugmsg( "%s oxytorch is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
Expand All @@ -5082,10 +5082,10 @@ void oxytorch_activity_actor::finish( player_activity &act, Character &who )
data = static_cast<const activity_data_common *>( &*furn_type->oxytorch );
here.furn_set( target, new_furn );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->oxytorch->valid() ) {
if( !testing ) {
debugmsg( "%s oxytorch is invalid", ter_type.id().str() );
debugmsg( "%s oxytorch is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -5374,10 +5374,10 @@ void prying_activity_actor::start( player_activity &act, Character &who )
const map &here = get_map();

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->prying->valid() ) {
if( !testing ) {
debugmsg( "%s prying is invalid", furn_type.id().str() );
debugmsg( "%s prying is invalid", furn_type->id.str() );
}
act.set_to_null();
return;
Expand All @@ -5387,10 +5387,10 @@ void prying_activity_actor::start( player_activity &act, Character &who )
act.moves_total = to_moves<int>(
prying_time( *furn_type->prying, tool, who ) );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->prying->valid() ) {
if( !testing ) {
debugmsg( "%s prying is invalid", ter_type.id().str() );
debugmsg( "%s prying is invalid", ter_type->id.str() );
}
act.set_to_null();
return;
Expand Down Expand Up @@ -5487,10 +5487,10 @@ void prying_activity_actor::handle_prying( Character &who )
};

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->prying->valid() ) {
if( !testing ) {
debugmsg( "%s prying is invalid", furn_type.id().str() );
debugmsg( "%s prying is invalid", furn_type->id.str() );
}
return;
}
Expand All @@ -5511,10 +5511,10 @@ void prying_activity_actor::handle_prying( Character &who )

here.furn_set( target, new_furn );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->prying->valid() ) {
if( !testing ) {
debugmsg( "%s prying is invalid", ter_type.id().str() );
debugmsg( "%s prying is invalid", ter_type->id.str() );
}
return;
}
Expand Down Expand Up @@ -5576,10 +5576,10 @@ void prying_activity_actor::handle_prying_nails( Character &who )
const activity_data_common *data;

if( here.has_furn( target ) ) {
const furn_id furn_type = here.furn( target );
const resolved_furn_id furn_type = here.furn( target );
if( !furn_type->prying->valid() ) {
if( !testing ) {
debugmsg( "%s prying is invalid", furn_type.id().str() );
debugmsg( "%s prying is invalid", furn_type->id.str() );
}
return;
}
Expand All @@ -5595,10 +5595,10 @@ void prying_activity_actor::handle_prying_nails( Character &who )
data = static_cast<const activity_data_common *>( &*furn_type->prying );
here.furn_set( target, new_furn );
} else if( !here.ter( target )->is_null() ) {
const ter_id ter_type = here.ter( target );
const resolved_ter_id ter_type = here.ter( target );
if( !ter_type->prying->valid() ) {
if( !testing ) {
debugmsg( "%s prying is invalid", ter_type.id().str() );
debugmsg( "%s prying is invalid", ter_type->id.str() );
}
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,11 +824,11 @@ construction const *_find_prereq( tripoint_bub_ms const &loc, construction_id co
bool already_done( construction const &build, tripoint_bub_ms const &loc )
{
map &here = get_map();
const furn_id furn = here.furn( loc );
const ter_id ter = here.ter( loc );
const resolved_furn_id furn = here.furn( loc );
const resolved_ter_id ter = here.ter( loc );
return !build.post_terrain.empty() &&
( ( !build.post_is_furniture && ter_id( build.post_terrain ) == ter ) ||
( build.post_is_furniture && furn_id( build.post_terrain ) == furn ) );
( ( !build.post_is_furniture && resolved_ter_id( build.post_terrain ) == ter ) ||
( build.post_is_furniture && resolved_furn_id( build.post_terrain ) == furn ) );
}

} // namespace
Expand Down Expand Up @@ -2448,7 +2448,7 @@ static bool chop_tree_activity( Character &you, const tripoint_bub_ms &src_loc )
you.consume_charges( best_qual, best_qual.type->charges_to_use() );
}
map &here = get_map();
const ter_id ter = here.ter( src_loc );
const resolved_ter_id ter = here.ter( src_loc );
if( here.has_flag( ter_furn_flag::TFLAG_TREE, src_loc ) ) {
you.assign_activity( chop_tree_activity_actor( moves, item_location( you, &best_qual ) ) );
you.activity.placement = here.getglobal( src_loc );
Expand Down Expand Up @@ -2644,7 +2644,7 @@ static std::unordered_set<tripoint_abs_ms> generic_multi_activity_locations(
continue;
}
if( act_id == ACT_MULTIPLE_FISH ) {
const ter_id terrain_id = here.ter( set_pt );
const resolved_ter_id terrain_id = here.ter( set_pt );
if( !terrain_id.obj().has_flag( ter_furn_flag::TFLAG_DEEP_WATER ) ) {
it2 = src_set.erase( it2 );
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,27 +913,27 @@ void game::draw_radiation_override( const tripoint &, const int )
#endif

#if defined(TILES)
void game::draw_terrain_override( const tripoint &p, const ter_id &id )
void game::draw_terrain_override( const tripoint &p, const resolved_ter_id &id )
{
if( use_tiles ) {
tilecontext->init_draw_terrain_override( p, id );
}
}
#else
void game::draw_terrain_override( const tripoint &, const ter_id & )
void game::draw_terrain_override( const tripoint &, const resolved_ter_id & )
{
}
#endif

#if defined(TILES)
void game::draw_furniture_override( const tripoint &p, const furn_id &id )
void game::draw_furniture_override( const tripoint &p, const resolved_furn_id &id )
{
if( use_tiles ) {
tilecontext->init_draw_furniture_override( p, id );
}
}
#else
void game::draw_furniture_override( const tripoint &, const furn_id & )
void game::draw_furniture_override( const tripoint &, const resolved_furn_id & )
{
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,8 +1893,8 @@ void avatar::try_to_sleep( const time_duration &dur )
map &here = get_map();
const optional_vpart_position vp = here.veh_at( pos() );
const trap &trap_at_pos = here.tr_at( pos() );
const ter_id ter_at_pos = here.ter( pos() );
const furn_id furn_at_pos = here.furn( pos() );
const resolved_ter_id ter_at_pos = here.ter( pos() );
const resolved_furn_id furn_at_pos = here.furn( pos() );
bool plantsleep = false;
bool fungaloid_cosplay = false;
bool websleep = false;
Expand Down
2 changes: 1 addition & 1 deletion src/build_reqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ struct parameterized_build_reqs {

build_reqs get_build_reqs_for_furn_ter_ids(
const std::pair<std::map<ter_id, int>, std::map<furn_id, int>> &changed_ids,
ter_id const &base_ter = t_dirt );
ter_id const &base_ter = t_dirt->id );

#endif // CATA_SRC_BUILD_REQS_H
Loading

0 comments on commit 462ee91

Please sign in to comment.