diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 6c48c7277dd0f..e854936d76d86 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -923,6 +923,7 @@ static const mtype_id mon_zombie_waif( "mon_zombie_waif" ); static const std::string flag_ACID( "ACID" ); static const std::string flag_ACT_IN_FIRE( "ACT_IN_FIRE" ); +static const std::string flag_ACT_ON_RANGED_HIT( "ACT_ON_RANGED_HIT" ); static const std::string flag_ACTIVE_CLOAKING( "ACTIVE_CLOAKING" ); static const std::string flag_ALARMED( "ALARMED" ); static const std::string flag_ALLERGEN_EGG( "ALLERGEN_EGG" ); @@ -932,12 +933,14 @@ static const std::string flag_ALLERGEN_MEAT( "ALLERGEN_MEAT" ); static const std::string flag_ALLERGEN_MILK( "ALLERGEN_MILK" ); static const std::string flag_ALLERGEN_VEGGY( "ALLERGEN_VEGGY" ); static const std::string flag_ALLERGEN_WHEAT( "ALLERGEN_WHEAT" ); +static const std::string flag_ALLOW_ROTTEN( "ALLOW_ROTTEN" ); static const std::string flag_ALLOWS_NATURAL_ATTACKS( "ALLOWS_NATURAL_ATTACKS" ); static const std::string flag_ALLOWS_REMOTE_USE( "ALLOWS_REMOTE_USE" ); static const std::string flag_ALWAYS_TWOHAND( "ALWAYS_TWOHAND" ); static const std::string flag_ANESTHESIA( "ANESTHESIA" ); static const std::string flag_AURA( "AURA" ); static const std::string flag_AUT_START( "AUT_START" ); +static const std::string flag_auto_wield( "auto_wield" ); static const std::string flag_AUTODOC( "AUTODOC" ); static const std::string flag_AUTODOC_COUCH( "AUTODOC_COUCH" ); static const std::string flag_BAD_DAY( "BAD_DAY" ); @@ -955,6 +958,7 @@ static const std::string flag_BLIND_HARD( "BLIND_HARD" ); static const std::string flag_BLOCK_WHILE_WORN( "BLOCK_WHILE_WORN" ); static const std::string flag_BLOCKSDOOR( "BLOCKSDOOR" ); static const std::string flag_BOMB( "BOMB" ); +static const std::string flag_BURROWABLE( "BURROWABLE" ); static const std::string flag_BUTCHER_EQ( "BUTCHER_EQ" ); static const std::string flag_BYPRODUCT( "BYPRODUCT" ); static const std::string flag_CABLE_SPOOL( "CABLE_SPOOL" ); @@ -964,6 +968,7 @@ static const std::string flag_CAMERA_PRO( "CAMERA_PRO" ); static const std::string flag_CAN_SIT( "CAN_SIT" ); static const std::string flag_CANNIBAL( "CANNIBAL" ); static const std::string flag_CANNIBALISM( "CANNIBALISM" ); +static const std::string flag_CANT_HEAL_EVERYONE( "CANT_HEAL_EVERYONE" ); static const std::string flag_CARNIVORE_OK( "CARNIVORE_OK" ); static const std::string flag_CASING( "CASING" ); static const std::string flag_CATTLE( "CATTLE" ); @@ -994,6 +999,7 @@ static const std::string flag_DIGGABLE_CAN_DEEPEN( "DIGGABLE_CAN_DEEPEN" ); static const std::string flag_DIMENSIONAL_ANCHOR( "DIMENSIONAL_ANCHOR" ); static const std::string flag_DISABLE_SIGHTS( "DISABLE_SIGHTS" ); static const std::string flag_DONT_REMOVE_ROTTEN( "DONT_REMOVE_ROTTEN" ); +static const std::string flag_DOOR( "DOOR" ); static const std::string flag_DROP_ACTION_ONLY_IF_LIQUID( "DROP_ACTION_ONLY_IF_LIQUID" ); static const std::string flag_DURABLE_MELEE( "DURABLE_MELEE" ); static const std::string flag_EASY_DECONSTRUCT( "EASY_DECONSTRUCT" ); @@ -1068,6 +1074,8 @@ static const std::string flag_INDOORS( "INDOORS" ); static const std::string flag_INEDIBLE( "INEDIBLE" ); static const std::string flag_INFECTED( "INFECTED" ); static const std::string flag_INITIAL_PART( "INITIAL_PART" ); +static const std::string flag_INSPIRATIONAL( "INSPIRATIONAL" ); +static const std::string flag_INSTALL_DIFFICULT( "INSTALL_DIFFICULT" ); static const std::string flag_IR_EFFECT( "IR_EFFECT" ); static const std::string flag_IRREMOVABLE( "IRREMOVABLE" ); static const std::string flag_IS_ARMOR( "IS_ARMOR" ); @@ -1084,6 +1092,7 @@ static const std::string flag_LOCKED( "LOCKED" ); static const std::string flag_LONE_START( "LONE_START" ); static const std::string flag_LUPINE( "LUPINE" ); static const std::string flag_MAG_BELT( "MAG_BELT" ); +static const std::string flag_MAG_BULKY( "MAG_BULKY" ); static const std::string flag_MAG_DESTROY( "MAG_DESTROY" ); static const std::string flag_MAG_EJECT( "MAG_EJECT" ); static const std::string flag_MAGIC_FOCUS( "MAGIC_FOCUS" ); @@ -1095,6 +1104,7 @@ static const std::string flag_MC_RANDOM_STUFF( "MC_RANDOM_STUFF" ); static const std::string flag_MC_SCIENCE_STUFF( "MC_SCIENCE_STUFF" ); static const std::string flag_MC_TURN_USED( "MC_TURN_USED" ); static const std::string flag_MC_USED( "MC_USED" ); +static const std::string flag_MECH_BAT( "MECH_BAT" ); static const std::string flag_MELTS( "MELTS" ); static const std::string flag_MESSY( "MESSY" ); static const std::string flag_MILLABLE( "MILLABLE" ); @@ -1109,9 +1119,11 @@ static const std::string flag_NEEDS_NO_LUBE( "NEEDS_NO_LUBE" ); static const std::string flag_NEEDS_UNFOLD( "NEEDS_UNFOLD" ); static const std::string flag_NEGATIVE_MONOTONY_OK( "NEGATIVE_MONOTONY_OK" ); static const std::string flag_NEVER_JAMS( "NEVER_JAMS" ); +static const std::string flag_no_auto_equip( "no_auto_equip" ); static const std::string flag_NO_CVD( "NO_CVD" ); static const std::string flag_NO_DISPLAY( "NO_DISPLAY" ); static const std::string flag_NO_DROP( "NO_DROP" ); +static const std::string flag_NO_INGEST( "NO_INGEST" ); static const std::string flag_NO_PACKED( "NO_PACKED" ); static const std::string flag_NO_PARASITES( "NO_PARASITES" ); static const std::string flag_NO_QUICKDRAW( "NO_QUICKDRAW" ); @@ -1120,12 +1132,14 @@ static const std::string flag_NO_REPAIR( "NO_REPAIR" ); static const std::string flag_NO_RESIZE( "NO_RESIZE" ); static const std::string flag_NO_SALVAGE( "NO_SALVAGE" ); static const std::string flag_NO_STERILE( "NO_STERILE" ); +static const std::string flag_NO_TAKEOFF( "NO_TAKEOFF" ); static const std::string flag_NO_UNLOAD( "NO_UNLOAD" ); static const std::string flag_NO_UNWIELD( "NO_UNWIELD" ); static const std::string flag_NOCOLLIDE( "NOCOLLIDE" ); static const std::string flag_NOITEM( "NOITEM" ); static const std::string flag_NON_FOULING( "NON-FOULING" ); static const std::string flag_NONCONDUCTIVE( "NONCONDUCTIVE" ); +static const std::string flag_NPC_ACTIVATE( "NPC_ACTIVATE" ); static const std::string flag_NPC_SAFE( "NPC_SAFE" ); static const std::string flag_NUTRIENT_OVERRIDE( "NUTRIENT_OVERRIDE" ); static const std::string flag_ONLY_ONE( "ONLY_ONE" ); @@ -1181,6 +1195,7 @@ static const std::string flag_RELOAD_ONE( "RELOAD_ONE" ); static const std::string flag_REQUIRES_TINDER( "REQUIRES_TINDER" ); static const std::string flag_RESTRICT_HANDS( "RESTRICT_HANDS" ); static const std::string flag_REVIVE_SPECIAL( "REVIVE_SPECIAL" ); +static const std::string flag_ROAD( "ROAD" ); static const std::string flag_ROLLER_INLINE( "ROLLER_INLINE" ); static const std::string flag_ROLLER_ONE( "ROLLER_ONE" ); static const std::string flag_ROLLER_QUAD( "ROLLER_QUAD" ); @@ -1208,6 +1223,7 @@ static const std::string flag_SPEEDLOADER( "SPEEDLOADER" ); static const std::string flag_SPLINT( "SPLINT" ); static const std::string flag_SPR_START( "SPR_START" ); static const std::string flag_STR_DRAW( "STR_DRAW" ); +static const std::string flag_STR_RELOAD( "STR_RELOAD" ); static const std::string flag_STURDY( "STURDY" ); static const std::string flag_SUM_ADV_START( "SUM_ADV_START" ); static const std::string flag_SUM_START( "SUM_START" ); @@ -1217,11 +1233,15 @@ static const std::string flag_SUPPORTS_ROOF( "SUPPORTS_ROOF" ); static const std::string flag_SUR_START( "SUR_START" ); static const std::string flag_SWIM_GOGGLES( "SWIM_GOGGLES" ); static const std::string flag_SWIMMABLE( "SWIMMABLE" ); +static const std::string flag_TACK( "TACK" ); +static const std::string flag_TANGLE( "TANGLE" ); static const std::string flag_THERMOMETER( "THERMOMETER" ); static const std::string flag_THIN_OBSTACLE( "THIN_OBSTACLE" ); +static const std::string flag_TIE_UP( "TIE_UP" ); static const std::string flag_TINDER( "TINDER" ); static const std::string flag_TINY( "TINY" ); static const std::string flag_TOBACCO( "TOBACCO" ); +static const std::string flag_TRADER_AVOID( "TRADER_AVOID" ); static const std::string flag_TRANSPARENT( "TRANSPARENT" ); static const std::string flag_TREE( "TREE" ); static const std::string flag_UNARMED_BONUS( "UNARMED_BONUS" ); @@ -1231,6 +1251,7 @@ static const std::string flag_UNCRAFT_LIQUIDS_CONTAINED( "UNCRAFT_LIQUIDS_CONTAI static const std::string flag_UNCRAFT_SINGLE_CHARGE( "UNCRAFT_SINGLE_CHARGE " ); static const std::string flag_UNDERSIZE( "UNDERSIZE" ); static const std::string flag_UNDERWATER_GUN( "UNDERWATER_GUN" ); +static const std::string flag_UNRECOVERABLE( "UNRECOVERABLE" ); static const std::string flag_UNSTABLE( "UNSTABLE" ); static const std::string flag_URSINE_HONEY( "URSINE_HONEY" ); static const std::string flag_USABLE_FIRE( "USABLE_FIRE" ); @@ -1313,9 +1334,11 @@ static const zone_type_id zone_type_LOOT_CORPSE( "LOOT_CORPSE" ); static const zone_type_id zone_type_LOOT_IGNORE( "LOOT_IGNORE" ); static const zone_type_id zone_type_LOOT_UNSORTED( "LOOT_UNSORTED" ); static const zone_type_id zone_type_LOOT_WOOD( "LOOT_WOOD" ); +static const zone_type_id zone_type_NO_AUTO_PICKUP( "NO_AUTO_PICKUP" ); static const zone_type_id zone_type_VEHICLE_DECONSTRUCT( "VEHICLE_DECONSTRUCT" ); static const zone_type_id zone_type_VEHICLE_REPAIR( "VEHICLE_REPAIR" ); + static const zone_type_id z_camp_food( "CAMP_FOOD" ); static const zone_type_id z_camp_storage( "CAMP_STORAGE" ); static const zone_type_id z_loot_unsorted( "LOOT_UNSORTED" ); diff --git a/src/monexamine.cpp b/src/monexamine.cpp index 9b358da1ddb7b..d73069489b1e3 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -101,7 +101,7 @@ bool monexamine::pet_menu( monster &z ) amenu.addentry( rope, true, 't', _( "Untie" ) ); } else if( !z.has_flag( MF_RIDEABLE_MECH ) ) { std::vector rope_inv = g->u.items_with( []( const item & itm ) { - return itm.has_flag( "TIE_UP" ); + return itm.has_flag( flag_TIE_UP ); } ); if( !rope_inv.empty() ) { amenu.addentry( rope, true, 't', _( "Tie" ) ); @@ -254,7 +254,7 @@ static item_location pet_armor_loc( monster &z ) static item_location tack_loc() { auto filter = []( const item & it ) { - return it.has_flag( "TACK" ); + return it.has_flag( flag_TACK ); }; return game_menus::inv::titled_filter_menu( filter, g->u, _( "Tack" ) ); @@ -273,7 +273,7 @@ void monexamine::insert_battery( monster &z ) return; } std::vector bat_inv = g->u.items_with( []( const item & itm ) { - return itm.has_flag( "MECH_BAT" ); + return itm.has_flag( flag_MECH_BAT ); } ); if( bat_inv.empty() ) { return; @@ -637,7 +637,7 @@ void monexamine::tie_or_untie( monster &z ) } } else { std::vector rope_inv = g->u.items_with( []( const item & itm ) { - return itm.has_flag( "TIE_UP" ); + return itm.has_flag( flag_TIE_UP ); } ); if( rope_inv.empty() ) { return; diff --git a/src/monmove.cpp b/src/monmove.cpp index a91efe9bdebe5..03d71e84653ad 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -89,10 +89,10 @@ bool monster::will_move_to( const tripoint &p ) const { if( g->m.impassable( p ) ) { if( digging() ) { - if( !g->m.has_flag( "BURROWABLE", p ) ) { + if( !g->m.has_flag( flag_BURROWABLE, p ) ) { return false; } - } else if( !( can_climb() && g->m.has_flag( "CLIMBABLE", p ) ) ) { + } else if( !( can_climb() && g->m.has_flag( flag_CLIMBABLE, p ) ) ) { return false; } } @@ -101,11 +101,11 @@ bool monster::will_move_to( const tripoint &p ) const return false; } - if( digs() && !g->m.has_flag( "DIGGABLE", p ) && !g->m.has_flag( "BURROWABLE", p ) ) { + if( digs() && !g->m.has_flag( flag_DIGGABLE, p ) && !g->m.has_flag( flag_BURROWABLE, p ) ) { return false; } - if( has_flag( MF_AQUATIC ) && !g->m.has_flag( "SWIMMABLE", p ) ) { + if( has_flag( MF_AQUATIC ) && !g->m.has_flag( flag_SWIMMABLE, p ) ) { return false; } @@ -163,7 +163,7 @@ bool monster::will_move_to( const tripoint &p ) const // Some things are only avoided if we're not attacking if( attitude( &g->u ) != MATT_ATTACK ) { // Sharp terrain is ignored while attacking - if( avoid_simple && g->m.has_flag( "SHARP", p ) && + if( avoid_simple && g->m.has_flag( flag_SHARP, p ) && !( type->size == MS_TINY || flies() ) ) { return false; } @@ -548,7 +548,7 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina bool monster::die_if_drowning( const tripoint &at_pos, const int chance ) { - if( g->m.has_flag( "LIQUID", at_pos ) && can_drown() && one_in( chance ) ) { + if( g->m.has_flag( flag_LIQUID, at_pos ) && can_drown() && one_in( chance ) ) { // if there's a vehicle here with a boardable part, the monster is on it // and not drowning if( g->m.veh_at( at_pos ).part_with_feature( "BOARDABLE", false ) ) { @@ -1132,40 +1132,40 @@ int monster::calc_movecost( const tripoint &f, const tripoint &t ) const const int source_cost = g->m.move_cost( f ); const int dest_cost = g->m.move_cost( t ); // Digging and flying monsters ignore terrain cost - if( flies() || ( digging() && g->m.has_flag( "DIGGABLE", t ) ) ) { + if( flies() || ( digging() && g->m.has_flag( flag_DIGGABLE, t ) ) ) { movecost = 100; // Swimming monsters move super fast in water } else if( swims() ) { - if( g->m.has_flag( "SWIMMABLE", f ) ) { + if( g->m.has_flag( flag_SWIMMABLE, f ) ) { movecost += 25; } else { movecost += 50 * g->m.move_cost( f ); } - if( g->m.has_flag( "SWIMMABLE", t ) ) { + if( g->m.has_flag( flag_SWIMMABLE, t ) ) { movecost += 25; } else { movecost += 50 * g->m.move_cost( t ); } } else if( can_submerge() ) { // No-breathe monsters have to walk underwater slowly - if( g->m.has_flag( "SWIMMABLE", f ) ) { + if( g->m.has_flag( flag_SWIMMABLE, f ) ) { movecost += 250; } else { movecost += 50 * g->m.move_cost( f ); } - if( g->m.has_flag( "SWIMMABLE", t ) ) { + if( g->m.has_flag( flag_SWIMMABLE, t ) ) { movecost += 250; } else { movecost += 50 * g->m.move_cost( t ); } movecost /= 2; } else if( climbs() ) { - if( g->m.has_flag( "CLIMBABLE", f ) ) { + if( g->m.has_flag( flag_CLIMBABLE, f ) ) { movecost += 150; } else { movecost += 50 * g->m.move_cost( f ); } - if( g->m.has_flag( "CLIMBABLE", t ) ) { + if( g->m.has_flag( flag_CLIMBABLE, t ) ) { movecost += 150; } else { movecost += 50 * g->m.move_cost( t ); @@ -1252,7 +1252,7 @@ bool monster::bash_at( const tripoint &p ) return false; } - bool flat_ground = g->m.has_flag( "ROAD", p ) || g->m.has_flag( "FLAT", p ); + bool flat_ground = g->m.has_flag( flag_ROAD, p ) || g->m.has_flag( flag_FLAT, p ); if( flat_ground ) { bool can_bash_ter = g->m.is_bashable_ter( p ); bool try_bash_ter = one_in( 50 ); @@ -1412,7 +1412,7 @@ bool monster::move_to( const tripoint &p, bool force, const float stagger_adjust // Allows climbing monsters to move on terrain with movecost <= 0 Creature *critter = g->critter_at( destination, is_hallucination() ); - if( g->m.has_flag( "CLIMBABLE", destination ) ) { + if( g->m.has_flag( flag_CLIMBABLE, destination ) ) { if( g->m.impassable( destination ) && critter == nullptr ) { if( flies() ) { moves -= 100; @@ -1495,15 +1495,17 @@ bool monster::move_to( const tripoint &p, bool force, const float stagger_adjust if( type->size != MS_TINY && on_ground ) { const int sharp_damage = rng( 1, 10 ); const int rough_damage = rng( 1, 2 ); - if( g->m.has_flag( "SHARP", pos() ) && !one_in( 4 ) && get_armor_cut( bp_torso ) < sharp_damage ) { + if( g->m.has_flag( flag_SHARP, pos() ) && !one_in( 4 ) && + get_armor_cut( bp_torso ) < sharp_damage ) { apply_damage( nullptr, bp_torso, sharp_damage ); } - if( g->m.has_flag( "ROUGH", pos() ) && one_in( 6 ) && get_armor_cut( bp_torso ) < rough_damage ) { + if( g->m.has_flag( flag_ROUGH, pos() ) && one_in( 6 ) && + get_armor_cut( bp_torso ) < rough_damage ) { apply_damage( nullptr, bp_torso, rough_damage ); } } - if( g->m.has_flag( "UNSTABLE", destination ) && on_ground ) { + if( g->m.has_flag( flag_UNSTABLE, destination ) && on_ground ) { add_effect( effect_bouldering, 1_turns, num_bp, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); @@ -1520,10 +1522,10 @@ bool monster::move_to( const tripoint &p, bool force, const float stagger_adjust return true; } if( !will_be_water && ( digs() || can_dig() ) ) { - underwater = g->m.has_flag( "DIGGABLE", pos() ); + underwater = g->m.has_flag( flag_DIGGABLE, pos() ); } // Diggers turn the dirt into dirtmound - if( digging() && g->m.has_flag( "DIGGABLE", pos() ) ) { + if( digging() && g->m.has_flag( flag_DIGGABLE, pos() ) ) { int factor = 0; switch( type->size ) { case MS_TINY: diff --git a/src/morale.cpp b/src/morale.cpp index c13b6f34d55ad..390acc6859f2a 100644 --- a/src/morale.cpp +++ b/src/morale.cpp @@ -748,9 +748,9 @@ void player_morale::on_effect_int_change( const efftype_id &eid, int intensity, void player_morale::set_worn( const item &it, bool worn ) { - const bool fancy = it.has_flag( "FANCY" ); - const bool super_fancy = it.has_flag( "SUPER_FANCY" ); - const bool filthy_gear = it.has_flag( "FILTHY" ); + const bool fancy = it.has_flag( flag_FANCY ); + const bool super_fancy = it.has_flag( flag_SUPER_FANCY ); + const bool filthy_gear = it.has_flag( flag_FILTHY ); const int sign = ( worn ) ? 1 : -1; const auto update_body_part = [&]( body_part_data & bp_data ) { diff --git a/src/mutation.cpp b/src/mutation.cpp index 3992cd011923c..6946186c946d0 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -360,7 +360,7 @@ bool Character::can_use_heal_item( const item &med ) const } } if( !got_restriction ) { - can_use = !med.has_flag( "CANT_HEAL_EVERYONE" ); + can_use = !med.has_flag( flag_CANT_HEAL_EVERYONE ); } if( !can_use ) { @@ -493,7 +493,7 @@ void Character::activate_mutation( const trait_id &mut ) // Check for adjacent trees. bool adjacent_tree = false; for( const tripoint &p2 : g->m.points_in_radius( pos(), 1 ) ) { - if( g->m.has_flag( "TREE", p2 ) ) { + if( g->m.has_flag( flag_TREE, p2 ) ) { adjacent_tree = true; } } diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index 40851bd7378c3..85575999b628c 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -528,11 +528,11 @@ bool avatar::create( character_type type, const std::string &tempname ) it.item_counter = 450; // Give it some time to dry off } // TODO: debugmsg if food that isn't a seed is inedible - if( it.has_flag( "no_auto_equip" ) ) { - it.unset_flag( "no_auto_equip" ); + if( it.has_flag( flag_no_auto_equip ) ) { + it.unset_flag( flag_no_auto_equip ); inv.push_back( it ); - } else if( it.has_flag( "auto_wield" ) ) { - it.unset_flag( "auto_wield" ); + } else if( it.has_flag( flag_auto_wield ) ) { + it.unset_flag( flag_auto_wield ); if( !is_armed() ) { wield( it ); } else { @@ -1436,9 +1436,9 @@ tab_direction set_profession( const catacurses::window &w, avatar &u, points_lef std::string buffer_worn; std::string buffer_inventory; for( const auto &it : prof_items ) { - if( it.has_flag( "no_auto_equip" ) ) { + if( it.has_flag( flag_no_auto_equip ) ) { buffer_inventory += it.display_name() + "\n"; - } else if( it.has_flag( "auto_wield" ) ) { + } else if( it.has_flag( flag_auto_wield ) ) { buffer_wielded += it.display_name() + "\n"; } else if( it.is_armor() ) { buffer_worn += it.display_name() + "\n"; @@ -1661,7 +1661,7 @@ tab_direction set_skills( const catacurses::window &w, avatar &u, points_left &p std::map > > recipes; for( const auto &e : recipe_dict ) { const auto &r = e.second; - if( r.has_flag( "SECRET" ) ) { + if( r.has_flag( flag_SECRET ) ) { continue; } //Find out if the current skill and its level is in the requirement list @@ -1814,8 +1814,8 @@ struct { } } - if( !cities_enabled && a->has_flag( "CITY_START" ) != b->has_flag( "CITY_START" ) ) { - return a->has_flag( "CITY_START" ) < b->has_flag( "CITY_START" ); + if( !cities_enabled && a->has_flag( flag_CITY_START ) != b->has_flag( flag_CITY_START ) ) { + return a->has_flag( flag_CITY_START ) < b->has_flag( flag_CITY_START ); } else if( sort_by_points ) { return a->point_cost() < b->point_cost(); } else { @@ -1898,7 +1898,7 @@ tab_direction set_scenario( const catacurses::window &w, avatar &u, points_left std::stable_sort( sorted_scens.begin(), sorted_scens.end(), scenario_sorter ); // If city size is 0 but the current scenario requires cities reset the scenario - if( !scenario_sorter.cities_enabled && g->scen->has_flag( "CITY_START" ) ) { + if( !scenario_sorter.cities_enabled && g->scen->has_flag( flag_CITY_START ) ) { reset_scenario( u, sorted_scens[0] ); points.init_from_options(); points.skill_points -= sorted_scens[cur_id]->point_cost(); @@ -1963,7 +1963,7 @@ tab_direction set_scenario( const catacurses::window &w, avatar &u, points_left const std::string scenDesc = sorted_scens[cur_id]->description( u.male ); - if( sorted_scens[cur_id]->has_flag( "CITY_START" ) && !scenario_sorter.cities_enabled ) { + if( sorted_scens[cur_id]->has_flag( flag_CITY_START ) && !scenario_sorter.cities_enabled ) { const std::string scenUnavailable = _( "This scenario is not available in this world due to city size settings." ); fold_and_print( w_description, point_zero, TERMX - 2, c_red, scenUnavailable ); @@ -1983,11 +1983,12 @@ tab_direction set_scenario( const catacurses::window &w, avatar &u, points_left " " ); nc_color col; if( g->scen != sorted_scens[i] ) { - if( sorted_scens[i] == sorted_scens[cur_id] && ( sorted_scens[i]->has_flag( "CITY_START" ) && + if( sorted_scens[i] == sorted_scens[cur_id] && ( sorted_scens[i]->has_flag( flag_CITY_START ) && !scenario_sorter.cities_enabled ) ) { col = h_dark_gray; - } else if( sorted_scens[i] != sorted_scens[cur_id] && ( sorted_scens[i]->has_flag( "CITY_START" ) && - !scenario_sorter.cities_enabled ) ) { + } else if( sorted_scens[i] != sorted_scens[cur_id] && + ( sorted_scens[i]->has_flag( flag_CITY_START ) && + !scenario_sorter.cities_enabled ) ) { col = c_dark_gray; } else { col = ( sorted_scens[i] == sorted_scens[cur_id] ? h_light_gray : c_light_gray ); @@ -2037,45 +2038,45 @@ tab_direction set_scenario( const catacurses::window &w, avatar &u, points_left mvwprintz( w_flags, point_zero, COL_HEADER, _( "Scenario Flags:" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); - if( sorted_scens[cur_id]->has_flag( "SPR_START" ) ) { + if( sorted_scens[cur_id]->has_flag( flag_SPR_START ) ) { wprintz( w_flags, c_light_gray, _( "Spring start" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); - } else if( sorted_scens[cur_id]->has_flag( "SUM_START" ) ) { + } else if( sorted_scens[cur_id]->has_flag( flag_SUM_START ) ) { wprintz( w_flags, c_light_gray, _( "Summer start" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); - } else if( sorted_scens[cur_id]->has_flag( "AUT_START" ) ) { + } else if( sorted_scens[cur_id]->has_flag( flag_AUT_START ) ) { wprintz( w_flags, c_light_gray, _( "Autumn start" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); - } else if( sorted_scens[cur_id]->has_flag( "WIN_START" ) ) { + } else if( sorted_scens[cur_id]->has_flag( flag_WIN_START ) ) { wprintz( w_flags, c_light_gray, _( "Winter start" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); - } else if( sorted_scens[cur_id]->has_flag( "SUM_ADV_START" ) ) { + } else if( sorted_scens[cur_id]->has_flag( flag_SUM_ADV_START ) ) { wprintz( w_flags, c_light_gray, _( "Next summer start" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } - if( sorted_scens[cur_id]->has_flag( "INFECTED" ) ) { + if( sorted_scens[cur_id]->has_flag( flag_INFECTED ) ) { wprintz( w_flags, c_light_gray, _( "Infected player" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } - if( sorted_scens[cur_id]->has_flag( "BAD_DAY" ) ) { + if( sorted_scens[cur_id]->has_flag( flag_BAD_DAY ) ) { wprintz( w_flags, c_light_gray, _( "Drunk and sick player" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } - if( sorted_scens[cur_id]->has_flag( "FIRE_START" ) ) { + if( sorted_scens[cur_id]->has_flag( flag_FIRE_START ) ) { wprintz( w_flags, c_light_gray, _( "Fire nearby" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } - if( sorted_scens[cur_id]->has_flag( "SUR_START" ) ) { + if( sorted_scens[cur_id]->has_flag( flag_SUR_START ) ) { wprintz( w_flags, c_light_gray, _( "Zombies nearby" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } - if( sorted_scens[cur_id]->has_flag( "HELI_CRASH" ) ) { + if( sorted_scens[cur_id]->has_flag( flag_HELI_CRASH ) ) { wprintz( w_flags, c_light_gray, _( "Various limb wounds" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } if( get_option( "STARTING_NPC" ) == "scenario" && - sorted_scens[cur_id]->has_flag( "LONE_START" ) ) { + sorted_scens[cur_id]->has_flag( flag_LONE_START ) ) { wprintz( w_flags, c_light_gray, _( "No starting NPC" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } @@ -2100,7 +2101,7 @@ tab_direction set_scenario( const catacurses::window &w, avatar &u, points_left cur_id = scens_length - 1; } } else if( action == "CONFIRM" ) { - if( sorted_scens[cur_id]->has_flag( "CITY_START" ) && !scenario_sorter.cities_enabled ) { + if( sorted_scens[cur_id]->has_flag( flag_CITY_START ) && !scenario_sorter.cities_enabled ) { continue; } reset_scenario( u, sorted_scens[cur_id] ); diff --git a/src/npc.cpp b/src/npc.cpp index c0ec9b68fda0d..24ac42dcd1d37 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -140,7 +140,7 @@ standard_npc::standard_npc( const std::string &name, const tripoint &pos, } for( item &e : worn ) { - if( e.has_flag( "VARSIZE" ) ) { + if( e.has_flag( flag_VARSIZE ) ) { e.item_tags.insert( "FIT" ); } } @@ -515,7 +515,7 @@ void starting_clothes( npc &who, const npc_class_id &type, bool male ) } who.worn.clear(); for( item &it : ret ) { - if( it.has_flag( "VARSIZE" ) ) { + if( it.has_flag( flag_VARSIZE ) ) { it.item_tags.insert( "FIT" ); } if( who.can_wear( it ).success() ) { @@ -569,7 +569,7 @@ void starting_inv( npc &who, const npc_class_id &type ) while( qty-- != 0 ) { item tmp = random_item_from( type, "misc" ).in_its_container(); if( !tmp.is_null() ) { - if( !one_in( 3 ) && tmp.has_flag( "VARSIZE" ) ) { + if( !one_in( 3 ) && tmp.has_flag( flag_VARSIZE ) ) { tmp.item_tags.insert( "FIT" ); } if( who.can_pickVolume( tmp ) ) { @@ -579,7 +579,7 @@ void starting_inv( npc &who, const npc_class_id &type ) } res.erase( std::remove_if( res.begin(), res.end(), [&]( const item & e ) { - return e.has_flag( "TRADER_AVOID" ); + return e.has_flag( flag_TRADER_AVOID ); } ), res.end() ); for( auto &it : res ) { it.set_owner( who ); @@ -993,7 +993,7 @@ bool npc::wear_if_wanted( const item &it, std::string &reason ) // Splints ignore limits, but only when being equipped on a broken part // TODO: Drop splints when healed - if( it.has_flag( "SPLINT" ) ) { + if( it.has_flag( flag_SPLINT ) ) { for( int i = 0; i < num_hp_parts; i++ ) { hp_part hpp = static_cast( i ); body_part bp = player::hp_to_bp( hpp ); @@ -1029,7 +1029,7 @@ bool npc::wear_if_wanted( const item &it, std::string &reason ) auto iter = std::find_if( worn.begin(), worn.end(), [bp]( const item & armor ) { return armor.covers( bp ); } ); - if( iter != worn.end() && !( is_limb_broken( bp_to_hp( bp ) ) && iter->has_flag( "SPLINT" ) ) ) { + if( iter != worn.end() && !( is_limb_broken( bp_to_hp( bp ) ) && iter->has_flag( flag_SPLINT ) ) ) { took_off = takeoff( *iter ); break; } @@ -1654,7 +1654,7 @@ int npc::value( const item &it ) const int npc::value( const item &it, int market_price ) const { - if( it.is_dangerous() || ( it.has_flag( "BOMB" ) && it.active ) || it.made_of( LIQUID ) ) { + if( it.is_dangerous() || ( it.has_flag( flag_BOMB ) && it.active ) || it.made_of( LIQUID ) ) { // NPCs won't be interested in buying active explosives or spilled liquids return -1000; } @@ -2673,7 +2673,7 @@ void npc::on_load() has_new_items = true; // for spawned npcs - if( g->m.has_flag( "UNSTABLE", pos() ) ) { + if( g->m.has_flag( flag_UNSTABLE, pos() ) ) { add_effect( effect_bouldering, 1_turns, num_bp, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 6c2e959967ec7..8943206686755 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1629,7 +1629,7 @@ bool npc::recharge_cbm() if( use_bionic_by_id( bio_furnace ) ) { const std::function furnace_filter = []( const item & it ) { return it.typeId() == itype_id( "withered" ) || it.typeId() == itype_id( "file" ) || - it.has_flag( "FIREWOOD" ); + it.has_flag( flag_FIREWOOD ); }; if( consume_cbm_items( furnace_filter ) ) { return true; @@ -2257,7 +2257,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo } moves -= 100; moved = true; - } else if( g->m.passable( p ) && !g->m.has_flag( "DOOR", p ) ) { + } else if( g->m.passable( p ) && !g->m.has_flag( flag_DOOR, p ) ) { bool diag = trigdist && posx() != p.x && posy() != p.y; if( is_mounted() ) { const double base_moves = run_cost( g->m.combined_movecost( pos(), p ), @@ -2322,7 +2322,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo g->m.creature_on_trap( *mounted_creature ); } } - if( g->m.has_flag( "UNSTABLE", pos() ) ) { + if( g->m.has_flag( flag_UNSTABLE, pos() ) ) { add_effect( effect_bouldering, 1_turns, num_bp, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); @@ -3332,7 +3332,7 @@ bool npc::alt_attack() } // Are we going to throw this item? - if( !used->active && used->has_flag( "NPC_ACTIVATE" ) ) { + if( !used->active && used->has_flag( flag_NPC_ACTIVATE ) ) { activate_item( weapon_index ); // Note: intentional lack of return here // We want to ignore player-centric rules to avoid carrying live explosives @@ -3527,7 +3527,7 @@ static float rate_food( const item &it, int want_nutr, int want_quench ) return 0.0f; } - if( food->parasites && !it.has_flag( "NO_PARASITES" ) ) { + if( food->parasites && !it.has_flag( flag_NO_PARASITES ) ) { return 0.0; } @@ -4350,7 +4350,7 @@ bool npc::adjust_worn() }; for( auto &elem : worn ) { - if( !elem.has_flag( "SPLINT" ) ) { + if( !elem.has_flag( flag_SPLINT ) ) { continue; } diff --git a/src/npctrade.cpp b/src/npctrade.cpp index 4a3cbab663727..ea722164791e2 100644 --- a/src/npctrade.cpp +++ b/src/npctrade.cpp @@ -97,7 +97,7 @@ std::vector npc_trading::init_selling( npc &np ) if( np.will_exchange_items_freely() && !np.weapon.is_null() && - !np.weapon.has_flag( "NO_UNWIELD" ) + !np.weapon.has_flag( flag_NO_UNWIELD ) ) { result.emplace_back( np, np.weapon, np.value( np.weapon ), false ); } @@ -171,7 +171,7 @@ std::vector npc_trading::init_buying( player &buyer, player &selle check_item( item_location( seller, &i->front() ), i->size() ); } - if( !seller.weapon.has_flag( "NO_UNWIELD" ) ) { + if( !seller.weapon.has_flag( flag_NO_UNWIELD ) ) { check_item( item_location( seller, &seller.weapon ), 1 ); } diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index c6004be305064..d7999d768e73c 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -1477,7 +1477,7 @@ static tripoint display( const tripoint &orig, const draw_data_t &data = draw_da } else { const oter_id oter = overmap_buffer.ter( curs ); // going to or coming from a water tile - if( is_river_or_lake( oter ) || g->m.has_flag( "SWIMMABLE", g->u.pos() ) ) { + if( is_river_or_lake( oter ) || g->m.has_flag( flag_SWIMMABLE, g->u.pos() ) ) { ptype.amphibious = true; } } diff --git a/src/pathfinding.cpp b/src/pathfinding.cpp index 2857b3f6efff8..5629d5d29148e 100644 --- a/src/pathfinding.cpp +++ b/src/pathfinding.cpp @@ -23,6 +23,7 @@ #include "line.h" #include "type_id.h" #include "point.h" +#include "cata_string_consts.h" enum astar_state { ASL_NONE, @@ -334,7 +335,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, // Climbing fences newg += climb_cost; } else if( doors && ( terrain.open || furniture.open ) && - ( !terrain.has_flag( "OPENCLOSE_INSIDE" ) || !furniture.has_flag( "OPENCLOSE_INSIDE" ) || + ( !terrain.has_flag( flag_OPENCLOSE_INSIDE ) || !furniture.has_flag( flag_OPENCLOSE_INSIDE ) || !is_outside( cur ) ) ) { // Only try to open INSIDE doors from the inside // To open and then move onto the tile diff --git a/src/pickup.cpp b/src/pickup.cpp index 2dafb6bba70f4..22c7165bb8b3f 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -148,7 +148,7 @@ static pickup_answer handle_problematic_pickup( const item &it, bool &offered_sw offered_swap = true; // TODO: Gray out if not enough hands if( u.is_armed() ) { - amenu.addentry( WIELD, !u.weapon.has_flag( "NO_UNWIELD" ), 'w', + amenu.addentry( WIELD, !u.weapon.has_flag( flag_NO_UNWIELD ), 'w', _( "Dispose of %s and wield %s" ), u.weapon.display_name(), it.display_name() ); } else { @@ -438,7 +438,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( g->m.has_flag( "SEALED", p ) ) { + if( g->m.has_flag( flag_SEALED, p ) ) { return; } } @@ -493,9 +493,9 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) } // Bail out if this square cannot be auto-picked-up - if( g->check_zone( zone_type_id( "NO_AUTO_PICKUP" ), p ) ) { + if( g->check_zone( zone_type_NO_AUTO_PICKUP, p ) ) { return; - } else if( g->m.has_flag( "SEALED", p ) ) { + } else if( g->m.has_flag( flag_SEALED, p ) ) { return; } } diff --git a/src/player.cpp b/src/player.cpp index 055cb5a243772..c6aec70ab95bb 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -461,7 +461,7 @@ int player::run_cost( int base_cost, bool diag ) const } const bool flatground = movecost < 105; // The "FLAT" tag includes soft surfaces, so not a good fit. - const bool on_road = flatground && g->m.has_flag( "ROAD", pos() ); + const bool on_road = flatground && g->m.has_flag( flag_ROAD, pos() ); const bool on_fungus = g->m.has_flag_ter_or_furn( "FUNGUS", pos() ); if( !is_mounted() ) { @@ -549,7 +549,7 @@ int player::run_cost( int base_cost, bool diag ) const movecost += 8; } - if( has_trait( trait_ROOTS3 ) && g->m.has_flag( "DIGGABLE", pos() ) ) { + if( has_trait( trait_ROOTS3 ) && g->m.has_flag( flag_DIGGABLE, pos() ) ) { movecost += 10 * footwear_factor(); } @@ -843,19 +843,19 @@ std::list player::get_radio_items() const invslice &stacks = inv.slice(); for( auto &stack : stacks ) { item &stack_iter = stack->front(); - if( stack_iter.has_flag( "RADIO_ACTIVATION" ) ) { + if( stack_iter.has_flag( flag_RADIO_ACTIVATION ) ) { rc_items.push_back( &stack_iter ); } } for( auto &elem : worn ) { - if( elem.has_flag( "RADIO_ACTIVATION" ) ) { + if( elem.has_flag( flag_RADIO_ACTIVATION ) ) { rc_items.push_back( &elem ); } } if( is_armed() ) { - if( weapon.has_flag( "RADIO_ACTIVATION" ) ) { + if( weapon.has_flag( flag_RADIO_ACTIVATION ) ) { rc_items.push_back( &weapon ); } } @@ -1070,7 +1070,7 @@ void player::pause() bp_hand_r } }, true ); - } else if( g->m.has_flag( "SWIMMABLE", pos() ) ) { + } else if( g->m.has_flag( flag_SWIMMABLE, pos() ) ) { drench( 40, { { bp_foot_l, bp_foot_r, bp_leg_l, bp_leg_r } }, false ); } } @@ -1911,7 +1911,7 @@ void player::knock_back_to( const tripoint &to ) } // If we're still in the function at this point, we're actually moving a tile! - if( g->m.has_flag( "LIQUID", to ) && g->m.has_flag( TFLAG_DEEP_WATER, to ) ) { + if( g->m.has_flag( flag_LIQUID, to ) && g->m.has_flag( TFLAG_DEEP_WATER, to ) ) { if( !is_npc() ) { avatar_action::swim( g->m, g->u, to ); } @@ -2378,7 +2378,7 @@ void player::process_items() item *cloak = nullptr; item *power_armor = nullptr; std::vector active_worn_items; - bool weapon_active = weapon.has_flag( "USE_UPS" ) && + bool weapon_active = weapon.has_flag( flag_USE_UPS ) && weapon.charges < weapon.type->maximum_charges(); std::vector active_held_items; int ch_UPS = 0; @@ -2390,18 +2390,18 @@ void player::process_items() } else if( identifier == "adv_UPS_off" ) { ch_UPS += it.ammo_remaining() / 0.6; } - if( it.has_flag( "USE_UPS" ) && it.charges < it.type->maximum_charges() ) { + if( it.has_flag( flag_USE_UPS ) && it.charges < it.type->maximum_charges() ) { active_held_items.push_back( index ); } } bool update_required = get_check_encumbrance(); for( item &w : worn ) { - if( w.has_flag( "USE_UPS" ) && + if( w.has_flag( flag_USE_UPS ) && w.charges < w.type->maximum_charges() ) { active_worn_items.push_back( &w ); } if( w.active ) { - if( cloak == nullptr && w.has_flag( "ACTIVE_CLOAKING" ) ) { + if( cloak == nullptr && w.has_flag( flag_ACTIVE_CLOAKING ) ) { cloak = &w; } // Only the main power armor item can be active, the other ones (hauling frame, helmet) aren't. @@ -2612,7 +2612,7 @@ bool player::consume_med( item &target ) // TODO: Get the target it was used on // Otherwise injecting someone will give us addictions etc. - if( target.has_flag( "NO_INGEST" ) ) { + if( target.has_flag( flag_NO_INGEST ) ) { const auto &comest = *target.get_comestible(); // Assume that parenteral meds don't spoil, so don't apply rot modify_health( comest ); @@ -2810,7 +2810,7 @@ item::reload_option player::select_ammo( const item &base, uilist menu; menu.text = string_format( base.is_watertight_container() ? _( "Refill %s" ) : - base.has_flag( "RELOAD_AND_SHOOT" ) ? _( "Select ammo for %s" ) : _( "Reload %s" ), + base.has_flag( flag_RELOAD_AND_SHOOT ) ? _( "Select ammo for %s" ) : _( "Reload %s" ), base.tname() ); menu.w_width = -1; menu.w_height = -1; @@ -3009,7 +3009,7 @@ item::reload_option player::select_ammo( const item &base, } return false; } - } cb( opts, draw_row, last_key, default_to, !base.has_flag( "RELOAD_ONE" ) ); + } cb( opts, draw_row, last_key, default_to, !base.has_flag( flag_RELOAD_ONE ) ); menu.callback = &cb; menu.query(); @@ -3053,11 +3053,11 @@ bool player::list_ammo( const item &base, std::vector &ammo : ammo->typeId(); if( e->can_reload_with( id ) ) { // Speedloaders require an empty target. - if( !ammo->has_flag( "SPEEDLOADER" ) || e->ammo_remaining() < 1 ) { + if( !ammo->has_flag( flag_SPEEDLOADER ) || e->ammo_remaining() < 1 ) { ammo_match_found = true; } } - if( can_reload( *e, id ) || e->has_flag( "RELOAD_AND_SHOOT" ) ) { + if( can_reload( *e, id ) || e->has_flag( flag_RELOAD_AND_SHOOT ) ) { ammo_list.emplace_back( this, e, &base, std::move( ammo ) ); } } @@ -3134,11 +3134,11 @@ ret_val player::can_wield( const item &it ) const _( "You need at least one arm to even consider wielding something." ) ); } - if( it.is_two_handed( *this ) && ( !has_two_arms() || worn_with_flag( "RESTRICT_HANDS" ) ) ) { - if( worn_with_flag( "RESTRICT_HANDS" ) ) { + if( it.is_two_handed( *this ) && ( !has_two_arms() || worn_with_flag( flag_RESTRICT_HANDS ) ) ) { + if( worn_with_flag( flag_RESTRICT_HANDS ) ) { return ret_val::make_failure( _( "Something you are wearing hinders the use of both hands." ) ); - } else if( it.has_flag( "ALWAYS_TWOHAND" ) ) { + } else if( it.has_flag( flag_ALWAYS_TWOHAND ) ) { return ret_val::make_failure( _( "The %s can't be wielded with only one arm." ), it.tname() ); } else { @@ -3457,7 +3457,7 @@ int player::item_reload_cost( const item &it, const item &ammo, int qty ) const // We have the ammo in our hands right now int mv = item_handling_cost( obj, true, 0 ); - if( ammo.has_flag( "MAG_BULKY" ) ) { + if( ammo.has_flag( flag_MAG_BULKY ) ) { mv *= 1.5; // bulky magazines take longer to insert } @@ -3477,7 +3477,7 @@ int player::item_reload_cost( const item &it, const item &ammo, int qty ) const skill_id sk = it.is_gun() ? it.type->gun->skill_used : skill_gun; mv += cost / ( 1.0f + std::min( get_skill_level( sk ) * 0.1f, 1.0f ) ); - if( it.has_flag( "STR_RELOAD" ) ) { + if( it.has_flag( flag_STR_RELOAD ) ) { /** @EFFECT_STR reduces reload time of some weapons */ mv -= get_str() * 20; } @@ -3565,7 +3565,7 @@ ret_val player::can_takeoff( const item &it, const std::list *res ) _( "You can't take off power armor while wearing other power armor components." ) : _( " can't take off power armor while wearing other power armor components." ) ); } - if( it.has_flag( "NO_TAKEOFF" ) ) { + if( it.has_flag( flag_NO_TAKEOFF ) ) { return ret_val::make_failure( !is_npc() ? _( "You can't take that item off." ) : _( " can't take that item off." ) ); @@ -3678,7 +3678,7 @@ bool player::unload( item &it ) std::vector opts( 1, &it ); for( auto e : it.gunmods() ) { - if( e->is_gun() && !e->has_flag( "NO_UNLOAD" ) && + if( e->is_gun() && !e->has_flag( flag_NO_UNLOAD ) && ( e->magazine_current() || e->ammo_remaining() > 0 || e->casings_count() > 0 ) ) { msgs.emplace_back( e->tname() ); opts.emplace_back( e ); @@ -3705,8 +3705,8 @@ bool player::unload( item &it ) return false; } - if( target->has_flag( "NO_UNLOAD" ) ) { - if( target->has_flag( "RECHARGE" ) || target->has_flag( "USE_UPS" ) ) { + if( target->has_flag( flag_NO_UNLOAD ) ) { + if( target->has_flag( flag_RECHARGE ) || target->has_flag( flag_USE_UPS ) ) { add_msg( m_info, _( "You can't unload a rechargeable %s!" ), target->tname() ); } else { add_msg( m_info, _( "You can't unload a %s!" ), target->tname() ); @@ -3842,7 +3842,7 @@ hint_rating player::rate_action_unload( const item &it ) const return HINT_GOOD; } - if( it.has_flag( "NO_UNLOAD" ) ) { + if( it.has_flag( flag_NO_UNLOAD ) ) { return HINT_CANT; } @@ -3851,7 +3851,7 @@ hint_rating player::rate_action_unload( const item &it ) const } for( auto e : it.gunmods() ) { - if( e->is_gun() && !e->has_flag( "NO_UNLOAD" ) && + if( e->is_gun() && !e->has_flag( flag_NO_UNLOAD ) && ( e->magazine_current() || e->ammo_remaining() > 0 || e->casings_count() > 0 ) ) { return HINT_GOOD; } @@ -4055,7 +4055,7 @@ bool player::gunmod_remove( item &gun, item &mod ) std::pair player::gunmod_installation_odds( const item &gun, const item &mod ) const { // Mods with INSTALL_DIFFICULT have a chance to fail, potentially damaging the gun - if( !mod.has_flag( "INSTALL_DIFFICULT" ) || has_trait( trait_DEBUG_HS ) ) { + if( !mod.has_flag( flag_INSTALL_DIFFICULT ) || has_trait( trait_DEBUG_HS ) ) { return std::make_pair( 100, 0 ); } @@ -4198,7 +4198,7 @@ bool player::fun_to_read( const item &book ) const has_trait( trait_SAPIOVORE ) ) && book.typeId() == "cookbook_human" ) { return true; - } else if( has_trait( trait_SPIRITUAL ) && book.has_flag( "INSPIRATIONAL" ) ) { + } else if( has_trait( trait_SPIRITUAL ) && book.has_flag( flag_INSPIRATIONAL ) ) { return true; } else { return book_fun_for( book, *this ) > 0; @@ -4218,7 +4218,7 @@ int player::book_fun_for( const item &book, const player &p ) const p.has_trait( trait_SAPIOVORE ) ) && book.typeId() == "cookbook_human" ) { fun_bonus = abs( fun_bonus ); - } else if( p.has_trait( trait_SPIRITUAL ) && book.has_flag( "INSPIRATIONAL" ) ) { + } else if( p.has_trait( trait_SPIRITUAL ) && book.has_flag( flag_INSPIRATIONAL ) ) { fun_bonus = abs( fun_bonus * 3 ); } @@ -4567,8 +4567,9 @@ float player::fine_detail_vision_mod( const tripoint &p ) const bool player::natural_attack_restricted_on( body_part bp ) const { for( auto &i : worn ) { - if( i.covers( bp ) && !i.has_flag( "ALLOWS_NATURAL_ATTACKS" ) && !i.has_flag( "SEMITANGIBLE" ) && - !i.has_flag( "PERSONAL" ) && !i.has_flag( "AURA" ) ) { + if( i.covers( bp ) && !i.has_flag( flag_ALLOWS_NATURAL_ATTACKS ) && + !i.has_flag( flag_SEMITANGIBLE ) && + !i.has_flag( flag_PERSONAL ) && !i.has_flag( flag_AURA ) ) { return true; } } @@ -4745,7 +4746,7 @@ bool player::has_gun_for_ammo( const ammotype &at ) const bool player::has_magazine_for_ammo( const ammotype &at ) const { return has_item_with( [&at]( const item & it ) { - return !it.has_flag( "NO_RELOAD" ) && + return !it.has_flag( flag_NO_RELOAD ) && ( ( it.is_magazine() && it.ammo_types().count( at ) ) || ( it.is_gun() && it.magazine_integral() && it.ammo_types().count( at ) ) || ( it.is_gun() && it.magazine_current() != nullptr && @@ -4760,11 +4761,11 @@ std::string player::weapname( unsigned int truncate ) const std::string str = string_format( "(%s) %s", weapon.gun_current_mode().tname(), weapon.type_name() ); // Is either the base item or at least one auxiliary gunmod loaded (includes empty magazines) - bool base = weapon.ammo_capacity() > 0 && !weapon.has_flag( "RELOAD_AND_SHOOT" ); + bool base = weapon.ammo_capacity() > 0 && !weapon.has_flag( flag_RELOAD_AND_SHOOT ); const auto mods = weapon.gunmods(); bool aux = std::any_of( mods.begin(), mods.end(), [&]( const item * e ) { - return e->is_gun() && e->ammo_capacity() > 0 && !e->has_flag( "RELOAD_AND_SHOOT" ); + return e->is_gun() && e->ammo_capacity() > 0 && !e->has_flag( flag_RELOAD_AND_SHOOT ); } ); if( base || aux ) { @@ -4780,7 +4781,7 @@ std::string player::weapname( unsigned int truncate ) const str += ")"; for( auto e : mods ) { - if( e->is_gun() && e->ammo_capacity() > 0 && !e->has_flag( "RELOAD_AND_SHOOT" ) ) { + if( e->is_gun() && e->ammo_capacity() > 0 && !e->has_flag( flag_RELOAD_AND_SHOOT ) ) { str += " (" + std::to_string( e->ammo_remaining() ); if( e->magazine_integral() ) { str += "/" + std::to_string( e->ammo_capacity() ); diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 0946237d1520c..c85ac58333884 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -1145,7 +1145,7 @@ void player::hardcoded_effects( effect &it ) if( mp == pos() ) { continue; } - if( g->m.has_flag( "FLAT", mp ) && + if( g->m.has_flag( flag_FLAT, mp ) && g->m.pl_sees( mp, 2 ) ) { g->spawn_hallucination( mp ); if( ++count > max_count ) { diff --git a/src/profession.cpp b/src/profession.cpp index 20765f0229e7b..acf39956d6361 100644 --- a/src/profession.cpp +++ b/src/profession.cpp @@ -23,6 +23,7 @@ #include "item.h" #include "flat_set.h" #include "type_id.h" +#include "cata_string_consts.h" namespace { @@ -403,7 +404,7 @@ std::list profession::items( bool male, const std::vector &trait if( it.is_holster() && it.contents.size() == 1 ) { clear_faults( it.contents.front() ); } - if( it.has_flag( "VARSIZE" ) ) { + if( it.has_flag( flag_VARSIZE ) ) { it.item_tags.insert( "FIT" ); } } diff --git a/src/ranged.cpp b/src/ranged.cpp index 39b1cb0f459cb..42ca346d8ec85 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -176,7 +176,7 @@ bool player::handle_gun_damage( item &it ) // and so are immune to this effect, note also that WATERPROOF_GUN status does not // mean the gun will actually be accurate underwater. int effective_durability = firing.durability; - if( is_underwater() && !it.has_flag( "WATERPROOF_GUN" ) && one_in( effective_durability ) ) { + if( is_underwater() && !it.has_flag( flag_WATERPROOF_GUN ) && one_in( effective_durability ) ) { add_msg_player_or_npc( _( "Your %s misfires with a wet click!" ), _( "'s %s misfires with a wet click!" ), it.tname() ); @@ -611,7 +611,7 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & static_cast( MAX_SKILL ) ) * 0.85 + 0.15; impact.add_damage( DT_BASH, std::min( weight / 100.0_gram, stats_mod ) ); - if( thrown.has_flag( "ACT_ON_RANGED_HIT" ) ) { + if( thrown.has_flag( flag_ACT_ON_RANGED_HIT ) ) { proj_effects.insert( "ACT_ON_RANGED_HIT" ); thrown.active = true; } @@ -664,7 +664,7 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & du.res_pen += skill_level / 2.0f; } // handling for tangling thrown items - if( thrown.has_flag( "TANGLE" ) ) { + if( thrown.has_flag( flag_TANGLE ) ) { proj_effects.insert( "TANGLE" ); } @@ -2189,13 +2189,13 @@ static void cycle_action( item &weap, const tripoint &pos ) // for turrets try and drop casings or linkages directly to any CARGO part on the same tile const optional_vpart_position vp = g->m.veh_at( pos ); std::vector cargo; - if( vp && weap.has_flag( "VEHICLE" ) ) { + if( vp && weap.has_flag( flag_VEHICLE ) ) { cargo = vp->vehicle().get_parts_at( pos, "CARGO", part_status_flag::any ); } if( weap.ammo_data() && weap.ammo_data()->ammo->casing ) { const itype_id casing = *weap.ammo_data()->ammo->casing; - if( weap.has_flag( "RELOAD_EJECT" ) || weap.gunmod_find( "brass_catcher" ) ) { + if( weap.has_flag( flag_RELOAD_EJECT ) || weap.gunmod_find( "brass_catcher" ) ) { weap.contents.push_back( item( casing ).set_flag( "CASING" ) ); } else { if( cargo.empty() ) { diff --git a/src/recipe.cpp b/src/recipe.cpp index 2766064917da8..21b250c75b8bd 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -26,6 +26,7 @@ #include "string_id.h" #include "flat_set.h" #include "units.h" +#include "cata_string_consts.h" extern bool test_mode; @@ -444,7 +445,7 @@ std::vector recipe::create_byproducts( int batch ) const std::vector bps; for( const auto &e : byproducts ) { item obj( e.first, calendar::turn, item::default_charges_tag{} ); - if( obj.has_flag( "VARSIZE" ) ) { + if( obj.has_flag( flag_VARSIZE ) ) { obj.item_tags.insert( "FIT" ); } @@ -559,7 +560,7 @@ std::function recipe::get_component_filter( // Disallow crafting of non-perishables with rotten components // Make an exception for items with the ALLOW_ROTTEN flag such as seeds const bool recipe_forbids_rotten = - result.is_food() && !result.goes_bad() && !has_flag( "ALLOW_ROTTEN" ); + result.is_food() && !result.goes_bad() && !has_flag( flag_ALLOW_ROTTEN ); const bool flags_forbid_rotten = static_cast( flags & recipe_filter_flags::no_rotten ) && result.goes_bad(); std::function rotten_filter = return_true; @@ -575,14 +576,14 @@ std::function recipe::get_component_filter( std::function frozen_filter = return_true; if( result.is_food() && !hot_result() ) { frozen_filter = []( const item & component ) { - return !component.has_flag( "FROZEN" ) || component.has_flag( "EDIBLE_FROZEN" ); + return !component.has_flag( flag_FROZEN ) || component.has_flag( flag_EDIBLE_FROZEN ); }; } // Disallow usage of non-full magazines as components // This is primarily used to require a fully charged battery, but works for any magazine. std::function magazine_filter = return_true; - if( has_flag( "FULL_MAGAZINE" ) ) { + if( has_flag( flag_FULL_MAGAZINE ) ) { magazine_filter = []( const item & component ) { return !component.is_magazine() || ( component.ammo_remaining() >= component.ammo_capacity() ); }; diff --git a/src/requirements.cpp b/src/requirements.cpp index 30af435881715..a0a5754b7b567 100644 --- a/src/requirements.cpp +++ b/src/requirements.cpp @@ -1026,7 +1026,7 @@ requirement_data requirement_data::disassembly_requirements() const []( std::vector &cov ) { cov.erase( std::remove_if( cov.begin(), cov.end(), []( const item_comp & comp ) { - return !comp.recoverable || item( comp.type ).has_flag( "UNRECOVERABLE" ); + return !comp.recoverable || item( comp.type ).has_flag( flag_UNRECOVERABLE ); } ), cov.end() ); return cov.empty(); } ), ret.components.end() );