Skip to content

Commit

Permalink
Remove extern ter ids (CleverRaven#72766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Procyonae authored Apr 4, 2024
1 parent 15b95a2 commit e9f4fbd
Show file tree
Hide file tree
Showing 58 changed files with 1,518 additions and 1,592 deletions.
31 changes: 20 additions & 11 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ static const skill_id skill_traps( "traps" );

static const species_id species_ZOMBIE( "ZOMBIE" );

static const ter_str_id ter_t_card_reader_broken( "t_card_reader_broken" );
static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_dirtmound( "t_dirtmound" );
static const ter_str_id ter_t_door_c( "t_door_c" );
static const ter_str_id ter_t_door_locked_alarm( "t_door_locked_alarm" );
static const ter_str_id ter_t_door_metal_c( "t_door_metal_c" );
static const ter_str_id ter_t_door_metal_locked( "t_door_metal_locked" );
static const ter_str_id ter_t_stump( "t_stump" );
static const ter_str_id ter_t_trunk( "t_trunk" );
static const ter_str_id ter_t_underbrush_harvested_autumn( "t_underbrush_harvested_autumn" );
static const ter_str_id ter_t_underbrush_harvested_spring( "t_underbrush_harvested_spring" );
static const ter_str_id ter_t_underbrush_harvested_summer( "t_underbrush_harvested_summer" );
Expand Down Expand Up @@ -814,10 +823,10 @@ void hacking_activity_actor::finish( player_activity &act, Character &who )
} else if( type == hack_type::DOOR ) {
who.add_msg_if_player( _( "You activate the panel!" ) );
who.add_msg_if_player( m_good, _( "The nearby doors unlock." ) );
here.ter_set( examp, t_card_reader_broken );
here.ter_set( examp, ter_t_card_reader_broken );
for( const tripoint &tmp : here.points_in_radius( examp, 3 ) ) {
if( here.ter( tmp ) == t_door_metal_locked ) {
here.ter_set( tmp, t_door_metal_c );
if( here.ter( tmp ) == ter_t_door_metal_locked ) {
here.ter_set( tmp, ter_t_door_metal_c );
}
}
}
Expand Down Expand Up @@ -2811,7 +2820,7 @@ void lockpick_activity_actor::finish( player_activity &act, Character &who )
you->practice( skill_traps, xp_gain );
}

if( !perfect && ter_type == t_door_locked_alarm && ( lock_roll + dice( 1, 30 ) ) > pick_roll ) {
if( !perfect && ter_type == ter_t_door_locked_alarm && ( lock_roll + dice( 1, 30 ) ) > pick_roll ) {
sounds::sound( who.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), true, "environment",
"alarm" );
}
Expand Down Expand Up @@ -2858,7 +2867,7 @@ std::optional<tripoint> lockpick_activity_actor::select_location( avatar &you )
} else if( get_creature_tracker().creature_at<npc>( *target ) ) {
you.add_msg_if_player( m_info,
_( "You can pick your friends, and you can\npick your nose, but you can't pick\nyour friend's nose." ) );
} else if( terr_type == t_door_c ) {
} else if( terr_type == ter_t_door_c ) {
you.add_msg_if_player( m_info, _( "That door isn't locked." ) );
} else {
you.add_msg_if_player( m_info, _( "That cannot be picked." ) );
Expand Down Expand Up @@ -6213,11 +6222,11 @@ void chop_logs_activity_actor::finish( player_activity &act, Character &who )
int log_quan;
int stick_quan;
int splint_quan;
if( here.ter( pos ) == t_trunk ) {
if( here.ter( pos ) == ter_t_trunk ) {
log_quan = rng( 2, 3 );
stick_quan = rng( 0, 3 );
splint_quan = 0;
} else if( here.ter( pos ) == t_stump ) {
} else if( here.ter( pos ) == ter_t_stump ) {
log_quan = rng( 0, 2 );
stick_quan = 0;
splint_quan = rng( 5, 15 );
Expand All @@ -6241,7 +6250,7 @@ void chop_logs_activity_actor::finish( player_activity &act, Character &who )
obj.set_var( "activity_var", who.name );
here.add_item_or_charges( pos, obj );
}
here.ter_set( pos, t_dirt );
here.ter_set( pos, ter_t_dirt );
who.add_msg_if_player( m_good, _( "You finish chopping wood." ) );

act.set_to_null();
Expand Down Expand Up @@ -6399,10 +6408,10 @@ void chop_tree_activity_actor::finish( player_activity &act, Character &who )
std::vector<tripoint> tree = line_to( pos, to, rng( 1, 8 ) );
for( const tripoint &elem : tree ) {
here.batter( elem, 300, 5 );
here.ter_set( elem, t_trunk );
here.ter_set( elem, ter_t_trunk );
}

here.ter_set( pos, t_stump );
here.ter_set( pos, ter_t_stump );
who.add_msg_if_player( m_good, _( "You finish chopping down a tree." ) );
// sound of falling tree
here.collapse_at( pos, false, true, false );
Expand Down Expand Up @@ -6445,7 +6454,7 @@ void churn_activity_actor::finish( player_activity &act, Character &who )
{
map &here = get_map();
who.add_msg_if_player( _( "You finish churning up the earth here." ) );
here.ter_set( here.getlocal( act.placement ), t_dirtmound );
here.ter_set( here.getlocal( act.placement ), ter_t_dirtmound );
// Go back to what we were doing before
// could be player zone activity, or could be NPC multi-farming
act.set_to_null();
Expand Down
7 changes: 5 additions & 2 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ static const species_id species_FERAL( "FERAL" );
static const species_id species_HUMAN( "HUMAN" );
static const species_id species_ZOMBIE( "ZOMBIE" );

static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_tree( "t_tree" );

static const trait_id trait_DEBUG_HS( "DEBUG_HS" );
static const trait_id trait_SPIRITUAL( "SPIRITUAL" );
static const trait_id trait_STOCKY_TROGLO( "STOCKY_TROGLO" );
Expand Down Expand Up @@ -1670,7 +1673,7 @@ void activity_handlers::pickaxe_finish( player_activity *act, Character *you )
if( you->is_avatar() ) {
const int helpersize = get_player_character().get_num_crafting_helpers( 3 );
if( here.is_bashable( pos ) && here.has_flag( ter_furn_flag::TFLAG_SUPPORTS_ROOF, pos ) &&
here.ter( pos ) != t_tree ) {
here.ter( pos ) != ter_t_tree ) {
// Tunneling through solid rock is sweaty, backbreaking work
// Betcha wish you'd opted for the J-Hammer
if( you->has_trait( trait_STOCKY_TROGLO ) ) {
Expand Down Expand Up @@ -3273,7 +3276,7 @@ void activity_handlers::plant_seed_finish( player_activity *act, Character *you
if( here.has_flag_furn( seed_id->seed->required_terrain_flag, examp ) ) {
here.furn_set( examp, furn_str_id( here.furn( examp )->plant->transform ) );
} else if( seed_id->seed->required_terrain_flag == ter_furn_flag::TFLAG_PLANTABLE ) {
here.set( examp, t_dirt, f_plant_seed );
here.set( examp, ter_t_dirt, f_plant_seed );
} else {
here.furn_set( examp, f_plant_seed );
}
Expand Down
9 changes: 6 additions & 3 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ static const quality_id qual_WELD( "WELD" );

static const requirement_id requirement_data_mining_standard( "mining_standard" );

static const ter_str_id ter_t_stump( "t_stump" );
static const ter_str_id ter_t_trunk( "t_trunk" );

static const trait_id trait_SAPROPHAGE( "SAPROPHAGE" );
static const trait_id trait_SAPROVORE( "SAPROVORE" );

Expand Down Expand Up @@ -1167,8 +1170,8 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara
}
}
if( act == ACT_MULTIPLE_CHOP_TREES ) {
if( here.has_flag( ter_furn_flag::TFLAG_TREE, src_loc ) || here.ter( src_loc ) == t_trunk ||
here.ter( src_loc ) == t_stump ) {
if( here.has_flag( ter_furn_flag::TFLAG_TREE, src_loc ) || here.ter( src_loc ) == ter_t_trunk ||
here.ter( src_loc ) == ter_t_stump ) {
if( you.has_quality( qual_AXE ) ) {
return activity_reason_info::ok( do_activity_reason::NEEDS_TREE_CHOPPING );
} else {
Expand Down Expand Up @@ -2456,7 +2459,7 @@ static bool chop_tree_activity( Character &you, const tripoint_bub_ms &src_loc )
you.assign_activity( chop_tree_activity_actor( moves, item_location( you, &best_qual ) ) );
you.activity.placement = here.getglobal( src_loc );
return true;
} else if( ter == t_trunk || ter == t_stump ) {
} else if( ter == ter_t_trunk || ter == ter_t_stump ) {
you.assign_activity( chop_logs_activity_actor( moves, item_location( you, &best_qual ) ) );
you.activity.placement = here.getglobal( src_loc );
return true;
Expand Down
15 changes: 10 additions & 5 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ static const move_mode_id move_mode_walk( "walk" );

static const string_id<monfaction> monfaction_player( "player" );

static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_dirtmound( "t_dirtmound" );
static const ter_str_id ter_t_floor( "t_floor" );
static const ter_str_id ter_t_grass( "t_grass" );
static const ter_str_id ter_t_pit( "t_pit" );
static const ter_str_id ter_t_pit_shallow( "t_pit_shallow" );

static const trait_id trait_ARACHNID_ARMS( "ARACHNID_ARMS" );
static const trait_id trait_ARACHNID_ARMS_OK( "ARACHNID_ARMS_OK" );
static const trait_id trait_CENOBITE( "CENOBITE" );
Expand Down Expand Up @@ -1929,10 +1936,8 @@ void avatar::try_to_sleep( const time_duration &dur )
bool watersleep = false;
if( has_trait( trait_CHLOROMORPH ) ) {
plantsleep = true;
if( ( ter_at_pos == t_dirt || ter_at_pos == t_pit ||
ter_at_pos == t_dirtmound || ter_at_pos == t_pit_shallow ||
ter_at_pos == t_grass ) && !vp &&
furn_at_pos == f_null ) {
const std::unordered_set<ter_str_id> comfy_ters = { ter_t_dirt, ter_t_dirtmound, ter_t_grass, ter_t_pit, ter_t_pit_shallow };
if( comfy_ters.find( ter_at_pos.id() ) != comfy_ters.end() && !vp && furn_at_pos == f_null ) {
add_msg_if_player( m_good, _( "You relax as your roots embrace the soil." ) );
} else if( vp ) {
add_msg_if_player( m_bad, _( "It's impossible to sleep in this wheeled pot!" ) );
Expand Down Expand Up @@ -2004,7 +2009,7 @@ void avatar::try_to_sleep( const time_duration &dur )
vp.part_with_feature( "BED", true ) ) ) {
add_msg_if_player( m_good, _( "This is a comfortable place to sleep." ) );
} else if( !plantsleep && !fungaloid_cosplay && !watersleep ) {
if( !vp && ter_at_pos != t_floor ) {
if( !vp && ter_at_pos != ter_t_floor ) {
add_msg_if_player( ter_at_pos.obj().movecost <= 2 ?
_( "It's a little hard to get to sleep on this %s." ) :
_( "It's hard to get to sleep on this %s." ),
Expand Down
33 changes: 23 additions & 10 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ static const move_mode_id move_mode_prone( "prone" );

static const skill_id skill_swimming( "swimming" );

static const ter_str_id ter_t_door_bar_locked( "t_door_bar_locked" );
static const ter_str_id ter_t_door_locked( "t_door_locked" );
static const ter_str_id ter_t_door_locked_alarm( "t_door_locked_alarm" );
static const ter_str_id ter_t_door_locked_interior( "t_door_locked_interior" );
static const ter_str_id ter_t_door_locked_peep( "t_door_locked_peep" );
static const ter_str_id ter_t_fault( "t_fault" );
static const ter_str_id ter_t_grass( "t_grass" );
static const ter_str_id ter_t_grass_alien( "t_grass_alien" );
static const ter_str_id ter_t_grass_dead( "t_grass_dead" );
static const ter_str_id ter_t_grass_golf( "t_grass_golf" );
static const ter_str_id ter_t_grass_white( "t_grass_white" );

static const trait_id trait_GRAZER( "GRAZER" );
static const trait_id trait_RUMINANT( "RUMINANT" );
static const trait_id trait_SHELL2( "SHELL2" );
Expand Down Expand Up @@ -294,7 +306,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
const tripoint minp = tripoint( 0, 0, you.posz() );
const tripoint maxp = tripoint( MAPSIZE_X, MAPSIZE_Y, you.posz() );
for( const tripoint &pt : m.points_in_rectangle( minp, maxp ) ) {
if( m.ter( pt ) == t_fault ) {
if( m.ter( pt ) == ter_t_fault ) {
int dist = rl_dist( pt, you.pos() );
if( dist < curdist ) {
curdist = dist;
Expand Down Expand Up @@ -534,12 +546,12 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
if( waste_moves ) {
you.mod_moves( -you.get_speed() );
}
} else if( m.ter( dest_loc ) == t_door_locked || m.ter( dest_loc ) == t_door_locked_peep ||
m.ter( dest_loc ) == t_door_locked_alarm || m.ter( dest_loc ) == t_door_locked_interior ) {
} else if( m.ter( dest_loc ) == ter_t_door_bar_locked ) {
add_msg( _( "You rattle the bars but the door is locked!" ) );
} else if( const std::unordered_set<ter_str_id> locked_doors = { ter_t_door_locked, ter_t_door_locked_peep, ter_t_door_locked_alarm, ter_t_door_locked_interior };
locked_doors.find( m.ter( dest_loc ).id() ) != locked_doors.end() ) {
// Don't drain move points for learning something you could learn just by looking
add_msg( _( "That door is locked!" ) );
} else if( m.ter( dest_loc ) == t_door_bar_locked ) {
add_msg( _( "You rattle the bars but the door is locked!" ) );
}
return false;
}
Expand Down Expand Up @@ -876,7 +888,7 @@ bool avatar_action::eat_here( avatar &you )
add_msg( _( "You're too full to eat the leaves from the %s." ), here.ter( you.pos() )->name() );
return true;
} else {
here.ter_set( you.pos(), t_grass );
here.ter_set( you.pos(), ter_t_grass );
item food( "underbrush", calendar::turn, 1 );
you.assign_activity( consume_activity_actor( food ) );
return true;
Expand Down Expand Up @@ -909,16 +921,17 @@ bool avatar_action::eat_here( avatar &you )
}
}
if( you.has_active_mutation( trait_GRAZER ) ) {
if( here.ter( you.pos() ) == t_grass_golf || here.ter( you.pos() ) == t_grass ) {
const ter_id &ter_underfoot = here.ter( you.pos() );
if( ter_underfoot == ter_t_grass_golf || ter_underfoot == ter_t_grass ) {
add_msg( _( "This grass is too short to graze." ) );
return true;
} else if( here.ter( you.pos() ) == t_grass_dead ) {
} else if( ter_underfoot == ter_t_grass_dead ) {
add_msg( _( "This grass is dead and too mangled for you to graze." ) );
return true;
} else if( here.ter( you.pos() ) == t_grass_white ) {
} else if( ter_underfoot == ter_t_grass_white ) {
add_msg( _( "This grass is tainted with paint and thus inedible." ) );
return true;
} else if( here.ter( you.pos() ) == t_grass_alien ) {
} else if( ter_underfoot == ter_t_grass_alien ) {
add_msg( _( "This grass is razor sharp and would probably shred your mouth." ) );
return true;
}
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 = ter_str_id( "t_dirt" ).id() );

#endif // CATA_SRC_BUILD_REQS_H
12 changes: 7 additions & 5 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
static const efftype_id effect_ridden( "ridden" );

static const itype_id itype_corpse( "corpse" );

static const trait_id trait_INATTENTIVE( "INATTENTIVE" );

static const trap_str_id tr_unfinished_construction( "tr_unfinished_construction" );

static const std::string ITEM_HIGHLIGHT( "highlight_item" );
Expand Down Expand Up @@ -4839,15 +4841,15 @@ void cata_tiles::get_terrain_orientation( const tripoint &p, int &rota, int &sub
{
map &here = get_map();
const bool overridden = ter_override.find( p ) != ter_override.end();
const auto ter = [&]( const tripoint & q, const bool invis ) -> ter_id {
const auto override = ter_override.find( q );
return override != ter_override.end() ? override->second :
( !overridden || !invis ) ? here.ter( q ) : t_null;
const auto ter = [&]( const tripoint & q, const bool invis ) -> ter_str_id {
const auto override_it = ter_override.find( q );
return override_it != ter_override.end() ? override_it->second.id() :
( !overridden || !invis ) ? here.ter( q ).id() : ter_str_id::NULL_ID();
};

// get terrain at x,y
const ter_id tid = ter( p, invisible[0] );
if( tid == t_null ) {
if( tid == ter_str_id::NULL_ID() ) {
subtile = 0;
rota = 0;
return;
Expand Down
12 changes: 9 additions & 3 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ static const species_id species_HUMAN( "HUMAN" );

static const start_location_id start_location_sloc_shelter_a( "sloc_shelter_a" );

static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_dirtmound( "t_dirtmound" );
static const ter_str_id ter_t_grass( "t_grass" );
static const ter_str_id ter_t_pit( "t_pit" );
static const ter_str_id ter_t_pit_shallow( "t_pit_shallow" );

static const trait_id trait_ADRENALINE( "ADRENALINE" );
static const trait_id trait_ANTENNAE( "ANTENNAE" );
static const trait_id trait_BADBACK( "BADBACK" );
Expand Down Expand Up @@ -5647,12 +5653,12 @@ Character::comfort_response_t Character::base_comfort_value( const tripoint_bub_
comfort = static_cast<int>( comfort_level::impossible );
} else {
// It's very easy for Chloromorphs to get to sleep on soil!
if( ter_at_pos == t_dirt || ter_at_pos == t_pit || ter_at_pos == t_dirtmound ||
ter_at_pos == t_pit_shallow ) {
const std::unordered_set<ter_str_id> very_comfy_ters = { ter_t_dirt, ter_t_dirtmound, ter_t_pit, ter_t_pit_shallow };
if( very_comfy_ters.find( ter_at_pos.id() ) != very_comfy_ters.end() ) {
comfort += static_cast<int>( comfort_level::very_comfortable );
}
// Not as much if you have to dig through stuff first
else if( ter_at_pos == t_grass ) {
else if( ter_at_pos == ter_t_grass ) {
comfort += static_cast<int>( comfort_level::comfortable );
}
// Sleep ain't happening
Expand Down
Loading

0 comments on commit e9f4fbd

Please sign in to comment.