From 128a0e934e1bfd5ae7c3511b9ebae22a1f8e5448 Mon Sep 17 00:00:00 2001 From: Zhilkin Serg Date: Sat, 28 Aug 2021 14:57:52 +0300 Subject: [PATCH 1/2] Use ter_bitflags instead of flag strings --- src/action.cpp | 9 +-- src/activity_handlers.cpp | 3 +- src/activity_item_handling.cpp | 4 +- src/avatar.cpp | 4 +- src/avatar_action.cpp | 7 +-- src/ballistics.cpp | 4 +- src/bionics.cpp | 4 +- src/cata_tiles.cpp | 2 +- src/character.cpp | 20 +++--- src/construction.cpp | 11 ++-- src/do_turn.cpp | 4 +- src/flag.cpp | 2 - src/flag.h | 1 - src/fungal_effects.cpp | 13 ++-- src/game.cpp | 86 +++++++++++++------------- src/gates.cpp | 2 +- src/iexamine.cpp | 5 +- src/item.cpp | 12 ++-- src/iuse.cpp | 24 ++++---- src/iuse_actor.cpp | 8 +-- src/level_cache.h | 6 +- src/map.cpp | 101 ++++++++++++++++--------------- src/map_extras.cpp | 17 +++--- src/mapgen.cpp | 34 +++++------ src/melee.cpp | 4 +- src/mission_start.cpp | 2 +- src/monattack.cpp | 4 +- src/monmove.cpp | 27 ++++----- src/npc.cpp | 2 +- src/npcmove.cpp | 4 +- src/overmap_ui.cpp | 2 +- src/pickup.cpp | 4 +- src/player_hardcoded_effects.cpp | 4 +- src/start_location.cpp | 4 +- src/vehicle_move.cpp | 2 +- src/vehicle_use.cpp | 4 +- src/visitable.cpp | 2 +- src/weather.cpp | 2 +- 38 files changed, 210 insertions(+), 240 deletions(-) diff --git a/src/action.cpp b/src/action.cpp index 56d8ad67194e3..80cce3a40de4a 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -45,9 +45,6 @@ static const quality_id qual_BUTCHER( "BUTCHER" ); static const quality_id qual_CUT_FINE( "CUT_FINE" ); static const std::string flag_CONSOLE( "CONSOLE" ); -static const std::string flag_GOES_DOWN( "GOES_DOWN" ); -static const std::string flag_GOES_UP( "GOES_UP" ); -static const std::string flag_SWIMMABLE( "SWIMMABLE" ); static void parse_keymap( std::istream &keymap_txt, std::map &kmap, std::set &unbound_keymap ); @@ -624,7 +621,7 @@ bool can_move_vertical_at( const tripoint &p, int movez ) Character &player_character = get_player_character(); map &here = get_map(); // TODO: unify this with game::move_vertical - if( here.has_flag( flag_SWIMMABLE, p ) && here.has_flag( TFLAG_DEEP_WATER, p ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, p ) && here.has_flag( TFLAG_DEEP_WATER, p ) ) { if( movez == -1 ) { return !player_character.is_underwater() && !player_character.worn_with_flag( flag_FLOTATION ); } else { @@ -634,9 +631,9 @@ bool can_move_vertical_at( const tripoint &p, int movez ) } if( movez == -1 ) { - return here.has_flag( flag_GOES_DOWN, p ); + return here.has_flag( TFLAG_GOES_DOWN, p ); } else { - return here.has_flag( flag_GOES_UP, p ); + return here.has_flag( TFLAG_GOES_UP, p ); } } diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 32a5132fbd673..131d7c6306505 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -233,7 +233,6 @@ static const trait_id trait_STOCKY_TROGLO( "STOCKY_TROGLO" ); static const std::string flag_AUTODOC( "AUTODOC" ); static const std::string flag_AUTODOC_COUCH( "AUTODOC_COUCH" ); static const std::string flag_PLANTABLE( "PLANTABLE" ); -static const std::string flag_SUPPORTS_ROOF( "SUPPORTS_ROOF" ); using namespace activity_handlers; @@ -1782,7 +1781,7 @@ void activity_handlers::pickaxe_finish( player_activity *act, Character *you ) act->set_to_null(); if( you->is_avatar() ) { const int helpersize = get_player_character().get_num_crafting_helpers( 3 ); - if( here.is_bashable( pos ) && here.has_flag( flag_SUPPORTS_ROOF, pos ) && + if( here.is_bashable( pos ) && here.has_flag( TFLAG_SUPPORTS_ROOF, pos ) && here.ter( pos ) != t_tree ) { // Tunneling through solid rock is sweaty, backbreaking work // Betcha wish you'd opted for the J-Hammer diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index f3c16b1b0bcdb..9ff2ba7b971ad 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1131,7 +1131,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } if( act == ACT_MULTIPLE_MINE ) { - if( !here.has_flag( "MINEABLE", src_loc ) ) { + if( !here.has_flag( TFLAG_MINEABLE, src_loc ) ) { return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } std::vector mining_inv = you.items_with( [&you]( const item & itm ) { @@ -2174,7 +2174,7 @@ static bool mine_activity( Character &you, const tripoint &src_loc ) } ); map &here = get_map(); if( mining_inv.empty() || you.is_mounted() || you.is_underwater() || here.veh_at( src_loc ) || - !here.has_flag( "MINEABLE", src_loc ) || you.has_effect( effect_incorporeal ) ) { + !here.has_flag( TFLAG_MINEABLE, src_loc ) || you.has_effect( effect_incorporeal ) ) { return false; } item *chosen_item = nullptr; diff --git a/src/avatar.cpp b/src/avatar.cpp index ab169cc538eee..2e0e705f5588a 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -1779,7 +1779,7 @@ void avatar::try_to_sleep( const time_duration &dur ) } } else if( has_trait( trait_M_SKIN3 ) ) { fungaloid_cosplay = true; - if( here.has_flag_ter_or_furn( "FUNGUS", pos() ) ) { + if( here.has_flag_ter_or_furn( TFLAG_FUNGUS, pos() ) ) { add_msg_if_player( m_good, _( "Our fibers meld with the ground beneath us. The gills on our neck begin to seed the air with spores as our awareness fades." ) ); } @@ -1826,7 +1826,7 @@ void avatar::try_to_sleep( const time_duration &dur ) add_msg_if_player( m_good, _( "You lay beneath the waves' embrace, gazing up through the water's surface…" ) ); watersleep = true; - } else if( here.has_flag_ter( "SWIMMABLE", pos() ) ) { + } else if( here.has_flag_ter( TFLAG_SWIMMABLE, pos() ) ) { add_msg_if_player( m_good, _( "You settle into the water and begin to drowse…" ) ); watersleep = true; } diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 0ca6fac6db463..55dab0cbfe1ee 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -78,7 +78,6 @@ static const trait_id trait_RUMINANT( "RUMINANT" ); static const trait_id trait_SHELL2( "SHELL2" ); static const std::string flag_RAMP_END( "RAMP_END" ); -static const std::string flag_SWIMMABLE( "SWIMMABLE" ); #define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " @@ -402,9 +401,9 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) return false; } } - bool toSwimmable = m.has_flag( flag_SWIMMABLE, dest_loc ); + bool toSwimmable = m.has_flag( TFLAG_SWIMMABLE, dest_loc ); bool toDeepWater = m.has_flag( TFLAG_DEEP_WATER, dest_loc ); - bool fromSwimmable = m.has_flag( flag_SWIMMABLE, you.pos() ); + bool fromSwimmable = m.has_flag( TFLAG_SWIMMABLE, you.pos() ); bool fromDeepWater = m.has_flag( TFLAG_DEEP_WATER, you.pos() ); bool fromBoat = veh0 != nullptr && veh0->is_in_water( fromDeepWater ); bool toBoat = veh1 != nullptr && veh1->is_in_water( toDeepWater ); @@ -573,7 +572,7 @@ bool avatar_action::ramp_move( avatar &you, map &m, const tripoint &dest_loc ) void avatar_action::swim( map &m, avatar &you, const tripoint &p ) { - if( !m.has_flag( flag_SWIMMABLE, p ) ) { + if( !m.has_flag( TFLAG_SWIMMABLE, p ) ) { dbg( D_ERROR ) << "game:plswim: Tried to swim in " << m.tername( p ) << "!"; debugmsg( "Tried to swim in %s!", m.tername( p ) ); diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 720987045bb70..1ab3d0b9f0fe8 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -41,8 +41,6 @@ static const efftype_id effect_bounced( "bounced" ); static const json_character_flag json_flag_HARDTOHIT( "HARDTOHIT" ); -static const std::string flag_LIQUID( "LIQUID" ); - static void drop_or_embed_projectile( const dealt_projectile_attack &attack ) { const auto &proj = attack.proj; @@ -143,7 +141,7 @@ static void drop_or_embed_projectile( const dealt_projectile_attack &attack ) } if( effects.count( "HEAVY_HIT" ) ) { - if( here.has_flag( flag_LIQUID, pt ) ) { + if( here.has_flag( TFLAG_LIQUID, pt ) ) { sounds::sound( pt, 10, sounds::sound_t::combat, _( "splash!" ), false, "bullet_hit", "hit_water" ); } else { sounds::sound( pt, 8, sounds::sound_t::combat, _( "thud." ), false, "bullet_hit", "hit_wall" ); diff --git a/src/bionics.cpp b/src/bionics.cpp index b9a02a56f2e40..779617b8e76c6 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -187,8 +187,6 @@ static const json_character_flag json_flag_BIONIC_NPC_USABLE( "BIONIC_NPC_USABLE static const json_character_flag json_flag_BIONIC_WEAPON( "BIONIC_WEAPON" ); static const json_character_flag json_flag_BIONIC_TOGGLED( "BIONIC_TOGGLED" ); -static const std::string flag_SEALED( "SEALED" ); - struct Character::auto_toggle_bionic_result { bool can_burn_fuel = false; bool has_burnable_fuel = false; @@ -945,7 +943,7 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) std::vector> affected; const units::mass weight_cap = weight_capacity(); for( const tripoint &p : here.points_in_radius( pos(), 10 ) ) { - if( p == pos() || !here.has_items( p ) || here.has_flag( flag_SEALED, p ) ) { + if( p == pos() || !here.has_items( p ) || here.has_flag( TFLAG_SEALED, p ) ) { continue; } diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index ca7f88f940149..ba814ce3d2d00 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3909,7 +3909,7 @@ void cata_tiles::get_tile_values_with_ter( const tripoint &p, const int t, const if( val == 0 ) { for( int i = 0; i < 4; ++i ) { const tripoint &pt = p + four_adjacent_offsets[i]; - if( here.has_flag( "WALL", pt ) || here.has_flag( "WINDOW", pt ) || + if( here.has_flag( TFLAG_WALL, pt ) || here.has_flag( "WINDOW", pt ) || here.has_flag( "DOOR", pt ) ) { val += 1 << i; } diff --git a/src/character.cpp b/src/character.cpp index bb01c0f5c31d5..58739b8dba0bb 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -5113,7 +5113,7 @@ bool Character::in_climate_control() return true; } map &here = get_map(); - if( has_trait( trait_M_SKIN3 ) && here.has_flag_ter_or_furn( "FUNGUS", pos() ) && + if( has_trait( trait_M_SKIN3 ) && here.has_flag_ter_or_furn( TFLAG_FUNGUS, pos() ) && in_sleep_state() ) { return true; } @@ -5854,7 +5854,7 @@ bool Character::is_deaf() const { return get_effect_int( effect_deaf ) > 2 || worn_with_flag( flag_DEAF ) || has_flag( json_flag_DEAF ) || - ( has_trait( trait_M_SKIN3 ) && get_map().has_flag_ter_or_furn( "FUNGUS", pos() ) + ( has_trait( trait_M_SKIN3 ) && get_map().has_flag_ter_or_furn( TFLAG_FUNGUS, pos() ) && in_sleep_state() ); } @@ -7672,8 +7672,8 @@ Character::comfort_response_t Character::base_comfort_value( const tripoint &p ) } } } - if( ( fungaloid_cosplay && here.has_flag_ter_or_furn( "FUNGUS", pos() ) ) || - ( watersleep && here.has_flag_ter( "SWIMMABLE", pos() ) ) ) { + if( ( fungaloid_cosplay && here.has_flag_ter_or_furn( TFLAG_FUNGUS, pos() ) ) || + ( watersleep && here.has_flag_ter( TFLAG_SWIMMABLE, pos() ) ) ) { comfort += static_cast( comfort_level::very_comfortable ); } } else if( plantsleep ) { @@ -12663,7 +12663,7 @@ int Character::run_cost( int base_cost, bool diag ) const map &here = get_map(); // The "FLAT" tag includes soft surfaces, so not a good fit. const bool on_road = flatground && here.has_flag( STATIC( "ROAD" ), pos() ); - const bool on_fungus = here.has_flag_ter_or_furn( STATIC( "FUNGUS" ), pos() ); + const bool on_fungus = here.has_flag_ter_or_furn( TFLAG_FUNGUS, pos() ); if( !is_mounted() ) { if( movecost > 105 ) { @@ -12738,7 +12738,7 @@ int Character::run_cost( int base_cost, bool diag ) const movecost += 8; } - if( has_trait( trait_ROOTS3 ) && here.has_flag( STATIC( "DIGGABLE" ), pos() ) ) { + if( has_trait( trait_ROOTS3 ) && here.has_flag( TFLAG_DIGGABLE, pos() ) ) { movecost += 10 * footwear_factor(); } @@ -12861,7 +12861,7 @@ std::vector Character::get_targetable_creatures( const int range, bo for( const tripoint &point : path ) { if( here.impassable( point ) && !( weapon.has_flag( flag_SPEAR ) && // Fences etc. Spears can stab through those - here.has_flag( STATIC( "THIN_OBSTACLE" ), + here.has_flag( TFLAG_THIN_OBSTACLE, point ) ) ) { //this mirrors melee.cpp function reach_attack can_see = false; break; @@ -13288,7 +13288,7 @@ int Character::sleep_spot( const tripoint &p ) const sleepy = enchantment_cache->modify_value( enchant_vals::mod::SLEEPY, sleepy ); - if( watersleep && get_map().has_flag_ter( "SWIMMABLE", pos() ) ) { + if( watersleep && get_map().has_flag_ter( TFLAG_SWIMMABLE, pos() ) ) { sleepy += 10; //comfy water! } @@ -14814,7 +14814,7 @@ void Character::knock_back_to( const tripoint &to ) map &here = get_map(); // If we're still in the function at this point, we're actually moving a tile! - if( here.has_flag( "LIQUID", to ) && here.has_flag( TFLAG_DEEP_WATER, to ) ) { + if( here.has_flag( TFLAG_LIQUID, to ) && here.has_flag( TFLAG_DEEP_WATER, to ) ) { if( !is_npc() ) { avatar_action::swim( here, get_avatar(), to ); } @@ -15674,7 +15674,7 @@ void Character::pause() body_part_hand_r } }, true ); - } else if( here.has_flag( "SWIMMABLE", pos() ) ) { + } else if( here.has_flag( TFLAG_SWIMMABLE, pos() ) ) { drench( 80, { { body_part_foot_l, body_part_foot_r, body_part_leg_l, body_part_leg_r } }, false ); } diff --git a/src/construction.cpp b/src/construction.cpp index 4ddae4edae55c..9fcc860bb86c9 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -88,10 +88,7 @@ static const trait_id trait_PAINRESIST_TROGLO( "PAINRESIST_TROGLO" ); static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); static const trait_id trait_STOCKY_TROGLO( "STOCKY_TROGLO" ); -static const std::string flag_FLAT( "FLAT" ); static const std::string flag_INITIAL_PART( "INITIAL_PART" ); -static const std::string flag_SUPPORTS_ROOF( "SUPPORTS_ROOF" ); -static const std::string flag_NO_FLOOR( "NO_FLOOR" ); static bool finalized = false; @@ -1114,7 +1111,7 @@ bool construct::check_empty( const tripoint &p ) map &here = get_map(); // @TODO should check for *visible* traps only. But calling code must // first know how to handle constructing on top of an invisible trap! - return ( here.has_flag( flag_FLAT, p ) && !here.has_furn( p ) && + return ( here.has_flag( TFLAG_FLAT, p ) && !here.has_furn( p ) && g->is_empty( p ) && here.tr_at( p ).is_null() && here.i_at( p ).empty() && !here.veh_at( p ) ); } @@ -1138,7 +1135,7 @@ bool construct::check_support( const tripoint &p ) } int num_supports = 0; for( const tripoint &nb : get_orthogonal_neighbors( p ) ) { - if( here.has_flag( flag_SUPPORTS_ROOF, nb ) ) { + if( here.has_flag( TFLAG_SUPPORTS_ROOF, nb ) ) { num_supports++; } } @@ -1147,7 +1144,7 @@ bool construct::check_support( const tripoint &p ) bool construct::check_stable( const tripoint &p ) { - return get_map().has_flag( flag_SUPPORTS_ROOF, p + tripoint_below ); + return get_map().has_flag( TFLAG_SUPPORTS_ROOF, p + tripoint_below ); } bool construct::check_empty_stable( const tripoint &p ) @@ -1157,7 +1154,7 @@ bool construct::check_empty_stable( const tripoint &p ) bool construct::check_nofloor_above( const tripoint &p ) { - return get_map().has_flag( flag_NO_FLOOR, p + tripoint_above ); + return get_map().has_flag( TFLAG_NO_FLOOR, p + tripoint_above ); } bool construct::check_deconstruct( const tripoint &p ) diff --git a/src/do_turn.cpp b/src/do_turn.cpp index d5768ca196d42..d9a2d2a4f8b90 100644 --- a/src/do_turn.cpp +++ b/src/do_turn.cpp @@ -377,8 +377,8 @@ void update_stair_monsters() avatar &u = get_avatar(); for( const tripoint &dest : m.points_on_zlevel( u.posz() ) ) { - if( ( from_below && m.has_flag( "GOES_DOWN", dest ) ) || - ( !from_below && m.has_flag( "GOES_UP", dest ) ) ) { + if( ( from_below && m.has_flag( TFLAG_GOES_DOWN, dest ) ) || + ( !from_below && m.has_flag( TFLAG_GOES_UP, dest ) ) ) { stairx.push_back( dest.x ); stairy.push_back( dest.y ); stairdist.push_back( rl_dist( dest, u.pos() ) ); diff --git a/src/flag.cpp b/src/flag.cpp index 89eb2450d92e1..ff649ea52242d 100644 --- a/src/flag.cpp +++ b/src/flag.cpp @@ -278,7 +278,6 @@ const flag_id flag_TACK( "TACK" ); const flag_id flag_TANGLE( "TANGLE" ); const flag_id flag_TARDIS( "TARDIS" ); const flag_id flag_THERMOMETER( "THERMOMETER" ); -const flag_id flag_THIN_OBSTACLE( "THIN_OBSTACLE" ); const flag_id flag_TIE_UP( "TIE_UP" ); const flag_id flag_TINDER( "TINDER" ); const flag_id flag_TOBACCO( "TOBACCO" ); @@ -287,7 +286,6 @@ const flag_id flag_TOW_CABLE( "TOW_CABLE" ); const flag_id flag_TRADER_AVOID( "TRADER_AVOID" ); const flag_id flag_TRADER_KEEP( "TRADER_KEEP" ); const flag_id flag_TRADER_KEEP_EQUIPPED( "TRADER_KEEP_EQUIPPED" ); -const flag_id flag_TRANSPARENT( "TRANSPARENT" ); const flag_id flag_TWO_WAY_RADIO( "TWO_WAY_RADIO" ); const flag_id flag_UNARMED_WEAPON( "UNARMED_WEAPON" ); const flag_id flag_UNBREAKABLE_MELEE( "UNBREAKABLE_MELEE" ); diff --git a/src/flag.h b/src/flag.h index d819d457afe69..dccac1438bf96 100644 --- a/src/flag.h +++ b/src/flag.h @@ -294,7 +294,6 @@ extern const flag_id flag_TOW_CABLE; extern const flag_id flag_TRADER_AVOID; extern const flag_id flag_TRADER_KEEP; extern const flag_id flag_TRADER_KEEP_EQUIPPED; -extern const flag_id flag_TRANSPARENT; extern const flag_id flag_TWO_WAY_RADIO; extern const flag_id flag_UNARMED_WEAPON; extern const flag_id flag_UNBREAKABLE_MELEE; diff --git a/src/fungal_effects.cpp b/src/fungal_effects.cpp index 4a30067ff1b34..74778fa7843ca 100644 --- a/src/fungal_effects.cpp +++ b/src/fungal_effects.cpp @@ -39,16 +39,11 @@ static const species_id species_FUNGUS( "FUNGUS" ); static const trait_id trait_TAIL_CATTLE( "TAIL_CATTLE" ); static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" ); -static const std::string flag_DIGGABLE( "DIGGABLE" ); -static const std::string flag_FLAMMABLE( "FLAMMABLE" ); -static const std::string flag_FLAT( "FLAT" ); static const std::string flag_FLOWER( "FLOWER" ); static const std::string flag_ORGANIC( "ORGANIC" ); static const std::string flag_PLANT( "PLANT" ); static const std::string flag_SHRUB( "SHRUB" ); -static const std::string flag_THIN_OBSTACLE( "THIN_OBSTACLE" ); static const std::string flag_TREE( "TREE" ); -static const std::string flag_WALL( "WALL" ); static const std::string flag_YOUNG( "YOUNG" ); void fungal_effects::fungalize( const tripoint &p, Creature *origin, double spore_chance ) @@ -142,12 +137,12 @@ void fungal_effects::spread_fungus_one_tile( const tripoint &p, const int growth map &here = get_map(); bool converted = false; // Terrain conversion - if( here.has_flag_ter( flag_DIGGABLE, p ) ) { + if( here.has_flag_ter( TFLAG_DIGGABLE, p ) ) { if( x_in_y( growth * 10, 100 ) ) { here.ter_set( p, t_fungus ); converted = true; } - } else if( here.has_flag( flag_FLAT, p ) ) { + } else if( here.has_flag( TFLAG_FLAT, p ) ) { if( here.has_flag( TFLAG_INDOORS, p ) ) { if( x_in_y( growth * 10, 500 ) ) { here.ter_set( p, t_fungus_floor_in ); @@ -172,7 +167,7 @@ void fungal_effects::spread_fungus_one_tile( const tripoint &p, const int growth here.ter_set( p, t_marloss ); converted = true; } - } else if( here.has_flag( flag_THIN_OBSTACLE, p ) ) { + } else if( here.has_flag( TFLAG_THIN_OBSTACLE, p ) ) { if( x_in_y( growth * 10, 150 ) ) { here.ter_set( p, t_fungus_mound ); converted = true; @@ -209,7 +204,7 @@ void fungal_effects::spread_fungus_one_tile( const tripoint &p, const int growth } converted = true; } - } else if( here.has_flag( flag_WALL, p ) && here.has_flag( flag_FLAMMABLE, p ) ) { + } else if( here.has_flag( TFLAG_WALL, p ) && here.has_flag( TFLAG_FLAMMABLE, p ) ) { if( x_in_y( growth * 10, 5000 ) ) { here.ter_set( p, t_fungus_wall ); converted = true; diff --git a/src/game.cpp b/src/game.cpp index eaec5d1f87e91..6a82387e855ea 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4091,13 +4091,13 @@ void game::knockback( std::vector &traj, int stun, int dam_mult ) break; } targ->setpos( traj[i] ); - if( m.has_flag( "LIQUID", targ->pos() ) && !targ->can_drown() && !targ->is_dead() ) { + if( m.has_flag( TFLAG_LIQUID, targ->pos() ) && !targ->can_drown() && !targ->is_dead() ) { targ->die( nullptr ); if( u.sees( *targ ) ) { add_msg( _( "The %s drowns!" ), targ->name() ); } } - if( !m.has_flag( "LIQUID", targ->pos() ) && targ->has_flag( MF_AQUATIC ) && + if( !m.has_flag( TFLAG_LIQUID, targ->pos() ) && targ->has_flag( MF_AQUATIC ) && !targ->is_dead() ) { targ->die( nullptr ); if( u.sees( *targ ) ) { @@ -4241,7 +4241,7 @@ void game::knockback( std::vector &traj, int stun, int dam_mult ) knockback( traj, stun, dam_mult ); break; } - if( m.has_flag( "LIQUID", u.pos() ) && force_remaining == 0 ) { + if( m.has_flag( TFLAG_LIQUID, u.pos() ) && force_remaining == 0 ) { avatar_action::swim( m, u, u.pos() ); } else { u.setpos( traj[i] ); @@ -4579,7 +4579,7 @@ bool game::swap_critters( Creature &a, Creature &b ) bool game::is_empty( const tripoint &p ) { - return ( m.passable( p ) || m.has_flag( "LIQUID", p ) ) && + return ( m.passable( p ) || m.has_flag( TFLAG_LIQUID, p ) ) && get_creature_tracker().creature_at( p ) == nullptr; } @@ -4821,7 +4821,7 @@ bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int } m.ter_set( point( x, y ), door_type ); - if( m.has_flag( "NOITEM", point( x, y ) ) ) { + if( m.has_flag( TFLAG_NOITEM, point( x, y ) ) ) { map_stack items = m.i_at( point( x, y ) ); for( map_stack::iterator it = items.begin(); it != items.end(); ) { if( it->made_of( phase_id::LIQUID ) ) { @@ -4870,7 +4870,7 @@ void game::moving_vehicle_dismount( const tripoint &dest_loc ) // Dive three tiles in the direction of tox and toy fling_creature( &u, d, 30, true ); // Hit the ground according to vehicle speed - if( !m.has_flag( "SWIMMABLE", u.pos() ) ) { + if( !m.has_flag( TFLAG_SWIMMABLE, u.pos() ) ) { if( veh->velocity > 0 ) { fling_creature( &u, veh->face.dir(), veh->velocity / static_cast( 100 ) ); } else { @@ -5284,9 +5284,9 @@ void game::examine( const tripoint &examp ) add_msg( fire_fuel ); } - if( m.has_flag( "SEALED", examp ) ) { + if( m.has_flag( TFLAG_SEALED, examp ) ) { if( none ) { - if( m.has_flag( "UNSTABLE", examp ) ) { + if( m.has_flag( TFLAG_UNSTABLE, examp ) ) { add_msg( _( "The %s is too unstable to remove anything." ), m.name( examp ) ); } else { add_msg( _( "The %s is firmly sealed." ), m.name( examp ) ); @@ -8071,7 +8071,7 @@ void game::butcher() const std::string no_corpse_msg = _( "There are no corpses here to butcher." ); //You can't butcher on sealed terrain- you have to smash/shovel/etc it open first - if( m.has_flag( "SEALED", u.pos() ) ) { + if( m.has_flag( TFLAG_SEALED, u.pos() ) ) { if( m.sees_some_items( u.pos(), u ) ) { add_msg( m_info, _( "You can't access the items here." ) ); } else if( factor > INT_MIN || factorD > INT_MIN ) { @@ -8824,12 +8824,12 @@ std::vector game::get_dangerous_tile( const tripoint &dest_loc ) co return u.immune_to( bp, { damage_type::CUT, 10 } ); }; - if( m.has_flag( "ROUGH", dest_loc ) && !m.has_flag( "ROUGH", u.pos() ) && !veh_dest && + if( m.has_flag( TFLAG_ROUGH, dest_loc ) && !m.has_flag( TFLAG_ROUGH, u.pos() ) && !veh_dest && ( u.get_armor_bash( bodypart_id( "foot_l" ) ) < 5 || u.get_armor_bash( bodypart_id( "foot_r" ) ) < 5 ) ) { // NOLINT(bugprone-branch-clone) harmful_stuff.emplace_back( m.name( dest_loc ) ); - } else if( m.has_flag( "SHARP", dest_loc ) && !m.has_flag( "SHARP", u.pos() ) && !( u.in_vehicle || - m.veh_at( dest_loc ) ) && + } else if( m.has_flag( TFLAG_SHARP, dest_loc ) && !m.has_flag( TFLAG_SHARP, u.pos() ) && + !( u.in_vehicle || m.veh_at( dest_loc ) ) && u.dex_cur < 78 && !std::all_of( sharp_bps.begin(), sharp_bps.end(), sharp_bp_check ) ) { harmful_stuff.emplace_back( m.name( dest_loc ) ); } @@ -9027,8 +9027,8 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool // Print a message if movement is slow const int mcost_to = m.move_cost( dest_loc ); //calculate this _after_ calling grabbed_move - const bool fungus = m.has_flag_ter_or_furn( "FUNGUS", u.pos() ) || - m.has_flag_ter_or_furn( "FUNGUS", + const bool fungus = m.has_flag_ter_or_furn( TFLAG_FUNGUS, u.pos() ) || + m.has_flag_ter_or_furn( TFLAG_FUNGUS, dest_loc ); //fungal furniture has no slowing effect on mycus characters const bool slowed = ( ( !u.has_proficiency( proficiency_prof_parkour ) && ( mcost_to > 2 || mcost_from > 2 ) ) || @@ -9066,7 +9066,7 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool ///\EFFECT_DEX decreases chance of tentacles getting stuck to the ground ///\EFFECT_INT decreases chance of tentacles getting stuck to the ground - if( !m.has_flag( "SWIMMABLE", dest_loc ) && one_in( 80 + u.dex_cur + u.int_cur ) ) { + if( !m.has_flag( TFLAG_SWIMMABLE, dest_loc ) && one_in( 80 + u.dex_cur + u.int_cur ) ) { add_msg( _( "Your tentacles stick to the ground, but you pull them free." ) ); u.mod_fatigue( 1 ); } @@ -9175,22 +9175,22 @@ point game::place_player( const tripoint &dest_loc ) } } // TODO: Move the stuff below to a Character method so that NPCs can reuse it - if( m.has_flag( "ROUGH", dest_loc ) && ( !u.in_vehicle ) && ( !u.is_mounted() ) ) { + if( m.has_flag( TFLAG_ROUGH, dest_loc ) && ( !u.in_vehicle ) && ( !u.is_mounted() ) ) { if( one_in( 5 ) && u.get_armor_bash( bodypart_id( "foot_l" ) ) < rng( 2, 5 ) ) { add_msg( m_bad, _( "You hurt your left foot on the %s!" ), - m.has_flag_ter( "ROUGH", dest_loc ) ? m.tername( dest_loc ) : m.furnname( + m.has_flag_ter( TFLAG_ROUGH, dest_loc ) ? m.tername( dest_loc ) : m.furnname( dest_loc ) ); u.deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_type::CUT, 1 ) ); } if( one_in( 5 ) && u.get_armor_bash( bodypart_id( "foot_r" ) ) < rng( 2, 5 ) ) { add_msg( m_bad, _( "You hurt your right foot on the %s!" ), - m.has_flag_ter( "ROUGH", dest_loc ) ? m.tername( dest_loc ) : m.furnname( + m.has_flag_ter( TFLAG_ROUGH, dest_loc ) ? m.tername( dest_loc ) : m.furnname( dest_loc ) ); u.deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_type::CUT, 1 ) ); } } ///\EFFECT_DEX increases chance of avoiding cuts on sharp terrain - if( m.has_flag( "SHARP", dest_loc ) && !one_in( 3 ) && !x_in_y( 1 + u.dex_cur / 2.0, 40 ) && + if( m.has_flag( TFLAG_SHARP, dest_loc ) && !one_in( 3 ) && !x_in_y( 1 + u.dex_cur / 2.0, 40 ) && ( !u.in_vehicle && !m.veh_at( dest_loc ) ) && ( !u.has_proficiency( proficiency_prof_parkour ) || one_in( 4 ) ) && ( u.has_trait( trait_THICKSKIN ) ? !one_in( 8 ) : true ) ) { if( u.is_mounted() ) { @@ -9203,7 +9203,7 @@ point game::place_player( const tripoint &dest_loc ) //~ 1$s - bodypart name in accusative, 2$s is terrain name. add_msg( m_bad, _( "You cut your %1$s on the %2$s!" ), body_part_name_accusative( bp ), - m.has_flag_ter( "SHARP", dest_loc ) ? m.tername( dest_loc ) : m.furnname( + m.has_flag_ter( TFLAG_SHARP, dest_loc ) ? m.tername( dest_loc ) : m.furnname( dest_loc ) ); if( !u.has_trait( trait_INFIMMUNE ) ) { const int chance_in = u.has_trait( trait_INFRESIST ) ? 1024 : 256; @@ -9214,7 +9214,7 @@ point game::place_player( const tripoint &dest_loc ) } } } - if( m.has_flag( "UNSTABLE", dest_loc ) && !u.is_mounted() ) { + if( m.has_flag( TFLAG_UNSTABLE, dest_loc ) && !u.is_mounted() ) { u.add_effect( effect_bouldering, 1_turns, true ); } else if( u.has_effect( effect_bouldering ) ) { u.remove_effect( effect_bouldering ); @@ -9226,7 +9226,7 @@ point game::place_player( const tripoint &dest_loc ) } // If we moved out of the nonant, we need update our map data - if( m.has_flag( "SWIMMABLE", dest_loc ) && u.has_effect( effect_onfire ) ) { + if( m.has_flag( TFLAG_SWIMMABLE, dest_loc ) && u.has_effect( effect_onfire ) ) { add_msg( _( "The water puts out the flames!" ) ); u.remove_effect( effect_onfire ); if( u.is_mounted() ) { @@ -9407,14 +9407,14 @@ point game::place_player( const tripoint &dest_loc ) m.creature_on_trap( u ); } // Drench the player if swimmable - if( m.has_flag( "SWIMMABLE", u.pos() ) && + if( m.has_flag( TFLAG_SWIMMABLE, u.pos() ) && !( u.is_mounted() || ( u.in_vehicle && vp1->vehicle().can_float() ) ) ) { u.drench( 80, { { body_part_foot_l, body_part_foot_r, body_part_leg_l, body_part_leg_r } }, false ); } // List items here - if( !m.has_flag( "SEALED", u.pos() ) ) { + if( !m.has_flag( TFLAG_SEALED, u.pos() ) ) { if( get_option( "NO_AUTO_PICKUP_ZONES_LIST_ITEMS" ) || !check_zone( zone_type_id( "NO_AUTO_PICKUP" ), u.pos() ) ) { if( u.is_blind() && !m.i_at( u.pos() ).empty() ) { @@ -9620,7 +9620,7 @@ bool game::can_move_furniture( tripoint fdest, const tripoint &dp ) creatures.creature_at( fdest ) == nullptr && creatures.creature_at( fdest ) == nullptr && ( !pulling_furniture || is_empty( u.pos() + dp ) ) && - ( !has_floor || m.has_flag( "FLAT", fdest ) ) && + ( !has_floor || m.has_flag( TFLAG_FLAT, fdest ) ) && !m.has_furn( fdest ) && !m.veh_at( fdest ) && ( !has_floor || m.tr_at( fdest ).is_null() ); @@ -9647,13 +9647,13 @@ int game::grabbed_furn_move_time( const tripoint &dp ) return liquid_item.made_of_from_type( phase_id::LIQUID ); } ); - const bool dst_item_ok = !m.has_flag( "NOITEM", fdest ) && - !m.has_flag( "SWIMMABLE", fdest ) && - !m.has_flag( "DESTROY_ITEM", fdest ) && + const bool dst_item_ok = !m.has_flag( TFLAG_NOITEM, fdest ) && + !m.has_flag( TFLAG_SWIMMABLE, fdest ) && + !m.has_flag( TFLAG_DESTROY_ITEM, fdest ) && only_liquid_items; const bool src_item_ok = m.furn( fpos ).obj().has_flag( "CONTAINER" ) || - m.furn( fpos ).obj().has_flag( "FIRE_CONTAINER" ) || - m.furn( fpos ).obj().has_flag( "SEALED" ); + m.furn( fpos ).obj().has_flag( TFLAG_FIRE_CONTAINER ) || + m.furn( fpos ).obj().has_flag( TFLAG_SEALED ); int str_req = furntype.move_str_req; // Factor in weight of items contained in the furniture. @@ -9726,13 +9726,13 @@ bool game::grabbed_furn_move( const tripoint &dp ) return liquid_item.made_of_from_type( phase_id::LIQUID ); } ); - const bool dst_item_ok = !m.has_flag( "NOITEM", fdest ) && - !m.has_flag( "SWIMMABLE", fdest ) && - !m.has_flag( "DESTROY_ITEM", fdest ); + const bool dst_item_ok = !m.has_flag( TFLAG_NOITEM, fdest ) && + !m.has_flag( TFLAG_SWIMMABLE, fdest ) && + !m.has_flag( TFLAG_DESTROY_ITEM, fdest ); const bool src_item_ok = m.furn( fpos ).obj().has_flag( "CONTAINER" ) || - m.furn( fpos ).obj().has_flag( "FIRE_CONTAINER" ) || - m.furn( fpos ).obj().has_flag( "SEALED" ); + m.furn( fpos ).obj().has_flag( TFLAG_FIRE_CONTAINER ) || + m.furn( fpos ).obj().has_flag( TFLAG_SEALED ); const int fire_intensity = m.get_field_intensity( fpos, fd_fire ); time_duration fire_age = m.get_field_age( fpos, fd_fire ); @@ -9838,7 +9838,7 @@ bool game::grabbed_furn_move( const tripoint &dp ) } } - if( !m.has_floor( fdest ) && !m.has_flag( "FLAT", fdest ) ) { + if( !m.has_floor( fdest ) && !m.has_flag( TFLAG_FLAT, fdest ) ) { std::string danger_tile = enumerate_as_string( get_dangerous_tile( fdest ) ); add_msg( _( "You let go of the %1$s as it falls down the %2$s." ), furntype.name(), danger_tile ); u.grab( object_type::NONE ); @@ -10101,7 +10101,7 @@ void game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo } // Fall down to the ground - always on the last reached tile - if( !m.has_flag( "SWIMMABLE", c->pos() ) ) { + if( !m.has_flag( TFLAG_SWIMMABLE, c->pos() ) ) { const trap &trap_under_creature = m.tr_at( c->pos() ); // Didn't smash into a wall or a floor so only take the fall damage if( thru && trap_under_creature == tr_ledge ) { @@ -10203,7 +10203,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) map &here = get_map(); // > and < are used for diving underwater. - if( here.has_flag( "SWIMMABLE", u.pos() ) && here.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, u.pos() ) && here.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { if( movez == -1 ) { if( u.is_underwater() ) { add_msg( m_info, _( "You are already underwater!" ) ); @@ -10233,7 +10233,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) bool climbing = false; int move_cost = 100; tripoint stairs( u.posx(), u.posy(), u.posz() + movez ); - if( here.has_zlevels() && !force && movez == 1 && !here.has_flag( "GOES_UP", u.pos() ) ) { + if( here.has_zlevels() && !force && movez == 1 && !here.has_flag( TFLAG_GOES_UP, u.pos() ) ) { // Climbing if( here.has_floor_or_support( stairs ) ) { add_msg( m_info, _( "You can't climb here - there's a ceiling above your head." ) ); @@ -10273,10 +10273,10 @@ void game::vertical_move( int movez, bool force, bool peeking ) } } - if( !force && movez == -1 && !here.has_flag( "GOES_DOWN", u.pos() ) ) { + if( !force && movez == -1 && !here.has_flag( TFLAG_GOES_DOWN, u.pos() ) ) { add_msg( m_info, _( "You can't go down here!" ) ); return; - } else if( !climbing && !force && movez == 1 && !here.has_flag( "GOES_UP", u.pos() ) ) { + } else if( !climbing && !force && movez == 1 && !here.has_flag( TFLAG_GOES_UP, u.pos() ) ) { add_msg( m_info, _( "You can't go up here!" ) ); return; } @@ -10304,7 +10304,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) return; } - if( here.has_flag( "UNSTABLE", u.pos() ) ) { + if( here.has_flag( TFLAG_UNSTABLE, u.pos() ) ) { u.moves -= 500; if( movez == 1 && slip_down() ) { return; @@ -10696,7 +10696,7 @@ cata::optional game::find_or_make_stairs( map &mp, const int z_after, } if( movez > 0 ) { - if( !mp.has_flag( "GOES_DOWN", *stairs ) ) { + if( !mp.has_flag( TFLAG_GOES_DOWN, *stairs ) ) { if( !query_yn( _( "You may be unable to return back down these stairs. Continue up?" ) ) ) { return cata::nullopt; } diff --git a/src/gates.cpp b/src/gates.cpp index f97213a040ef6..074743a192b52 100644 --- a/src/gates.cpp +++ b/src/gates.cpp @@ -327,7 +327,7 @@ void doors::close_door( map &m, Creature &who, const tripoint &closep ) items_in_way.size() == 1 ? items_in_way.only_item().tname() : _( "stuff" ) ); who.mod_moves( -std::min( items_in_way.stored_volume() / ( max_nudge / 50 ), 100 ) ); - if( m.has_flag( "NOITEM", closep ) ) { + if( m.has_flag( TFLAG_NOITEM, closep ) ) { // Just plopping items back on their origin square will displace them to adjacent squares // since the door is closed now. for( auto &elem : items_in_way ) { diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 3eadc93091437..637507db5656b 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -218,7 +218,6 @@ static const std::string flag_GROWTH_HARVEST( "GROWTH_HARVEST" ); static const std::string flag_OPENCLOSE_INSIDE( "OPENCLOSE_INSIDE" ); static const std::string flag_PICKABLE( "PICKABLE" ); static const std::string flag_NANOFAB_TABLE( "NANOFAB_TABLE" ); -static const std::string flag_WALL( "WALL" ); // @TODO maybe make this a property of the item (depend on volume/type) static const time_duration milling_time = 6_hours; @@ -3957,7 +3956,7 @@ void iexamine::curtains( Character &you, const tripoint &examp ) { map &here = get_map(); const bool closed_window_with_curtains = here.has_flag( flag_BARRICADABLE_WINDOW_CURTAINS, examp ); - if( here.is_outside( you.pos() ) && ( here.has_flag( flag_WALL, examp ) || + if( here.is_outside( you.pos() ) && ( here.has_flag( TFLAG_WALL, examp ) || closed_window_with_curtains ) ) { locked_object( you, examp ); return; @@ -4568,7 +4567,7 @@ void iexamine::ledge( Character &you, const tripoint &examp ) if( has_grapnel ) { you.add_msg_if_player( _( "You tie the rope around your waist and begin to climb down." ) ); - } else if( here.has_flag( "UNSTABLE", examp + tripoint_below ) && g->slip_down( true ) ) { + } else if( here.has_flag( TFLAG_UNSTABLE, examp + tripoint_below ) && g->slip_down( true ) ) { return; } diff --git a/src/item.cpp b/src/item.cpp index 4be3ac738f7b4..a13e0261430f8 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -172,10 +172,6 @@ static const std::string flag_NO_DISPLAY( "NO_DISPLAY" ); static const std::string flag_SILENT( "SILENT" ); // terrain-furniture flags -static const std::string flag_FLAMMABLE( "FLAMMABLE" ); -static const std::string flag_FLAMMABLE_ASH( "FLAMMABLE_ASH" ); -static const std::string flag_DEEP_WATER( "DEEP_WATER" ); -static const std::string flag_LIQUID( "LIQUID" ); static const std::string flag_LIQUIDCONT( "LIQUIDCONT" ); static const matec_id RAPID( "RAPID" ); @@ -10387,8 +10383,8 @@ bool item::process_litcig( Character *carrier, const tripoint &pos ) if( item_counter % 5 == 0 ) { // lit cigarette can start fires if( here.flammable_items_at( pos ) || - here.has_flag( flag_FLAMMABLE, pos ) || - here.has_flag( flag_FLAMMABLE_ASH, pos ) ) { + here.has_flag( TFLAG_FLAMMABLE, pos ) || + here.has_flag( TFLAG_FLAMMABLE_ASH, pos ) ) { here.add_field( pos, fd_fire, 1 ); } } @@ -10442,11 +10438,11 @@ bool item::process_extinguish( Character *carrier, const tripoint &pos ) break; } map &here = get_map(); - if( in_inv && !in_veh && here.has_flag( flag_DEEP_WATER, pos ) ) { + if( in_inv && !in_veh && here.has_flag( TFLAG_DEEP_WATER, pos ) ) { extinguish = true; submerged = true; } - if( ( !in_inv && here.has_flag( flag_LIQUID, pos ) && !here.veh_at( pos ) ) || + if( ( !in_inv && here.has_flag( TFLAG_LIQUID, pos ) && !here.veh_at( pos ) ) || ( precipitation && !g->is_sheltered( pos ) ) ) { extinguish = true; } diff --git a/src/iuse.cpp b/src/iuse.cpp index b6f8d2f263c63..329439441a171 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -365,8 +365,6 @@ static const bionic_id bio_tools( "bio_tools" ); static const json_character_flag json_flag_ENHANCED_VISION( "ENHANCED_VISION" ); // terrain/furn flags -static const std::string flag_CURRENT( "CURRENT" ); -static const std::string flag_DIGGABLE( "DIGGABLE" ); static const std::string flag_FISHABLE( "FISHABLE" ); static const std::string flag_LIQUIDCONT( "LIQUIDCONT" ); static const std::string flag_PLANT( "PLANT" ); @@ -1823,7 +1821,7 @@ static bool good_fishing_spot( const tripoint &pos, Character *p ) const oter_id &cur_omt = overmap_buffer.ter( tripoint_abs_omt( ms_to_omt_copy( here.getabs( pos ) ) ) ); std::string om_id = cur_omt.id().c_str(); - if( fishables.empty() && !here.has_flag( "CURRENT", pos ) && + if( fishables.empty() && !here.has_flag( TFLAG_CURRENT, pos ) && om_id.find( "river_" ) == std::string::npos && !cur_omt->is_lake() && !cur_omt->is_lake_shore() ) { p->add_msg_if_player( m_info, _( "You doubt you will have much luck catching fish here." ) ); return false; @@ -2814,7 +2812,7 @@ cata::optional iuse::dig( Character *p, item *it, bool t, const tripoint & const tripoint dig_point = p->pos(); map &here = get_map(); - const bool can_dig_here = here.has_flag( "DIGGABLE", dig_point ) && + const bool can_dig_here = here.has_flag( TFLAG_DIGGABLE, dig_point ) && !here.has_furn( dig_point ) && !here.can_see_trap_at( dig_point, *p ) && ( here.ter( dig_point ) == t_grave_new || here.i_at( dig_point ).empty() ) && @@ -2922,12 +2920,12 @@ cata::optional iuse::dig_channel( Character *p, item *it, bool t, const tri tripoint east = dig_point + point_east; map &here = get_map(); - const bool can_dig_here = here.has_flag( flag_DIGGABLE, dig_point ) && + const bool can_dig_here = here.has_flag( TFLAG_DIGGABLE, dig_point ) && !here.has_furn( dig_point ) && !here.can_see_trap_at( dig_point, *p ) && here.i_at( dig_point ).empty() && !here.veh_at( dig_point ) && - ( here.has_flag( flag_CURRENT, north ) || here.has_flag( flag_CURRENT, south ) || - here.has_flag( flag_CURRENT, east ) || here.has_flag( flag_CURRENT, west ) ); + ( here.has_flag( TFLAG_CURRENT, north ) || here.has_flag( TFLAG_CURRENT, south ) || + here.has_flag( TFLAG_CURRENT, east ) || here.has_flag( TFLAG_CURRENT, west ) ); if( !can_dig_here ) { p->add_msg_if_player( @@ -3359,8 +3357,8 @@ cata::optional iuse::jackhammer( Character *p, item *it, bool, const tripoi } map &here = get_map(); - bool mineable_furn = here.has_flag_furn( "MINEABLE", pnt ); - bool mineable_ter = here.has_flag_ter( "MINEABLE", pnt ); + bool mineable_furn = here.has_flag_furn( TFLAG_MINEABLE, pnt ); + bool mineable_ter = here.has_flag_ter( TFLAG_MINEABLE, pnt ); if( !mineable_furn && !mineable_ter ) { p->add_msg_if_player( m_info, _( "You can't drill there." ) ); return cata::nullopt; @@ -3470,8 +3468,8 @@ cata::optional iuse::pickaxe( Character *p, item *it, bool, const tripoint } map &here = get_map(); - bool mineable_furn = here.has_flag_furn( "MINEABLE", pnt ); - bool mineable_ter = here.has_flag_ter( "MINEABLE", pnt ); + bool mineable_furn = here.has_flag_furn( TFLAG_MINEABLE, pnt ); + bool mineable_ter = here.has_flag_ter( TFLAG_MINEABLE, pnt ); if( !mineable_furn && !mineable_ter ) { p->add_msg_if_player( m_info, _( "You can't mine there." ) ); return cata::nullopt; @@ -6657,7 +6655,7 @@ static std::string colorized_feature_description_at( const tripoint ¢er_poin if( !sign_message.empty() ) { furn_str += string_format( _( " with message \"%s\"" ), sign_message ); } - if( !furn->has_flag( "CONTAINER" ) && !furn->has_flag( "SEALED" ) ) { + if( !furn->has_flag( "CONTAINER" ) && !furn->has_flag( TFLAG_SEALED ) ) { const item item = get_top_item_at_point( center_point, min_visible_volume ); if( !item.is_null() ) { furn_str += string_format( _( " with %s on it" ), colorized_item_name( item ) ); @@ -7638,7 +7636,7 @@ cata::optional iuse::ehandcuffs( Character *p, item *it, bool t, const trip if( t ) { - if( get_map().has_flag( "SWIMMABLE", pos.xy() ) ) { + if( get_map().has_flag( TFLAG_SWIMMABLE, pos.xy() ) ) { it->unset_flag( flag_NO_UNWIELD ); it->ammo_unset(); it->active = false; diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index eb1a93e9c4c80..b166ec4c506e6 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1036,10 +1036,10 @@ void deploy_furn_actor::info( const item &, std::vector &dump ) const if( the_furn.has_flag( "CAN_SIT" ) ) { can_function_as.emplace_back( _( "a place to sit" ) ); } - if( the_furn.has_flag( "HIDE_PLACE" ) ) { + if( the_furn.has_flag( TFLAG_HIDE_PLACE ) ) { can_function_as.emplace_back( _( "a place to hide" ) ); } - if( the_furn.has_flag( "FIRE_CONTAINER" ) ) { + if( the_furn.has_flag( TFLAG_FIRE_CONTAINER ) ) { can_function_as.emplace_back( _( "a safe place to contain a fire" ) ); } if( the_furn.crafting_pseudo_item == itype_char_smoker ) { @@ -3828,7 +3828,7 @@ cata::optional place_trap_actor::use( Character &p, item &it, bool, const t } const bool has_shovel = p.has_quality( quality_id( "DIG" ), 3 ); - const bool is_diggable = here.has_flag( "DIGGABLE", pos ); + const bool is_diggable = here.has_flag( TFLAG_DIGGABLE, pos ); bool bury = false; if( could_bury && has_shovel && is_diggable ) { bury = query_yn( "%s", bury_question ); @@ -4284,7 +4284,7 @@ cata::optional deploy_tent_actor::use( Character &p, item &it, bool, const add_msg( m_info, _( "The %s is in the way." ), c->disp_name() ); return cata::nullopt; } - if( here.impassable( dest ) || !here.has_flag( "FLAT", dest ) ) { + if( here.impassable( dest ) || !here.has_flag( TFLAG_FLAT, dest ) ) { add_msg( m_info, _( "The %s in that direction isn't suitable for placing the %s." ), here.name( dest ), it.tname() ); return cata::nullopt; diff --git a/src/level_cache.h b/src/level_cache.h index 5c31931b20eef..6fe68f51d9618 100644 --- a/src/level_cache.h +++ b/src/level_cache.h @@ -37,11 +37,11 @@ struct level_cache { float light_source_buffer[MAPSIZE_X][MAPSIZE_Y]; // if false, means tile is under the roof ("inside"), true means tile is "outside" - // "inside" tiles are protected from sun, rain, etc. (see "INDOORS" flag) + // "inside" tiles are protected from sun, rain, etc. (see TFLAG_INDOORS flag) bool outside_cache[MAPSIZE_X][MAPSIZE_Y]; - // true when vehicle below has "ROOF" or "OPAQUE" part, furniture below has "SUN_ROOF_ABOVE" - // or terrain doesn't have "NO_FLOOR" flag + // true when vehicle below has "ROOF" or "OPAQUE" part, furniture below has TFLAG_SUN_ROOF_ABOVE + // or terrain doesn't have TFLAG_NO_FLOOR flag // false otherwise // i.e. true == has floor bool floor_cache[MAPSIZE_X][MAPSIZE_Y]; diff --git a/src/map.cpp b/src/map.cpp index dcf4e7d728bae..92ad092966ffb 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -661,7 +661,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac } veh.handle_trap( wheel_p, w ); - if( !has_flag( "SEALED", wheel_p ) ) { + if( !has_flag( TFLAG_SEALED, wheel_p ) ) { const float wheel_area = veh.part( w ).wheel_area(); // Damage is calculated based on the weight of the vehicle, @@ -1755,16 +1755,16 @@ std::string map::features( const tripoint &p ) // to take up one line. So, make sure it does that. // FIXME: can't control length of localized text. add_if( is_bashable( p ), _( "Smashable." ) ); - add_if( has_flag( "DIGGABLE", p ), _( "Diggable." ) ); + add_if( has_flag( TFLAG_DIGGABLE, p ), _( "Diggable." ) ); add_if( has_flag( "PLOWABLE", p ), _( "Plowable." ) ); - add_if( has_flag( "ROUGH", p ), _( "Rough." ) ); - add_if( has_flag( "UNSTABLE", p ), _( "Unstable." ) ); - add_if( has_flag( "SHARP", p ), _( "Sharp." ) ); - add_if( has_flag( "FLAT", p ), _( "Flat." ) ); + add_if( has_flag( TFLAG_ROUGH, p ), _( "Rough." ) ); + add_if( has_flag( TFLAG_UNSTABLE, p ), _( "Unstable." ) ); + add_if( has_flag( TFLAG_SHARP, p ), _( "Sharp." ) ); + add_if( has_flag( TFLAG_FLAT, p ), _( "Flat." ) ); add_if( has_flag( "EASY_DECONSTRUCT", p ), _( "Simple." ) ); add_if( has_flag( "MOUNTABLE", p ), _( "Mountable." ) ); - add_if( has_flag( "FLAMMABLE", p ) || has_flag( "FLAMMABLE_ASH", p ) || - has_flag( "FLAMMABLE_HARD", p ), _( "Flammable." ) ); + add_if( has_flag( TFLAG_FLAMMABLE, p ) || has_flag( TFLAG_FLAMMABLE_ASH, p ) || + has_flag( TFLAG_FLAMMABLE_HARD, p ), _( "Flammable." ) ); return result; } @@ -2038,7 +2038,7 @@ int map::climb_difficulty( const tripoint &p ) const best_difficulty = std::min( best_difficulty, 7 ); } - if( best_difficulty > 5 && has_flag( "CLIMBABLE", pt ) ) { + if( best_difficulty > 5 && has_flag( TFLAG_CLIMBABLE, pt ) ) { best_difficulty = 5; } } @@ -2184,7 +2184,7 @@ void map::drop_furniture( const tripoint &p ) weight = frn_obj.is_movable() ? frn_obj.move_str_req : 20; } - if( frn_obj.has_flag( "ROUGH" ) || frn_obj.has_flag( "SHARP" ) ) { + if( frn_obj.has_flag( TFLAG_ROUGH ) || frn_obj.has_flag( TFLAG_SHARP ) ) { weight += 5; } @@ -2347,7 +2347,7 @@ bool map::can_put_items( const tripoint &p ) const bool map::can_put_items_ter_furn( const tripoint &p ) const { - return !has_flag( "NOITEM", p ) && !has_flag( "SEALED", p ); + return !has_flag( TFLAG_NOITEM, p ) && !has_flag( TFLAG_SEALED, p ); } bool map::has_flag_ter( const std::string &flag, const tripoint &p ) const @@ -2601,12 +2601,12 @@ void map::make_rubble( const tripoint &p, const furn_id &rubble_type, const bool bool map::is_water_shallow_current( const tripoint &p ) const { - return has_flag( "CURRENT", p ) && !has_flag( TFLAG_DEEP_WATER, p ); + return has_flag( TFLAG_CURRENT, p ) && !has_flag( TFLAG_DEEP_WATER, p ); } bool map::is_divable( const tripoint &p ) const { - return has_flag( "SWIMMABLE", p ) && has_flag( TFLAG_DEEP_WATER, p ); + return has_flag( TFLAG_SWIMMABLE, p ) && has_flag( TFLAG_DEEP_WATER, p ); } bool map::is_outside( const tripoint &p ) const @@ -2649,9 +2649,9 @@ bool map::is_last_ter_wall( const bool no_furn, const point &p, if( no_furn && has_furn( p2 ) ) { loop = false; result = false; - } else if( !has_flag_ter( "FLAT", p2 ) ) { + } else if( !has_flag_ter( TFLAG_FLAT, p2 ) ) { loop = false; - if( !has_flag_ter( "WALL", p2 ) ) { + if( !has_flag_ter( TFLAG_WALL, p2 ) ) { result = false; } } @@ -2901,17 +2901,17 @@ bool map::mop_spills( const tripoint &p ) int map::collapse_check( const tripoint &p ) { - const bool collapses = has_flag( "COLLAPSES", p ); - const bool supports_roof = has_flag( "SUPPORTS_ROOF", p ); + const bool collapses = has_flag( TFLAG_COLLAPSES, p ); + const bool supports_roof = has_flag( TFLAG_SUPPORTS_ROOF, p ); int num_supports = p.z == OVERMAP_DEPTH ? 0 : -5; // if there's support below, things are less likely to collapse if( p.z > -OVERMAP_DEPTH ) { const tripoint &pbelow = tripoint( p.xy(), p.z - 1 ); for( const tripoint &tbelow : points_in_radius( pbelow, 1 ) ) { - if( has_flag( "SUPPORTS_ROOF", tbelow ) ) { + if( has_flag( TFLAG_SUPPORTS_ROOF, tbelow ) ) { num_supports += 1; - if( has_flag( "WALL", tbelow ) ) { + if( has_flag( TFLAG_WALL, tbelow ) ) { num_supports += 2; } if( tbelow == pbelow ) { @@ -2927,16 +2927,16 @@ int map::collapse_check( const tripoint &p ) } if( collapses ) { - if( has_flag( "COLLAPSES", t ) ) { + if( has_flag( TFLAG_COLLAPSES, t ) ) { num_supports++; - } else if( has_flag( "SUPPORTS_ROOF", t ) ) { + } else if( has_flag( TFLAG_SUPPORTS_ROOF, t ) ) { num_supports += 2; } } else if( supports_roof ) { - if( has_flag( "SUPPORTS_ROOF", t ) ) { - if( has_flag( "WALL", t ) ) { + if( has_flag( TFLAG_SUPPORTS_ROOF, t ) ) { + if( has_flag( TFLAG_WALL, t ) ) { num_supports += 4; - } else if( !has_flag( "COLLAPSES", t ) ) { + } else if( !has_flag( TFLAG_COLLAPSES, t ) ) { num_supports += 3; } } @@ -2951,15 +2951,15 @@ int map::collapse_check( const tripoint &p ) void map::collapse_at( const tripoint &p, const bool silent, const bool was_supporting, const bool destroy_pos ) { - const bool supports = was_supporting || has_flag( "SUPPORTS_ROOF", p ); - const bool wall = was_supporting || has_flag( "WALL", p ); + const bool supports = was_supporting || has_flag( TFLAG_SUPPORTS_ROOF, p ); + const bool wall = was_supporting || has_flag( TFLAG_WALL, p ); // don't bash again if the caller already bashed here if( destroy_pos ) { destroy( p, silent ); crush( p ); make_rubble( p ); } - const bool still_supports = has_flag( "SUPPORTS_ROOF", p ); + const bool still_supports = has_flag( TFLAG_SUPPORTS_ROOF, p ); // If something supporting the roof collapsed, see what else collapses if( supports && !still_supports ) { @@ -2972,12 +2972,12 @@ void map::collapse_at( const tripoint &p, const bool silent, const bool was_supp } // if a wall collapses, walls without support from below risk collapsing and //propogate the collapse upwards - if( zlevels && wall && p == t && has_flag( "WALL", tz ) ) { + if( zlevels && wall && p == t && has_flag( TFLAG_WALL, tz ) ) { collapse_at( tz, silent ); } // floors without support from below risk collapsing into open air and can propogate // the collapse horizontally but not vertically - if( p != t && ( has_flag( "SUPPORTS_ROOF", t ) && has_flag( "COLLAPSES", t ) ) ) { + if( p != t && ( has_flag( TFLAG_SUPPORTS_ROOF, t ) && has_flag( TFLAG_COLLAPSES, t ) ) ) { collapse_at( t, silent ); } // this tile used to support a roof, now it doesn't, which means there is only @@ -3265,7 +3265,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) if( bash->str_min_supported != -1 || bash->str_max_supported != -1 ) { tripoint below( p.xy(), p.z - 1 ); - if( !zlevels || has_flag( "SUPPORTS_ROOF", below ) ) { + if( !zlevels || has_flag( TFLAG_SUPPORTS_ROOF, below ) ) { if( bash->str_min_supported != -1 ) { smin = bash->str_min_supported; } @@ -3308,8 +3308,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) i_clear( p ); } - if( ( smash_furn && has_flag_furn( "FUNGUS", p ) ) || - ( smash_ter && has_flag_ter( "FUNGUS", p ) ) ) { + if( ( smash_furn && has_flag_furn( TFLAG_FUNGUS, p ) ) || + ( smash_ter && has_flag_ter( TFLAG_FUNGUS, p ) ) ) { fungal_effects().create_spores( p ); } @@ -3326,7 +3326,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) soundfxid = "smash_success"; const translation &sound = bash->sound; // Set this now in case the ter_set below changes this - const bool will_collapse = smash_ter && has_flag( "SUPPORTS_ROOF", p ) && !has_flag( "INDOORS", p ); + const bool will_collapse = smash_ter && + has_flag( TFLAG_SUPPORTS_ROOF, p ) && !has_flag( TFLAG_INDOORS, p ); const bool tent = smash_furn && !bash->tent_centers.empty(); // Special code to collapse the tent if destroyed @@ -3406,7 +3407,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) } else { tripoint below( p.xy(), p.z - 1 ); const auto &ter_below = ter( below ).obj(); - if( bash->bash_below && ter_below.has_flag( "SUPPORTS_ROOF" ) ) { + if( bash->bash_below && ter_below.has_flag( TFLAG_SUPPORTS_ROOF ) ) { // When bashing the tile below, don't allow bashing the floor bash_params params_below = params; // Make a copy params_below.bashing_from_above = true; @@ -3435,7 +3436,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) explosion_handler::explosion( p, bash->explosive, 0.8, false ); } - if( will_collapse && !has_flag( "SUPPORTS_ROOF", p ) ) { + if( will_collapse && !has_flag( TFLAG_SUPPORTS_ROOF, p ) ) { collapse_at( p, params.silent, true, bash->explosive > 0 ); } @@ -3460,7 +3461,7 @@ bash_params map::bash( const tripoint &p, const int str, } bool bashed_sealed = false; - if( has_flag( "SEALED", p ) ) { + if( has_flag( TFLAG_SEALED, p ) ) { bash_ter_furn( p, bsh ); bashed_sealed = true; } @@ -3820,7 +3821,7 @@ bool map::hit_with_fire( const tripoint &p ) } // non passable but flammable terrain, set it on fire - if( has_flag( "FLAMMABLE", p ) || has_flag( "FLAMMABLE_ASH", p ) ) { + if( has_flag( TFLAG_FLAMMABLE, p ) || has_flag( TFLAG_FLAMMABLE_ASH, p ) ) { add_field( p, fd_fire, 3 ); } return true; @@ -3842,7 +3843,7 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only ter_set( p, ter.open ); if( player_character.has_trait( trait_id( "SCHIZOPHRENIC" ) ) && - one_in( 50 ) && !ter.has_flag( "TRANSPARENT" ) ) { + one_in( 50 ) && !ter.has_flag( TFLAG_TRANSPARENT ) ) { tripoint mp = p + -2 * player_character.pos().xy() + tripoint( 2 * p.x, 2 * p.y, p.z ); g->spawn_hallucination( mp ); } @@ -4144,10 +4145,10 @@ void map::i_clear( const tripoint &p ) std::vector map::spawn_items( const tripoint &p, const std::vector &new_items ) { std::vector ret; - if( !inbounds( p ) || has_flag( "DESTROY_ITEM", p ) ) { + if( !inbounds( p ) || has_flag( TFLAG_DESTROY_ITEM, p ) ) { return ret; } - const bool swimmable = has_flag( "SWIMMABLE", p ); + const bool swimmable = has_flag( TFLAG_SWIMMABLE, p ); for( const item &new_item : new_items ) { if( new_item.made_of( phase_id::LIQUID ) && swimmable ) { @@ -4199,8 +4200,8 @@ void map::spawn_item( const tripoint &p, const itype_id &type_id, const unsigned new_item.charges = charges; } new_item = new_item.in_its_container(); - if( ( new_item.made_of( phase_id::LIQUID ) && has_flag( "SWIMMABLE", p ) ) || - has_flag( "DESTROY_ITEM", p ) ) { + if( ( new_item.made_of( phase_id::LIQUID ) && has_flag( TFLAG_SWIMMABLE, p ) ) || + has_flag( TFLAG_DESTROY_ITEM, p ) ) { return; } @@ -4239,12 +4240,12 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) } // Some tiles destroy items (e.g. lava) - if( has_flag( "DESTROY_ITEM", e ) ) { + if( has_flag( TFLAG_DESTROY_ITEM, e ) ) { return false; } // Cannot drop liquids into tiles that are comprised of liquid - if( obj.made_of_from_type( phase_id::LIQUID ) && has_flag( "SWIMMABLE", e ) ) { + if( obj.made_of_from_type( phase_id::LIQUID ) && has_flag( TFLAG_SWIMMABLE, e ) ) { return false; } @@ -4285,8 +4286,8 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) return null_item_reference(); } - if( ( !has_flag( "NOITEM", pos ) || ( has_flag( "LIQUIDCONT", pos ) && - obj.made_of( phase_id::LIQUID ) ) ) + if( ( !has_flag( TFLAG_NOITEM, pos ) || + ( has_flag( "LIQUIDCONT", pos ) && obj.made_of( phase_id::LIQUID ) ) ) && valid_limits( pos ) ) { // Pass map into on_drop, because this map may not be the global map object (in mapgen, for instance). if( obj.made_of( phase_id::LIQUID ) || !obj.has_flag( flag_DROP_ACTION_ONLY_IF_LIQUID ) ) { @@ -4321,7 +4322,7 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) } if( !valid_tile( e ) || !valid_limits( e ) || - has_flag( "NOITEM", e ) || has_flag( "SEALED", e ) ) { + has_flag( TFLAG_NOITEM, e ) || has_flag( TFLAG_SEALED, e ) ) { continue; } return place_item( e ); @@ -4356,11 +4357,11 @@ item &map::add_item( const tripoint &p, item new_item ) new_item.process( nullptr, p ); } - if( new_item.made_of( phase_id::LIQUID ) && has_flag( "SWIMMABLE", p ) ) { + if( new_item.made_of( phase_id::LIQUID ) && has_flag( TFLAG_SWIMMABLE, p ) ) { return null_item_reference(); } - if( has_flag( "DESTROY_ITEM", p ) ) { + if( has_flag( TFLAG_DESTROY_ITEM, p ) ) { return null_item_reference(); } @@ -6419,7 +6420,7 @@ bool map::clear_path( const tripoint &f, const tripoint &t, const int range, bool map::accessible_items( const tripoint &t ) const { - return !has_flag( "SEALED", t ) || has_flag( "LIQUIDCONT", t ); + return !has_flag( TFLAG_SEALED, t ) || has_flag( "LIQUIDCONT", t ); } std::vector map::get_dir_circle( const tripoint &f, const tripoint &t ) const diff --git a/src/map_extras.cpp b/src/map_extras.cpp index e1253dc13aa20..64732ad5a9d88 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -64,10 +64,7 @@ static const trap_str_id tr_caltrops( "tr_caltrops" ); static const trap_str_id tr_nailboard( "tr_nailboard" ); -static const std::string flag_DIGGABLE( "DIGGABLE" ); -static const std::string flag_FLAT( "FLAT" ); static const std::string flag_FLOWER( "FLOWER" ); -static const std::string flag_LIQUID( "LIQUID" ); static const std::string flag_ORGANIC( "ORGANIC" ); static const std::string flag_PLANT( "PLANT" ); static const std::string flag_SHRUB( "SHRUB" ); @@ -1128,7 +1125,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const point p( rng( 3, SEEX * 2 - 4 ), rng( SEEY, SEEY * 2 - 2 ) ); - if( m.has_flag( flag_DIGGABLE, p ) ) { + if( m.has_flag( TFLAG_DIGGABLE, p ) ) { place_trap_if_clear( m, p, tr_landmine_buried ); } else { place_trap_if_clear( m, p, tr_landmine ); @@ -1231,7 +1228,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const point p3( rng( 3, SEEX * 2 - 4 ), rng( 1, SEEY ) ); - if( m.has_flag( flag_DIGGABLE, p3 ) ) { + if( m.has_flag( TFLAG_DIGGABLE, p3 ) ) { place_trap_if_clear( m, p3, tr_landmine_buried ); } else { place_trap_if_clear( m, p3, tr_landmine ); @@ -1378,7 +1375,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const point p5( rng( SEEX + 1, SEEX * 2 - 2 ), rng( 3, SEEY * 2 - 4 ) ); - if( m.has_flag( flag_DIGGABLE, p5 ) ) { + if( m.has_flag( TFLAG_DIGGABLE, p5 ) ) { place_trap_if_clear( m, p5, tr_landmine_buried ); } else { place_trap_if_clear( m, p5, tr_landmine ); @@ -1517,7 +1514,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const point p7( rng( 1, SEEX ), rng( 3, SEEY * 2 - 4 ) ); - if( m.has_flag( flag_DIGGABLE, p7 ) ) { + if( m.has_flag( TFLAG_DIGGABLE, p7 ) ) { place_trap_if_clear( m, p7, tr_landmine_buried ); } else { place_trap_if_clear( m, p7, tr_landmine ); @@ -1754,7 +1751,7 @@ static bool mx_spider( map &m, const tripoint &abs_sub ) for( int j = 0; j < SEEY * 2; j++ ) { const tripoint location( i, j, abs_sub.z ); - bool should_web_flat = m.has_flag_ter( flag_FLAT, location ) && !one_in( 3 ); + bool should_web_flat = m.has_flag_ter( TFLAG_FLAT, location ) && !one_in( 3 ); bool should_web_shrub = m.has_flag_ter( flag_SHRUB, location ) && !one_in( 4 ); bool should_web_tree = m.has_flag_ter( flag_TREE, location ) && !one_in( 4 ); @@ -2097,7 +2094,7 @@ static void burned_ground_parser( map &m, const tripoint &loc ) while( m.is_bashable( loc ) ) { // one is not enough m.destroy( loc, true ); } - if( one_in( 5 ) && !tr.has_flag( flag_LIQUID ) ) { + if( one_in( 5 ) && !tr.has_flag( TFLAG_LIQUID ) ) { m.spawn_item( loc, itype_ash, 1, rng( 1, 10 ) ); } } else if( ter_furn_has_flag( tr, fid, TFLAG_FLAMMABLE_ASH ) ) { @@ -2105,7 +2102,7 @@ static void burned_ground_parser( map &m, const tripoint &loc ) m.destroy( loc, true ); } m.furn_set( loc, f_ash ); - if( !tr.has_flag( flag_LIQUID ) ) { + if( !tr.has_flag( TFLAG_LIQUID ) ) { m.spawn_item( loc, itype_ash, 1, rng( 1, 100 ) ); } } diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 84225df7ab4d0..7f24064dcf7ec 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -2331,7 +2331,7 @@ class jmapgen_terrain : public jmapgen_piece } dat.m.ter_set( point( x.get(), y.get() ), chosen_id ); // Delete furniture if a wall was just placed over it. TODO: need to do anything for fluid, monsters? - if( dat.m.has_flag_ter( "WALL", point( x.get(), y.get() ) ) ) { + if( dat.m.has_flag_ter( TFLAG_WALL, point( x.get(), y.get() ) ) ) { dat.m.furn_set( point( x.get(), y.get() ), f_null ); // and items, unless the wall has PLACE_ITEM flag indicating it stores things. if( !dat.m.has_flag_ter( "PLACE_ITEM", point( x.get(), y.get() ) ) ) { @@ -4089,7 +4089,7 @@ void map::draw_lab( mapgendata &dat ) // We determine if a border isn't handled by checking the east-facing // border space where the door normally is -- it should be a wall or door. tripoint east_border( 23, 11, abs_sub.z ); - if( !has_flag_ter( "WALL", east_border ) && + if( !has_flag_ter( TFLAG_WALL, east_border ) && !has_flag_ter( "DOOR", east_border ) ) { // TODO: create a ter_reset function that does ter_set, // furn_set, and i_clear? @@ -4338,7 +4338,7 @@ void map::draw_lab( mapgendata &dat ) if( i + j > 10 && i + j < 36 && std::abs( i - j ) < 13 ) { // Doors and walls get sometimes destroyed: // 100% at the edge, usually in a central cross, occasionally elsewhere. - if( ( has_flag_ter( "DOOR", point( i, j ) ) || has_flag_ter( "WALL", point( i, j ) ) ) ) { + if( ( has_flag_ter( "DOOR", point( i, j ) ) || has_flag_ter( TFLAG_WALL, point( i, j ) ) ) ) { if( ( i == 0 || j == 0 || i == 23 || j == 23 ) || ( !one_in( 3 ) && ( i == 11 || i == 12 || j == 11 || j == 12 ) ) || one_in( 4 ) ) { @@ -4351,8 +4351,8 @@ void map::draw_lab( mapgendata &dat ) } // and then randomly destroy 5% of the remaining nonstairs. } else if( one_in( 20 ) && - !has_flag_ter( "GOES_DOWN", p2 ) && - !has_flag_ter( "GOES_UP", p2 ) ) { + !has_flag_ter( TFLAG_GOES_DOWN, p2 ) && + !has_flag_ter( TFLAG_GOES_UP, p2 ) ) { destroy( { i, j, abs_sub.z } ); // bashed squares can create dirt & floors, but we want rock floors. if( t_dirt == ter( point( i, j ) ) || t_floor == ter( point( i, j ) ) ) { @@ -4495,8 +4495,8 @@ void map::draw_lab( mapgendata &dat ) ARTPROP_GLOWING }; draw_rough_circle( [this]( const point & p ) { - if( has_flag_ter( "GOES_DOWN", p ) || - has_flag_ter( "GOES_UP", p ) || + if( has_flag_ter( TFLAG_GOES_DOWN, p ) || + has_flag_ter( TFLAG_GOES_UP, p ) || has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } @@ -4511,7 +4511,7 @@ void map::draw_lab( mapgendata &dat ) // radioactive accident. case 6: { tripoint center( rng( 6, SEEX * 2 - 7 ), rng( 6, SEEY * 2 - 7 ), abs_sub.z ); - if( has_flag_ter( "WALL", center.xy() ) ) { + if( has_flag_ter( TFLAG_WALL, center.xy() ) ) { // just skip it, we don't want to risk embedding radiation out of sight. break; } @@ -4528,8 +4528,8 @@ void map::draw_lab( mapgendata &dat ) set_radiation( p, 50 ); }, center.xy(), 1 ); draw_circle( [this]( const point & p ) { - if( has_flag_ter( "GOES_DOWN", p ) || - has_flag_ter( "GOES_UP", p ) || + if( has_flag_ter( TFLAG_GOES_DOWN, p ) || + has_flag_ter( TFLAG_GOES_UP, p ) || has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } @@ -4560,14 +4560,14 @@ void map::draw_lab( mapgendata &dat ) for( int i = 0; i < EAST_EDGE; i++ ) { for( int j = 0; j < SOUTH_EDGE; j++ ) { // Create a mostly spread fungal area throughout entire lab. - if( !one_in( 5 ) && ( has_flag( "FLAT", point( i, j ) ) ) ) { + if( !one_in( 5 ) && ( has_flag( TFLAG_FLAT, point( i, j ) ) ) ) { ter_set( point( i, j ), t_fungus_floor_in ); if( has_flag_furn( "ORGANIC", point( i, j ) ) ) { furn_set( point( i, j ), f_fungal_clump ); } } else if( has_flag_ter( "DOOR", point( i, j ) ) && !one_in( 5 ) ) { ter_set( point( i, j ), t_fungus_floor_in ); - } else if( has_flag_ter( "WALL", point( i, j ) ) && one_in( 3 ) ) { + } else if( has_flag_ter( TFLAG_WALL, point( i, j ) ) && one_in( 3 ) ) { ter_set( point( i, j ), t_fungus_wall ); } } @@ -4576,12 +4576,12 @@ void map::draw_lab( mapgendata &dat ) // Make a portal surrounded by more dense fungal stuff and a fungaloid. draw_rough_circle( [this]( const point & p ) { - if( has_flag_ter( "GOES_DOWN", p ) || - has_flag_ter( "GOES_UP", p ) || + if( has_flag_ter( TFLAG_GOES_DOWN, p ) || + has_flag_ter( TFLAG_GOES_UP, p ) || has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } - if( has_flag_ter( "WALL", p ) ) { + if( has_flag_ter( TFLAG_WALL, p ) ) { ter_set( p, t_fungus_wall ); } else { ter_set( p, t_fungus_floor_in ); @@ -4630,7 +4630,7 @@ void map::draw_lab( mapgendata &dat ) // We determine if a border isn't handled by checking the east-facing // border space where the door normally is -- it should be a wall or door. tripoint east_border( 23, 11, abs_sub.z ); - if( !has_flag_ter( "WALL", east_border ) && !has_flag_ter( "DOOR", east_border ) ) { + if( !has_flag_ter( TFLAG_WALL, east_border ) && !has_flag_ter( "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; @@ -5866,7 +5866,7 @@ std::vector map::place_items( return terrain.movecost == 0 && !terrain.has_flag( "PLACE_ITEM" ) && !ongrass && - !terrain.has_flag( "FLAT" ); + !terrain.has_flag( TFLAG_FLAT ); }; tripoint p; diff --git a/src/melee.cpp b/src/melee.cpp index 1e89336c5167c..fec92c23f56f6 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -862,7 +862,7 @@ void Character::reach_attack( const tripoint &p ) } else if( here.impassable( path_point ) && // Fences etc. Spears can stab through those !( weapon.has_flag( flag_SPEAR ) && - here.has_flag( "THIN_OBSTACLE", path_point ) && + here.has_flag( TFLAG_THIN_OBSTACLE, path_point ) && x_in_y( skill, 10 ) ) ) { /** @EFFECT_STR increases bash effects when reach attacking past something */ here.bash( path_point, str_cur + weapon.damage_melee( damage_type::BASH ) ); @@ -1690,7 +1690,7 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, d if( technique.knockback_follow ) { const optional_vpart_position vp0 = here.veh_at( pos() ); vehicle *const veh0 = veh_pointer_or_null( vp0 ); - bool to_swimmable = here.has_flag( "SWIMMABLE", prev_pos ); + bool to_swimmable = here.has_flag( TFLAG_SWIMMABLE, prev_pos ); bool to_deepwater = here.has_flag( TFLAG_DEEP_WATER, prev_pos ); // Check if it's possible to move to the new tile diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 28d348a5eae16..682a58b87cdb9 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -166,7 +166,7 @@ static tripoint find_potential_computer_point( const tinymap &compmap ) } int wall = 0; for( const tripoint &p2 : compmap.points_in_radius( p, 1 ) ) { - if( compmap.has_flag_ter( "WALL", p2 ) ) { + if( compmap.has_flag_ter( TFLAG_WALL, p2 ) ) { wall++; } } diff --git a/src/monattack.cpp b/src/monattack.cpp index e8c0854f8a97c..db535f503ed3d 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -1400,7 +1400,7 @@ bool mattack::growplants( monster *z ) for( const auto &p : here.points_in_radius( z->pos(), 3 ) ) { // Only affect natural, dirtlike terrain or trees. - if( !( here.has_flag_ter( "DIGGABLE", p ) || + if( !( here.has_flag_ter( TFLAG_DIGGABLE, p ) || here.has_flag_ter( "TREE", p ) || here.ter( p ) == t_tree_young ) ) { continue; @@ -2217,7 +2217,7 @@ bool mattack::plant( monster *z ) map &here = get_map(); fungal_effects fe; const tripoint monster_position = z->pos(); - const bool is_fungi = here.has_flag_ter( "FUNGUS", monster_position ); + const bool is_fungi = here.has_flag_ter( TFLAG_FUNGUS, monster_position ); // Spores taking seed and growing into a fungaloid fe.spread_fungus( monster_position ); if( is_fungi && one_in( 10 + g->num_creatures() / 5 ) ) { diff --git a/src/monmove.cpp b/src/monmove.cpp index bc9e7087d4c3e..a0e1658f805b2 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -71,7 +71,6 @@ static const species_id species_FUNGUS( "FUNGUS" ); static const species_id species_ZOMBIE( "ZOMBIE" ); static const std::string flag_AUTODOC_COUCH( "AUTODOC_COUCH" ); -static const std::string flag_LIQUID( "LIQUID" ); bool monster::wander() { @@ -125,7 +124,7 @@ bool monster::will_move_to( const tripoint &p ) const if( !here.has_flag( "BURROWABLE", p ) ) { return false; } - } else if( !( can_climb() && here.has_flag( "CLIMBABLE", p ) ) ) { + } else if( !( can_climb() && here.has_flag( TFLAG_CLIMBABLE, p ) ) ) { return false; } } @@ -134,12 +133,12 @@ bool monster::will_move_to( const tripoint &p ) const return false; } - if( digs() && !here.has_flag( "DIGGABLE", p ) && !here.has_flag( "BURROWABLE", p ) ) { + if( digs() && !here.has_flag( TFLAG_DIGGABLE, p ) && !here.has_flag( "BURROWABLE", p ) ) { return false; } if( has_flag( MF_AQUATIC ) && ( - !here.has_flag( "SWIMMABLE", p ) || + !here.has_flag( TFLAG_SWIMMABLE, p ) || // AQUATIC (confined to water) monster avoid vehicles, unless they are already underneath one ( here.veh_at( p ) && !here.veh_at( pos() ) ) ) ) { @@ -200,7 +199,7 @@ bool monster::will_move_to( const tripoint &p ) const // Some things are only avoided if we're not attacking if( attitude( &get_player_character() ) != MATT_ATTACK ) { // Sharp terrain is ignored while attacking - if( avoid_simple && here.has_flag( "SHARP", p ) && + if( avoid_simple && here.has_flag( TFLAG_SHARP, p ) && !( type->size == creature_size::tiny || flies() ) ) { return false; } @@ -678,7 +677,7 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina bool monster::is_aquatic_danger( const tripoint &at_pos ) { map &here = get_map(); - return here.has_flag_ter( TFLAG_DEEP_WATER, at_pos ) && here.has_flag( flag_LIQUID, at_pos ) && + return here.has_flag_ter( TFLAG_DEEP_WATER, at_pos ) && here.has_flag( TFLAG_LIQUID, at_pos ) && can_drown() && !here.veh_at( at_pos ).part_with_feature( "BOARDABLE", false ); } @@ -1337,40 +1336,40 @@ int monster::calc_movecost( const tripoint &f, const tripoint &t ) const const int source_cost = here.move_cost( f ); const int dest_cost = here.move_cost( t ); // Digging and flying monsters ignore terrain cost - if( flies() || ( digging() && here.has_flag( "DIGGABLE", t ) ) ) { + if( flies() || ( digging() && here.has_flag( TFLAG_DIGGABLE, t ) ) ) { movecost = 100; // Swimming monsters move super fast in water } else if( swims() ) { - if( here.has_flag( "SWIMMABLE", f ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, f ) ) { movecost += 25; } else { movecost += 50 * here.move_cost( f ); } - if( here.has_flag( "SWIMMABLE", t ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, t ) ) { movecost += 25; } else { movecost += 50 * here.move_cost( t ); } } else if( can_submerge() ) { // No-breathe monsters have to walk underwater slowly - if( here.has_flag( "SWIMMABLE", f ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, f ) ) { movecost += 250; } else { movecost += 50 * here.move_cost( f ); } - if( here.has_flag( "SWIMMABLE", t ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, t ) ) { movecost += 250; } else { movecost += 50 * here.move_cost( t ); } movecost /= 2; } else if( climbs() ) { - if( here.has_flag( "CLIMBABLE", f ) ) { + if( here.has_flag( TFLAG_CLIMBABLE, f ) ) { movecost += 150; } else { movecost += 50 * here.move_cost( f ); } - if( here.has_flag( "CLIMBABLE", t ) ) { + if( here.has_flag( TFLAG_CLIMBABLE, t ) ) { movecost += 150; } else { movecost += 50 * here.move_cost( t ); @@ -1460,7 +1459,7 @@ bool monster::bash_at( const tripoint &p ) map &here = get_map(); if( !( here.is_bashable_furn( p ) || here.veh_at( p ).obstacle_at_part() ) ) { // if the only thing here is road or flat, rarely bash it - bool flat_ground = here.has_flag( "ROAD", p ) || here.has_flag( "FLAT", p ); + bool flat_ground = here.has_flag( "ROAD", p ) || here.has_flag( TFLAG_FLAT, p ); if( !here.is_bashable_ter( p ) || ( flat_ground && !one_in( 50 ) ) ) { return false; } diff --git a/src/npc.cpp b/src/npc.cpp index ef52d0a813cc6..2b582f5115b3d 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -2810,7 +2810,7 @@ void npc::on_load() map &here = get_map(); // for spawned npcs - if( here.has_flag( "UNSTABLE", pos() ) ) { + if( here.has_flag( TFLAG_UNSTABLE, pos() ) ) { add_effect( effect_bouldering, 1_turns, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 2c672bb0896d2..e4e97dca0b325 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -2355,7 +2355,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo moves -= 100; moved = true; } - } else if( get_dex() > 1 && here.has_flag_ter_or_furn( "CLIMBABLE", p ) ) { + } else if( get_dex() > 1 && here.has_flag_ter_or_furn( TFLAG_CLIMBABLE, p ) ) { ///\EFFECT_DEX_NPC increases chance to climb CLIMBABLE furniture or terrain int climb = get_dex(); if( one_in( climb ) ) { @@ -2398,7 +2398,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo here.creature_on_trap( *mounted_creature ); } } - if( here.has_flag( "UNSTABLE", pos() ) ) { + if( here.has_flag( TFLAG_UNSTABLE, pos() ) ) { add_effect( effect_bouldering, 1_turns, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 700270f0c4101..a1a4e044f3bd1 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -1628,7 +1628,7 @@ static std::vector get_overmap_path_to( const tripoint_abs_omt params = overmap_path_params::for_player(); const oter_id dest_ter = overmap_buffer.ter_existing( dest ); // already in water or going to a water tile - if( here.has_flag( "SWIMMABLE", player_character.pos() ) || is_river_or_lake( dest_ter ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, player_character.pos() ) || is_river_or_lake( dest_ter ) ) { params.water_cost = 100; } } diff --git a/src/pickup.cpp b/src/pickup.cpp index 2c81344b7e466..1672c71fc6fc8 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -471,7 +471,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) from_vehicle = cargo_part >= 0; } else { // Nothing to change, default is to pick from ground anyway. - if( local.has_flag( "SEALED", p ) ) { + if( local.has_flag( TFLAG_SEALED, p ) ) { return; } } @@ -530,7 +530,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) if( g->check_zone( zone_type_id( "NO_AUTO_PICKUP" ), p ) ) { return; } - if( local.has_flag( "SEALED", p ) ) { + if( local.has_flag( TFLAG_SEALED, p ) ) { return; } } diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 34ce6473bd1d9..10ece47bf647b 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -962,7 +962,7 @@ static void eff_fun_sleep( Character &u, effect &it ) } if( u.has_trait( trait_M_SKIN3 ) ) { // Spores happen! - if( here.has_flag_ter_or_furn( "FUNGUS", u.pos() ) ) { + if( here.has_flag_ter_or_furn( TFLAG_FUNGUS, u.pos() ) ) { if( u.get_fatigue() >= 0 ) { u.mod_fatigue( -5 ); // Local guides need less sleep on fungal soil } @@ -1096,7 +1096,7 @@ static void eff_fun_sleep( Character &u, effect &it ) if( mp == u.pos() ) { continue; } - if( here.has_flag( "FLAT", mp ) && + if( here.has_flag( TFLAG_FLAT, mp ) && here.pl_sees( mp, 2 ) ) { g->spawn_hallucination( mp ); if( ++count > max_count ) { diff --git a/src/start_location.cpp b/src/start_location.cpp index d431762268bfd..880a4d91a9a23 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -277,7 +277,7 @@ static int rate_location( map &m, const tripoint &p, const bool must_be_inside, checked[cur.x][cur.y] = attempt; if( cur.x == 0 || cur.x == MAPSIZE_X - 1 || cur.y == 0 || cur.y == MAPSIZE_Y - 1 || - m.has_flag( "GOES_UP", cur ) ) { + m.has_flag( TFLAG_GOES_UP, cur ) ) { return INT_MAX; } @@ -373,7 +373,7 @@ void start_location::burn( const tripoint_abs_omt &omtstart, const size_t count, m.has_flag_ter( "OPENCLOSE_INSIDE", p ) || m.is_outside( p ) || ( p.x >= u.x - rad && p.x <= u.x + rad && p.y >= u.y - rad && p.y <= u.y + rad ) ) ) { - if( m.has_flag( "FLAMMABLE", p ) || m.has_flag( "FLAMMABLE_ASH", p ) ) { + if( m.has_flag( TFLAG_FLAMMABLE, p ) || m.has_flag( TFLAG_FLAMMABLE_ASH, p ) ) { valid.push_back( p ); } } diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 1c176c97ca744..90f707e0ae268 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -823,7 +823,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, return ret; } // we just ran into a fish, so move it out of the way - if( here.has_flag( "SWIMMABLE", critter->pos() ) ) { + if( here.has_flag( TFLAG_SWIMMABLE, critter->pos() ) ) { tripoint end_pos = critter->pos(); tripoint start_pos; const units::angle angle = diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 517ab1c706e9e..b609ff1f33fd1 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -1453,7 +1453,7 @@ void vehicle::operate_scoop() } item *that_item_there = nullptr; map_stack items = here.i_at( position ); - if( here.has_flag( "SEALED", position ) ) { + if( here.has_flag( TFLAG_SEALED, position ) ) { // Ignore it. Street sweepers are not known for their ability to harvest crops. continue; } @@ -2035,7 +2035,7 @@ void vehicle::interact_with( const vpart_position &vp ) map &here = get_map(); avatar &player_character = get_avatar(); const bool has_items_on_ground = here.sees_some_items( vp.pos(), player_character ); - const bool items_are_sealed = here.has_flag( "SEALED", vp.pos() ); + const bool items_are_sealed = here.has_flag( TFLAG_SEALED, vp.pos() ); const turret_data turret = turret_query( vp.pos() ); const cata::optional vp_curtain = vp.avail_part_with_feature( "CURTAIN" ); const cata::optional vp_faucet = vp.part_with_tool( itype_water_faucet ); diff --git a/src/visitable.cpp b/src/visitable.cpp index b53ba441e66e3..e263335cea830 100644 --- a/src/visitable.cpp +++ b/src/visitable.cpp @@ -457,7 +457,7 @@ VisitResponse map_cursor::visit_items( { map &here = get_map(); // skip inaccessible items - if( here.has_flag( "SEALED", pos() ) && !here.has_flag( "LIQUIDCONT", pos() ) ) { + if( here.has_flag( TFLAG_SEALED, pos() ) && !here.has_flag( "LIQUIDCONT", pos() ) ) { return VisitResponse::NEXT; } diff --git a/src/weather.cpp b/src/weather.cpp index 018d96529b32e..d83dce90e729b 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -845,7 +845,7 @@ double get_local_windpower( double windpower, const oter_id &omter, const tripoi bool is_wind_blocker( const tripoint &location ) { - return get_map().has_flag( "BLOCK_WIND", location ); + return get_map().has_flag( TFLAG_BLOCK_WIND, location ); } // Description of Wind Speed - https://en.wikipedia.org/wiki/Beaufort_scale From ab2e056b33e42771d6812a2f37615350eb1f3396 Mon Sep 17 00:00:00 2001 From: Zhilkin Serg Date: Sun, 29 Aug 2021 10:13:01 +0300 Subject: [PATCH 2/2] Add set_flag function using ter_bitflags parameter --- src/mapdata.cpp | 35 +++++++++++++++++++++++++---------- src/mapdata.h | 3 +++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/mapdata.cpp b/src/mapdata.cpp index e14b274012e6a..49a0d7ecb4341 100644 --- a/src/mapdata.cpp +++ b/src/mapdata.cpp @@ -26,10 +26,6 @@ #include "trap.h" #include "type_id.h" -static const std::string flag_DIGGABLE( "DIGGABLE" ); -static const std::string flag_LOCKED( "LOCKED" ); -static const std::string flag_TRANSPARENT( "TRANSPARENT" ); - namespace { @@ -184,7 +180,8 @@ static const std::unordered_map ter_bitflags_map = { { "Z_TRANSPARENT", TFLAG_Z_TRANSPARENT }, // Doesn't block vision passing through the z-level { "SMALL_PASSAGE", TFLAG_SMALL_PASSAGE }, // A small passage, that large or huge things cannot pass through { "SUN_ROOF_ABOVE", TFLAG_SUN_ROOF_ABOVE }, // This furniture has a "fake roof" above, that blocks sunlight (see #44421). - { "FUNGUS", TFLAG_FUNGUS } // Fungal covered. + { "FUNGUS", TFLAG_FUNGUS }, // Fungal covered. + { "LOCKED", TFLAG_LOCKED } // Fungal covered. } }; @@ -368,7 +365,7 @@ furn_t null_furniture_t() new_furniture.movecost = 0; new_furniture.move_str_req = -1; new_furniture.transparent = true; - new_furniture.set_flag( flag_TRANSPARENT ); + new_furniture.set_flag( TFLAG_TRANSPARENT ); new_furniture.examine_func = iexamine_function_from_string( "none" ); new_furniture.max_volume = DEFAULT_MAX_VOLUME_IN_SQUARE; return new_furniture; @@ -389,8 +386,8 @@ ter_t null_terrain_t() new_terrain.light_emitted = 0; new_terrain.movecost = 0; new_terrain.transparent = true; - new_terrain.set_flag( flag_TRANSPARENT ); - new_terrain.set_flag( flag_DIGGABLE ); + new_terrain.set_flag( TFLAG_TRANSPARENT ); + new_terrain.set_flag( TFLAG_DIGGABLE ); new_terrain.examine_func = iexamine_function_from_string( "none" ); new_terrain.max_volume = DEFAULT_MAX_VOLUME_IN_SQUARE; return new_terrain; @@ -543,6 +540,24 @@ void map_data_common_t::set_flag( const std::string &flag ) } } +void map_data_common_t::set_flag( const ter_bitflags flag ) +{ + bitflags.set( flag ); + if( !transparent && flag == TFLAG_TRANSPARENT ) { + transparent = true; + } + // wall connection check for JSON backwards compatibility + if( flag == TFLAG_WALL || flag == TFLAG_CONNECT_TO_WALL ) { + set_connects( "WALL" ); + } + for( const auto &f : ter_bitflags_map ) { + if( f.second == flag ) { + flags.insert( f.first ); + break; + } + } +} + void map_data_common_t::set_connects( const std::string &connect_group_string ) { const auto it = ter_connects_map.find( connect_group_string ); @@ -1368,10 +1383,10 @@ void ter_t::check() const } // Check transition consistency for opening/closing terrain. Has an obvious // exception for locked terrains - those aren't expected to be locked again - if( open && open->close && open->close != id && !has_flag( flag_LOCKED ) ) { + if( open && open->close && open->close != id && !has_flag( TFLAG_LOCKED ) ) { debugmsg( "opening terrain %s for %s doesn't reciprocate", open.c_str(), id.c_str() ); } - if( close && close->open && close->open != id && !has_flag( flag_LOCKED ) ) { + if( close && close->open && close->open != id && !has_flag( TFLAG_LOCKED ) ) { debugmsg( "closing terrain %s for %s doesn't reciprocate", close.c_str(), id.c_str() ); } diff --git a/src/mapdata.h b/src/mapdata.h index 1eb981b280820..98e5fc52f25c7 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -235,6 +235,7 @@ enum ter_bitflags : int { TFLAG_Z_TRANSPARENT, TFLAG_SUN_ROOF_ABOVE, TFLAG_FUNGUS, + TFLAG_LOCKED, NUM_TERFLAGS }; @@ -426,6 +427,8 @@ struct map_data_common_t { void set_flag( const std::string &flag ); + void set_flag( const ter_bitflags flag ); + int connect_group = 0; void set_connects( const std::string &connect_group_string );