diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 90e4939e5b3d8..292152ac651cd 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -1215,10 +1215,10 @@ 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; @@ -1226,10 +1226,10 @@ void hacksaw_activity_actor::start( player_activity &act, Character &/*who*/ ) moves_before_quality = to_moves( 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; @@ -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; @@ -1316,10 +1316,10 @@ void hacksaw_activity_actor::finish( player_activity &act, Character &who ) data = static_cast( &*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; @@ -2253,10 +2253,10 @@ 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; @@ -2264,10 +2264,10 @@ void boltcutting_activity_actor::start( player_activity &act, Character &/*who*/ act.moves_total = to_moves( 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; @@ -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; @@ -2327,10 +2327,10 @@ void boltcutting_activity_actor::finish( player_activity &act, Character &who ) data = static_cast( &*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; @@ -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; @@ -2621,7 +2621,7 @@ std::optional 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( *target ) ) { @@ -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; @@ -5004,10 +5004,10 @@ 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; @@ -5015,10 +5015,10 @@ void oxytorch_activity_actor::start( player_activity &act, Character &/*who*/ ) act.moves_total = to_moves( 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; @@ -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; @@ -5082,10 +5082,10 @@ void oxytorch_activity_actor::finish( player_activity &act, Character &who ) data = static_cast( &*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; @@ -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; @@ -5387,10 +5387,10 @@ void prying_activity_actor::start( player_activity &act, Character &who ) act.moves_total = to_moves( 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; @@ -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; } @@ -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; } @@ -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; } @@ -5595,10 +5595,10 @@ void prying_activity_actor::handle_prying_nails( Character &who ) data = static_cast( &*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; } diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 68681f09a47f1..80e14c30a72b8 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -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 @@ -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 ); @@ -2644,7 +2644,7 @@ static std::unordered_set 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 { diff --git a/src/animation.cpp b/src/animation.cpp index e775652801df6..95432892e144f 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -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 diff --git a/src/avatar.cpp b/src/avatar.cpp index 8f23fbd6a04ba..a4b105e84821a 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -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; diff --git a/src/build_reqs.h b/src/build_reqs.h index 66fe94fe69db0..b544505d5b1a7 100644 --- a/src/build_reqs.h +++ b/src/build_reqs.h @@ -40,6 +40,6 @@ struct parameterized_build_reqs { build_reqs get_build_reqs_for_furn_ter_ids( const std::pair, std::map> &changed_ids, - ter_id const &base_ter = t_dirt ); + ter_id const &base_ter = t_dirt->id ); #endif // CATA_SRC_BUILD_REQS_H diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index c47788e82d6b7..161a7eaef18f7 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3157,13 +3157,13 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh } } // first memorize the actual terrain - const ter_id &t = here.ter( p ); - const std::string &tname = t.id().str(); + const resolved_ter_id &t = here.ter( p ); + const std::string &tname = t->id.str(); // Legacy mode does not draw fog sprites if( fov_3d_z_range == 0 && tname == "t_open_air" ) { return false; } - if( t && !invisible[0] ) { + if( t != t_null && !invisible[0] ) { int subtile = 0; int rotation = 0; const std::bitset &connect_group = t.obj().connect_to_groups; @@ -3190,8 +3190,8 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh } if( invisible[0] ? overridden : neighborhood_overridden ) { // and then draw the override terrain - const ter_id &t2 = overridden ? override->second : t; - if( t2 ) { + const resolved_ter_id &t2 = overridden ? override->second : t; + if( t2 != t_null ) { // both the current and neighboring overrides may change the appearance // of the tile, so always re-calculate it. int subtile = 0; @@ -3204,7 +3204,7 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh } else { get_terrain_orientation( p, rotation, subtile, terrain_override, invisible, rotate_group ); } - const std::string &tname = t2.id().str(); + const std::string &tname = t2->id.str(); // tile overrides are never memorized // tile overrides are always shown with full visibility const lit_level lit = overridden ? lit_level::LIT : ll; @@ -3245,13 +3245,13 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei } map &here = get_map(); // first memorize the actual furniture - const furn_id &f = here.furn( p ); - if( f && !invisible[0] ) { + const resolved_furn_id &f = here.furn( p ); + if( f != f_null && !invisible[0] ) { const std::array neighborhood = { - static_cast( here.furn( p + point_south ) ), - static_cast( here.furn( p + point_east ) ), - static_cast( here.furn( p + point_west ) ), - static_cast( here.furn( p + point_north ) ) + static_cast( here.furn( p + point_south )->id.id() ), + static_cast( here.furn( p + point_east )->id.id() ), + static_cast( here.furn( p + point_west )->id.id() ), + static_cast( here.furn( p + point_north )->id.id() ) }; int subtile = 0; int rotation = 0; @@ -3261,9 +3261,9 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei if( connect_group.any() ) { get_furn_connect_values( p, subtile, rotation, connect_group, rotate_group, {} ); } else { - get_tile_values_with_ter( p, f.to_i(), neighborhood, subtile, rotation, rotate_group ); + get_tile_values_with_ter( p, f->id.id().to_i(), neighborhood, subtile, rotation, rotate_group ); } - const std::string &fname = f.id().str(); + const std::string &fname = f->id.str(); if( !( you.get_grab_type() == object_type::FURNITURE && p == you.pos() + you.grab_point ) && here.memory_cache_dec_is_dirty( p ) ) { @@ -3279,20 +3279,20 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei } if( invisible[0] ? overridden : neighborhood_overridden ) { // and then draw the override furniture - const furn_id &f2 = overridden ? override->second : f; - if( f2 ) { + const resolved_furn_id &f2 = overridden ? override->second : f; + if( f2 != f_null ) { // both the current and neighboring overrides may change the appearance // of the tile, so always re-calculate it. - const auto furn = [&]( const tripoint & q, const bool invis ) -> furn_id { + const auto furn = [&]( const tripoint & q, const bool invis ) -> resolved_furn_id { const auto it = furniture_override.find( q ); return it != furniture_override.end() ? it->second : ( !overridden || !invis ) ? here.furn( q ) : f_null; }; const std::array neighborhood = { - static_cast( furn( p + point_south, invisible[1] ) ), - static_cast( furn( p + point_east, invisible[2] ) ), - static_cast( furn( p + point_west, invisible[3] ) ), - static_cast( furn( p + point_north, invisible[4] ) ) + static_cast( furn( p + point_south, invisible[1] )->id.id() ), + static_cast( furn( p + point_east, invisible[2] )->id.id() ), + static_cast( furn( p + point_west, invisible[3] )->id.id() ), + static_cast( furn( p + point_north, invisible[4] )->id.id() ) }; int subtile = 0; int rotation = 0; @@ -3302,10 +3302,10 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei if( connect_group.any() ) { get_furn_connect_values( p, subtile, rotation, connect_group, rotate_group, {} ); } else { - get_tile_values_with_ter( p, f.to_i(), neighborhood, subtile, rotation, rotate_group ); + get_tile_values_with_ter( p, f->id.id().to_i(), neighborhood, subtile, rotation, rotate_group ); } - get_tile_values_with_ter( p, f2.to_i(), neighborhood, subtile, rotation, 0 ); - const std::string &fname = f2.id().str(); + get_tile_values_with_ter( p, f2->id.id().to_i(), neighborhood, subtile, rotation, 0 ); + const std::string &fname = f2->id.str(); // tile overrides are never memorized // tile overrides are always shown with full visibility const lit_level lit = overridden ? lit_level::LIT : ll; @@ -4370,11 +4370,11 @@ void cata_tiles::init_draw_radiation_override( const tripoint &p, const int rad { radiation_override.emplace( p, rad ); } -void cata_tiles::init_draw_terrain_override( const tripoint &p, const ter_id &id ) +void cata_tiles::init_draw_terrain_override( const tripoint &p, const resolved_ter_id &id ) { terrain_override.emplace( p, id ); } -void cata_tiles::init_draw_furniture_override( const tripoint &p, const furn_id &id ) +void cata_tiles::init_draw_furniture_override( const tripoint &p, const resolved_furn_id &id ) { furniture_override.emplace( p, id ); } @@ -4820,19 +4820,19 @@ void cata_tiles::init_light() } void cata_tiles::get_terrain_orientation( const tripoint &p, int &rota, int &subtile, - const std::map &ter_override, const std::array &invisible, + const std::map &ter_override, const std::array &invisible, const std::bitset &rotate_group ) { 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 ter = [&]( const tripoint & q, const bool invis ) -> resolved_ter_id { const auto override = ter_override.find( q ); return override != ter_override.end() ? override->second : ( !overridden || !invis ) ? here.ter( q ) : t_null; }; // get terrain at x,y - const ter_id tid = ter( p, invisible[0] ); + const resolved_ter_id tid = ter( p, invisible[0] ); if( tid == t_null ) { subtile = 0; rota = 0; @@ -4840,7 +4840,7 @@ void cata_tiles::get_terrain_orientation( const tripoint &p, int &rota, int &sub } // get terrain neighborhood - const std::array neighborhood = { + const std::array neighborhood = { ter( p + point_south, invisible[1] ), ter( p + point_east, invisible[2] ), ter( p + point_west, invisible[3] ), @@ -5099,7 +5099,7 @@ int cata_tiles::get_rotation_unconnected( const char rot_to ) void cata_tiles::get_connect_values( const tripoint &p, int &subtile, int &rotation, const std::bitset &connect_group, const std::bitset &rotate_to_group, - const std::map &ter_override ) + const std::map &ter_override ) { uint8_t connections = get_map().get_known_connections( p, connect_group, ter_override ); uint8_t rotation_targets = get_map().get_known_rotates_to( p, rotate_to_group, ter_override ); @@ -5108,7 +5108,7 @@ void cata_tiles::get_connect_values( const tripoint &p, int &subtile, int &rotat void cata_tiles::get_furn_connect_values( const tripoint &p, int &subtile, int &rotation, const std::bitset &connect_group, const std::bitset &rotate_to_group, - const std::map &furn_override ) + const std::map &furn_override ) { uint8_t connections = get_map().get_known_connections_f( p, connect_group, furn_override ); uint8_t rotation_targets = get_map().get_known_rotates_to_f( p, rotate_to_group, {}, {} ); diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 730749dabed69..d7b8e5d05693a 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -497,13 +497,13 @@ class cata_tiles static void get_connect_values( const tripoint &p, int &subtile, int &rotation, const std::bitset &connect_group, const std::bitset &rotate_to_group, - const std::map &ter_override ); + const std::map &ter_override ); static void get_furn_connect_values( const tripoint &p, int &subtile, int &rotation, const std::bitset &connect_group, const std::bitset &rotate_to_group, - const std::map &furn_override ); + const std::map &furn_override ); void get_terrain_orientation( const tripoint &p, int &rota, int &subtile, - const std::map &ter_override, + const std::map &ter_override, const std::array &invisible, const std::bitset &rotate_group ); @@ -614,10 +614,10 @@ class cata_tiles void init_draw_radiation_override( const tripoint &p, int rad ); void void_radiation_override(); - void init_draw_terrain_override( const tripoint &p, const ter_id &id ); + void init_draw_terrain_override( const tripoint &p, const resolved_ter_id &id ); void void_terrain_override(); - void init_draw_furniture_override( const tripoint &p, const furn_id &id ); + void init_draw_furniture_override( const tripoint &p, const resolved_furn_id &id ); void void_furniture_override(); void init_draw_graffiti_override( const tripoint &p, bool has ); @@ -781,8 +781,8 @@ class cata_tiles point op; std::map radiation_override; - std::map terrain_override; - std::map furniture_override; + std::map terrain_override; + std::map furniture_override; std::map graffiti_override; std::map trap_override; std::map field_override; diff --git a/src/character.cpp b/src/character.cpp index 22cd2488f7dbe..441be25cf9fda 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -5540,8 +5540,8 @@ Character::comfort_response_t Character::base_comfort_value( const tripoint &p ) const optional_vpart_position vp = here.veh_at( p ); const maptile tile = here.maptile_at( p ); const trap &trap_at_pos = tile.get_trap_t(); - const ter_id ter_at_pos = tile.get_ter(); - const furn_id furn_at_pos = tile.get_furn(); + const resolved_ter_id ter_at_pos = tile.get_ter(); + const resolved_furn_id furn_at_pos = tile.get_furn(); int web = here.get_field_intensity( p, fd_web ); @@ -9154,8 +9154,8 @@ units::temperature_delta Character::floor_bedding_warmth( const tripoint &pos ) { map &here = get_map(); 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 ); const optional_vpart_position vp = here.veh_at( pos ); const std::optional boardable = vp.part_with_feature( "BOARDABLE", true ); diff --git a/src/character_body.cpp b/src/character_body.cpp index 934497ee558d9..08970e7cf475d 100644 --- a/src/character_body.cpp +++ b/src/character_body.cpp @@ -436,7 +436,7 @@ void Character::update_bodytemp() const int climate_control_heat = climate_control.first; const int climate_control_chill = climate_control.second; const bool use_floor_warmth = can_use_floor_warmth(); - const furn_id furn_at_pos = here.furn( pos() ); + const resolved_furn_id furn_at_pos = here.furn( pos() ); const std::optional boardable = vp.part_with_feature( "BOARDABLE", true ); // This means which temperature is comfortable for a naked person // Ambient normal temperature is lower while asleep diff --git a/src/construction.cpp b/src/construction.cpp index a3dcf0af39006..264b3880bb5c6 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -919,7 +919,8 @@ bool player_can_see_to_build( Character &you, const construction_group_str_id &g return false; } -bool can_construct_furn_ter( const construction &con, furn_id const &f, ter_id const &t ) +bool can_construct_furn_ter( const construction &con, resolved_furn_id const &f, + resolved_ter_id const &t ) { return std::all_of( con.pre_flags.begin(), con.pre_flags.end(), [&f, &t]( auto const & flag ) { const bool use_ter = flag.second || f == f_null; @@ -931,8 +932,8 @@ bool can_construct_furn_ter( const construction &con, furn_id const &f, ter_id c bool can_construct( const construction &con, const tripoint_bub_ms &p ) { const map &here = get_map(); - const furn_id f = here.furn( p ); - const ter_id t = here.ter( p ); + const resolved_furn_id f = here.furn( p ); + const resolved_ter_id t = here.ter( p ); if( !con.pre_special( p ) || // pre-function !has_pre_terrain( con, p ) || // terrain type diff --git a/src/construction.h b/src/construction.h index 420ed64741466..efa7cc8b6b451 100644 --- a/src/construction.h +++ b/src/construction.h @@ -124,7 +124,8 @@ void load_construction( const JsonObject &jo ); void reset_constructions(); construction_id construction_menu( bool blueprint ); void complete_construction( Character *you ); -bool can_construct_furn_ter( const construction &con, furn_id const &furn, ter_id const &ter ); +bool can_construct_furn_ter( const construction &con, resolved_furn_id const &furn, + resolved_ter_id const &ter ); bool can_construct( const construction &con, const tripoint_bub_ms &p ); bool player_can_build( Character &you, const read_only_visitable &inv, const construction &con, bool can_construct_skip = false ); diff --git a/src/descriptions.cpp b/src/descriptions.cpp index cc795fe5eb238..2674daf6ee173 100644 --- a/src/descriptions.cpp +++ b/src/descriptions.cpp @@ -112,7 +112,7 @@ void game::extended_description( const tripoint &p ) if( !u.sees( p ) || !m.has_furn( p ) ) { desc = _( "You do not see any furniture here." ); } else { - const furn_id fid = m.furn( p ); + const resolved_furn_id fid = m.furn( p ); const std::string mod_src = enumerate_as_string( fid->src.begin(), fid->src.end(), []( const std::pair &source ) { return string_format( "'%s'", source.second->name() ); @@ -124,7 +124,7 @@ void game::extended_description( const tripoint &p ) if( !u.sees( p ) ) { desc = _( "You can't see the terrain here." ); } else { - const ter_id tid = m.ter( p ); + const resolved_ter_id tid = m.ter( p ); const std::string mod_src = enumerate_as_string( tid->src.begin(), tid->src.end(), []( const std::pair &source ) { return string_format( "'%s'", source.second->name() ); diff --git a/src/editmap.cpp b/src/editmap.cpp index 45e531707a1de..6960a3327b70f 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -231,7 +231,7 @@ void editmap_hilight::draw( editmap &em, bool update ) char t_sym = terrain.symbol(); nc_color t_col = terrain.color(); - if( here.furn( p ).to_i() > 0 ) { + if( here.furn( p )->id.id().to_i() > 0 ) { const furn_t &furniture_type = here.furn( p ).obj(); t_sym = furniture_type.symbol(); t_col = furniture_type.color(); @@ -668,7 +668,7 @@ void editmap::draw_main_ui_overlay() std::map> spawns; for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { - submap *sm = tmpmap.get_submap_at_grid( { x, y, target.z } ); + submap *sm = tmpmap.get_submap_at_grid( tripoint { x, y, target.z } ); if( sm ) { const tripoint sm_origin = origin_p + tripoint( x * SEEX, y * SEEY, target.z ); for( const spawn_point &sp : sm->spawns ) { @@ -727,15 +727,15 @@ void editmap::update_view_with_help( const std::string &txt, const std::string & mvwprintz( w_info, point( 2, 0 ), c_light_gray, "< %d,%d,%d >", target.x, target.y, target.z ); mvwputch( w_info, point( 2, off ), terrain_type.color(), terrain_type.symbol() ); - mvwprintw( w_info, point( 4, off ), _( "%d: %s; move cost %d" ), here.ter( target ).to_i(), + mvwprintw( w_info, point( 4, off ), _( "%d: %s; move cost %d" ), here.ter( target )->id.id().to_i(), static_cast( terrain_type.id ), terrain_type.movecost ); off++; // 2 - if( here.furn( target ).to_i() > 0 ) { + if( here.furn( target )->id.id().to_i() > 0 ) { mvwputch( w_info, point( 2, off ), furniture_type.color(), furniture_type.symbol() ); mvwprintw( w_info, point( 4, off ), _( "%d: %s; move cost %d movestr %d" ), - here.furn( target ).to_i(), + here.furn( target )->id.id().to_i(), static_cast( furniture_type.id ), furniture_type.movecost, furniture_type.move_str_req @@ -898,13 +898,13 @@ static T_id feature( const tripoint &p ); template<> ter_id feature( const tripoint &p ) { - return get_map().ter( p ); + return get_map().ter( p )->id; } template<> furn_id feature( const tripoint &p ) { - return get_map().furn( p ); + return get_map().furn( p )->id; } template<> @@ -2011,7 +2011,7 @@ vehicle *editmap::mapgen_veh_query( const tripoint_abs_omt &omt_tgt ) std::vector possible_vehicles; for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { - submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } ); + submap *destsm = target_bay.get_submap_at_grid( tripoint { x, y, target.z } ); if( destsm == nullptr ) { debugmsg( "Tried to get vehicles at (%d,%d,%d) but the submap is not loaded", x, y, target.z ); continue; @@ -2048,7 +2048,7 @@ bool editmap::mapgen_veh_destroy( const tripoint_abs_omt &omt_tgt, vehicle *car_ target_bay.load( project_to( omt_tgt ), false ); for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { - submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } ); + submap *destsm = target_bay.get_submap_at_grid( tripoint { x, y, target.z } ); if( destsm == nullptr ) { debugmsg( "Tried to destroy vehicle at (%d,%d,%d) but the submap is not loaded", x, y, target.z ); continue; diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 222544dcbd4ad..2a1a5496783c3 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -3285,7 +3285,7 @@ static std::pair farm_action( const tripoint_abs_omt &omt_t return ( bay1.ter( pos ) == t_dirtmound ) && ( !bay2.has_furn( pos ) ); }; const auto is_unplowed = []( const tripoint & pos, tinymap & farm_map ) { - const ter_id &farm_ter = farm_map.ter( pos ); + const resolved_ter_id &farm_ter = farm_map.ter( pos ); return farm_ter->has_flag( ter_furn_flag::TFLAG_PLOWABLE ); }; diff --git a/src/game.cpp b/src/game.cpp index eeb0cdb111b5f..243dae81d0f61 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -10528,9 +10528,9 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool } else { add_msg( m_warning, _( "Moving onto this %s is slow!" ), m.name( dest_loc ) ); if( m.has_furn( dest_loc ) ) { - sfx::do_obstacle( m.furn( dest_loc ).id().str() ); + sfx::do_obstacle( m.furn( dest_loc )->id.str() ); } else { - sfx::do_obstacle( m.ter( dest_loc ).id().str() ); + sfx::do_obstacle( m.ter( dest_loc )->id.str() ); } } } else { @@ -10541,9 +10541,9 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool } else { add_msg( m_warning, _( "Moving off of this %s is slow!" ), m.name( u.pos() ) ); if( m.has_furn( u.pos() ) ) { - sfx::do_obstacle( m.furn( u.pos() ).id().str() ); + sfx::do_obstacle( m.furn( u.pos() )->id.str() ); } else { - sfx::do_obstacle( m.ter( u.pos() ).id().str() ); + sfx::do_obstacle( m.ter( u.pos() )->id.str() ); } } } @@ -11892,7 +11892,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) // > and < are used for diving underwater. if( here.has_flag( ter_furn_flag::TFLAG_SWIMMABLE, u.pos() ) ) { swimming = true; - const ter_id &target_ter = here.ter( u.pos() + tripoint( 0, 0, movez ) ); + const resolved_ter_id &target_ter = here.ter( u.pos() + tripoint( 0, 0, movez ) ); // If we're in a water tile that has both air above and deep enough water to submerge in... if( here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, u.pos() ) && @@ -13582,7 +13582,7 @@ void avatar_moves( const tripoint &old_abs_pos, const avatar &u, const map &m ) if( u.is_mounted() ) { mount_type = u.mounted_creature->type->id; } - get_event_bus().send( mount_type, m.ter( new_pos ).id(), + get_event_bus().send( mount_type, m.ter( new_pos )->id, u.current_movement_mode(), u.is_underwater(), new_pos.z ); // TODO: fix point types diff --git a/src/game.h b/src/game.h index 5c82e1abbb8bc..842103bb1c3d4 100644 --- a/src/game.h +++ b/src/game.h @@ -778,8 +778,8 @@ class game void draw_async_anim( const tripoint &p, const std::string &tile_id, const std::string &ncstr = "", const nc_color &nccol = c_black ); void draw_radiation_override( const tripoint &p, int rad ); - void draw_terrain_override( const tripoint &p, const ter_id &id ); - void draw_furniture_override( const tripoint &p, const furn_id &id ); + void draw_terrain_override( const tripoint &p, const resolved_ter_id &id ); + void draw_furniture_override( const tripoint &p, const resolved_furn_id &id ); void draw_graffiti_override( const tripoint &p, bool has ); void draw_trap_override( const tripoint &p, const trap_id &id ); void draw_field_override( const tripoint &p, const field_type_id &id ); diff --git a/src/gates.cpp b/src/gates.cpp index 1bc1674c8327d..1b3076903b584 100644 --- a/src/gates.cpp +++ b/src/gates.cpp @@ -75,7 +75,7 @@ struct gate_data { gate_id get_gate_id( const tripoint &pos ) { - return gate_id( get_map().ter( pos ).id().str() ); + return gate_id( get_map().ter( pos )->id.str() ); } generic_factory gates_data( "gate type" ); @@ -131,9 +131,9 @@ void gate_data::check() const bool gate_data::is_suitable_wall( const tripoint &pos ) const { - const ter_id wid = get_map().ter( pos ); + const resolved_ter_id wid = get_map().ter( pos ); const auto iter = std::find_if( walls.begin(), walls.end(), [ wid ]( const ter_str_id & wall ) { - return wall.id() == wid; + return wall == wid->id; } ); return iter != walls.end(); } @@ -206,7 +206,7 @@ void gates::open_gate( const tripoint &pos ) if( !close ) { // Opening the gate... tripoint cur_pos = gate_pos; while( true ) { - const ter_id ter = here.ter( cur_pos ); + const resolved_ter_id ter = here.ter( cur_pos ); if( ter == gate.door.id() ) { here.ter_set( cur_pos, gate.floor.id() ); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 4d303deb35580..25d0e418c8ae8 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -636,7 +636,7 @@ static void open() if( didit ) { player_character.add_msg_if_player( _( "You open the %s." ), here.name( openp ) ); } else { - const ter_str_id tid = here.ter( openp ).id(); + const ter_str_id tid = here.ter( openp )->id; if( here.has_flag( ter_furn_flag::TFLAG_LOCKED, openp ) ) { add_msg( m_info, _( "The door is locked!" ) ); @@ -884,7 +884,7 @@ static void smash() smash_floor = true; } get_event_bus().send( - player_character.getID(), here.ter( smashp ).id(), here.furn( smashp ).id() ); + player_character.getID(), here.ter( smashp )->id, here.furn( smashp )->id ); if( player_character.is_mounted() ) { monster *crit = player_character.mounted_creature.get(); if( crit->has_flag( mon_flag_RIDEABLE_MECH ) ) { diff --git a/src/iexamine.cpp b/src/iexamine.cpp index eb9b6bd38fc24..c963591ca3560 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1624,7 +1624,7 @@ static std::pair find_tent_itype( const fur void iexamine::portable_structure( Character &you, const tripoint &examp ) { map &here = get_map(); - const furn_str_id fid = here.furn( examp ).id(); + const furn_str_id fid = here.furn( examp )->id; const std::pair tent_item_type = find_tent_itype( fid ); if( tent_item_type.first.is_null() ) { debugmsg( "unknown furniture %s: don't know how to transform it into an item", fid.str() ); @@ -2046,7 +2046,7 @@ void iexamine::fswitch( Character &you, const tripoint &examp ) none( you, examp ); return; } - ter_id terid = here.ter( examp ); + resolved_ter_id terid = here.ter( examp ); you.moves -= to_moves( 1_seconds ); tripoint tmp; tmp.z = examp.z; @@ -2729,7 +2729,7 @@ void iexamine::fertilize_plant( Character &you, const tripoint &tile, // The plant furniture has the NOITEM token which prevents adding items on that square, // spawned items are moved to an adjacent field instead, but the fertilizer token // must be on the square of the plant, therefore this hack: - const furn_id old_furn = here.furn( tile ); + const resolved_furn_id old_furn = here.furn( tile ); here.furn_set( tile, f_null ); here.spawn_item( tile, itype_fertilizer, 1, 1, calendar::turn ); here.furn_set( tile, old_furn ); @@ -2812,15 +2812,15 @@ void iexamine::aggie_plant( Character &you, const tripoint &examp ) void iexamine::kiln_empty( Character &you, const tripoint &examp ) { map &here = get_map(); - furn_id cur_kiln_type = here.furn( examp ); - furn_id next_kiln_type = f_null; + resolved_furn_id cur_kiln_type = here.furn( examp ); + resolved_furn_id next_kiln_type = f_null; if( cur_kiln_type == f_kiln_empty ) { next_kiln_type = f_kiln_full; } else if( cur_kiln_type == f_kiln_metal_empty ) { next_kiln_type = f_kiln_metal_full; } else { debugmsg( "Examined furniture has action kiln_empty, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } @@ -2905,15 +2905,15 @@ void iexamine::kiln_empty( Character &you, const tripoint &examp ) void iexamine::kiln_full( Character &, const tripoint &examp ) { map &here = get_map(); - furn_id cur_kiln_type = here.furn( examp ); - furn_id next_kiln_type = f_null; + resolved_furn_id cur_kiln_type = here.furn( examp ); + resolved_furn_id next_kiln_type = f_null; if( cur_kiln_type == f_kiln_full ) { next_kiln_type = f_kiln_empty; } else if( cur_kiln_type == f_kiln_metal_full ) { next_kiln_type = f_kiln_metal_empty; } else { debugmsg( "Examined furniture has action kiln_full, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } map_stack items = here.i_at( examp ); @@ -2965,13 +2965,13 @@ void iexamine::kiln_full( Character &, const tripoint &examp ) void iexamine::arcfurnace_empty( Character &you, const tripoint &examp ) { map &here = get_map(); - furn_id cur_arcfurnace_type = here.furn( examp ); - furn_id next_arcfurnace_type = f_null; + resolved_furn_id cur_arcfurnace_type = here.furn( examp ); + resolved_furn_id next_arcfurnace_type = f_null; if( cur_arcfurnace_type == f_arcfurnace_empty ) { next_arcfurnace_type = f_arcfurnace_full; } else { debugmsg( "Examined furniture has action arcfurnace_empty, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.c_str() ); return; } @@ -3038,13 +3038,13 @@ void iexamine::arcfurnace_empty( Character &you, const tripoint &examp ) void iexamine::arcfurnace_full( Character &, const tripoint &examp ) { map &here = get_map(); - furn_id cur_arcfurnace_type = here.furn( examp ); - furn_id next_arcfurnace_type = f_null; + resolved_furn_id cur_arcfurnace_type = here.furn( examp ); + resolved_furn_id next_arcfurnace_type = f_null; if( cur_arcfurnace_type == f_arcfurnace_full ) { next_arcfurnace_type = f_arcfurnace_empty; } else { debugmsg( "Examined furniture has action arcfurnace_full, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } @@ -3097,13 +3097,13 @@ void iexamine::arcfurnace_full( Character &, const tripoint &examp ) void iexamine::stook_empty( Character &, const tripoint &examp ) { map &here = get_map(); - furn_id cur_stook_type = here.furn( examp ); - furn_id next_stook_type = f_null; + resolved_furn_id cur_stook_type = here.furn( examp ); + resolved_furn_id next_stook_type = f_null; if( cur_stook_type == f_stook_empty ) { next_stook_type = f_stook_full; } else { debugmsg( "Examined furniture has action stook_empty, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } @@ -3139,13 +3139,13 @@ void iexamine::stook_empty( Character &, const tripoint &examp ) void iexamine::stook_full( Character &, const tripoint &examp ) { map &here = get_map(); - furn_id cur_stook_type = here.furn( examp ); - furn_id next_stook_type = f_null; + resolved_furn_id cur_stook_type = here.furn( examp ); + resolved_furn_id next_stook_type = f_null; if( cur_stook_type == f_stook_full ) { next_stook_type = f_null; } else { debugmsg( "Examined furniture has action stook_full, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } map_stack items = here.i_at( examp ); @@ -3186,13 +3186,13 @@ void iexamine::stook_full( Character &, const tripoint &examp ) void iexamine::autoclave_empty( Character &you, const tripoint &examp ) { map &here = get_map(); - furn_id cur_autoclave_type = here.furn( examp ); - furn_id next_autoclave_type = f_null; + resolved_furn_id cur_autoclave_type = here.furn( examp ); + resolved_furn_id next_autoclave_type = f_null; if( cur_autoclave_type == furn_id( "f_autoclave" ) ) { next_autoclave_type = furn_id( "f_autoclave_full" ); } else { debugmsg( "Examined furniture has action autoclave_empty, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.c_str() ); return; } @@ -3246,13 +3246,13 @@ void iexamine::autoclave_empty( Character &you, const tripoint &examp ) void iexamine::autoclave_full( Character &, const tripoint &examp ) { map &here = get_map(); - furn_id cur_autoclave_type = here.furn( examp ); - furn_id next_autoclave_type = f_null; + resolved_furn_id cur_autoclave_type = here.furn( examp ); + resolved_furn_id next_autoclave_type = f_null; if( cur_autoclave_type == furn_id( "f_autoclave_full" ) ) { next_autoclave_type = furn_id( "f_autoclave" ); } else { debugmsg( "Examined furniture has action autoclave_full, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.c_str() ); return; } @@ -3436,7 +3436,7 @@ void iexamine::fireplace( Character &you, const tripoint &examp ) static void fvat_set_empty( const tripoint &pos ) { map &here = get_map(); - furn_id furn = here.furn( pos ); + resolved_furn_id furn = here.furn( pos ); if( furn == f_fvat_wood_empty || furn == f_fvat_wood_full ) { here.furn_set( pos, f_fvat_wood_empty ); } else { @@ -3447,7 +3447,7 @@ static void fvat_set_empty( const tripoint &pos ) static void fvat_set_full( const tripoint &pos ) { map &here = get_map(); - furn_id furn = here.furn( pos ); + resolved_furn_id furn = here.furn( pos ); if( furn == f_fvat_wood_empty || furn == f_fvat_wood_full ) { here.furn_set( pos, f_fvat_wood_full ); } else { @@ -3681,7 +3681,7 @@ static void displace_items_except_one_liquid( const tripoint &examp ) { map &here = get_map(); // Temporarily replace the real furniture with a fake furniture with NOITEM - const furn_id previous_furn = here.furn( examp ); + const resolved_furn_id previous_furn = here.furn( examp ); here.furn_set( examp, furn_id( "f_no_item" ) ); bool liquid_present = false; @@ -3899,7 +3899,7 @@ bool iexamine::pour_into_keg( const tripoint &pos, item &liquid ) } static void pick_plant( Character &you, const tripoint &examp, - const itype_id &itemType, ter_id new_ter, bool seeds = false ) + const itype_id &itemType, resolved_ter_id new_ter, bool seeds = false ) { map &here = get_map(); bool auto_forage = get_option( "AUTO_FEATURES" ) && @@ -4511,7 +4511,7 @@ void iexamine::curtains( Character &you, const tripoint &examp ) return; } - const ter_id ter = here.ter( examp ); + const resolved_ter_id ter = here.ter( examp ); // Peek through the curtains, or tear them down. uilist window_menu; @@ -4602,7 +4602,7 @@ static int getNearPumpCount( const tripoint &p, fuel_station_fuel_type &fuel_typ int result = 0; map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( p, 12 ) ) { - const ter_id t = here.ter( tmp ); + const resolved_ter_id t = here.ter( tmp ); if( t == ter_t_gas_pump || t == ter_t_gas_pump_a ) { result++; fuel_type = FUEL_TYPE_GASOLINE; @@ -4623,8 +4623,7 @@ std::optional iexamine::getNearFilledGasTank( const tripoint ¢er, map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( center, SEEX * 2 ) ) { - - furn_id check_for_fuel_tank = here.furn( tmp ); + resolved_furn_id check_for_fuel_tank = here.furn( tmp ); if( ( fuel_type == FUEL_TYPE_GASOLINE && check_for_fuel_tank != furn_f_gas_tank ) || ( fuel_type == FUEL_TYPE_DIESEL && check_for_fuel_tank != furn_f_diesel_tank ) ) { @@ -4727,7 +4726,7 @@ std::optional iexamine::getGasPumpByNumber( const tripoint &p, int num int k = 0; map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( p, 12 ) ) { - const ter_id t = here.ter( tmp ); + const resolved_ter_id t = here.ter( tmp ); if( ( t == ter_t_gas_pump || t == ter_t_gas_pump_a || t == ter_t_diesel_pump || t == ter_t_diesel_pump_a ) && number == k++ ) { return tmp; @@ -4774,8 +4773,8 @@ static int fromPumpFuel( const tripoint &dst, const tripoint &src ) item liq_d( item_it->type, calendar::turn, amount ); // add the charges to the destination - const ter_id backup_ter = here.ter( dst ); - const furn_id backup_furn = here.furn( dst ); + const resolved_ter_id backup_ter = here.ter( dst ); + const resolved_furn_id backup_furn = here.furn( dst ); here.ter_set( dst, ter_str_id::NULL_ID() ); here.furn_set( dst, furn_str_id::NULL_ID() ); here.add_item_or_charges( dst, liq_d ); @@ -4795,7 +4794,7 @@ static void turnOnSelectedPump( const tripoint &p, int number, fuel_station_fuel int k = 0; map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( p, 12 ) ) { - const ter_id t = here.ter( tmp ); + const resolved_ter_id t = here.ter( tmp ); if( fuel_type == FUEL_TYPE_GASOLINE ) { if( t == ter_t_gas_pump || t == ter_t_gas_pump_a ) { if( number == k++ ) { @@ -5688,15 +5687,15 @@ static int get_milled_amount( const itype_id &milled_id, const tripoint &examp, static void mill_activate( Character &you, const tripoint &examp ) { map &here = get_map(); - const furn_id cur_mill_type = here.furn( examp ); - furn_id next_mill_type = f_null; + const resolved_furn_id cur_mill_type = here.furn( examp ); + resolved_furn_id next_mill_type = f_null; if( cur_mill_type == f_wind_mill ) { next_mill_type = f_wind_mill_active; } else if( cur_mill_type == f_water_mill ) { next_mill_type = f_water_mill_active; } else { debugmsg( "Examined furniture has action mill_activate, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } bool food_present = false; @@ -5764,8 +5763,8 @@ static void mill_activate( Character &you, const tripoint &examp ) static void smoker_activate( Character &you, const tripoint &examp ) { map &here = get_map(); - furn_id cur_smoker_type = here.furn( examp ); - furn_id next_smoker_type = f_null; + resolved_furn_id cur_smoker_type = here.furn( examp ); + resolved_furn_id next_smoker_type = f_null; const bool portable = here.furn( examp ) == furn_f_metal_smoking_rack || here.furn( examp ) == furn_f_metal_smoking_rack_active; if( cur_smoker_type == f_smoking_rack ) { @@ -5774,7 +5773,7 @@ static void smoker_activate( Character &you, const tripoint &examp ) next_smoker_type = f_metal_smoking_rack_active; } else { debugmsg( "Examined furniture has action smoker_activate, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } bool food_present = false; @@ -5878,15 +5877,15 @@ static void smoker_activate( Character &you, const tripoint &examp ) void iexamine::mill_finalize( Character &, const tripoint &examp, const time_point &start_time ) { map &here = get_map(); - const furn_id cur_mill_type = here.furn( examp ); - furn_id next_mill_type = f_null; + const resolved_furn_id cur_mill_type = here.furn( examp ); + resolved_furn_id next_mill_type = f_null; if( cur_mill_type == f_wind_mill_active ) { next_mill_type = f_wind_mill; } else if( cur_mill_type == f_water_mill_active ) { next_mill_type = f_water_mill; } else { debugmsg( "Furniture executed action mill_finalize, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.str() ); return; } @@ -5978,15 +5977,15 @@ void iexamine::mill_finalize( Character &, const tripoint &examp, const time_poi static void smoker_finalize( Character &, const tripoint &examp, const time_point &start_time ) { map &here = get_map(); - furn_id cur_smoker_type = here.furn( examp ); - furn_id next_smoker_type = f_null; + resolved_furn_id cur_smoker_type = here.furn( examp ); + resolved_furn_id next_smoker_type = f_null; if( cur_smoker_type == f_smoking_rack_active ) { next_smoker_type = f_smoking_rack; } else if( cur_smoker_type == f_metal_smoking_rack_active ) { next_smoker_type = f_metal_smoking_rack; } else { debugmsg( "Furniture executed action smoker_finalize, but is of type %s", - here.furn( examp ).id().c_str() ); + here.furn( examp )->id.c_str() ); return; } @@ -6044,7 +6043,7 @@ static void smoker_load_food( Character &you, const tripoint &examp, return; } - furn_id rack = here.furn( examp ); + resolved_furn_id rack = here.furn( examp ); units::volume total_capacity = rack == furn_f_metal_smoking_rack ? sm_rack::MAX_FOOD_VOLUME_PORTABLE : sm_rack::MAX_FOOD_VOLUME; diff --git a/src/iexamine_actors.cpp b/src/iexamine_actors.cpp index eeae77b7477d9..d8bf886dd7ee2 100644 --- a/src/iexamine_actors.cpp +++ b/src/iexamine_actors.cpp @@ -143,8 +143,8 @@ bool cardreader_examine_actor::apply( const tripoint &examp ) const open = false; const tripoint_range points = here.points_in_radius( examp, radius ); for( const tripoint &tmp : points ) { - const auto ter_iter = terrain_changes.find( here.ter( tmp ).id() ); - const auto furn_iter = furn_changes.find( here.furn( tmp ).id() ); + const auto ter_iter = terrain_changes.find( here.ter( tmp )->id ); + const auto furn_iter = furn_changes.find( here.furn( tmp )->id ); if( ter_iter != terrain_changes.end() ) { here.ter_set( tmp, ter_iter->second ); open = true; @@ -252,7 +252,7 @@ std::unique_ptr cardreader_examine_actor::clone() const void eoc_examine_actor::call( Character &you, const tripoint &examp ) const { dialogue d( get_talker_for( you ), nullptr ); - d.set_value( "npctalk_var_this", get_map().furn( examp ).id().str() ); + d.set_value( "npctalk_var_this", get_map().furn( examp )->id.str() ); d.set_value( "npctalk_var_pos", get_map().getglobal( examp ).to_string() ); for( const effect_on_condition_id &eoc : eocs ) { eoc->activate( d ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 8fc7831c8e9b9..b5c98580189da 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -4839,13 +4839,13 @@ std::optional iuse::chop_logs( Character *p, item *it, const tripoint & ) return std::nullopt; } - const std::set allowed_ter_id { + const std::set allowed_ter_id { t_trunk, t_stump }; map &here = get_map(); const std::function f = [&allowed_ter_id, &here]( const tripoint & pnt ) { - const ter_id type = here.ter( pnt ); + const resolved_ter_id type = here.ter( pnt ); const bool is_allowed_terrain = allowed_ter_id.find( type ) != allowed_ter_id.end(); return is_allowed_terrain; }; @@ -6031,7 +6031,7 @@ static std::string colorized_ter_name_flags_at( const tripoint &point, const std::vector &flags, const std::vector &ter_whitelist ) { map &here = get_map(); - const ter_id ter = here.ter( point ); + const resolved_ter_id ter = here.ter( point ); std::string name = colorize( ter->name(), ter->color() ); const std::string &graffiti_message = here.graffiti_at( point ); @@ -6067,7 +6067,7 @@ static std::string colorized_feature_description_at( const tripoint ¢er_poin { item_found = false; map &here = get_map(); - const furn_id furn = here.furn( center_point ); + const resolved_furn_id furn = here.furn( center_point ); if( furn != f_null && furn.is_valid() ) { std::string furn_str = colorize( furn->name(), c_yellow ); std::string sign_message = here.get_signage( center_point ); @@ -6490,8 +6490,8 @@ static item::extended_photo_def photo_def_for_camera_point( const tripoint &aim_ found_item_aim_point = !item.is_null(); } - const ter_id ter_aim = here.ter( aim_point ); - const furn_id furn_aim = here.furn( aim_point ); + const resolved_ter_id ter_aim = here.ter( aim_point ); + const resolved_furn_id furn_aim = here.furn( aim_point ); if( !description_figures_status.empty() ) { std::string names = enumerate_as_string( description_figures_status.begin(), diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index f6c024a88412a..748abeee09d7e 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -5337,7 +5337,7 @@ bool deploy_tent_actor::check_intact( const tripoint ¢er ) const { map &here = get_map(); for( const tripoint &dest : here.points_in_radius( center, radius ) ) { - const furn_id fid = here.furn( dest ); + const resolved_furn_id fid = here.furn( dest ); if( dest == center && floor_center ) { if( fid != *floor_center ) { return false; diff --git a/src/json.h b/src/json.h index 689f7c791e0ae..293628f1defc1 100644 --- a/src/json.h +++ b/src/json.h @@ -22,6 +22,7 @@ #include "json_error.h" #include "int_id.h" #include "memory_fast.h" +#include "resolved_id.h" #include "string_id.h" /* Cataclysm-DDA homegrown JSON tools @@ -836,6 +837,11 @@ class JsonOut write( thing.id().str() ); } + template + auto write( const resolved_id &thing ) { + write( thing->id ); + } + // enum ~> string template > * = nullptr> void write_as_string( const E value ) { diff --git a/src/lightmap.cpp b/src/lightmap.cpp index b64d11b788b7c..48ba7d1cb3a42 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -461,11 +461,11 @@ void map::generate_lightmap( const int zlev ) add_light_from_items( p, i_at( p ) ); } - const ter_id terrain = cur_submap->get_ter( { sx, sy } ); + const resolved_ter_id terrain = cur_submap->get_ter( { sx, sy } ); if( terrain->light_emitted > 0 ) { add_light_source( p, terrain->light_emitted ); } - const furn_id furniture = cur_submap->get_furn( {sx, sy } ); + const resolved_furn_id furniture = cur_submap->get_furn( {sx, sy } ); if( furniture->light_emitted > 0 ) { add_light_source( p, furniture->light_emitted ); } diff --git a/src/magic_ter_fur_transform.cpp b/src/magic_ter_fur_transform.cpp index 3a0ea911f001e..d8758314f9e8d 100644 --- a/src/magic_ter_fur_transform.cpp +++ b/src/magic_ter_fur_transform.cpp @@ -216,10 +216,10 @@ std::optional>> ter_furn_tra void ter_furn_transform::transform( map &m, const tripoint_bub_ms &location ) const { avatar &you = get_avatar(); - const ter_id ter_at_loc = m.ter( location ); + const resolved_ter_id ter_at_loc = m.ter( location ); std::optional>> ter_potential = next_ter( ter_at_loc->id ); - const furn_id furn_at_loc = m.furn( location ); + const resolved_furn_id furn_at_loc = m.furn( location ); std::optional>> furn_potential = next_furn( furn_at_loc->id ); const trap_str_id trap_at_loc = m.maptile_at( location ).get_trap().id(); diff --git a/src/map.cpp b/src/map.cpp index e169d43d51283..f8a133fdddd15 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -842,7 +842,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac !veh.is_flying_in_air() && dp.z == 0 ) { veh.velocity -= std::clamp( veh.velocity, -2000, 2000 ); // extra drag for( const tripoint &p : veh.get_points() ) { - const ter_id &pter = ter( p ); + const resolved_ter_id &pter = ter( p ); if( pter == t_dirt || pter == t_grass ) { ter_set( p, t_dirtmound ); } @@ -1633,7 +1633,8 @@ bool map::displace_water( const tripoint &p ) // End of 3D vehicle -void map::set( const tripoint &p, const ter_id &new_terrain, const furn_id &new_furniture ) +void map::set( const tripoint &p, const resolved_ter_id &new_terrain, + const resolved_furn_id &new_furniture ) { furn_set( p, new_furniture ); ter_set( p, new_terrain ); @@ -1672,7 +1673,7 @@ bool map::has_furn( const tripoint_bub_ms &p ) const return has_furn( p.raw() ); } -furn_id map::furn( const tripoint &p ) const +resolved_furn_id map::furn( const tripoint &p ) const { if( !inbounds( p ) ) { return f_null; @@ -1688,12 +1689,12 @@ furn_id map::furn( const tripoint &p ) const return current_submap->get_furn( l ); } -furn_id map::furn( const tripoint_bub_ms &p ) const +resolved_furn_id map::furn( const tripoint_bub_ms &p ) const { return furn( p.raw() ); } -bool map::furn_set( const tripoint &p, const furn_id &new_furniture, const bool furn_reset, +bool map::furn_set( const tripoint &p, const resolved_furn_id &new_furniture, const bool furn_reset, bool avoid_creatures ) { if( !inbounds( p ) ) { @@ -1712,8 +1713,8 @@ bool map::furn_set( const tripoint &p, const furn_id &new_furniture, const bool debugmsg( "Tried to set furniture at (%d,%d) but the submap is not loaded", l.x, l.y ); return false; } - const furn_id new_target_furniture = new_furniture == f_clear ? f_null : new_furniture; - const furn_id old_id = current_submap->get_furn( l ); + const resolved_furn_id new_target_furniture = new_furniture == f_clear ? f_null : new_furniture; + const resolved_furn_id old_id = current_submap->get_furn( l ); if( old_id == new_target_furniture ) { // Nothing changed return true; @@ -1731,10 +1732,10 @@ bool map::furn_set( const tripoint &p, const furn_id &new_furniture, const bool if( current_submap->is_open_air( l ) && !new_f.has_flag( ter_furn_flag::TFLAG_ALLOW_ON_OPEN_AIR ) && new_target_furniture != f_null ) { - const ter_id current_ter = current_submap->get_ter( l ); + const resolved_ter_id current_ter = current_submap->get_ter( l ); debugmsg( "Setting furniture %s at %s where terrain is %s (which is_open_air)\n" "If this is intentional, set the ALLOW_ON_OPEN_AIR flag on the furniture", - new_target_furniture.id().str(), p.to_string(), current_ter.id().str() ); + new_target_furniture->id.str(), p.to_string(), current_ter->id.str() ); result = false; } @@ -1806,7 +1807,8 @@ bool map::furn_set( const tripoint &p, const furn_id &new_furniture, const bool return result; } -bool map::furn_set( const tripoint_bub_ms &p, const furn_id &new_furniture, const bool furn_reset, +bool map::furn_set( const tripoint_bub_ms &p, const resolved_furn_id &new_furniture, + const bool furn_reset, bool avoid_creatures ) { return furn_set( p.raw(), new_furniture, furn_reset, avoid_creatures ); @@ -1870,7 +1872,7 @@ std::string map::furnname( const tripoint_bub_ms &p ) * retained for high performance comparisons, save/load, and gradual transition * to string terrain.id */ -ter_id map::ter( const tripoint &p ) const +resolved_ter_id map::ter( const tripoint &p ) const { if( !inbounds( p ) ) { return t_null; @@ -1886,7 +1888,7 @@ ter_id map::ter( const tripoint &p ) const return current_submap->get_ter( l ); } -ter_id map::ter( const tripoint_bub_ms &p ) const +resolved_ter_id map::ter( const tripoint_bub_ms &p ) const { return ter( p.raw() ); } @@ -1923,7 +1925,7 @@ void map::set_map_damage( const tripoint_bub_ms &p, int dmg ) uint8_t map::get_known_connections( const tripoint &p, const std::bitset &connect_group, - const std::map &override ) const + const std::map &override ) const { if( connect_group.none() ) { return 0; @@ -1980,7 +1982,7 @@ uint8_t map::get_known_connections( const tripoint &p, uint8_t map::get_known_rotates_to( const tripoint &p, const std::bitset &rotate_to_group, - const std::map &override ) const + const std::map &override ) const { if( rotate_to_group.none() ) { return CHAR_MAX; @@ -2009,7 +2011,7 @@ uint8_t map::get_known_rotates_to( const tripoint &p, uint8_t map::get_known_connections_f( const tripoint &p, const std::bitset &connect_group, - const std::map &override ) const + const std::map &override ) const { if( connect_group.none() ) { return 0; @@ -2066,8 +2068,8 @@ uint8_t map::get_known_connections_f( const tripoint &p, uint8_t map::get_known_rotates_to_f( const tripoint &p, const std::bitset &rotate_to_group, - const std::map &override, - const std::map &override_f ) const + const std::map &override, + const std::map &override_f ) const { if( rotate_to_group.none() ) { return CHAR_MAX; @@ -2107,7 +2109,7 @@ uint8_t map::get_known_rotates_to_f( const tripoint &p, */ const harvest_id &map::get_harvest( const tripoint &pos ) const { - const furn_id furn_here = furn( pos ); + const resolved_furn_id furn_here = furn( pos ); if( !furn_here->has_flag( ter_furn_flag::TFLAG_HARVESTED ) ) { const harvest_id &harvest = furn_here->get_harvest(); if( ! harvest.is_null() ) { @@ -2115,7 +2117,7 @@ const harvest_id &map::get_harvest( const tripoint &pos ) const } } - const ter_id ter_here = ter( pos ); + const resolved_ter_id ter_here = ter( pos ); if( ter_here->has_flag( ter_furn_flag::TFLAG_HARVESTED ) ) { return harvest_id::NULL_ID(); } @@ -2126,7 +2128,7 @@ const harvest_id &map::get_harvest( const tripoint &pos ) const const std::set &map::get_harvest_names( const tripoint &pos ) const { static const std::set null_harvest_names = {}; - const furn_id furn_here = furn( pos ); + const resolved_furn_id furn_here = furn( pos ); if( furn_here->can_examine( pos ) ) { if( furn_here->has_flag( ter_furn_flag::TFLAG_HARVESTED ) ) { return null_harvest_names; @@ -2135,7 +2137,7 @@ const std::set &map::get_harvest_names( const tripoint &pos ) const return furn_here->get_harvest_names(); } - const ter_id ter_here = ter( pos ); + const resolved_ter_id ter_here = ter( pos ); if( ter_here->has_flag( ter_furn_flag::TFLAG_HARVESTED ) ) { return null_harvest_names; } @@ -2174,7 +2176,7 @@ bool map::is_harvestable( const tripoint &pos ) const /* * set terrain via string; this works for -any- terrain id */ -bool map::ter_set( const tripoint &p, const ter_id &new_terrain, bool avoid_creatures ) +bool map::ter_set( const tripoint &p, const resolved_ter_id &new_terrain, bool avoid_creatures ) { if( !inbounds( p ) ) { return false; @@ -2192,7 +2194,7 @@ bool map::ter_set( const tripoint &p, const ter_id &new_terrain, bool avoid_crea debugmsg( "Tried to set terrain at (%d,%d) but the submap is not loaded", l.x, l.y ); return true; } - const ter_id old_id = current_submap->get_ter( l ); + const resolved_ter_id old_id = current_submap->get_ter( l ); if( old_id == new_terrain ) { // Nothing changed return false; @@ -2206,12 +2208,12 @@ bool map::ter_set( const tripoint &p, const ter_id &new_terrain, bool avoid_crea const ter_t &new_t = new_terrain.obj(); if( current_submap->is_open_air( l ) ) { - const furn_id ¤t_furn = current_submap->get_furn( l ); + const resolved_furn_id ¤t_furn = current_submap->get_furn( l ); if( current_furn != f_null && !current_furn->has_flag( ter_furn_flag::TFLAG_ALLOW_ON_OPEN_AIR ) ) { debugmsg( "Setting terrain %s at %s where furniture is %s. Terrain is_open_air\n" "If this is intentional, set the ALLOW_ON_OPEN_AIR flag on the furniture", - new_terrain.id().str(), p.to_string(), current_furn.id().str() ); + new_terrain->id.str(), p.to_string(), current_furn->id.str() ); } } @@ -2282,7 +2284,8 @@ bool map::ter_set( const tripoint &p, const ter_id &new_terrain, bool avoid_crea return true; } -bool map::ter_set( const tripoint_bub_ms &p, const ter_id &new_terrain, bool avoid_creatures ) +bool map::ter_set( const tripoint_bub_ms &p, const resolved_ter_id &new_terrain, + bool avoid_creatures ) { return ter_set( p.raw(), new_terrain, avoid_creatures ); } @@ -2669,7 +2672,7 @@ bool map::supports_above( const tripoint &p ) const return true; } - const furn_id frn_id = tile.get_furn(); + const resolved_furn_id frn_id = tile.get_furn(); if( frn_id != f_null ) { const furn_t &frn = frn_id.obj(); if( frn.movecost < 0 ) { @@ -2711,7 +2714,7 @@ void map::drop_everything( const tripoint &p ) void map::drop_furniture( const tripoint &p ) { - const furn_id frn = furn( p ); + const resolved_furn_id frn = furn( p ); if( frn == f_null ) { return; } @@ -2739,7 +2742,7 @@ void map::drop_furniture( const tripoint &p ) return SS_GOOD_SUPPORT; } - const furn_id frn_id = furn( below_dest ); + const resolved_furn_id frn_id = furn( below_dest ); if( frn_id != f_null ) { const furn_t &frn = frn_id.obj(); // Allow crushing tiny/nocollide furniture @@ -3226,8 +3229,8 @@ int map::bash_rating( const int str, const tripoint &p, const bool allow_floor ) // End of 3D bashable -void map::make_rubble( const tripoint &p, const furn_id &rubble_type, const bool items, - const ter_id &floor_type, bool overwrite ) +void map::make_rubble( const tripoint &p, const resolved_furn_id &rubble_type, const bool items, + const resolved_ter_id &floor_type, bool overwrite ) { if( overwrite ) { ter_set( p, floor_type ); @@ -3541,7 +3544,7 @@ bool map::has_nearby_chair( const tripoint &p, int radius ) const return false; } -bool map::has_nearby_ter( const tripoint &p, const ter_id &type, int radius ) const +bool map::has_nearby_ter( const tripoint &p, const resolved_ter_id &type, int radius ) const { for( const tripoint &pt : points_in_radius( p, radius ) ) { if( ter( pt ) == type ) { @@ -3863,7 +3866,7 @@ void map::smash_items( const tripoint &p, const int power, const std::string &ca } } -ter_id map::get_roof( const tripoint &p, const bool allow_air ) const +resolved_ter_id map::get_roof( const tripoint &p, const bool allow_air ) const { // This function should not be called from the 2D mode // Just use t_dirt instead @@ -3886,7 +3889,7 @@ ter_id map::get_roof( const tripoint &p, const bool allow_air ) const return t_open_air; } - ter_id new_ter = roof.id(); + resolved_ter_id new_ter = roof.id(); if( new_ter == t_null ) { debugmsg( "map::get_new_floor: %d,%d,%d has invalid roof type %s", p.x, p.y, p.z, roof.c_str() ); @@ -3951,7 +3954,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) // HACK: A hack for destroy && !bash_floor // We have to check what would we create and cancel if it is what we have now tripoint below( p.xy(), p.z - 1 ); - const ter_id roof = get_roof( below, false ); + const resolved_ter_id roof = get_roof( below, false ); if( roof == ter( p ) ) { smash_ter = false; bash = nullptr; @@ -4075,14 +4078,14 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) // Special code to collapse the tent if destroyed if( tent ) { // Get ids of possible centers - std::set centers; + std::set centers; for( const auto &cur_id : bash->tent_centers ) { if( cur_id.is_valid() ) { centers.insert( cur_id ); } } - std::optional> tentp; + std::optional> tentp; // Find the center of the tent // First check if we're not currently bashing the center @@ -4090,7 +4093,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) tentp.emplace( p, furn( p ) ); } else { for( const tripoint &pt : points_in_radius( p, bash->collapse_radius ) ) { - const furn_id &f_at = furn( pt ); + const resolved_furn_id &f_at = furn( pt ); // Check if we found the center of the current tent if( centers.count( f_at ) > 0 ) { tentp.emplace( pt, f_at ); @@ -4106,7 +4109,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) // Take the tent down const int rad = tentp->second.obj().bash.collapse_radius; for( const tripoint &pt : points_in_radius( tentp->first, rad ) ) { - const furn_id frn = furn( pt ); + const resolved_furn_id frn = furn( pt ); if( frn == f_null ) { continue; } @@ -4166,7 +4169,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) if( smash_ter && ter( p ) == t_open_air && zlevels ) { tripoint below( p.xy(), p.z - 1 ); - const ter_id roof = get_roof( below, params.bash_floor && ter( below ).obj().movecost != 0 ); + const resolved_ter_id roof = get_roof( below, params.bash_floor && + ter( below ).obj().movecost != 0 ); ter_set( p, roof ); } @@ -4453,8 +4457,8 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) return false; }; - furn_id furniture = furn( p ); - ter_id terrain = ter( p ); + resolved_furn_id furniture = furn( p ); + resolved_ter_id terrain = ter( p ); bool hit_something = false; // shoot through furniture or terrain and see if we hit something @@ -4530,7 +4534,7 @@ bool map::hit_with_acid( const tripoint &p ) if( passable( p ) ) { return false; // Didn't hit the tile! } - const ter_id t = ter( p ); + const resolved_ter_id t = ter( p ); if( t == t_wall_glass || t == t_wall_glass_alarm || t == t_vat ) { ter_set( p, t_floor ); @@ -4634,7 +4638,7 @@ bool map::open_door( Creature const &u, const tripoint &p, const bool inside, return false; } -void map::translate( const ter_id &from, const ter_id &to ) +void map::translate( const resolved_ter_id &from, const resolved_ter_id &to ) { if( from == to ) { debugmsg( "map::translate %s => %s", @@ -4650,8 +4654,8 @@ void map::translate( const ter_id &from, const ter_id &to ) } //This function performs the translate function within a given radius of the player. -void map::translate_radius( const ter_id &from, const ter_id &to, float radi, const tripoint &p, - const bool same_submap, const bool toggle_between ) +void map::translate_radius( const resolved_ter_id &from, const resolved_ter_id &to, float radi, + const tripoint &p, const bool same_submap, const bool toggle_between ) { if( from == to ) { debugmsg( "map::translate %s => %s", from.obj().name(), to.obj().name() ); @@ -5321,7 +5325,7 @@ item map::water_from( const tripoint &p ) } } - const ter_id terrain_id = ter( p ); + const resolved_ter_id terrain_id = ter( p ); if( terrain_id == t_sewage ) { item ret( "water_sewage", calendar::turn, item::INFINITE_CHARGES ); ret.set_item_temperature( std::max( weather.get_temperature( p ), @@ -7298,7 +7302,7 @@ int map::obstacle_coverage( const tripoint &loc1, const tripoint &loc2 ) const obstaclepos = new_point; return false; } ); - if( const furn_id obstacle_f = furn( obstaclepos ) ) { + if( const resolved_furn_id obstacle_f = furn( obstaclepos ); obstacle_f != f_null ) { return obstacle_f->coverage; } if( const optional_vpart_position vp = veh_at( obstaclepos ) ) { @@ -7347,7 +7351,7 @@ int map::ledge_coverage( const Creature &viewer, const tripoint &target_p ) cons } } // Viewer eye level is higher when standing on furniture - const furn_id viewer_furn = furn( viewer_p ); + const resolved_furn_id viewer_furn = furn( viewer_p ); if( viewer_furn.obj().id ) { eye_level += viewer_furn->coverage * 0.01f; } @@ -7398,7 +7402,7 @@ int map::ledge_coverage( const tripoint &viewer_p, const tripoint &target_p, float ledge_coverage = ( covered_z - target_p.z * zlevel_to_grid_ratio ) * 100; // Target has a coverage penalty when standing on furniture - const furn_id target_furn = furn( target_p ); + const resolved_furn_id target_furn = furn( target_p ); if( target_furn.obj().id || ( move_cost( target_p ) > 2 && !has_flag_ter( ter_furn_flag::TFLAG_FLAT, target_p ) ) ) { ledge_coverage -= target_furn->coverage; @@ -7409,7 +7413,7 @@ int map::ledge_coverage( const tripoint &viewer_p, const tripoint &target_p, int map::coverage( const tripoint &p ) const { - if( const furn_id obstacle_f = furn( p ) ) { + if( const resolved_furn_id obstacle_f = furn( p ); obstacle_f != f_null ) { return obstacle_f->coverage; } if( const optional_vpart_position vp = veh_at( p ) ) { @@ -8433,19 +8437,19 @@ void map::rad_scorch( const tripoint &p, const time_duration &time_since_last_ac furn_set( p, f_null ); } - const ter_id tid = ter( p ); + const resolved_ter_id tid = ter( p ); // TODO: De-hardcode this - static const std::map dies_into {{ - {t_grass, ter_t_dirt}, - {t_tree_young, ter_t_dirt}, - {t_tree_pine, ter_t_tree_deadpine}, - {t_tree_birch, ter_t_tree_birch_harvested}, - {t_tree_willow, ter_t_tree_willow_harvested}, - {t_tree_hickory, ter_t_tree_hickory_dead}, - {t_tree_hickory_harvested, ter_t_tree_hickory_dead}, + static const std::map dies_into {{ + {t_grass->id, ter_t_dirt}, + {t_tree_young->id, ter_t_dirt}, + {t_tree_pine->id, ter_t_tree_deadpine}, + {t_tree_birch->id, ter_t_tree_birch_harvested}, + {t_tree_willow->id, ter_t_tree_willow_harvested}, + {t_tree_hickory->id, ter_t_tree_hickory_dead}, + {t_tree_hickory_harvested->id, ter_t_tree_hickory_dead}, }}; - const auto iter = dies_into.find( tid ); + const auto iter = dies_into.find( tid->id ); if( iter != dies_into.end() ) { ter_set( p, iter->second ); return; @@ -8572,7 +8576,7 @@ void map::add_roofs( const tripoint &grid ) for( int x = 0; x < SEEX; x++ ) { for( int y = 0; y < SEEY; y++ ) { - const ter_id ter_here = sub_here->get_ter( { x, y } ); + const resolved_ter_id ter_here = sub_here->get_ter( { x, y } ); if( ter_here != t_open_air ) { continue; } @@ -8942,7 +8946,7 @@ bool tinymap::inbounds( const tripoint &p ) const // set up a map just long enough scribble on it // this tinymap should never, ever get saved -fake_map::fake_map( const ter_id &ter_type ) +fake_map::fake_map( const resolved_ter_id &ter_type ) { const tripoint_abs_sm tripoint_below_zero( 0, 0, fake_map_z ); @@ -9556,7 +9560,7 @@ size_t map::get_nonant( const tripoint &gridp ) const } } -void map::draw_line_ter( const ter_id &type, const point &p1, const point &p2, +void map::draw_line_ter( const resolved_ter_id &type, const point &p1, const point &p2, bool avoid_creatures ) { draw_line( [this, type, avoid_creatures]( const point & p ) { @@ -9564,7 +9568,7 @@ void map::draw_line_ter( const ter_id &type, const point &p1, const point &p2, }, p1, p2 ); } -void map::draw_line_furn( const furn_id &type, const point &p1, const point &p2, +void map::draw_line_furn( const resolved_furn_id &type, const point &p1, const point &p2, bool avoid_creatures ) { draw_line( [this, type, avoid_creatures]( const point & p ) { @@ -9572,7 +9576,7 @@ void map::draw_line_furn( const furn_id &type, const point &p1, const point &p2, }, p1, p2 ); } -void map::draw_fill_background( const ter_id &type ) +void map::draw_fill_background( const resolved_ter_id &type ) { // Need to explicitly set caches dirty - set_ter would do it before set_transparency_cache_dirty( abs_sub.z() ); @@ -9593,16 +9597,16 @@ void map::draw_fill_background( const ter_id &type ) } } -void map::draw_fill_background( ter_id( *f )() ) +void map::draw_fill_background( resolved_ter_id( *f )() ) { draw_square_ter( f, point_zero, point( SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ) ); } -void map::draw_fill_background( const weighted_int_list &f ) +void map::draw_fill_background( const weighted_int_list &f ) { draw_square_ter( f, point_zero, point( SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ) ); } -void map::draw_square_ter( const ter_id &type, const point &p1, const point &p2, +void map::draw_square_ter( const resolved_ter_id &type, const point &p1, const point &p2, bool avoid_creatures ) { draw_square( [this, type, avoid_creatures]( const point & p ) { @@ -9610,7 +9614,7 @@ void map::draw_square_ter( const ter_id &type, const point &p1, const point &p2, }, p1, p2 ); } -void map::draw_square_furn( const furn_id &type, const point &p1, const point &p2, +void map::draw_square_furn( const resolved_furn_id &type, const point &p1, const point &p2, bool avoid_creatures ) { draw_square( [this, type, avoid_creatures]( const point & p ) { @@ -9618,30 +9622,31 @@ void map::draw_square_furn( const furn_id &type, const point &p1, const point &p }, p1, p2 ); } -void map::draw_square_ter( ter_id( *f )(), const point &p1, const point &p2, bool avoid_creatures ) +void map::draw_square_ter( resolved_ter_id( *f )(), const point &p1, const point &p2, + bool avoid_creatures ) { draw_square( [this, f, avoid_creatures]( const point & p ) { this->ter_set( p, f(), avoid_creatures ); }, p1, p2 ); } -void map::draw_square_ter( const weighted_int_list &f, const point &p1, +void map::draw_square_ter( const weighted_int_list &f, const point &p1, const point &p2, bool avoid_creatures ) { draw_square( [this, f, avoid_creatures]( const point & p ) { - const ter_id *tid = f.pick(); + const resolved_ter_id *tid = f.pick(); this->ter_set( p, tid != nullptr ? *tid : t_null, avoid_creatures ); }, p1, p2 ); } -void map::draw_rough_circle_ter( const ter_id &type, const point &p, int rad ) +void map::draw_rough_circle_ter( const resolved_ter_id &type, const point &p, int rad ) { draw_rough_circle( [this, type]( const point & q ) { this->ter_set( q, type ); }, p, rad ); } -void map::draw_rough_circle_furn( const furn_id &type, const point &p, int rad ) +void map::draw_rough_circle_furn( const resolved_furn_id &type, const point &p, int rad ) { draw_rough_circle( [this, type]( const point & q ) { if( !is_open_air( tripoint( q, abs_sub.z() ) ) ) { @@ -9650,21 +9655,21 @@ void map::draw_rough_circle_furn( const furn_id &type, const point &p, int rad ) }, p, rad ); } -void map::draw_circle_ter( const ter_id &type, const rl_vec2d &p, double rad ) +void map::draw_circle_ter( const resolved_ter_id &type, const rl_vec2d &p, double rad ) { draw_circle( [this, type]( const point & q ) { this->ter_set( q, type ); }, p, rad ); } -void map::draw_circle_ter( const ter_id &type, const point &p, int rad ) +void map::draw_circle_ter( const resolved_ter_id &type, const point &p, int rad ) { draw_circle( [this, type]( const point & q ) { this->ter_set( q, type ); }, p, rad ); } -void map::draw_circle_furn( const furn_id &type, const point &p, int rad ) +void map::draw_circle_furn( const resolved_furn_id &type, const point &p, int rad ) { draw_circle( [this, type]( const point & q ) { this->furn_set( q, type ); diff --git a/src/map.h b/src/map.h index de3c82c6af5a0..799890468db9d 100644 --- a/src/map.h +++ b/src/map.h @@ -786,8 +786,10 @@ class map vehicle *move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing ); // Furniture - void set( const tripoint &p, const ter_id &new_terrain, const furn_id &new_furniture ); - void set( const point &p, const ter_id &new_terrain, const furn_id &new_furniture ) { + void set( const tripoint &p, const resolved_ter_id &new_terrain, + const resolved_furn_id &new_furniture ); + void set( const point &p, const resolved_ter_id &new_terrain, + const resolved_furn_id &new_furniture ) { furn_set( p, new_furniture ); ter_set( p, new_terrain ); } @@ -810,9 +812,9 @@ class map return has_furn( tripoint( p, abs_sub.z() ) ); } // TODO: fix point types (remove the first overload) - furn_id furn( const tripoint &p ) const; - furn_id furn( const tripoint_bub_ms &p ) const; - furn_id furn( const point &p ) const { + resolved_furn_id furn( const tripoint &p ) const; + resolved_furn_id furn( const tripoint_bub_ms &p ) const; + resolved_furn_id furn( const point &p ) const { return furn( tripoint( p, abs_sub.z() ) ); } /** @@ -820,11 +822,12 @@ class map * when the player is grab-moving furniture */ // TODO: fix point types (remove the first overload) - bool furn_set( const tripoint &p, const furn_id &new_furniture, bool furn_reset = false, + bool furn_set( const tripoint &p, const resolved_furn_id &new_furniture, bool furn_reset = false, bool avoid_creatures = false ); - bool furn_set( const tripoint_bub_ms &p, const furn_id &new_furniture, + bool furn_set( const tripoint_bub_ms &p, const resolved_furn_id &new_furniture, bool furn_reset = false, bool avoid_creatures = false ); - bool furn_set( const point &p, const furn_id &new_furniture, bool avoid_creatures = false ) { + bool furn_set( const point &p, const resolved_furn_id &new_furniture, + bool avoid_creatures = false ) { return furn_set( tripoint( p, abs_sub.z() ), new_furniture, false, avoid_creatures ); } void furn_clear( const tripoint &p ) { @@ -843,9 +846,9 @@ class map // Terrain // TODO: fix point types (remove the first overload) - ter_id ter( const tripoint &p ) const; - ter_id ter( const tripoint_bub_ms &p ) const; - ter_id ter( const point &p ) const { + resolved_ter_id ter( const tripoint &p ) const; + resolved_ter_id ter( const tripoint_bub_ms &p ) const; + resolved_ter_id ter( const point &p ) const { return ter( tripoint( p, abs_sub.z() ) ); } @@ -860,10 +863,10 @@ class map // at specific positions. This is used to display terrain overview in // the map editor. uint8_t get_known_connections( const tripoint &p, const std::bitset &connect_group, - const std::map &override = {} ) const; + const std::map &override = {} ) const; // as above, but for furniture uint8_t get_known_connections_f( const tripoint &p, const std::bitset &connect_group, - const std::map &override = {} ) const; + const std::map &override = {} ) const; // Return a bitfield of the adjacent tiles which rotate towards the given // connect_group. From least-significant bit the order is south, east, @@ -873,11 +876,11 @@ class map // Additional overrides can be passed in to override terrain // at specific positions. uint8_t get_known_rotates_to( const tripoint &p, const std::bitset &rotate_to_group, - const std::map &override = {} ) const; + const std::map &override = {} ) const; // as above, but for furniture (considers neighbouring terrain and furniture) uint8_t get_known_rotates_to_f( const tripoint &p, const std::bitset &rotate_to_group, - const std::map &override = {}, - const std::map &override_f = {} ) const; + const std::map &override = {}, + const std::map &override_f = {} ) const; /** * Returns the full harvest list, for spawning. @@ -890,13 +893,15 @@ class map ter_id get_ter_transforms_into( const tripoint &p ) const; // TODO: fix point types (remove the first overload) - bool ter_set( const tripoint &p, const ter_id &new_terrain, bool avoid_creatures = false ); - bool ter_set( const tripoint_bub_ms &, const ter_id &new_terrain, bool avoid_creatures = false ); + bool ter_set( const tripoint &p, const resolved_ter_id &new_terrain, bool avoid_creatures = false ); + bool ter_set( const tripoint_bub_ms &, const resolved_ter_id &new_terrain, + bool avoid_creatures = false ); // TODO: fix point types (remove the first overload) - bool ter_set( const point &p, const ter_id &new_terrain, bool avoid_creatures = false ) { + bool ter_set( const point &p, const resolved_ter_id &new_terrain, bool avoid_creatures = false ) { return ter_set( tripoint( p, abs_sub.z() ), new_terrain, avoid_creatures ); } - bool ter_set( const point_bub_ms &p, const ter_id &new_terrain, bool avoid_creatures = false ) { + bool ter_set( const point_bub_ms &p, const resolved_ter_id &new_terrain, + bool avoid_creatures = false ) { return ter_set( tripoint_bub_ms( p, abs_sub.z() ), new_terrain, avoid_creatures ); } @@ -921,7 +926,7 @@ class map /** * Checks whether a specific terrain is nearby. */ - bool has_nearby_ter( const tripoint &p, const ter_id &type, int radius = 1 ) const; + bool has_nearby_ter( const tripoint &p, const resolved_ter_id &type, int radius = 1 ) const; /** * Check if creature can see some items at p. Includes: * - check for items at this location (has_items(p)) @@ -1073,9 +1078,9 @@ class map // Rubble /** Generates rubble at the given location, if overwrite is true it just writes on top of what currently exists * floor_type is only used if there is a non-bashable wall at the location or with overwrite = true */ - void make_rubble( const tripoint &p, const furn_id &rubble_type, bool items, - const ter_id &floor_type, bool overwrite = false ); - void make_rubble( const tripoint &p, const furn_id &rubble_type, bool items ) { + void make_rubble( const tripoint &p, const resolved_furn_id &rubble_type, bool items, + const resolved_ter_id &floor_type, bool overwrite = false ); + void make_rubble( const tripoint &p, const resolved_furn_id &rubble_type, bool items ) { make_rubble( p, rubble_type, items, t_dirt, false ); } void make_rubble( const tripoint &p ) { @@ -1133,36 +1138,37 @@ class map point random_outdoor_tile() const; // mapgen - void draw_line_ter( const ter_id &type, const point &p1, const point &p2, + void draw_line_ter( const resolved_ter_id &type, const point &p1, const point &p2, bool avoid_creature = false ); - void draw_line_furn( const furn_id &type, const point &p1, const point &p2, + void draw_line_furn( const resolved_furn_id &type, const point &p1, const point &p2, bool avoid_creatures = false ); - void draw_fill_background( const ter_id &type ); - void draw_fill_background( ter_id( *f )() ); - void draw_fill_background( const weighted_int_list &f ); + void draw_fill_background( const resolved_ter_id &type ); + void draw_fill_background( resolved_ter_id( *f )() ); + void draw_fill_background( const weighted_int_list &f ); - void draw_square_ter( const ter_id &type, const point &p1, const point &p2, + void draw_square_ter( const resolved_ter_id &type, const point &p1, const point &p2, bool avoid_creature = false ); - void draw_square_furn( const furn_id &type, const point &p1, const point &p2, + void draw_square_furn( const resolved_furn_id &type, const point &p1, const point &p2, bool avoid_creatures = false ); - void draw_square_ter( ter_id( *f )(), const point &p1, const point &p2, + void draw_square_ter( resolved_ter_id( *f )(), const point &p1, const point &p2, bool avoid_creatures = false ); - void draw_square_ter( const weighted_int_list &f, const point &p1, + void draw_square_ter( const weighted_int_list &f, const point &p1, const point &p2, bool avoid_creatures = false ); - void draw_rough_circle_ter( const ter_id &type, const point &p, int rad ); - void draw_rough_circle_furn( const furn_id &type, const point &p, int rad ); - void draw_circle_ter( const ter_id &type, const rl_vec2d &p, double rad ); - void draw_circle_ter( const ter_id &type, const point &p, int rad ); - void draw_circle_furn( const furn_id &type, const point &p, int rad ); + void draw_rough_circle_ter( const resolved_ter_id &type, const point &p, int rad ); + void draw_rough_circle_furn( const resolved_furn_id &type, const point &p, int rad ); + void draw_circle_ter( const resolved_ter_id &type, const rl_vec2d &p, double rad ); + void draw_circle_ter( const resolved_ter_id &type, const point &p, int rad ); + void draw_circle_furn( const resolved_furn_id &type, const point &p, int rad ); void add_corpse( const tripoint &p ); // Terrain changing functions // Change all instances of $from->$to - void translate( const ter_id &from, const ter_id &to ); + void translate( const resolved_ter_id &from, const resolved_ter_id &to ); // Change all instances $from->$to within this radius, optionally limited to locations in the same submap. // Optionally toggles instances $from->$to & $to->$from - void translate_radius( const ter_id &from, const ter_id &to, float radi, const tripoint &p, + void translate_radius( const resolved_ter_id &from, const resolved_ter_id &to, float radi, + const tripoint &p, bool same_submap = false, bool toggle_between = false ); void transform_radius( const ter_furn_transform_id &transform, int radi, const tripoint_abs_ms &p ); @@ -2185,7 +2191,7 @@ class map // Gets the roof type of the tile at p // Second argument refers to whether we have to get a roof (we're over an unpassable tile) // or can just return air because we bashed down an entire floor tile - ter_id get_roof( const tripoint &p, bool allow_air ) const; + resolved_ter_id get_roof( const tripoint &p, bool allow_air ) const; public: void process_items(); @@ -2381,7 +2387,7 @@ class fake_map : public tinymap private: std::vector> temp_submaps_; public: - explicit fake_map( const ter_id &ter_type = t_dirt ); + explicit fake_map( const resolved_ter_id &ter_type = t_dirt ); ~fake_map() override; static constexpr int fake_map_z = -OVERMAP_DEPTH; }; diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 26ffd849e8bb7..440e50bc4f276 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -229,22 +229,22 @@ static void dead_vegetation_parser( map &m, const tripoint &loc ) m.spawn_item( loc, itype_withered ); } // terrain specific conversions - const ter_id tid = m.ter( loc ); - static const std::map dies_into {{ - {t_grass, ter_t_grass_dead}, - {t_grass_long, ter_t_grass_dead}, - {t_grass_tall, ter_t_grass_dead}, - {t_moss, ter_t_grass_dead}, - {t_tree_pine, ter_t_tree_deadpine}, - {t_tree_birch, ter_t_tree_birch_harvested}, - {t_tree_willow, ter_t_tree_dead}, - {t_tree_hickory, ter_t_tree_hickory_dead}, - {t_tree_hickory_harvested, ter_t_tree_hickory_dead}, - {t_grass_golf, ter_t_grass_dead}, - {t_grass_white, ter_t_grass_dead}, + const resolved_ter_id tid = m.ter( loc ); + static const std::map dies_into {{ + {t_grass->id, ter_t_grass_dead}, + {t_grass_long->id, ter_t_grass_dead}, + {t_grass_tall->id, ter_t_grass_dead}, + {t_moss->id, ter_t_grass_dead}, + {t_tree_pine->id, ter_t_tree_deadpine}, + {t_tree_birch->id, ter_t_tree_birch_harvested}, + {t_tree_willow->id, ter_t_tree_dead}, + {t_tree_hickory->id, ter_t_tree_hickory_dead}, + {t_tree_hickory_harvested->id, ter_t_tree_hickory_dead}, + {t_grass_golf->id, ter_t_grass_dead}, + {t_grass_white->id, ter_t_grass_dead}, }}; - const auto iter = dies_into.find( tid ); + const auto iter = dies_into.find( tid->id ); if( iter != dies_into.end() ) { m.ter_set( loc, iter->second ); } @@ -1118,7 +1118,7 @@ static bool mx_grove( map &m, const tripoint &abs_sub ) // This map extra finds the first tree in the area, and then converts all trees, young trees, // and shrubs in the area into that type of tree. - ter_id tree; + resolved_ter_id tree; bool found_tree = false; for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { @@ -1153,7 +1153,7 @@ static bool mx_shrubbery( map &m, const tripoint &abs_sub ) // This map extra finds the first shrub in the area, and then converts all trees, young trees, // and shrubs in the area into that type of shrub. - ter_id shrubbery; + resolved_ter_id shrubbery; bool found_shrubbery = false; for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { @@ -1320,7 +1320,7 @@ static bool mx_point_dead_vegetation( map &m, const tripoint &abs_sub ) static void burned_ground_parser( map &m, const tripoint &loc ) { const furn_t &fid = m.furn( loc ).obj(); - const ter_id tid = m.ter( loc ); + const resolved_ter_id tid = m.ter( loc ); const ter_t &tr = tid.obj(); VehicleList vehs = m.get_vehicles(); @@ -1358,17 +1358,17 @@ static void burned_ground_parser( map &m, const tripoint &loc ) // grass is converted separately // this method is deliberate to allow adding new post-terrains // (TODO: expand this list when new destroyed terrain is added) - static const std::map dies_into {{ - {t_grass, ter_t_grass_dead}, - {t_grass_long, ter_t_grass_dead}, - {t_grass_tall, ter_t_grass_dead}, - {t_moss, ter_t_grass_dead}, - {t_fungus, ter_t_dirt}, - {t_grass_golf, ter_t_grass_dead}, - {t_grass_white, ter_t_grass_dead}, + static const std::map dies_into {{ + {t_grass->id, ter_t_grass_dead}, + {t_grass_long->id, ter_t_grass_dead}, + {t_grass_tall->id, ter_t_grass_dead}, + {t_moss->id, ter_t_grass_dead}, + {t_fungus->id, ter_t_dirt}, + {t_grass_golf->id, ter_t_grass_dead}, + {t_grass_white->id, ter_t_grass_dead}, }}; - const auto iter = dies_into.find( tid ); + const auto iter = dies_into.find( tid->id ); if( iter != dies_into.end() ) { if( one_in( 6 ) ) { m.ter_set( loc, t_dirt ); @@ -1524,7 +1524,7 @@ static bool mx_reed( map &m, const tripoint &abs_sub ) return false; }; - weighted_int_list vegetation; + weighted_int_list vegetation; vegetation.add( f_cattails, 15 ); vegetation.add( f_lotus, 5 ); vegetation.add( furn_id( "f_purple_loosestrife" ), 1 ); @@ -1534,7 +1534,7 @@ static bool mx_reed( map &m, const tripoint &abs_sub ) const tripoint loc( i, j, abs_sub.z ); if( ( m.ter( loc ) == t_water_sh || m.ter( loc ) == t_water_moving_sh ) && one_in( intensity ) ) { - m.furn_set( loc, vegetation.pick()->id() ); + m.furn_set( loc, *vegetation.pick() ); } // tall grass imitates reed if( ( m.ter( loc ) == t_dirt || m.ter( loc ) == t_grass ) && @@ -1566,12 +1566,12 @@ static bool mx_roadworks( map &m, const tripoint &abs_sub ) const bool road_at_east = east->get_type_id() == oter_type_road; // defect types - weighted_int_list road_defects; + weighted_int_list road_defects; road_defects.add( t_pit_shallow, 15 ); road_defects.add( t_dirt, 15 ); road_defects.add( t_dirtmound, 15 ); road_defects.add( t_pavement, 55 ); - const weighted_int_list defects = road_defects; + const weighted_int_list defects = road_defects; // location holders point defects_from; // road defects square start diff --git a/src/map_field.cpp b/src/map_field.cpp index 5ef9593bdec74..804421d4be8a1 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1144,7 +1144,7 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da } } // If the flames are in a pit, it can't spread to non-pit - const bool in_pit = ter.id.id() == t_pit; + const bool in_pit = ter.id == t_pit->id; // Count adjacent fires, to optimize out needless smoke and hot air int adjacent_fires = 0; @@ -1301,7 +1301,7 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da // Allow weaker fires to spread occasionally const int power = cur.get_field_intensity() + one_in( 5 ); if( can_spread && rng( 1, 100 ) < spread_chance && - ( in_pit == ( dster.id.id() == t_pit ) ) && + ( in_pit == ( dster.id == t_pit->id ) ) && ( ( power >= 2 && ( ter_furn_has_flag( dster, dsfrn, ter_furn_flag::TFLAG_FLAMMABLE ) && one_in( 2 ) ) ) || @@ -1361,7 +1361,7 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da // Allow weaker fires to spread occasionally const int power = cur.get_field_intensity() + one_in( 5 ); if( can_spread && rng( 1, 100 ) < spread_chance && - ( in_pit == ( dster.id.id() == t_pit ) ) && + ( in_pit == ( dster.id == t_pit->id ) ) && ( ( power >= 2 && ( ter_furn_has_flag( dster, dsfrn, ter_furn_flag::TFLAG_FLAMMABLE ) && one_in( 2 ) ) ) || diff --git a/src/mapdata.cpp b/src/mapdata.cpp index f1c06b3632dc8..bf699ccfaa760 100644 --- a/src/mapdata.cpp +++ b/src/mapdata.cpp @@ -36,11 +36,17 @@ const units::volume DEFAULT_MAX_VOLUME_IN_SQUARE = units::from_liter( 1000 ); generic_factory terrain_data( "terrain" ); generic_factory furniture_data( "furniture" ); +ter_id null_ter; +furn_id null_furn; + +ter_t invalid_ter; +furn_t invalid_furn; + } // namespace /** @relates int_id */ template<> -inline bool int_id::is_valid() const +bool int_id::is_valid() const { return terrain_data.is_valid( *this ); } @@ -63,7 +69,7 @@ const string_id &int_id::id() const template<> int_id string_id::id() const { - return terrain_data.convert( *this, t_null ); + return terrain_data.convert( *this, null_ter ); } /** @relates int_id */ @@ -86,6 +92,12 @@ bool string_id::is_valid() const return terrain_data.is_valid( *this ); } +template<> +const ter_t &resolved_id::invalid_obj() const +{ + return invalid_ter; +} + /** @relates int_id */ template<> bool int_id::is_valid() const @@ -125,7 +137,7 @@ const furn_t &string_id::obj() const template<> int_id string_id::id() const { - return furniture_data.convert( *this, f_null ); + return furniture_data.convert( *this, null_furn ); } /** @relates int_id */ @@ -134,6 +146,12 @@ int_id::int_id( const string_id &id ) : _id( id.id() ) { } +template<> +const furn_t &resolved_id::invalid_obj() const +{ + return invalid_furn; +} + namespace io { @@ -739,131 +757,133 @@ void map_data_common_t::set_groups( std::bitset &bits, } } -ter_id t_null, - t_hole, // Real nothingness; makes you fall a z-level - // Ground - t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave, t_grave_new, - t_pit_corpsed, t_pit_covered, t_pit_spiked, t_pit_spiked_covered, t_pit_glass, t_pit_glass_covered, - t_rock_floor, - t_grass, t_grass_long, t_grass_tall, t_grass_golf, t_grass_dead, t_grass_white, t_moss, - t_grass_alien, - t_metal_floor, - t_pavement, t_pavement_y, t_sidewalk, t_concrete, t_zebra, - t_thconc_floor, t_thconc_floor_olight, t_strconc_floor, - t_floor, t_floor_waxed, - t_dirtfloor,//Dirt floor(Has roof) - t_carpet_red, t_carpet_yellow, t_carpet_purple, t_carpet_green, - t_linoleum_white, t_linoleum_gray, - t_grate, - t_slime, - t_bridge, - t_covered_well, - // Lighting related - t_utility_light, - // Walls - t_wall_log_half, t_wall_log, t_wall_log_chipped, t_wall_log_broken, t_palisade, t_palisade_gate, - t_palisade_gate_o, - t_wall_half, t_wall_wood, t_wall_wood_chipped, t_wall_wood_broken, - t_wall, t_concrete_wall, t_brick_wall, - t_wall_metal, - t_scrap_wall, - t_scrap_wall_halfway, - t_wall_glass, - t_wall_glass_alarm, - t_reinforced_glass, t_reinforced_glass_shutter, t_reinforced_glass_shutter_open, - t_laminated_glass, t_ballistic_glass, - t_reinforced_door_glass_o, t_reinforced_door_glass_c, - t_bars, - t_reb_cage, - t_door_c, t_door_c_peep, t_door_b, t_door_b_peep, t_door_o, t_door_o_peep, t_rdoor_c, t_rdoor_b, - t_rdoor_o, t_door_locked_interior, t_door_locked, t_door_locked_peep, t_door_locked_alarm, - t_door_frame, - t_chaingate_l, t_fencegate_c, t_fencegate_o, t_chaingate_c, t_chaingate_o, - t_retractable_gate_c, t_retractable_gate_l, t_retractable_gate_o, - t_door_boarded, t_door_boarded_damaged, t_door_boarded_peep, t_rdoor_boarded, - t_rdoor_boarded_damaged, t_door_boarded_damaged_peep, - t_door_metal_c, t_door_metal_o, t_door_metal_locked, t_door_metal_pickable, t_mdoor_frame, - t_door_bar_c, t_door_bar_o, t_door_bar_locked, - t_door_glass_c, t_door_glass_o, t_door_glass_frosted_c, t_door_glass_frosted_o, - t_portcullis, - t_recycler, t_window, t_window_taped, t_window_domestic, t_window_domestic_taped, t_window_open, - t_curtains, t_window_bars_curtains, t_window_bars_domestic, - t_window_alarm, t_window_alarm_taped, t_window_empty, t_window_frame, t_window_boarded, - t_window_boarded_noglass, t_window_reinforced, t_window_reinforced_noglass, t_window_enhanced, - t_window_enhanced_noglass, t_window_bars_alarm, t_window_bars, - t_metal_grate_window, t_metal_grate_window_with_curtain, t_metal_grate_window_with_curtain_open, - t_metal_grate_window_noglass, t_metal_grate_window_with_curtain_noglass, - t_metal_grate_window_with_curtain_open_noglass, - t_window_stained_green, t_window_stained_red, t_window_stained_blue, - t_window_no_curtains, t_window_no_curtains_open, t_window_no_curtains_taped, - t_rock, t_fault, - t_paper, - t_rock_wall, t_rock_wall_half, - // Tree - t_tree, t_tree_young, t_tree_apple, t_tree_apple_harvested, t_tree_coffee, t_tree_coffee_harvested, - t_tree_pear, t_tree_pear_harvested, t_tree_cherry, t_tree_cherry_harvested, - t_tree_peach, t_tree_peach_harvested, t_tree_apricot, t_tree_apricot_harvested, t_tree_plum, - t_tree_plum_harvested, - t_tree_pine, t_tree_blackjack, t_tree_birch, t_tree_willow, t_tree_maple, t_tree_maple_tapped, - t_tree_hickory, t_tree_hickory_dead, t_tree_hickory_harvested, t_tree_deadpine, t_underbrush, - t_shrub, t_shrub_blueberry, t_shrub_strawberry, t_trunk, t_stump, - t_root_wall, - t_wax, t_floor_wax, - t_fence, t_chainfence, t_chainfence_posts, - t_fence_post, t_fence_wire, t_fence_barbed, t_fence_rope, - t_railing, - // Nether - t_marloss, t_fungus_floor_in, t_fungus_floor_sup, t_fungus_floor_out, t_fungus_wall, - t_fungus_mound, t_fungus, t_shrub_fungal, t_tree_fungal, t_tree_fungal_young, t_marloss_tree, - // Water, lava, etc. - t_water_moving_dp, t_water_moving_sh, t_water_sh, t_water_dp, t_swater_sh, t_swater_dp, - t_swater_surf, t_water_pool, t_sewage, - t_lava, - // More embellishments than you can shake a stick at. - t_sandbox, t_slide, t_monkey_bars, t_backboard, - t_gas_pump, t_gas_pump_smashed, - t_diesel_pump, t_diesel_pump_smashed, - t_atm, - t_missile, t_missile_exploded, - t_radio_tower, t_radio_controls, - t_gates_mech_control, t_gates_control_concrete, t_gates_control_brick, - t_barndoor, t_palisade_pulley, - t_gates_control_metal, - t_sewage_pipe, t_sewage_pump, - t_column, - t_vat, - t_rootcellar, - t_cvdbody, t_cvdmachine, - t_water_pump, - t_conveyor, - t_improvised_shelter, - // Staircases etc. - t_stairs_down, t_stairs_up, t_manhole, t_ladder_up, t_ladder_down, t_slope_down, - t_slope_up, t_rope_up, - t_manhole_cover, - // Special - t_card_science, t_card_military, t_card_industrial, t_card_reader_broken, t_slot_machine, - t_elevator_control, t_elevator_control_off, t_elevator, t_pedestal_wyrm, - t_pedestal_temple, - // Temple tiles - t_rock_red, t_rock_green, t_rock_blue, t_floor_red, t_floor_green, t_floor_blue, - t_switch_rg, t_switch_gb, t_switch_rb, t_switch_even, t_open_air, - t_pavement_bg_dp, t_pavement_y_bg_dp, t_sidewalk_bg_dp, t_guardrail_bg_dp, - t_rad_platform, - // Railroad and subway - t_railroad_rubble, - t_buffer_stop, t_railroad_crossing_signal, t_crossbuck_wood, t_crossbuck_metal, - t_railroad_tie, t_railroad_tie_h, t_railroad_tie_v, t_railroad_tie_d, - t_railroad_track, t_railroad_track_h, t_railroad_track_v, t_railroad_track_d, t_railroad_track_d1, - t_railroad_track_d2, - t_railroad_track_on_tie, t_railroad_track_h_on_tie, t_railroad_track_v_on_tie, - t_railroad_track_d_on_tie; +ter_str_id t_str_null( "t_null" ); + +resolved_ter_id t_null, + t_hole, // Real nothingness; makes you fall a z-level + // Ground + t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave, t_grave_new, + t_pit_corpsed, t_pit_covered, t_pit_spiked, t_pit_spiked_covered, t_pit_glass, t_pit_glass_covered, + t_rock_floor, + t_grass, t_grass_long, t_grass_tall, t_grass_golf, t_grass_dead, t_grass_white, t_moss, + t_grass_alien, + t_metal_floor, + t_pavement, t_pavement_y, t_sidewalk, t_concrete, t_zebra, + t_thconc_floor, t_thconc_floor_olight, t_strconc_floor, + t_floor, t_floor_waxed, + t_dirtfloor,//Dirt floor(Has roof) + t_carpet_red, t_carpet_yellow, t_carpet_purple, t_carpet_green, + t_linoleum_white, t_linoleum_gray, + t_grate, + t_slime, + t_bridge, + t_covered_well, + // Lighting related + t_utility_light, + // Walls + t_wall_log_half, t_wall_log, t_wall_log_chipped, t_wall_log_broken, t_palisade, t_palisade_gate, + t_palisade_gate_o, + t_wall_half, t_wall_wood, t_wall_wood_chipped, t_wall_wood_broken, + t_wall, t_concrete_wall, t_brick_wall, + t_wall_metal, + t_scrap_wall, + t_scrap_wall_halfway, + t_wall_glass, + t_wall_glass_alarm, + t_reinforced_glass, t_reinforced_glass_shutter, t_reinforced_glass_shutter_open, + t_laminated_glass, t_ballistic_glass, + t_reinforced_door_glass_o, t_reinforced_door_glass_c, + t_bars, + t_reb_cage, + t_door_c, t_door_c_peep, t_door_b, t_door_b_peep, t_door_o, t_door_o_peep, t_rdoor_c, t_rdoor_b, + t_rdoor_o, t_door_locked_interior, t_door_locked, t_door_locked_peep, t_door_locked_alarm, + t_door_frame, + t_chaingate_l, t_fencegate_c, t_fencegate_o, t_chaingate_c, t_chaingate_o, + t_retractable_gate_c, t_retractable_gate_l, t_retractable_gate_o, + t_door_boarded, t_door_boarded_damaged, t_door_boarded_peep, t_rdoor_boarded, + t_rdoor_boarded_damaged, t_door_boarded_damaged_peep, + t_door_metal_c, t_door_metal_o, t_door_metal_locked, t_door_metal_pickable, t_mdoor_frame, + t_door_bar_c, t_door_bar_o, t_door_bar_locked, + t_door_glass_c, t_door_glass_o, t_door_glass_frosted_c, t_door_glass_frosted_o, + t_portcullis, + t_recycler, t_window, t_window_taped, t_window_domestic, t_window_domestic_taped, t_window_open, + t_curtains, t_window_bars_curtains, t_window_bars_domestic, + t_window_alarm, t_window_alarm_taped, t_window_empty, t_window_frame, t_window_boarded, + t_window_boarded_noglass, t_window_reinforced, t_window_reinforced_noglass, t_window_enhanced, + t_window_enhanced_noglass, t_window_bars_alarm, t_window_bars, + t_metal_grate_window, t_metal_grate_window_with_curtain, t_metal_grate_window_with_curtain_open, + t_metal_grate_window_noglass, t_metal_grate_window_with_curtain_noglass, + t_metal_grate_window_with_curtain_open_noglass, + t_window_stained_green, t_window_stained_red, t_window_stained_blue, + t_window_no_curtains, t_window_no_curtains_open, t_window_no_curtains_taped, + t_rock, t_fault, + t_paper, + t_rock_wall, t_rock_wall_half, + // Tree + t_tree, t_tree_young, t_tree_apple, t_tree_apple_harvested, t_tree_coffee, t_tree_coffee_harvested, + t_tree_pear, t_tree_pear_harvested, t_tree_cherry, t_tree_cherry_harvested, + t_tree_peach, t_tree_peach_harvested, t_tree_apricot, t_tree_apricot_harvested, t_tree_plum, + t_tree_plum_harvested, + t_tree_pine, t_tree_blackjack, t_tree_birch, t_tree_willow, t_tree_maple, t_tree_maple_tapped, + t_tree_hickory, t_tree_hickory_dead, t_tree_hickory_harvested, t_tree_deadpine, t_underbrush, + t_shrub, t_shrub_blueberry, t_shrub_strawberry, t_trunk, t_stump, + t_root_wall, + t_wax, t_floor_wax, + t_fence, t_chainfence, t_chainfence_posts, + t_fence_post, t_fence_wire, t_fence_barbed, t_fence_rope, + t_railing, + // Nether + t_marloss, t_fungus_floor_in, t_fungus_floor_sup, t_fungus_floor_out, t_fungus_wall, + t_fungus_mound, t_fungus, t_shrub_fungal, t_tree_fungal, t_tree_fungal_young, t_marloss_tree, + // Water, lava, etc. + t_water_moving_dp, t_water_moving_sh, t_water_sh, t_water_dp, t_swater_sh, t_swater_dp, + t_swater_surf, t_water_pool, t_sewage, + t_lava, + // More embellishments than you can shake a stick at. + t_sandbox, t_slide, t_monkey_bars, t_backboard, + t_gas_pump, t_gas_pump_smashed, + t_diesel_pump, t_diesel_pump_smashed, + t_atm, + t_missile, t_missile_exploded, + t_radio_tower, t_radio_controls, + t_gates_mech_control, t_gates_control_concrete, t_gates_control_brick, + t_barndoor, t_palisade_pulley, + t_gates_control_metal, + t_sewage_pipe, t_sewage_pump, + t_column, + t_vat, + t_rootcellar, + t_cvdbody, t_cvdmachine, + t_water_pump, + t_conveyor, + t_improvised_shelter, + // Staircases etc. + t_stairs_down, t_stairs_up, t_manhole, t_ladder_up, t_ladder_down, t_slope_down, + t_slope_up, t_rope_up, + t_manhole_cover, + // Special + t_card_science, t_card_military, t_card_industrial, t_card_reader_broken, t_slot_machine, + t_elevator_control, t_elevator_control_off, t_elevator, t_pedestal_wyrm, + t_pedestal_temple, + // Temple tiles + t_rock_red, t_rock_green, t_rock_blue, t_floor_red, t_floor_green, t_floor_blue, + t_switch_rg, t_switch_gb, t_switch_rb, t_switch_even, t_open_air, + t_pavement_bg_dp, t_pavement_y_bg_dp, t_sidewalk_bg_dp, t_guardrail_bg_dp, + t_rad_platform, + // Railroad and subway + t_railroad_rubble, + t_buffer_stop, t_railroad_crossing_signal, t_crossbuck_wood, t_crossbuck_metal, + t_railroad_tie, t_railroad_tie_h, t_railroad_tie_v, t_railroad_tie_d, + t_railroad_track, t_railroad_track_h, t_railroad_track_v, t_railroad_track_d, t_railroad_track_d1, + t_railroad_track_d2, + t_railroad_track_on_tie, t_railroad_track_h_on_tie, t_railroad_track_v_on_tie, + t_railroad_track_d_on_tie; // TODO: Put this crap into an inclusion, which should be generated automatically using JSON data void set_ter_ids() { - t_null = ter_id( "t_null" ); + t_null = null_ter = t_str_null; t_hole = ter_id( "t_hole" ); t_dirt = ter_id( "t_dirt" ); t_sand = ter_id( "t_sand" ); @@ -1172,55 +1192,57 @@ void reset_furn_ter() furniture_data.reset(); } -furn_id f_null, f_clear, - f_hay, - f_rubble, f_rubble_rock, f_wreckage, f_ash, - f_barricade_road, f_sandbag_half, f_sandbag_wall, - f_bulletin, - f_indoor_plant, - f_bed, f_toilet, f_makeshift_bed, f_straw_bed, - f_sink, f_oven, f_woodstove, f_fireplace, f_bathtub, - f_chair, f_armchair, f_sofa, f_cupboard, f_trashcan, f_desk, f_exercise, - f_bench, f_table, f_pool_table, - f_counter, - f_fridge, f_glass_fridge, f_dresser, f_locker, - f_rack, f_bookcase, - f_washer, f_dryer, - f_vending_c, f_vending_o, f_dumpster, f_dive_block, - f_crate_c, f_crate_o, f_coffin_c, f_coffin_o, - f_gunsafe_ml, f_gunsafe_mj, f_gun_safe_el, - f_large_canvas_wall, f_canvas_wall, f_canvas_door, f_canvas_door_o, f_groundsheet, - f_fema_groundsheet, f_large_groundsheet, - f_large_canvas_door, f_large_canvas_door_o, f_center_groundsheet, f_skin_wall, f_skin_door, - f_skin_door_o, f_skin_groundsheet, - f_mutpoppy, f_flower_fungal, f_fungal_mass, f_fungal_clump, - f_cattails, f_lotus, f_lilypad, - f_safe_c, f_safe_l, f_safe_o, - f_plant_seed, f_plant_seedling, f_plant_mature, f_plant_harvest, - f_fvat_empty, f_fvat_full, f_fvat_wood_empty, f_fvat_wood_full, - f_wood_keg, - f_standing_tank, - f_egg_sackbw, f_egg_sackcs, f_egg_sackws, f_egg_sacke, - f_flower_marloss, - f_tatami, - f_kiln_empty, f_kiln_full, f_kiln_metal_empty, f_kiln_metal_full, - f_arcfurnace_empty, f_arcfurnace_full, - f_smoking_rack, f_smoking_rack_active, f_metal_smoking_rack, f_metal_smoking_rack_active, - f_water_mill, f_water_mill_active, - f_wind_mill, f_wind_mill_active, - f_robotic_arm, f_vending_reinforced, - f_brazier, - f_firering, - f_tourist_table, - f_camp_chair, - f_sign, - f_stook_empty, f_stook_full, - f_street_light, f_traffic_light, f_flagpole, f_wooden_flagpole, - f_console, f_console_broken; +static furn_str_id f_str_null( "f_null" ); + +resolved_furn_id f_null, f_clear, + f_hay, + f_rubble, f_rubble_rock, f_wreckage, f_ash, + f_barricade_road, f_sandbag_half, f_sandbag_wall, + f_bulletin, + f_indoor_plant, + f_bed, f_toilet, f_makeshift_bed, f_straw_bed, + f_sink, f_oven, f_woodstove, f_fireplace, f_bathtub, + f_chair, f_armchair, f_sofa, f_cupboard, f_trashcan, f_desk, f_exercise, + f_bench, f_table, f_pool_table, + f_counter, + f_fridge, f_glass_fridge, f_dresser, f_locker, + f_rack, f_bookcase, + f_washer, f_dryer, + f_vending_c, f_vending_o, f_dumpster, f_dive_block, + f_crate_c, f_crate_o, f_coffin_c, f_coffin_o, + f_gunsafe_ml, f_gunsafe_mj, f_gun_safe_el, + f_large_canvas_wall, f_canvas_wall, f_canvas_door, f_canvas_door_o, f_groundsheet, + f_fema_groundsheet, f_large_groundsheet, + f_large_canvas_door, f_large_canvas_door_o, f_center_groundsheet, f_skin_wall, f_skin_door, + f_skin_door_o, f_skin_groundsheet, + f_mutpoppy, f_flower_fungal, f_fungal_mass, f_fungal_clump, + f_cattails, f_lotus, f_lilypad, + f_safe_c, f_safe_l, f_safe_o, + f_plant_seed, f_plant_seedling, f_plant_mature, f_plant_harvest, + f_fvat_empty, f_fvat_full, f_fvat_wood_empty, f_fvat_wood_full, + f_wood_keg, + f_standing_tank, + f_egg_sackbw, f_egg_sackcs, f_egg_sackws, f_egg_sacke, + f_flower_marloss, + f_tatami, + f_kiln_empty, f_kiln_full, f_kiln_metal_empty, f_kiln_metal_full, + f_arcfurnace_empty, f_arcfurnace_full, + f_smoking_rack, f_smoking_rack_active, f_metal_smoking_rack, f_metal_smoking_rack_active, + f_water_mill, f_water_mill_active, + f_wind_mill, f_wind_mill_active, + f_robotic_arm, f_vending_reinforced, + f_brazier, + f_firering, + f_tourist_table, + f_camp_chair, + f_sign, + f_stook_empty, f_stook_full, + f_street_light, f_traffic_light, f_flagpole, f_wooden_flagpole, + f_console, f_console_broken; void set_furn_ids() { - f_null = furn_id( "f_null" ); + f_null = null_furn = f_str_null; f_clear = furn_id( "f_clear" ); f_hay = furn_id( "f_hay" ); f_rubble = furn_id( "f_rubble" ); @@ -1783,7 +1805,7 @@ void activity_data_ter::load( const JsonObject &jo ) void activity_data_furn::load( const JsonObject &jo ) { - optional( jo, was_loaded, "result", result_, f_null.id() ); + optional( jo, was_loaded, "result", result_, f_str_null ); activity_data_common::load( jo ); valid_ = true; } diff --git a/src/mapdata.h b/src/mapdata.h index fa3d44da61fe8..576e7885b0961 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -690,8 +690,9 @@ provided for terrains added by mods. A string equivalent is always present, i.e. t_basalt "t_basalt" */ +extern ter_str_id t_str_null; // NOLINTNEXTLINE(cata-static-int_id-constants) -extern ter_id t_null, +extern resolved_ter_id t_null, t_hole, // Real nothingness; makes you fall a z-level // Ground t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave, t_grave_new, @@ -817,7 +818,7 @@ furn_id refers to a position in the furnlist[] where the furn_t struct is stored about ter_id above. */ // NOLINTNEXTLINE(cata-static-int_id-constants) -extern furn_id f_null, f_clear, +extern resolved_furn_id f_null, f_clear, f_hay, f_cattails, f_lotus, f_lilypad, f_rubble, f_rubble_rock, f_wreckage, f_ash, f_barricade_road, f_sandbag_half, f_sandbag_wall, diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 442ec509449f3..7914b80880e73 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -825,7 +825,7 @@ mapgen_function_json::mapgen_function_json( const JsonObject &jsobj, dbl_or_var w, const std::string &context, const point &grid_offset, const point &grid_total ) : mapgen_function( std::move( w ) ) , mapgen_function_json_base( jsobj, context ) - , fill_ter( t_null ) + , fill_ter( t_str_null ) , rotation( 0 ) , fallback_predecessor_mapgen_( oter_str_id::NULL_ID() ) { @@ -2843,14 +2843,14 @@ class jmapgen_terrain : public jmapgen_piece void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const std::string &context ) const override { - ter_id chosen_id = id.get( dat ); - if( chosen_id.id().is_null() ) { + resolved_ter_id chosen_id = id.get( dat ); + if( chosen_id->is_null() ) { return; } point p( x.get(), y.get() ); tripoint tp( p, dat.m.get_abs_sub().z() ); - ter_id terrain_here = dat.m.ter( p ); + resolved_ter_id terrain_here = dat.m.ter( p ); const ter_t &chosen_ter = *chosen_id; const bool is_wall = chosen_ter.has_flag( ter_furn_flag::TFLAG_WALL ); const bool place_item = chosen_ter.has_flag( ter_furn_flag::TFLAG_PLACE_ITEM ); @@ -2910,7 +2910,7 @@ class jmapgen_terrain : public jmapgen_piece dat.m.delete_signage( tp ); } else if( act_furn == apply_action::act_dismantle ) { int max_recurse = 10; // insurance against infinite looping - std::string initial_furn = dat.m.furn( p ) != f_null ? dat.m.furn( p ).id().str() : ""; + std::string initial_furn = dat.m.furn( p ) != f_null ? dat.m.furn( p )->id.str() : ""; while( dat.m.has_furn( p ) && max_recurse-- > 0 ) { const furn_t &f = dat.m.furn( p ).obj(); if( f.deconstruct.can_do ) { @@ -2954,7 +2954,7 @@ class jmapgen_terrain : public jmapgen_piece trap_str_id trap_here = dat.m.tr_at( tp ).id; if( act_furn != apply_action::act_ignore && dat.m.furn( p ) != f_null ) { // NOLINTNEXTLINE(cata-translate-string-literal) - error = string_format( "furniture was %s", dat.m.furn( p ).id().str() ); + error = string_format( "furniture was %s", dat.m.furn( p )->id.str() ); } else if( act_trap != apply_action::act_ignore && !trap_here.is_null() && trap_here.id() != terrain_here->trap ) { // NOLINTNEXTLINE(cata-translate-string-literal) @@ -2970,8 +2970,8 @@ class jmapgen_terrain : public jmapgen_piece "adding suitable removal commands to the mapgen, or by adding an " "appropriate clearing flag to the innermost layered mapgen. " "Consult the \"mapgen flags\" section in MAPGEN.md for options.", - context, dat.terrain_type().id().str(), chosen_id.id().str(), - terrain_here.id().str(), p.to_string(), error ); + context, dat.terrain_type().id().str(), chosen_id->id.str(), + terrain_here->id.str(), p.to_string(), error ); } } dat.m.ter_set( p, chosen_id ); @@ -3019,9 +3019,9 @@ class jmapgen_ter_furn_transform: public jmapgen_piece class jmapgen_make_rubble : public jmapgen_piece { public: - mapgen_value rubble_type = mapgen_value( f_rubble ); + mapgen_value rubble_type = mapgen_value( f_rubble->id ); bool items = false; - mapgen_value floor_type = mapgen_value( t_dirt ); + mapgen_value floor_type = mapgen_value( t_dirt->id ); bool overwrite = false; jmapgen_make_rubble( const JsonObject &jsi, const std::string_view/*context*/ ) { if( jsi.has_member( "rubble_type" ) ) { @@ -3035,12 +3035,12 @@ class jmapgen_make_rubble : public jmapgen_piece } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const std::string &/*context*/ ) const override { - furn_id chosen_rubble_type = rubble_type.get( dat ); - ter_id chosen_floor_type = floor_type.get( dat ); - if( chosen_rubble_type.id().is_null() ) { + resolved_furn_id chosen_rubble_type = rubble_type.get( dat ); + resolved_ter_id chosen_floor_type = floor_type.get( dat ); + if( chosen_rubble_type->id.is_null() ) { return; } - if( chosen_floor_type.id().is_null() ) { + if( chosen_floor_type->is_null() ) { debugmsg( "null floor type when making rubble" ); chosen_floor_type = t_dirt; } @@ -4352,7 +4352,7 @@ bool mapgen_function_json::setup_internal( const JsonObject &jo ) jo.read( "fallback_predecessor_mapgen", fallback_predecessor_mapgen_ ); - return fill_ter != t_null || predecessor_mapgen != oter_str_id::NULL_ID() || + return fill_ter != t_str_null || predecessor_mapgen != oter_str_id::NULL_ID() || fallback_predecessor_mapgen_ != oter_str_id::NULL_ID(); } @@ -5120,7 +5120,7 @@ static bool apply_mapgen_in_phases( void mapgen_function_json::generate( mapgendata &md ) { map *const m = &md.m; - if( fill_ter != t_null ) { + if( fill_ter != t_str_null ) { m->draw_fill_background( fill_ter ); } const oter_t &ter = *md.terrain_type(); @@ -5428,7 +5428,8 @@ void map::draw_lab( mapgendata &dat ) boarders++; } - const auto maybe_insert_stairs = [this]( const oter_id & terrain, const ter_id & t_stair_type ) { + const auto maybe_insert_stairs = [this]( const oter_id & terrain, + const resolved_ter_id & t_stair_type ) { if( is_ot_match( "stairs", terrain, ot_match_type::contains ) ) { const auto predicate = [this]( const tripoint & p ) { return ter( p ) == t_thconc_floor && furn( p ) == f_null && tr_at( p ).is_null(); @@ -5474,12 +5475,12 @@ void map::draw_lab( mapgendata &dat ) !has_flag_ter( ter_furn_flag::TFLAG_DOOR, east_border ) ) { // TODO: create a ter_reset function that does ter_set, // furn_set, and i_clear? - ter_id lw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; - ter_id tw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; - ter_id rw_type = tower_lab && rw == 2 ? t_reinforced_glass : - t_concrete_wall; - ter_id bw_type = tower_lab && bw == 2 ? t_reinforced_glass : - t_concrete_wall; + resolved_ter_id lw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; + resolved_ter_id tw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; + resolved_ter_id rw_type = tower_lab && rw == 2 ? t_reinforced_glass : + t_concrete_wall; + resolved_ter_id bw_type = tower_lab && bw == 2 ? t_reinforced_glass : + t_concrete_wall; for( int i = 0; i < SEEX * 2; i++ ) { ter_set( point( 23, i ), rw_type ); furn_set( point( 23, i ), f_null ); @@ -5805,7 +5806,7 @@ void map::draw_lab( mapgendata &dat ) // liquid floors. break; } - ter_id fluid_type = one_in( 3 ) ? t_sewage : t_water_sh; + resolved_ter_id fluid_type = one_in( 3 ) ? t_sewage : t_water_sh; for( int i = 0; i < EAST_EDGE; i++ ) { for( int j = 0; j < SOUTH_EDGE; j++ ) { // We spare some terrain to make it look better visually. @@ -5832,7 +5833,7 @@ void map::draw_lab( mapgendata &dat ) // liquid floors. break; } - ter_id fluid_type = one_in( 3 ) ? t_sewage : t_water_sh; + resolved_ter_id fluid_type = one_in( 3 ) ? t_sewage : t_water_sh; for( int i = 0; i < 2; ++i ) { draw_rough_circle( [this, fluid_type]( const point & p ) { if( t_thconc_floor == ter( p ) || t_strconc_floor == ter( p ) || @@ -5980,10 +5981,10 @@ void map::draw_lab( mapgendata &dat ) if( !has_flag_ter( ter_furn_flag::TFLAG_WALL, east_border ) && !has_flag_ter( ter_furn_flag::TFLAG_DOOR, east_border ) ) { // TODO: create a ter_reset function that does ter_set, furn_set, and i_clear? - ter_id lw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; - ter_id tw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; - ter_id rw_type = tower_lab && rw == 2 ? t_reinforced_glass : t_concrete_wall; - ter_id bw_type = tower_lab && bw == 2 ? t_reinforced_glass : t_concrete_wall; + resolved_ter_id lw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; + resolved_ter_id tw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; + resolved_ter_id rw_type = tower_lab && rw == 2 ? t_reinforced_glass : t_concrete_wall; + resolved_ter_id bw_type = tower_lab && bw == 2 ? t_reinforced_glass : t_concrete_wall; for( int i = 0; i < SEEX * 2; i++ ) { ter_set( point( 23, i ), rw_type ); furn_set( point( 23, i ), f_null ); @@ -6215,7 +6216,8 @@ void map::draw_lab( mapgendata &dat ) // Handle stairs in the unlikely case they are needed. - const auto maybe_insert_stairs = [this]( const oter_id & terrain, const ter_id & t_stair_type ) { + const auto maybe_insert_stairs = [this]( const oter_id & terrain, + const resolved_ter_id & t_stair_type ) { if( is_ot_match( "stairs", terrain, ot_match_type::contains ) ) { const auto predicate = [this]( const tripoint & p ) { return ter( p ) == t_thconc_floor && furn( p ) == f_null && @@ -7568,55 +7570,55 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo } ///////////////////// part of map -void line( map *m, const ter_id &type, const point &p1, const point &p2 ) +void line( map *m, const resolved_ter_id &type, const point &p1, const point &p2 ) { m->draw_line_ter( type, p1, p2 ); } -void line_furn( map *m, const furn_id &type, const point &p1, const point &p2 ) +void line_furn( map *m, const resolved_furn_id &type, const point &p1, const point &p2 ) { m->draw_line_furn( type, p1, p2 ); } -void fill_background( map *m, const ter_id &type ) +void fill_background( map *m, const resolved_ter_id &type ) { m->draw_fill_background( type ); } -void fill_background( map *m, ter_id( *f )() ) +void fill_background( map *m, resolved_ter_id( *f )() ) { m->draw_fill_background( f ); } -void square( map *m, const ter_id &type, const point &p1, const point &p2 ) +void square( map *m, const resolved_ter_id &type, const point &p1, const point &p2 ) { m->draw_square_ter( type, p1, p2 ); } -void square_furn( map *m, const furn_id &type, const point &p1, const point &p2 ) +void square_furn( map *m, const resolved_furn_id &type, const point &p1, const point &p2 ) { m->draw_square_furn( type, p1, p2 ); } -void square( map *m, ter_id( *f )(), const point &p1, const point &p2 ) +void square( map *m, resolved_ter_id( *f )(), const point &p1, const point &p2 ) { m->draw_square_ter( f, p1, p2 ); } -void square( map *m, const weighted_int_list &f, const point &p1, const point &p2 ) +void square( map *m, const weighted_int_list &f, const point &p1, const point &p2 ) { m->draw_square_ter( f, p1, p2 ); } -void rough_circle( map *m, const ter_id &type, const point &p, int rad ) +void rough_circle( map *m, const resolved_ter_id &type, const point &p, int rad ) { m->draw_rough_circle_ter( type, p, rad ); } -void rough_circle_furn( map *m, const furn_id &type, const point &p, int rad ) +void rough_circle_furn( map *m, const resolved_furn_id &type, const point &p, int rad ) { m->draw_rough_circle_furn( type, p, rad ); } -void circle( map *m, const ter_id &type, double x, double y, double rad ) +void circle( map *m, const resolved_ter_id &type, double x, double y, double rad ) { m->draw_circle_ter( type, rl_vec2d( x, y ), rad ); } -void circle( map *m, const ter_id &type, const point &p, int rad ) +void circle( map *m, const resolved_ter_id &type, const point &p, int rad ) { m->draw_circle_ter( type, p, rad ); } -void circle_furn( map *m, const furn_id &type, const point &p, int rad ) +void circle_furn( map *m, const resolved_furn_id &type, const point &p, int rad ) { m->draw_circle_furn( type, p, rad ); } @@ -7651,7 +7653,7 @@ bool update_mapgen_function_json::setup_update( const JsonObject &jo ) bool update_mapgen_function_json::setup_internal( const JsonObject &/*jo*/ ) { - fill_ter = t_null; + fill_ter = t_str_null; /* update_mapgen doesn't care about fill_ter or rows */ return true; } @@ -7806,13 +7808,13 @@ std::pair, std::map> get_changed_ids_from_up if( update_function->second.funcs()[0]->update_map( fake_md ) ) { for( const tripoint &pos : tmp_map.points_on_zlevel( fake_map::fake_map_z ) ) { - ter_id ter_at_pos = tmp_map.ter( pos ); + resolved_ter_id ter_at_pos = tmp_map.ter( pos ); if( ter_at_pos != base_ter ) { - terrains[ter_at_pos] += 1; + terrains[ter_at_pos->id] += 1; } if( tmp_map.has_furn( pos ) ) { - furn_id furn_at_pos = tmp_map.furn( pos ); - furnitures[furn_at_pos] += 1; + resolved_furn_id furn_at_pos = tmp_map.furn( pos ); + furnitures[furn_at_pos->id] += 1; } } } diff --git a/src/mapgen.h b/src/mapgen.h index bdc24000cbe04..eee6b7c7c5155 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -521,7 +521,7 @@ class update_mapgen_function_json : public mapgen_function_json_base protected: bool setup_internal( const JsonObject &/*jo*/ ) override; - ter_id fill_ter; + ter_str_id fill_ter; }; class mapgen_function_json_nested : public mapgen_function_json_base @@ -636,19 +636,20 @@ enum room_type { // helpful functions bool connects_to( const oter_id &there, int dir ); // wrappers for map:: functions -void line( map *m, const ter_id &type, const point &p1, const point &p2 ); -void line_furn( map *m, const furn_id &type, const point &p1, const point &p2 ); -void fill_background( map *m, const ter_id &type ); -void fill_background( map *m, ter_id( *f )() ); -void square( map *m, const ter_id &type, const point &p1, const point &p2 ); -void square( map *m, ter_id( *f )(), const point &p1, const point &p2 ); -void square( map *m, const weighted_int_list &f, const point &p1, const point &p2 ); -void square_furn( map *m, const furn_id &type, const point &p1, const point &p2 ); -void rough_circle( map *m, const ter_id &type, const point &, int rad ); -void rough_circle_furn( map *m, const furn_id &type, const point &, int rad ); -void circle( map *m, const ter_id &type, double x, double y, double rad ); -void circle( map *m, const ter_id &type, const point &, int rad ); -void circle_furn( map *m, const furn_id &type, const point &, int rad ); +void line( map *m, const resolved_ter_id &type, const point &p1, const point &p2 ); +void line_furn( map *m, const resolved_furn_id &type, const point &p1, const point &p2 ); +void fill_background( map *m, const resolved_ter_id &type ); +void fill_background( map *m, resolved_ter_id( *f )() ); +void square( map *m, const resolved_ter_id &type, const point &p1, const point &p2 ); +void square( map *m, resolved_ter_id( *f )(), const point &p1, const point &p2 ); +void square( map *m, const weighted_int_list &f, const point &p1, + const point &p2 ); +void square_furn( map *m, const resolved_furn_id &type, const point &p1, const point &p2 ); +void rough_circle( map *m, const resolved_ter_id &type, const point &, int rad ); +void rough_circle_furn( map *m, const resolved_furn_id &type, const point &, int rad ); +void circle( map *m, const resolved_ter_id &type, double x, double y, double rad ); +void circle( map *m, const resolved_ter_id &type, const point &, int rad ); +void circle_furn( map *m, const resolved_furn_id &type, const point &, int rad ); void add_corpse( map *m, const point & ); extern std::map nested_mapgens; diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index eba2eac16726f..fba1a791047fd 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -121,7 +121,7 @@ building_gen_pointer get_mapgen_cfunction( const std::string &ident ) return iter == pointers.end() ? nullptr : iter->second; } -ter_id grass_or_dirt() +resolved_ter_id grass_or_dirt() { if( one_in( 4 ) ) { return t_grass; @@ -129,7 +129,7 @@ ter_id grass_or_dirt() return t_dirt; } -ter_id clay_or_sand() +resolved_ter_id clay_or_sand() { if( one_in( 16 ) ) { return t_sand; @@ -1260,7 +1260,7 @@ void mapgen_forest( mapgendata &dat ) * @param p: The point to place the dependent feature, if one is selected. */ const auto set_terrain_dependent_furniture = - [&self_biome, &m]( const ter_id & tid, const point & p ) { + [&self_biome, &m]( const resolved_ter_id & tid, const point & p ) { const auto terrain_dependent_furniture_it = self_biome.terrain_dependent_furniture.find( tid ); if( terrain_dependent_furniture_it == self_biome.terrain_dependent_furniture.end() ) { @@ -2358,13 +2358,13 @@ void mremove_fields( map *m, const point &p ) void resolve_regional_terrain_and_furniture( const mapgendata &dat ) { for( const tripoint &p : dat.m.points_on_zlevel() ) { - const ter_id tid_before = dat.m.ter( p ); - const ter_id tid_after = dat.region.region_terrain_and_furniture.resolve( tid_before ); + const resolved_ter_id tid_before = dat.m.ter( p ); + const resolved_ter_id tid_after = dat.region.region_terrain_and_furniture.resolve( tid_before ); if( tid_after != tid_before ) { dat.m.ter_set( p, tid_after ); } - const furn_id fid_before = dat.m.furn( p ); - const furn_id fid_after = dat.region.region_terrain_and_furniture.resolve( fid_before ); + const resolved_furn_id fid_before = dat.m.furn( p ); + const resolved_furn_id fid_after = dat.region.region_terrain_and_furniture.resolve( fid_before ); if( fid_after != fid_before ) { dat.m.furn_set( p, fid_after ); } diff --git a/src/mapgen_functions.h b/src/mapgen_functions.h index c3fea7ac987a3..72c2a03aeb94b 100644 --- a/src/mapgen_functions.h +++ b/src/mapgen_functions.h @@ -32,8 +32,8 @@ int terrain_type_to_nesw_array( oter_id terrain_type, std::array &array using building_gen_pointer = void ( * )( mapgendata & ); building_gen_pointer get_mapgen_cfunction( const std::string &ident ); -ter_id grass_or_dirt(); -ter_id clay_or_sand(); +resolved_ter_id grass_or_dirt(); +resolved_ter_id clay_or_sand(); // helper functions for mapgen.cpp, so that we can avoid having a massive switch statement (sorta) void mapgen_null( mapgendata &dat ); @@ -72,7 +72,7 @@ bool run_mapgen_func( const std::string &mapgen_id, mapgendata &dat ); std::pair, std::map> get_changed_ids_from_update( const update_mapgen_id &, const mapgen_arguments &, - ter_id const &base_ter = t_dirt ); + ter_id const &base_ter = t_dirt->id ); mapgen_parameters get_map_special_params( const std::string &mapgen_id ); void resolve_regional_terrain_and_furniture( const mapgendata &dat ); diff --git a/src/mapgendata.cpp b/src/mapgendata.cpp index c56f9f96aa1fa..50cf2836e9b6b 100644 --- a/src/mapgendata.cpp +++ b/src/mapgendata.cpp @@ -238,9 +238,9 @@ bool mapgendata::has_flag( jmapgen_flags f ) const return mapgen_flags_.test( f ); } -ter_id mapgendata::groundcover() const +resolved_ter_id mapgendata::groundcover() const { - const ter_id *tid = default_groundcover.pick(); + const resolved_ter_id *tid = default_groundcover.pick(); return tid != nullptr ? *tid : t_null; } diff --git a/src/mapgendata.h b/src/mapgendata.h index 12c4613d02cc5..7f4b41888a672 100644 --- a/src/mapgendata.h +++ b/src/mapgendata.h @@ -131,7 +131,7 @@ class mapgendata map &m; - weighted_int_list default_groundcover; + weighted_int_list default_groundcover; struct dummy_settings_t {}; static constexpr dummy_settings_t dummy_settings = {}; @@ -226,7 +226,7 @@ class mapgendata const oter_id &neighbor_at( direction ) const; void fill_groundcover() const; void square_groundcover( const point &p1, const point &p2 ) const; - ter_id groundcover() const; + resolved_ter_id groundcover() const; bool is_groundcover( const ter_id &iid ) const; bool has_flag( jmapgen_flags ) const; diff --git a/src/mapgenformat.cpp b/src/mapgenformat.cpp index a325f6191e308..9012d2cd3e41d 100644 --- a/src/mapgenformat.cpp +++ b/src/mapgenformat.cpp @@ -11,7 +11,7 @@ namespace mapf { void formatted_set_simple( map *m, const point &start, const char *cstr, - const format_effect &ter_b, const format_effect &furn_b ) + const format_effect &ter_b, const format_effect &furn_b ) { const char *p = cstr; point p2( start ); @@ -20,8 +20,8 @@ void formatted_set_simple( map *m, const point &start, const char *cstr, p2.y++; p2.x = start.x; } else { - const ter_id ter = ter_b.translate( *p ); - const furn_id furn = furn_b.translate( *p ); + const resolved_ter_id ter = ter_b.translate( *p ); + const resolved_furn_id furn = furn_b.translate( *p ); if( ter != t_null ) { m->ter_set( p2, ter ); } @@ -58,5 +58,7 @@ ID format_effect::translate( const char c ) const template class format_effect; template class format_effect; +template class format_effect; +template class format_effect; }//END NAMESPACE mapf diff --git a/src/mapgenformat.h b/src/mapgenformat.h index 86bbc53e6dece..3da1c6f2fe2e1 100644 --- a/src/mapgenformat.h +++ b/src/mapgenformat.h @@ -29,7 +29,7 @@ class format_effect; * @param start Coordinates in the map where to start drawing \p cstr. */ void formatted_set_simple( map *m, const point &start, const char *cstr, - const format_effect &ter_b, const format_effect &furn_b ); + const format_effect &ter_b, const format_effect &furn_b ); template class format_effect @@ -64,24 +64,24 @@ class format_effect /**@{*/ template // NOLINTNEXTLINE(modernize-avoid-c-arrays) -inline format_effect ter_bind( const char ( &characters )[N], Args... ids ) +inline format_effect ter_bind( const char ( &characters )[N], Args... ids ) { // Note to self: N contains the 0-char at the end of a string literal! static_assert( N % 2 == 0, "list of characters to bind to must be odd, e.g. \"a b c\"" ); static_assert( N / 2 == sizeof...( Args ), "list of characters to bind to must match the size of the remaining arguments" ); - return format_effect( characters, { std::forward( ids )... } ); + return format_effect( characters, { std::forward( ids )... } ); } template // NOLINTNEXTLINE(modernize-avoid-c-arrays) -inline format_effect furn_bind( const char ( &characters )[N], Args... ids ) +inline format_effect furn_bind( const char ( &characters )[N], Args... ids ) { // Note to self: N contains the 0-char at the end of a string literal! static_assert( N % 2 == 0, "list of characters to bind to must be odd, e.g. \"a b c\"" ); static_assert( N / 2 == sizeof...( Args ), "list of characters to bind to must match the size of the remaining arguments" ); - return format_effect( characters, { std::forward( ids )... } ); + return format_effect( characters, { std::forward( ids )... } ); } /**@}*/ diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index 6dd92d933207c..5e51b6e1dcbe2 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -2767,7 +2767,7 @@ std::set talk_function::loot_building( const tripoint_abs_omt &site, creature_tracker &creatures = get_creature_tracker(); std::set return_items; for( const tripoint &p : bay.points_on_zlevel() ) { - const ter_id t = bay.ter( p ); + const resolved_ter_id t = bay.ter( p ); //Open all the doors, doesn't need to be exhaustive if( t == t_door_c || t == t_door_c_peep || t == t_door_b || t == t_door_boarded || t == t_door_boarded_damaged diff --git a/src/monattack.cpp b/src/monattack.cpp index 5c0310edbb4d4..7a79af3e16a37 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -1649,7 +1649,7 @@ bool mattack::growplants( monster *z ) return true; } for( const tripoint &p : here.points_in_radius( z->pos(), 5 ) ) { - const ter_id ter = here.ter( p ); + const resolved_ter_id ter = here.ter( p ); if( ter != t_tree_young && ter != t_underbrush ) { // Skip as soon as possible to avoid all the checks continue; diff --git a/src/monmove.cpp b/src/monmove.cpp index af0891254dadc..c14728a267199 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -305,7 +305,7 @@ bool monster::know_danger_at( const tripoint &p ) const // before hitting simple or complex but this is more explicit if( avoid_fire || avoid_fall || avoid_simple || avoid_complex || avoid_traps || avoid_sharp ) { - const ter_id target = here.ter( p ); + const resolved_ter_id target = here.ter( p ); if( !here.has_vehicle_floor( p ) ) { // Don't enter lava if we have any concept of heat being bad if( avoid_fire && target == t_lava ) { diff --git a/src/monster.cpp b/src/monster.cpp index bb2ea56357524..1e00d99245d72 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2702,7 +2702,7 @@ void monster::process_turn() if( zap != pos() ) { explosion_handler::emp_blast( zap ); // Fries electronics due to the intensity of the field } - const ter_id t = here.ter( zap ); + const resolved_ter_id t = here.ter( zap ); if( t == ter_t_gas_pump || t == ter_t_gas_pump_a ) { if( one_in( 4 ) ) { explosion_handler::explosion( this, pos(), 40, 0.8, true ); diff --git a/src/npctalk.cpp b/src/npctalk.cpp index fca6803de52fc..aefd86906ae0c 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -3442,14 +3442,14 @@ void talk_effect_fun_t::set_location_variable( const JsonObject &jo, std::string continue; } if( search_type.value() == "terrain" ) { - if( here.ter( search_loc ).id().c_str() == cur_search_target ) { + if( here.ter( search_loc )->id.str() == cur_search_target ) { target_pos = here.getabs( search_loc ); found = true; break; } } else if( search_type.value() == "furniture" ) { - if( here.furn( search_loc ).id().c_str() == cur_search_target || - ( !here.furn( search_loc ).id().is_null() && cur_search_target.empty() ) ) { + if( here.furn( search_loc )->id.str() == cur_search_target || + ( !here.furn( search_loc )->id.is_null() && cur_search_target.empty() ) ) { target_pos = here.getabs( search_loc ); found = true; break; diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index c983bdc93dfd8..7bc1bce56ff7e 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -92,7 +92,7 @@ SDL_Color get_map_color_at( const tripoint &p ) return curses_color_to_SDL( vd.color ); } - if( const furn_id furn_id = here.furn( p ) ) { + if( const resolved_furn_id furn_id = here.furn( p ); furn_id != f_null ) { return curses_color_to_SDL( furn_id->color() ); } diff --git a/src/regional_settings.cpp b/src/regional_settings.cpp index 8483ea0deae1d..640d6405d86c0 100644 --- a/src/regional_settings.cpp +++ b/src/regional_settings.cpp @@ -976,9 +976,9 @@ void region_terrain_and_furniture_settings::finalize() } } -ter_id region_terrain_and_furniture_settings::resolve( const ter_id &tid ) const +resolved_ter_id region_terrain_and_furniture_settings::resolve( const resolved_ter_id &tid ) const { - ter_id result = tid; + resolved_ter_id result = tid; auto region_list = terrain.find( result ); while( region_list != terrain.end() ) { result = *region_list->second.pick(); @@ -987,9 +987,9 @@ ter_id region_terrain_and_furniture_settings::resolve( const ter_id &tid ) const return result; } -furn_id region_terrain_and_furniture_settings::resolve( const furn_id &fid ) const +resolved_furn_id region_terrain_and_furniture_settings::resolve( const resolved_furn_id &fid ) const { - furn_id result = fid; + resolved_furn_id result = fid; auto region_list = furniture.find( result ); while( region_list != furniture.end() ) { result = *region_list->second.pick(); diff --git a/src/regional_settings.h b/src/regional_settings.h index 2551f4a83981d..4894f4e1aa586 100644 --- a/src/regional_settings.h +++ b/src/regional_settings.h @@ -80,8 +80,8 @@ struct city_settings { }; struct ter_furn_id { - ter_id ter; - furn_id furn; + resolved_ter_id ter; + resolved_furn_id furn; ter_furn_id(); }; @@ -97,7 +97,7 @@ struct groundcover_extra { std::map boosted_percent_str; std::map weightlist; std::map boosted_weightlist; - ter_id default_ter = t_null; + resolved_ter_id default_ter = t_null; int mpercent_coverage = 0; // % coverage where this is applied (*10000) int boost_chance = 0; int boosted_mpercent_coverage = 0; @@ -133,10 +133,10 @@ struct forest_biome { std::map unfinalized_biome_components; std::vector biome_components; std::map unfinalized_groundcover; - weighted_int_list groundcover; + weighted_int_list groundcover; std::map unfinalized_terrain_dependent_furniture; - std::map terrain_dependent_furniture; + std::map terrain_dependent_furniture; int sparseness_adjacency_factor = 0; int item_group_chance = 0; int item_spawn_iterations = 0; @@ -246,12 +246,12 @@ struct map_extras { struct region_terrain_and_furniture_settings { std::map> unfinalized_terrain; std::map> unfinalized_furniture; - std::map> terrain; - std::map> furniture; + std::map> terrain; + std::map> furniture; void finalize(); - ter_id resolve( const ter_id & ) const; - furn_id resolve( const furn_id & ) const; + resolved_ter_id resolve( const resolved_ter_id & ) const; + resolved_furn_id resolve( const resolved_furn_id & ) const; region_terrain_and_furniture_settings() = default; }; @@ -263,7 +263,7 @@ struct regional_settings { std::string id; // std::array default_oter; double river_scale = 1; - weighted_int_list default_groundcover; // i.e., 'grass_or_dirt' + weighted_int_list default_groundcover; // i.e., 'grass_or_dirt' shared_ptr_fast> default_groundcover_str; city_settings city_spec; // put what where in a city of what kind diff --git a/src/resolved_id.h b/src/resolved_id.h index 2cd974a3c641c..286a4d168d7f6 100644 --- a/src/resolved_id.h +++ b/src/resolved_id.h @@ -76,10 +76,6 @@ class resolved_id return ptr_ != rhs.ptr_; } - explicit operator bool() const { - return is_valid(); - } - const T &obj() const { return *ptr_; } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index b8faeb1623711..494470c3cd403 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -4747,7 +4747,7 @@ void submap::store( JsonOut &jsout ) const jsout.member( "terrain" ); jsout.start_array(); if( is_uniform() ) { - _write_rle_terrain( jsout, uniform_ter.id().str(), SEEX * SEEY ); + _write_rle_terrain( jsout, uniform_ter->id.str(), SEEX * SEEY ); jsout.end_array(); return; } @@ -4818,7 +4818,7 @@ void submap::store( JsonOut &jsout ) const for( int i = 0; i < SEEX; i++ ) { const point p( i, j ); // Save furniture - if( get_furn( p ) ) { + if( get_furn( p ) != f_null ) { jsout.start_array(); jsout.write( p.x ); jsout.write( p.y ); @@ -5004,7 +5004,7 @@ void submap::load( const JsonValue &jv, const std::string &member_name, int vers } else { // terrain is encoded using simple RLE int remaining = 0; - int_id iid; + resolved_ter_id iid; for( int j = 0; j < SEEY; j++ ) { // NOLINTNEXTLINE(modernize-loop-convert) for( int i = 0; i < SEEX; i++ ) { diff --git a/src/sounds.cpp b/src/sounds.cpp index 3022cb56f1fab..5fa68d350a90c 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1696,7 +1696,7 @@ void sfx::do_footstep() if( std::chrono::duration_cast ( sfx_time ).count() > 400 ) { const Character &player_character = get_player_character(); int heard_volume = sfx::get_heard_volume( player_character.pos() ); - const auto terrain = get_map().ter( player_character.pos() ).id(); + const auto terrain = get_map().ter( player_character.pos() )->id; static const std::set grass = { ter_t_grass, ter_t_shrub, diff --git a/src/start_location.cpp b/src/start_location.cpp index 3acd52586c99e..c6309a7bebc6d 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -164,7 +164,7 @@ static void board_up( map &m, const tripoint_range &range ) std::vector boardables; for( const tripoint &p : range ) { bool must_board_around = false; - const ter_id t = m.ter( p ); + const resolved_ter_id t = m.ter( p ); if( t == t_window_domestic || t == t_window || t == t_window_no_curtains ) { // Windows are always to the outside and must be boarded must_board_around = true; diff --git a/src/submap.cpp b/src/submap.cpp index 21124576852b6..db1dc2248c307 100644 --- a/src/submap.cpp +++ b/src/submap.cpp @@ -215,7 +215,7 @@ bool submap::contains_vehicle( vehicle *veh ) bool submap::is_open_air( const point &p ) const { - ter_id t = get_ter( p ); + resolved_ter_id t = get_ter( p ); return t->trap == tr_ledge; } diff --git a/src/submap.h b/src/submap.h index 9aa6584ca1f48..411e08bef0f28 100644 --- a/src/submap.h +++ b/src/submap.h @@ -55,8 +55,8 @@ struct spawn_point { // Suppression due to bug in clang-tidy 12 // NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) struct maptile_soa { - cata::mdarray ter; // Terrain on each square - cata::mdarray frn; // Furniture on each square + cata::mdarray ter; // Terrain on each square + cata::mdarray frn; // Furniture on each square cata::mdarray lum; // Num items emitting light on each square cata::mdarray, point_sm_ms> itm; // Items on each square cata::mdarray fld; // Field on each square @@ -107,19 +107,19 @@ class submap std::uninitialized_fill_n( &m->trp[0][0], elements, trap ); } - furn_id get_furn( const point &p ) const { + resolved_furn_id get_furn( const point &p ) const { if( is_uniform() ) { return f_null; } return m->frn[p.x][p.y]; } - void set_furn( const point &p, furn_id furn ) { + void set_furn( const point &p, resolved_furn_id furn ) { ensure_nonuniform(); m->frn[p.x][p.y] = furn; } - void set_all_furn( const furn_id &furn ) { + void set_all_furn( const resolved_furn_id &furn ) { ensure_nonuniform(); std::uninitialized_fill_n( &m->frn[0][0], elements, furn ); } @@ -135,19 +135,19 @@ class submap ephemeral_data[p] = { dmg }; } - ter_id get_ter( const point &p ) const { + resolved_ter_id get_ter( const point &p ) const { if( is_uniform() ) { return uniform_ter; } return m->ter[p.x][p.y]; } - void set_ter( const point &p, ter_id terr ) { + void set_ter( const point &p, resolved_ter_id terr ) { ensure_nonuniform(); m->ter[p.x][p.y] = terr; } - void set_all_ter( const ter_id &terr, bool uniform_ok = false ) { + void set_all_ter( const resolved_ter_id &terr, bool uniform_ok = false ) { if( !uniform_ok ) { ensure_nonuniform(); } @@ -315,7 +315,7 @@ class submap std::map computers; std::unique_ptr legacy_computer; std::unique_ptr m; - ter_id uniform_ter = t_null; + resolved_ter_id uniform_ter = t_null; int temperature_mod = 0; // delta in F void update_legacy_computer(); @@ -360,11 +360,11 @@ class maptile_impl return sm->get_trap( pos() ); } - furn_id get_furn() const { + resolved_furn_id get_furn() const { return sm->get_furn( pos() ); } - ter_id get_ter() const { + resolved_ter_id get_ter() const { return sm->get_ter( pos() ); } diff --git a/src/talker_item.cpp b/src/talker_item.cpp index 526aa5e2f93d5..9baced33c49c9 100644 --- a/src/talker_item.cpp +++ b/src/talker_item.cpp @@ -4,6 +4,7 @@ #include "item.h" #include "itype.h" #include "magic.h" +#include "map.h" #include "npc.h" #include "pimpl.h" #include "point.h" diff --git a/src/timed_event.cpp b/src/timed_event.cpp index d6c6f787cbb12..31fc8f1c3996a 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -196,7 +196,7 @@ void timed_event::actualize() case timed_event_type::TEMPLE_FLOOD: { bool flooded = false; - cata::mdarray flood_buf; + cata::mdarray flood_buf; for( const tripoint &p : here.points_on_zlevel() ) { flood_buf[p.x][p.y] = here.ter( p ); } diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 0adaf669f4d7e..b8ac60de8d4ea 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -1335,7 +1335,7 @@ bool trapfunc::temple_toggle( const tripoint &p, Creature *c, item * ) if( c->is_avatar() ) { add_msg( _( "You hear the grinding of shifting rock." ) ); map &here = get_map(); - const ter_id type = here.ter( p ); + const resolved_ter_id type = here.ter( p ); tripoint tmp = p; int &i = tmp.x; int &j = tmp.y; diff --git a/src/type_id.h b/src/type_id.h index 261d5ffb56263..7a2e96cf7ca24 100644 --- a/src/type_id.h +++ b/src/type_id.h @@ -5,6 +5,7 @@ // IWYU pragma: begin_exports #include "int_id.h" #include "string_id.h" +#include "resolved_id.h" // IWYU pragma: end_exports class achievement; @@ -98,6 +99,7 @@ using field_type_str_id = string_id; struct furn_t; using furn_id = int_id; using furn_str_id = string_id; +using resolved_furn_id = resolved_id; class climbing_aid; using climbing_aid_id = string_id; @@ -257,6 +259,7 @@ using proficiency_id = string_id; struct ter_t; using ter_id = int_id; using ter_str_id = string_id; +using resolved_ter_id = resolved_id; class ter_furn_transform; using ter_furn_transform_id = string_id; diff --git a/src/vehicle_autodrive.cpp b/src/vehicle_autodrive.cpp index d265ff562d996..ee04d30491bc5 100644 --- a/src/vehicle_autodrive.cpp +++ b/src/vehicle_autodrive.cpp @@ -689,12 +689,12 @@ bool vehicle::autodrive_controller::check_drivable( tripoint pt ) const // check for furniture that hinders movement; furniture with 0 move cost // can be driven on - const furn_id furniture = here.furn( pt ); + const resolved_furn_id furniture = here.furn( pt ); if( furniture != f_null && furniture.obj().movecost != 0 ) { return false; } - const ter_id terrain = here.ter( pt ); + const resolved_ter_id terrain = here.ter( pt ); if( terrain == t_null ) { return false; } diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index e27b7dc118e24..36dc6a4dd7346 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -1675,7 +1675,7 @@ void vehicle::precalculate_vehicle_turning( units::angle new_turn_dir, bool chec // special case for rails if( check_rail_direction ) { - ter_id terrain_at_wheel = here.ter( wheel_tripoint ); + resolved_ter_id terrain_at_wheel = here.ter( wheel_tripoint ); // check is it correct tile to turn into if( !is_diagonal_movement && ( terrain_at_wheel == t_railroad_track_d || terrain_at_wheel == t_railroad_track_d1 || diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 57c420286458e..776be4ca0c3a4 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -1034,11 +1034,11 @@ void vehicle::transform_terrain() } } if( prereq_fulfilled ) { - const ter_id new_ter = ter_id( ttd.post_terrain ); + const resolved_ter_id new_ter = ter_id( ttd.post_terrain ); if( new_ter != t_null ) { here.ter_set( start_pos, new_ter ); } - const furn_id new_furn = furn_id( ttd.post_furniture ); + const resolved_furn_id new_furn = furn_id( ttd.post_furniture ); if( new_furn != f_null ) { here.furn_set( start_pos, new_furn ); } diff --git a/tests/act_build_test.cpp b/tests/act_build_test.cpp index f0ddf71de4f50..78ff59ed65b15 100644 --- a/tests/act_build_test.cpp +++ b/tests/act_build_test.cpp @@ -209,7 +209,7 @@ void run_test_case( Character &u ) tripoint_bub_ms const tri_window( tripoint_south ); construction const build = setup_testcase( u, "test_constr_window_boarded", tri_window, tripoint_bub_ms() ); - ter_id const ter_pre = here.ter( tri_window ); + resolved_ter_id const ter_pre = here.ter( tri_window ); partial_con pc; pc.id = get_construction( "test_constr_door" ).id; here.partial_con_set( tri_window, pc ); diff --git a/tests/cardio_test.cpp b/tests/cardio_test.cpp index 958c35f5204b6..39f75d6d9b830 100644 --- a/tests/cardio_test.cpp +++ b/tests/cardio_test.cpp @@ -53,7 +53,7 @@ static void verify_default_cardio_options() } // Count the number of steps (tiles) until character runs out of stamina or becomes winded. -static int running_steps( Character &they, const ter_id &terrain = t_pavement ) +static int running_steps( Character &they, const resolved_ter_id &terrain = t_pavement ) { map &here = get_map(); // Please take off your shoes when entering, and no NPCs allowed diff --git a/tests/eoc_test.cpp b/tests/eoc_test.cpp index c1a9fbf8fae44..1fc75ed92e5ff 100644 --- a/tests/eoc_test.cpp +++ b/tests/eoc_test.cpp @@ -147,7 +147,7 @@ void complete_activity( Character &u ) } } -void check_ter_in_radius( tripoint_abs_ms const ¢er, int range, ter_id const &ter ) +void check_ter_in_radius( tripoint_abs_ms const ¢er, int range, resolved_ter_id const &ter ) { map tm; tm.load( project_to( center - point{ range, range } ), false, false ); @@ -160,7 +160,7 @@ void check_ter_in_radius( tripoint_abs_ms const ¢er, int range, ter_id const } void check_ter_in_line( tripoint_abs_ms const &first, tripoint_abs_ms const &second, - ter_id const &ter ) + resolved_ter_id const &ter ) { map tm; tripoint_abs_ms const orig = coord_min( first, second ); diff --git a/tests/ground_destroy_test.cpp b/tests/ground_destroy_test.cpp index d272c99685973..dfbff0f6d26b2 100644 --- a/tests/ground_destroy_test.cpp +++ b/tests/ground_destroy_test.cpp @@ -17,7 +17,7 @@ // https://github.com/CleverRaven/Cataclysm-DDA/issues/24707 TEST_CASE( "pavement_destroy", "[.]" ) { - const ter_id flat_roof_id = ter_id( "t_flat_roof" ); + const resolved_ter_id flat_roof_id = ter_id( "t_flat_roof" ); REQUIRE( flat_roof_id != t_null ); clear_map_and_put_player_underground(); @@ -27,7 +27,7 @@ TEST_CASE( "pavement_destroy", "[.]" ) // Destroy it here.destroy( tripoint_zero, true ); - ter_id after_destroy = here.ter( tripoint_zero ); + resolved_ter_id after_destroy = here.ter( tripoint_zero ); if( after_destroy == flat_roof_id ) { FAIL( flat_roof_id.obj().name() << " found after destroying pavement" ); } else { @@ -40,7 +40,7 @@ TEST_CASE( "pavement_destroy", "[.]" ) // https://github.com/CleverRaven/Cataclysm-DDA/issues/23250 TEST_CASE( "explosion_on_ground", "[.]" ) { - ter_id flat_roof_id = ter_id( "t_flat_roof" ); + resolved_ter_id flat_roof_id = ter_id( "t_flat_roof" ); REQUIRE( flat_roof_id != t_null ); clear_map_and_put_player_underground(); @@ -70,7 +70,7 @@ TEST_CASE( "explosion_on_ground", "[.]" ) for( int x = 0; x < area_dim; x++ ) { for( int y = 0; y < area_dim; y++ ) { tripoint pt( x, y, 0 ); - ter_id t_id = here.ter( pt ); + resolved_ter_id t_id = here.ter( pt ); if( t_id == flat_roof_id ) { FAIL( "After explosion, " << t_id.obj().name() << " found at " << x << "," << y ); } @@ -83,10 +83,10 @@ TEST_CASE( "explosion_on_ground", "[.]" ) // the defined roof of a t_rock-floor). TEST_CASE( "explosion_on_floor_with_rock_floor_basement", "[.]" ) { - ter_id flat_roof_id = ter_id( "t_flat_roof" ); - ter_id floor_id = ter_id( "t_floor" ); - ter_id rock_floor_id = ter_id( "t_rock_floor" ); - ter_id open_air_id = ter_id( "t_open_air" ); + resolved_ter_id flat_roof_id = ter_id( "t_flat_roof" ); + resolved_ter_id floor_id = ter_id( "t_floor" ); + resolved_ter_id rock_floor_id = ter_id( "t_rock_floor" ); + resolved_ter_id open_air_id = ter_id( "t_open_air" ); REQUIRE( flat_roof_id != t_null ); REQUIRE( floor_id != t_null ); @@ -117,7 +117,7 @@ TEST_CASE( "explosion_on_floor_with_rock_floor_basement", "[.]" ) for( int x = 0; x < area_dim; x++ ) { for( int y = 0; y < area_dim; y++ ) { tripoint pt( x, y, 0 ); - ter_id t_id = here.ter( pt ); + resolved_ter_id t_id = here.ter( pt ); INFO( "t " << t_id.obj().name() << " at " << x << "," << y ); if( t_id == open_air_id ) { found_open_air = true; @@ -140,10 +140,10 @@ TEST_CASE( "collapse_checks", "[.]" ) { constexpr int wall_size = 5; - const ter_id floor_id = ter_id( "t_floor" ); - const ter_id dirt_id = ter_id( "t_dirt" ); - const ter_id wall_id = ter_id( "t_wall" ); - const ter_id open_air_id = ter_id( "t_open_air" ); + const resolved_ter_id floor_id = ter_id( "t_floor" ); + const resolved_ter_id dirt_id = ter_id( "t_dirt" ); + const resolved_ter_id wall_id = ter_id( "t_wall" ); + const resolved_ter_id open_air_id = ter_id( "t_open_air" ); REQUIRE( floor_id != t_null ); REQUIRE( dirt_id != t_null ); @@ -206,7 +206,7 @@ TEST_CASE( "collapse_checks", "[.]" ) if( pt.z == 0 ) { continue; } - const ter_id t_id = here.ter( pt ); + const resolved_ter_id t_id = here.ter( pt ); tile_count += 1; if( t_id == t_open_air ) { open_air_count += 1; diff --git a/tests/map_helpers.cpp b/tests/map_helpers.cpp index 0962caca4140e..1f17dc2728b65 100644 --- a/tests/map_helpers.cpp +++ b/tests/map_helpers.cpp @@ -55,7 +55,7 @@ void wipe_map_terrain( map *target ) map &here = target ? *target : get_map(); const int mapsize = here.getmapsize() * SEEX; for( int z = -1; z <= OVERMAP_HEIGHT; ++z ) { - ter_id terrain = z == 0 ? t_grass : z < 0 ? t_rock : t_open_air; + resolved_ter_id terrain = z == 0 ? t_grass : z < 0 ? t_rock : t_open_air; for( int x = 0; x < mapsize; ++x ) { for( int y = 0; y < mapsize; ++y ) { here.set( { x, y, z}, terrain, f_null ); diff --git a/tests/map_test.cpp b/tests/map_test.cpp index 0cf299a0b000b..6ab7188b04c48 100644 --- a/tests/map_test.cpp +++ b/tests/map_test.cpp @@ -107,9 +107,9 @@ TEST_CASE( "map_bounds_checking" ) if( x < 0 || x >= MAPSIZE_X || y < 0 || y >= MAPSIZE_Y || z < -OVERMAP_DEPTH || z > OVERMAP_HEIGHT ) { - CHECK( !m.ter( tripoint{ x, y, z } ) ); + CHECK( m.ter( tripoint{ x, y, z } ) == t_null ); } else { - CHECK( m.ter( tripoint{ x, y, z } ) ); + CHECK( m.ter( tripoint{ x, y, z } ) != t_null ); } } } @@ -133,9 +133,9 @@ TEST_CASE( "tinymap_bounds_checking" ) if( x < 0 || x >= SEEX * 2 || y < 0 || y >= SEEY * 2 || z < -OVERMAP_DEPTH || z > OVERMAP_HEIGHT ) { - CHECK( !m.ter( tripoint{ x, y, z } ) ); + CHECK( m.ter( tripoint{ x, y, z } ) == t_null ); } else { - CHECK( m.ter( tripoint{ x, y, z } ) ); + CHECK( m.ter( tripoint{ x, y, z } ) != t_null ); } } } diff --git a/tests/submap_load_test.cpp b/tests/submap_load_test.cpp index d76ce413e5292..46922b3ebaa29 100644 --- a/tests/submap_load_test.cpp +++ b/tests/submap_load_test.cpp @@ -894,16 +894,16 @@ TEST_CASE( "submap_terrain_rle_load", "[submap][load]" ) REQUIRE( is_normal_submap( sm, checks ) ); - const ter_id ter_nw = sm.get_ter( corner_nw ); - const ter_id ter_ne = sm.get_ter( corner_ne ); - const ter_id ter_sw = sm.get_ter( corner_sw ); - const ter_id ter_se = sm.get_ter( corner_se ); + const resolved_ter_id ter_nw = sm.get_ter( corner_nw ); + const resolved_ter_id ter_ne = sm.get_ter( corner_ne ); + const resolved_ter_id ter_sw = sm.get_ter( corner_sw ); + const resolved_ter_id ter_se = sm.get_ter( corner_se ); // We placed a unique terrain in each of the corners. Check that those are correct - INFO( string_format( "nw: %s", ter_nw.id().str() ) ); - INFO( string_format( "ne: %s", ter_ne.id().str() ) ); - INFO( string_format( "sw: %s", ter_sw.id().str() ) ); - INFO( string_format( "se: %s", ter_se.id().str() ) ); + INFO( string_format( "nw: %s", ter_nw->id.str() ) ); + INFO( string_format( "ne: %s", ter_ne->id.str() ) ); + INFO( string_format( "sw: %s", ter_sw->id.str() ) ); + INFO( string_format( "se: %s", ter_se->id.str() ) ); // Require to prevent the lower CHECK from being spammy REQUIRE( ter_nw == t_floor_green ); REQUIRE( ter_ne == t_floor_red ); @@ -947,7 +947,7 @@ TEST_CASE( "submap_terrain_load_invalid_ter_ids_as_t_dirt", "[submap][load]" ) for( int y = 0; y < SEEY; y++ ) { CAPTURE( x, y ); // expect t_rock_floor patch in a corner - const ter_id expected = ( ( x == 11 ) && ( y == 11 ) ) ? t_rock_floor : t_dirt; + const resolved_ter_id expected = ( ( x == 11 ) && ( y == 11 ) ) ? t_rock_floor : t_dirt; CHECK( sm.get_ter( {x, y} ) == expected ); } } @@ -962,18 +962,18 @@ TEST_CASE( "submap_furniture_load", "[submap][load]" ) REQUIRE( is_normal_submap( sm, checks ) ); - const furn_id furn_nw = sm.get_furn( corner_nw ); - const furn_id furn_ne = sm.get_furn( corner_ne ); - const furn_id furn_sw = sm.get_furn( corner_sw ); - const furn_id furn_se = sm.get_furn( corner_se ); - const furn_id furn_ra = sm.get_furn( random_pt ); + const resolved_furn_id furn_nw = sm.get_furn( corner_nw ); + const resolved_furn_id furn_ne = sm.get_furn( corner_ne ); + const resolved_furn_id furn_sw = sm.get_furn( corner_sw ); + const resolved_furn_id furn_se = sm.get_furn( corner_se ); + const resolved_furn_id furn_ra = sm.get_furn( random_pt ); // We placed a unique furniture in a couple pf place. Check that those are correct - INFO( string_format( "nw: %s", furn_nw.id().str() ) ); - INFO( string_format( "ne: %s", furn_ne.id().str() ) ); - INFO( string_format( "sw: %s", furn_sw.id().str() ) ); - INFO( string_format( "se: %s", furn_se.id().str() ) ); - INFO( string_format( "ra: %s", furn_ra.id().str() ) ); + INFO( string_format( "nw: %s", furn_nw->id.str() ) ); + INFO( string_format( "ne: %s", furn_ne->id.str() ) ); + INFO( string_format( "sw: %s", furn_sw->id.str() ) ); + INFO( string_format( "se: %s", furn_se->id.str() ) ); + INFO( string_format( "ra: %s", furn_ra->id.str() ) ); // Require to prevent the lower CHECK from being spammy REQUIRE( furn_nw == f_coffin_c ); REQUIRE( furn_ne == f_bookcase ); diff --git a/tests/vehicle_efficiency_test.cpp b/tests/vehicle_efficiency_test.cpp index dcbef75a85a31..835100207dd7f 100644 --- a/tests/vehicle_efficiency_test.cpp +++ b/tests/vehicle_efficiency_test.cpp @@ -232,7 +232,7 @@ static int test_efficiency( const vproto_id &veh_id, int &expected_mass, // If the vehicle starts skidding, the effects become random and test is RUINED REQUIRE( !veh.skidding ); for( const tripoint &pos : veh.get_points() ) { - REQUIRE( here.ter( pos ) ); + REQUIRE( here.ter( pos ) != t_null ); } // How much it moved tiles_travelled += square_dist( starting_point, veh.global_pos3() ); diff --git a/tests/vehicle_ramp_test.cpp b/tests/vehicle_ramp_test.cpp index 8801cee70bd54..a0807f564d9d6 100644 --- a/tests/vehicle_ramp_test.cpp +++ b/tests/vehicle_ramp_test.cpp @@ -150,7 +150,7 @@ static void ramp_transition_angled( const vproto_id &veh_id, const units::angle // If the vehicle starts skidding, the effects become random and test is RUINED REQUIRE( !veh.skidding ); for( const tripoint &pos : veh.get_points() ) { - REQUIRE( here.ter( pos ) ); + REQUIRE( here.ter( pos ) != t_null ); } for( const vpart_reference &vp : veh.get_all_parts() ) { if( vp.info().location != "structure" ) {