From 0a6bf67436fc51f980ddff6d62703dd71ad36cf6 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 19 Feb 2020 07:43:18 -0500 Subject: [PATCH] Move string_consts --- src/cata_string_consts.h | 1 + src/map.cpp | 187 +++++++++++++++++++-------------------- src/mapgen.cpp | 10 +-- src/martialarts.cpp | 2 +- 4 files changed, 97 insertions(+), 103 deletions(-) diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index cda318081a5ff..bcf1a8decad43 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -1139,6 +1139,7 @@ static const std::string flag_OVERSIZE( "OVERSIZE" ); static const std::string flag_PARTIAL_DEAF( "PARTIAL_DEAF" ); static const std::string flag_PERPETUAL( "PERPETUAL" ); static const std::string flag_PERSONAL( "PERSONAL" ); +static const std::string flag_PLACE_ITEM( "PLACE_ITEM" ); static const std::string flag_PLACE_RANDOMLY( "PLACE_RANDOMLY" ); static const std::string flag_PLANT( "PLANT" ); static const std::string flag_PLANTABLE( "PLANTABLE" ); diff --git a/src/map.cpp b/src/map.cpp index 8de1321335920..8b03f010f952e 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -83,13 +83,7 @@ #include "string_id.h" #include "construction.h" #include "flat_set.h" - -static const mtype_id mon_zombie( "mon_zombie" ); - -static const skill_id skill_traps( "traps" ); - -static const efftype_id effect_boomered( "boomered" ); -static const efftype_id effect_crushed( "crushed" ); +#include "cata_string_consts.h" #define dbg(x) DebugLog((x),D_MAP) << __FILE__ << ":" << __LINE__ << ": " @@ -628,7 +622,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( flag_SEALED, wheel_p ) ) { const float wheel_area = veh.parts[ w ].wheel_area(); // Damage is calculated based on the weight of the vehicle, @@ -1158,7 +1152,7 @@ bool map::displace_vehicle( vehicle &veh, const tripoint &dp ) bool map::displace_water( const tripoint &p ) { // Check for shallow water - if( has_flag( "SWIMMABLE", p ) && !has_flag( TFLAG_DEEP_WATER, p ) ) { + if( has_flag( flag_SWIMMABLE, p ) && !has_flag( TFLAG_DEEP_WATER, p ) ) { int dis_places = 0; int sel_place = 0; for( int pass = 0; pass < 2; pass++ ) { @@ -1268,7 +1262,7 @@ void map::furn_set( const tripoint &p, const furn_id &new_furniture ) c->remove_effect( effect_crushed ); } } - if( new_t.has_flag( "EMITTER" ) ) { + if( new_t.has_flag( flag_EMITTER ) ) { field_furn_locs.push_back( p ); } if( old_t.transparent != new_t.transparent ) { @@ -1321,7 +1315,7 @@ bool map::can_move_furniture( const tripoint &pos, player *p ) std::string map::furnname( const tripoint &p ) { const furn_t &f = furn( p ).obj(); - if( f.has_flag( "PLANT" ) ) { + if( f.has_flag( flag_PLANT ) ) { // Can't use item_stack::only_item() since there might be fertilizer map_stack items = i_at( p ); const map_stack::iterator seed = std::find_if( items.begin(), items.end(), []( const item & it ) { @@ -1564,14 +1558,14 @@ 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( "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( "EASY_DECONSTRUCT", p ), _( "Simple." ) ); - add_if( has_flag( "MOUNTABLE", p ), _( "Mountable." ) ); + add_if( has_flag( flag_DIGGABLE, p ), _( "Diggable." ) ); + add_if( has_flag( flag_PLOWABLE, p ), _( "Plowable." ) ); + add_if( has_flag( flag_ROUGH, p ), _( "Rough." ) ); + add_if( has_flag( flag_UNSTABLE, p ), _( "Unstable." ) ); + add_if( has_flag( flag_SHARP, p ), _( "Sharp." ) ); + add_if( has_flag( flag_FLAT, p ), _( "Flat." ) ); + add_if( has_flag( flag_EASY_DECONSTRUCT, p ), _( "Simple." ) ); + add_if( has_flag( flag_MOUNTABLE, p ), _( "Mountable." ) ); return result; } @@ -1808,7 +1802,7 @@ int map::climb_difficulty( const tripoint &p ) const int best_difficulty = INT_MAX; int blocks_movement = 0; - if( has_flag( "LADDER", p ) ) { + if( has_flag( flag_LADDER, p ) ) { // Really easy, but you have to stand on the tile return 1; } else if( has_flag( TFLAG_RAMP, p ) ) { @@ -1827,7 +1821,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( flag_CLIMBABLE, pt ) ) { best_difficulty = 5; } } @@ -1920,7 +1914,7 @@ void map::drop_furniture( const tripoint &p ) if( frn_id != f_null ) { const furn_t &frn = frn_id.obj(); // Allow crushing tiny/nocollide furniture - if( !frn.has_flag( "TINY" ) && !frn.has_flag( "NOCOLLIDE" ) ) { + if( !frn.has_flag( flag_TINY ) && !frn.has_flag( flag_NOCOLLIDE ) ) { return SS_BAD_SUPPORT; } } @@ -1967,13 +1961,13 @@ void map::drop_furniture( const tripoint &p ) // Approximate weight/"bulkiness" based on strength to drag int weight; - if( frn_obj.has_flag( "TINY" ) || frn_obj.has_flag( "NOCOLLIDE" ) ) { + if( frn_obj.has_flag( flag_TINY ) || frn_obj.has_flag( flag_NOCOLLIDE ) ) { weight = 5; } else { 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( flag_ROUGH ) || frn_obj.has_flag( flag_SHARP ) ) { weight += 5; } @@ -2128,7 +2122,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( flag_NOITEM, p ) && !has_flag( flag_SEALED, p ); } bool map::has_flag_ter( const std::string &flag, const tripoint &p ) const @@ -2374,12 +2368,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( flag_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( flag_SWIMMABLE, p ) && has_flag( TFLAG_DEEP_WATER, p ); } bool map::is_outside( const tripoint &p ) const @@ -2439,7 +2433,7 @@ bool map::is_last_ter_wall( const bool no_furn, const point &p, bool map::tinder_at( const tripoint &p ) { for( const auto &i : i_at( p ) ) { - if( i.has_flag( "TINDER" ) ) { + if( i.has_flag( flag_TINDER ) ) { return true; } } @@ -2469,11 +2463,11 @@ bool map::is_flammable( const tripoint &p ) return true; } - if( has_flag( "FLAMMABLE", p ) ) { + if( has_flag( flag_FLAMMABLE, p ) ) { return true; } - if( has_flag( "FLAMMABLE_ASH", p ) ) { + if( has_flag( flag_FLAMMABLE_ASH, p ) ) { return true; } @@ -2591,7 +2585,7 @@ bool map::has_nearby_table( const tripoint &p, int radius ) { for( const tripoint &pt : points_in_radius( p, radius ) ) { const optional_vpart_position vp = veh_at( p ); - if( has_flag( "FLAT_SURF", pt ) ) { + if( has_flag( flag_FLAT_SURF, pt ) ) { return true; } if( vp && ( vp->vehicle().has_part( "KITCHEN" ) || vp->vehicle().has_part( "FLAT_SURF" ) ) ) { @@ -2605,7 +2599,7 @@ bool map::has_nearby_chair( const tripoint &p, int radius ) { for( const tripoint &pt : points_in_radius( p, radius ) ) { const optional_vpart_position vp = veh_at( pt ); - if( has_flag( "CAN_SIT", pt ) ) { + if( has_flag( flag_CAN_SIT, pt ) ) { return true; } if( vp && vp->vehicle().has_part( "SEAT" ) ) { @@ -2619,7 +2613,7 @@ bool map::mop_spills( const tripoint &p ) { bool retval = false; - if( !has_flag( "LIQUIDCONT", p ) ) { + if( !has_flag( flag_LIQUIDCONT, p ) ) { auto items = i_at( p ); auto new_end = std::remove_if( items.begin(), items.end(), []( const item & it ) { return it.made_of( LIQUID ); @@ -2672,17 +2666,14 @@ 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 ); - 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", pbelow ) ) { + if( has_flag( flag_SUPPORTS_ROOF, pbelow ) ) { num_supports += 1; - if( has_flag( "WALL", pbelow ) ) { + if( has_flag( flag_WALL, pbelow ) ) { num_supports = 2; } if( tbelow == pbelow ) { @@ -2697,17 +2688,17 @@ int map::collapse_check( const tripoint &p ) continue; } - if( collapses ) { - if( has_flag( "COLLAPSES", t ) ) { + if( has_flag( flag_COLLAPSES, p ) ) { + if( has_flag( flag_COLLAPSES, t ) ) { num_supports++; - } else if( has_flag( "SUPPORTS_ROOF", t ) ) { + } else if( has_flag( flag_SUPPORTS_ROOF, t ) ) { num_supports += 2; } - } else if( supports_roof ) { - if( has_flag( "SUPPORTS_ROOF", t ) ) { - if( has_flag( "WALL", t ) ) { + } else if( has_flag( flag_SUPPORTS_ROOF, p ) ) { + if( has_flag( flag_SUPPORTS_ROOF, t ) ) { + if( has_flag( flag_WALL, t ) ) { num_supports += 4; - } else if( !has_flag( "COLLAPSES", t ) ) { + } else if( !has_flag( flag_COLLAPSES, t ) ) { num_supports += 3; } } @@ -2722,15 +2713,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( flag_SUPPORTS_ROOF, p ); + const bool wall = was_supporting || has_flag( flag_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( flag_SUPPORTS_ROOF, p ); // If something supporting the roof collapsed, see what else collapses if( supports && !still_supports ) { @@ -2743,12 +2734,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( flag_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( flag_SUPPORTS_ROOF, t ) && has_flag( flag_COLLAPSES, t ) ) ) { collapse_at( t, silent ); } // this tile used to support a roof, now it doesn't, which means there is only @@ -2928,7 +2919,7 @@ static bool furn_is_supported( const map &m, const tripoint &p ) const int adj_x = p.x + cx[i]; const int adj_y = p.y + cy[i]; if( m.has_furn( tripoint( adj_x, adj_y, p.z ) ) && - m.furn( tripoint( adj_x, adj_y, p.z ) ).obj().has_flag( "BLOCKSDOOR" ) ) { + m.furn( tripoint( adj_x, adj_y, p.z ) ).obj().has_flag( flag_BLOCKSDOOR ) ) { return true; } } @@ -2982,7 +2973,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) } // TODO: what if silent is true? - if( has_flag( "ALARMED", p ) && !g->timed_events.queued( TIMED_EVENT_WANTED ) ) { + if( has_flag( flag_ALARMED, p ) && !g->timed_events.queued( TIMED_EVENT_WANTED ) ) { sounds::sound( p, 40, sounds::sound_t::alarm, _( "an alarm go off!" ), false, "environment", "alarm" ); // Blame nearby player @@ -3027,7 +3018,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( flag_SUPPORTS_ROOF, below ) ) { if( bash->str_min_supported != -1 ) { smin = bash->str_min_supported; } @@ -3089,7 +3080,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) soundfxid = "smash_success"; 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( flag_SUPPORTS_ROOF, p ) && + !has_flag( flag_INDOORS, p ); const bool tent = smash_furn && !bash->tent_centers.empty(); // Special code to collapse the tent if destroyed @@ -3169,7 +3161,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( flag_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; @@ -3198,7 +3190,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( flag_SUPPORTS_ROOF, p ) ) { collapse_at( p, params.silent, true, bash->explosive > 0 ); } @@ -3223,7 +3215,7 @@ bash_params map::bash( const tripoint &p, const int str, } bool bashed_sealed = false; - if( has_flag( "SEALED", p ) ) { + if( has_flag( flag_SEALED, p ) ) { bash_ter_furn( p, bsh ); bashed_sealed = true; } @@ -3397,7 +3389,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) float dam = initial_damage; const auto &ammo_effects = proj.proj_effects; - if( has_flag( "ALARMED", p ) && !g->timed_events.queued( TIMED_EVENT_WANTED ) ) { + if( has_flag( flag_ALARMED, p ) && !g->timed_events.queued( TIMED_EVENT_WANTED ) ) { sounds::sound( p, 30, sounds::sound_t::alarm, _( "an alarm sound!" ), true, "environment", "alarm" ); const tripoint abs = ms_to_sm_copy( getabs( p ) ); @@ -3682,7 +3674,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( flag_FLAMMABLE, p ) || has_flag( flag_FLAMMABLE_ASH, p ) ) { add_field( p, fd_fire, 3 ); } return true; @@ -3693,7 +3685,7 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only const auto &ter = this->ter( p ).obj(); const auto &furn = this->furn( p ).obj(); if( ter.open ) { - if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) { + if( has_flag( flag_OPENCLOSE_INSIDE, p ) && !inside ) { return false; } @@ -3702,8 +3694,8 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only "open_door", ter.id.str() ); ter_set( p, ter.open ); - if( ( g->u.has_trait( trait_id( "SCHIZOPHRENIC" ) ) || g->u.has_artifact_with( AEP_SCHIZO ) ) - && one_in( 50 ) && !ter.has_flag( "TRANSPARENT" ) ) { + if( ( g->u.has_trait( trait_SCHIZOPHRENIC ) || g->u.has_artifact_with( AEP_SCHIZO ) ) + && one_in( 50 ) && !ter.has_flag( flag_TRANSPARENT ) ) { tripoint mp = p + -2 * g->u.pos().xy() + tripoint( 2 * p.x, 2 * p.y, p.z ); g->spawn_hallucination( mp ); } @@ -3711,7 +3703,7 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only return true; } else if( furn.open ) { - if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) { + if( has_flag( flag_OPENCLOSE_INSIDE, p ) && !inside ) { return false; } @@ -3784,7 +3776,7 @@ void map::translate_radius( const ter_id &from, const ter_id &to, float radi, co bool map::close_door( const tripoint &p, const bool inside, const bool check_only ) { - if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) { + if( has_flag( flag_OPENCLOSE_INSIDE, p ) && !inside ) { return false; } @@ -3961,8 +3953,8 @@ item &map::spawn_an_item( const tripoint &p, item new_item, new_item.charges = charges; } new_item = new_item.in_its_container(); - if( ( new_item.made_of( LIQUID ) && has_flag( "SWIMMABLE", p ) ) || - has_flag( "DESTROY_ITEM", p ) ) { + if( ( new_item.made_of( LIQUID ) && has_flag( flag_SWIMMABLE, p ) ) || + has_flag( flag_DESTROY_ITEM, p ) ) { return null_item_reference(); } @@ -3974,10 +3966,10 @@ item &map::spawn_an_item( const tripoint &p, item new_item, 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( flag_DESTROY_ITEM, p ) ) { return ret; } - const bool swimmable = has_flag( "SWIMMABLE", p ); + const bool swimmable = has_flag( flag_SWIMMABLE, p ); for( const item &new_item : new_items ) { if( new_item.made_of( LIQUID ) && swimmable ) { @@ -4019,7 +4011,7 @@ void map::spawn_item( const tripoint &p, const std::string &type_id, } // spawn the item item new_item( type_id, birthday ); - if( one_in( 3 ) && new_item.has_flag( "VARSIZE" ) ) { + if( one_in( 3 ) && new_item.has_flag( flag_VARSIZE ) ) { new_item.item_tags.insert( "FIT" ); } @@ -4053,12 +4045,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( flag_DESTROY_ITEM, e ) ) { return false; } // Cannot drop liquids into tiles that are comprised of liquid - if( obj.made_of_from_type( LIQUID ) && has_flag( "SWIMMABLE", e ) ) { + if( obj.made_of_from_type( LIQUID ) && has_flag( flag_SWIMMABLE, e ) ) { return false; } @@ -4086,7 +4078,7 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) }; // Some items never exist on map as a discrete item (must be contained by another item) - if( obj.has_flag( "NO_DROP" ) ) { + if( obj.has_flag( flag_NO_DROP ) ) { return null_item_reference(); } @@ -4095,10 +4087,11 @@ 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( LIQUID ) ) ) + if( ( !has_flag( flag_NOITEM, pos ) || ( has_flag( flag_LIQUIDCONT, pos ) && + obj.made_of( 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( LIQUID ) || !obj.has_flag( "DROP_ACTION_ONLY_IF_LIQUID" ) ) { + if( obj.made_of( LIQUID ) || !obj.has_flag( flag_DROP_ACTION_ONLY_IF_LIQUID ) ) { if( obj.on_drop( pos, *this ) ) { return null_item_reference(); } @@ -4123,14 +4116,14 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) if( route( pos, e, setting ).empty() ) { continue; } - if( obj.made_of( LIQUID ) || !obj.has_flag( "DROP_ACTION_ONLY_IF_LIQUID" ) ) { + if( obj.made_of( LIQUID ) || !obj.has_flag( flag_DROP_ACTION_ONLY_IF_LIQUID ) ) { if( obj.on_drop( e, *this ) ) { return null_item_reference(); } } if( !valid_tile( e ) || !valid_limits( e ) || - has_flag( "NOITEM", e ) || has_flag( "SEALED", e ) ) { + has_flag( flag_NOITEM, e ) || has_flag( flag_SEALED, e ) ) { continue; } return place_item( e ); @@ -4155,16 +4148,16 @@ item &map::add_item( const tripoint &p, item new_item ) new_item.process( nullptr, p, false ); } - if( new_item.made_of( LIQUID ) && has_flag( "SWIMMABLE", p ) ) { + if( new_item.made_of( LIQUID ) && has_flag( flag_SWIMMABLE, p ) ) { return null_item_reference(); } - if( has_flag( "DESTROY_ITEM", p ) ) { + if( has_flag( flag_DESTROY_ITEM, p ) ) { return null_item_reference(); } - if( new_item.has_flag( "ACT_IN_FIRE" ) && get_field( p, fd_fire ) != nullptr ) { - if( new_item.has_flag( "BOMB" ) && new_item.is_transformable() ) { + if( new_item.has_flag( flag_ACT_IN_FIRE ) && get_field( p, fd_fire ) != nullptr ) { + if( new_item.has_flag( flag_BOMB ) && new_item.is_transformable() ) { //Convert a bomb item into its transformable version, e.g. incendiary grenade -> active incendiary grenade new_item.convert( dynamic_cast ( new_item.type->get_use( "transform" )->get_actor_ptr() )->target ); @@ -4192,7 +4185,7 @@ item &map::add_item( const tripoint &p, item new_item ) item map::water_from( const tripoint &p ) { - if( has_flag( "SALT_WATER", p ) ) { + if( has_flag( flag_SALT_WATER, p ) ) { return item( "salt_water", 0, item::INFINITE_CHARGES ); } @@ -4333,7 +4326,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part ) const time_duration time_left = cycle_time - n.age(); static const std::string no_sterile( "NO_STERILE" ); if( time_left <= 0_turns ) { - if( !n.has_flag( "NO_PACKED" ) ) { + if( !n.has_flag( flag_NO_PACKED ) ) { n.item_tags.erase( no_sterile ); } autoclave_finished = true; @@ -4352,7 +4345,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part ) if( cur_veh.part_with_feature( part, VPFLAG_RECHARGE, true ) >= 0 && cur_veh.has_part( "RECHARGE", true ) ) { for( auto &n : cur_veh.get_items( part ) ) { - if( !n.has_flag( "RECHARGE" ) && !n.has_flag( "USE_UPS" ) ) { + if( !n.has_flag( flag_RECHARGE ) && !n.has_flag( flag_USE_UPS ) ) { continue; } // TODO: BATTERIES this should be rewritten when vehicle power and items both use energy quantities @@ -4366,7 +4359,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part ) if( n.is_battery() ) { n.set_energy( 1_kJ ); } else { - n.ammo_set( "battery", n.ammo_remaining() + 1 ); + n.ammo_set( fuel_type_battery, n.ammo_remaining() + 1 ); } } @@ -4681,7 +4674,7 @@ std::list use_charges_from_stack( Stack stack, const itype_id &type, int & static void use_charges_from_furn( const furn_t &f, const itype_id &type, int &quantity, map *m, const tripoint &p, std::list &ret, const std::function &filter ) { - if( m->has_flag( "LIQUIDCONT", p ) ) { + if( m->has_flag( flag_LIQUIDCONT, p ) ) { auto item_list = m->i_at( p ); auto current_item = item_list.begin(); for( ; current_item != item_list.end(); ++current_item ) { @@ -4944,7 +4937,7 @@ std::list > map::get_rc_items( const tripoint &p ) } auto items = i_at( pos ); for( auto &elem : items ) { - if( elem.has_flag( "RADIO_ACTIVATION" ) || elem.has_flag( "RADIO_CONTAINER" ) ) { + if( elem.has_flag( flag_RADIO_ACTIVATION ) || elem.has_flag( flag_RADIO_CONTAINER ) ) { rc_pairs.push_back( std::make_pair( pos, &elem ) ); } } @@ -6251,7 +6244,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( flag_SEALED, t ) || has_flag( flag_LIQUIDCONT, t ); } std::vector map::get_dir_circle( const tripoint &f, const tripoint &t ) const @@ -6771,7 +6764,7 @@ void map::fill_funnels( const tripoint &p, const time_point &since ) void map::grow_plant( const tripoint &p ) { const auto &furn = this->furn( p ).obj(); - if( !furn.has_flag( "PLANT" ) ) { + if( !furn.has_flag( flag_PLANT ) ) { return; } // Can't use item_stack::only_item() since there might be fertilizer @@ -6789,15 +6782,15 @@ void map::grow_plant( const tripoint &p ) } const time_duration plantEpoch = seed->get_plant_epoch(); if( seed->age() >= plantEpoch * furn.plant->growth_multiplier && - !furn.has_flag( "GROWTH_HARVEST" ) ) { + !furn.has_flag( flag_GROWTH_HARVEST ) ) { if( seed->age() < plantEpoch * 2 ) { - if( has_flag_furn( "GROWTH_SEEDLING", p ) ) { + if( has_flag_furn( flag_GROWTH_SEEDLING, p ) ) { return; } // Remove fertilizer if any map_stack::iterator fertilizer = std::find_if( items.begin(), items.end(), []( const item & it ) { - return it.has_flag( "FERTILIZER" ); + return it.has_flag( flag_FERTILIZER ); } ); if( fertilizer != items.end() ) { items.erase( fertilizer ); @@ -6812,7 +6805,7 @@ void map::grow_plant( const tripoint &p ) // Remove fertilizer if any map_stack::iterator fertilizer = std::find_if( items.begin(), items.end(), []( const item & it ) { - return it.has_flag( "FERTILIZER" ); + return it.has_flag( flag_FERTILIZER ); } ); if( fertilizer != items.end() ) { items.erase( fertilizer ); @@ -6971,7 +6964,7 @@ void map::rad_scorch( const tripoint &p, const time_duration &time_since_last_ac // First destroy the farmable plants (those are furniture) // TODO: Rad-resistant mutant plants (that produce radioactive fruit) const furn_t &fid = furn( p ).obj(); - if( fid.has_flag( "PLANT" ) ) { + if( fid.has_flag( flag_PLANT ) ) { i_clear( p ); furn_set( p, f_null ); } @@ -6995,9 +6988,9 @@ void map::rad_scorch( const tripoint &p, const time_duration &time_since_last_ac } const ter_t &tr = tid.obj(); - if( tr.has_flag( "SHRUB" ) ) { + if( tr.has_flag( flag_SHRUB ) ) { ter_set( p, t_dirt ); - } else if( tr.has_flag( "TREE" ) ) { + } else if( tr.has_flag( flag_TREE ) ) { ter_set( p, ter_str_id( "t_tree_dead" ) ); } } @@ -7038,11 +7031,11 @@ void map::actualize( const tripoint &grid ) const tripoint pnt = sm_to_ms_copy( grid ) + point( x, y ); const point p( x, y ); const auto &furn = this->furn( pnt ).obj(); - if( furn.has_flag( "EMITTER" ) ) { + if( furn.has_flag( flag_EMITTER ) ) { field_furn_locs.push_back( pnt ); } // plants contain a seed item which must not be removed under any circumstances - if( !furn.has_flag( "DONT_REMOVE_ROTTEN" ) ) { + if( !furn.has_flag( flag_DONT_REMOVE_ROTTEN ) ) { remove_rotten_items( tmpsub->get_items( { x, y } ), pnt ); } diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 4e7e55f9f358e..1e550f80fcc0b 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1504,7 +1504,7 @@ class jmapgen_sealed_item : public jmapgen_piece return; } - if( furn.has_flag( "PLANT" ) ) { + if( furn.has_flag( flag_PLANT ) ) { // plant furniture requires exactly one seed item within it if( item_spawner && item_group_spawner ) { debugmsg( "%s (with flag PLANT) specifies both an item and an item group. " @@ -2350,7 +2350,7 @@ void mapgen_function_json_base::check_common( const std::string &oter_name ) con { auto check_furn = [&]( const furn_id & id ) { const furn_t &furn = id.obj(); - if( furn.has_flag( "PLANT" ) ) { + if( furn.has_flag( flag_PLANT ) ) { debugmsg( "json mapgen for overmap terrain %s specifies furniture %s, which has flag " "PLANT. Such furniture must be specified in a \"sealed_item\" special.", oter_name, furn.id.str() ); @@ -4013,7 +4013,7 @@ 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( flag_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 ); @@ -5887,9 +5887,9 @@ std::vector map::place_items( const items_location &loc, const int chanc auto is_valid_terrain = [this, ongrass]( int x, int y ) { auto &terrain = ter( point( x, y ) ).obj(); return terrain.movecost == 0 && - !terrain.has_flag( "PLACE_ITEM" ) && + !terrain.has_flag( flag_PLACE_ITEM ) && !ongrass && - !terrain.has_flag( "FLAT" ); + !terrain.has_flag( flag_FLAT ); }; int px = 0; diff --git a/src/martialarts.cpp b/src/martialarts.cpp index a5ae9dc53d148..8f95899f2972e 100644 --- a/src/martialarts.cpp +++ b/src/martialarts.cpp @@ -834,7 +834,7 @@ bool martialart::weapon_valid( const item &it ) const return true; } - if( !strictly_unarmed && !strictly_melee && !it.is_null() && it.has_flag( "UNARMED_WEAPON" ) ) { + if( !strictly_unarmed && !strictly_melee && !it.is_null() && it.has_flag( flag_UNARMED_WEAPON ) ) { return true; }