From 53b22533aafaee0b194f9444e5092f89d547fc03 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 17 Feb 2020 17:17:20 -0500 Subject: [PATCH] Move string consts to single location --- src/cata_string_consts.h | 1 + src/character.cpp | 6 +- src/game.cpp | 272 ++++++++++++++++----------------------- 3 files changed, 114 insertions(+), 165 deletions(-) diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 489bcdf3baab5..955b1185c9f08 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -1035,6 +1035,7 @@ static const std::string flag_FLOTATION( "FLOTATION" ); static const std::string flag_FLOWER( "FLOWER" ); static const std::string flag_FORAGE_HALLU( "FORAGE_HALLU" ); static const std::string flag_FORAGE_POISON( "FORAGE_POISON" ); +static const std::string flag_FRAGILE( "FRAGILE" ); static const std::string flag_FRAGILE_MELEE( "FRAGILE_MELEE" ); static const std::string flag_FREEZERBURN( "FREEZERBURN" ); static const std::string flag_FROZEN( "FROZEN" ); diff --git a/src/character.cpp b/src/character.cpp index 7c6c225bf98fd..c49a18314e3a5 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -2286,7 +2286,7 @@ ret_val Character::can_wear( const item &it, bool with_equip_change ) cons ret_val Character::can_unwield( const item &it ) const { - if( it.has_flag( "NO_UNWIELD" ) ) { + if( it.has_flag( flag_NO_UNWIELD ) ) { return ret_val::make_failure( _( "You cannot unwield your %s." ), it.tname() ); } @@ -2847,7 +2847,7 @@ static void layer_item( std::array &vals, * for the purposes of the layer penalty system. (normally an item has a minimum * layering_encumbrance of 2 ) */ - if( it.has_flag( "SEMITANGIBLE" ) ) { + if( it.has_flag( flag_SEMITANGIBLE ) ) { encumber_val = 0; layering_encumbrance = 0; } @@ -7456,7 +7456,7 @@ bool Character::armor_absorb( damage_unit &du, item &armor ) m_info ); } - return armor.mod_damage( armor.has_flag( "FRAGILE" ) ? + return armor.mod_damage( armor.has_flag( flag_FRAGILE ) ? rng( 2 * itype::damage_scale, 3 * itype::damage_scale ) : itype::damage_scale, du.type ); } diff --git a/src/game.cpp b/src/game.cpp index 17f2476f663a2..6a7f9c0e5097a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -143,6 +143,7 @@ #include "string_id.h" #include "colony.h" #include "item.h" +#include "cata_string_consts.h" class inventory; @@ -170,60 +171,6 @@ static constexpr int DANGEROUS_PROXIMITY = 5; /** Will be set to true when running unit tests */ bool test_mode = false; -static const mtype_id mon_manhack( "mon_manhack" ); - -static const skill_id skill_melee( "melee" ); -static const skill_id skill_dodge( "dodge" ); -static const skill_id skill_firstaid( "firstaid" ); -static const skill_id skill_survival( "survival" ); -static const skill_id skill_electronics( "electronics" ); -static const skill_id skill_computer( "computer" ); - -static const species_id PLANT( "PLANT" ); - -static const efftype_id effect_adrenaline_mycus( "adrenaline_mycus" ); -static const efftype_id effect_assisted( "assisted" ); -static const efftype_id effect_blind( "blind" ); -static const efftype_id effect_boomered( "boomered" ); -static const efftype_id effect_bouldering( "bouldering" ); -static const efftype_id effect_contacts( "contacts" ); -static const efftype_id effect_controlled( "controlled" ); -static const efftype_id effect_docile( "docile" ); -static const efftype_id effect_downed( "downed" ); -static const efftype_id effect_drunk( "drunk" ); -static const efftype_id effect_evil( "evil" ); -static const efftype_id effect_flu( "flu" ); -static const efftype_id effect_infected( "infected" ); -static const efftype_id effect_laserlocked( "laserlocked" ); -static const efftype_id effect_no_sight( "no_sight" ); -static const efftype_id effect_npc_suspend( "npc_suspend" ); -static const efftype_id effect_onfire( "onfire" ); -static const efftype_id effect_pacified( "pacified" ); -static const efftype_id effect_paid( "paid" ); -static const efftype_id effect_pet( "pet" ); -static const efftype_id effect_ridden( "ridden" ); -static const efftype_id effect_riding( "riding" ); -static const efftype_id effect_sleep( "sleep" ); -static const efftype_id effect_stunned( "stunned" ); -static const efftype_id effect_tetanus( "tetanus" ); -static const efftype_id effect_tied( "tied" ); -static const efftype_id effect_winded( "winded" ); - -static const bionic_id bio_remote( "bio_remote" ); - -static const trait_id trait_ILLITERATE( "ILLITERATE" ); -static const trait_id trait_INFIMMUNE( "INFIMMUNE" ); -static const trait_id trait_INFRESIST( "INFRESIST" ); -static const trait_id trait_LEG_TENT_BRACE( "LEG_TENT_BRACE" ); -static const trait_id trait_M_IMMUNE( "M_IMMUNE" ); -static const trait_id trait_PARKOUR( "PARKOUR" ); -static const trait_id trait_VINES2( "VINES2" ); -static const trait_id trait_VINES3( "VINES3" ); - -static const trap_str_id tr_unfinished_construction( "tr_unfinished_construction" ); - -static const faction_id your_followers( "your_followers" ); - void intro(); #if defined(__ANDROID__) @@ -748,17 +695,17 @@ bool game::start_game() //Put some NPCs in there! if( get_option( "STARTING_NPC" ) == "always" || ( get_option( "STARTING_NPC" ) == "scenario" && - !g->scen->has_flag( "LONE_START" ) ) ) { + !g->scen->has_flag( flag_LONE_START ) ) ) { create_starting_npcs(); } //Load NPCs. Set nearby npcs to active. load_npcs(); // Spawn the monsters const bool spawn_near = - get_option( "BLACK_ROAD" ) || g->scen->has_flag( "SUR_START" ); + get_option( "BLACK_ROAD" ) || g->scen->has_flag( flag_SUR_START ); // Surrounded start ones if( spawn_near ) { - start_loc.surround_with_monsters( omtstart, mongroup_id( "GROUP_ZOMBIE" ), 70 ); + start_loc.surround_with_monsters( omtstart, GROUP_ZOMBIE, 70 ); } m.spawn_monsters( !spawn_near ); // Static monsters @@ -778,18 +725,18 @@ bool game::start_game() u.set_highest_cat_level(); //Calculate mutation drench protection stats u.drench_mut_calc(); - if( scen->has_flag( "FIRE_START" ) ) { + if( scen->has_flag( flag_FIRE_START ) ) { start_loc.burn( omtstart, 3, 3 ); } - if( scen->has_flag( "INFECTED" ) ) { + if( scen->has_flag( flag_INFECTED ) ) { u.add_effect( effect_infected, 1_turns, random_body_part(), true ); } - if( scen->has_flag( "BAD_DAY" ) ) { + if( scen->has_flag( flag_BAD_DAY ) ) { u.add_effect( effect_flu, 1000_minutes ); u.add_effect( effect_drunk, 270_minutes ); u.add_morale( MORALE_FEELING_BAD, -100, -100, 50_minutes, 50_minutes ); } - if( scen->has_flag( "HELI_CRASH" ) ) { + if( scen->has_flag( flag_HELI_CRASH ) ) { start_loc.handle_heli_crash( u ); bool success = false; for( auto v : m.get_vehicles() ) { @@ -947,8 +894,8 @@ void game::create_starting_npcs() //This sets the NPC mission. This NPC remains in the starting location. tmp->mission = NPC_MISSION_SHELTER; tmp->chatbin.first_topic = "TALK_SHELTER"; - tmp->toggle_trait( trait_id( "NPC_STARTING_NPC" ) ); - tmp->set_fac( faction_id( "no_faction" ) ); + tmp->toggle_trait( trait_NPC_STARTING_NPC ); + tmp->set_fac( no_faction ); //One random starting NPC mission tmp->add_new_mission( mission::reserve_random( ORIGIN_OPENER_NPC, tmp->global_omt_location(), tmp->getID() ) ); @@ -1428,7 +1375,7 @@ bool game::do_turn() sfx::do_hearing_loss(); } - if( !u.has_effect( efftype_id( "sleep" ) ) ) { + if( !u.has_effect( effect_sleep ) ) { if( u.moves > 0 || uquit == QUIT_WATCH ) { while( u.moves > 0 || uquit == QUIT_WATCH ) { cleanup_dead(); @@ -1475,7 +1422,7 @@ bool game::do_turn() // If player is performing a task and a monster is dangerously close, warn them // regardless of previous safemode warnings - if( u.activity && !u.has_activity( activity_id( "ACT_AIM" ) ) && + if( u.activity && !u.has_activity( ACT_AIM ) && u.activity.moves_left > 0 && !u.activity.is_distraction_ignored( distraction_type::hostile_spotted ) ) { Creature *hostile_critter = is_hostile_very_close(); @@ -1499,8 +1446,8 @@ bool game::do_turn() } // No-scent debug mutation has to be processed here or else it takes time to start working - if( !u.has_active_bionic( bionic_id( "bio_scent_mask" ) ) && - !u.has_trait( trait_id( "DEBUG_NOSCENT" ) ) ) { + if( !u.has_active_bionic( bio_scent_mask ) && + !u.has_trait( trait_DEBUG_NOSCENT ) ) { scent.set( u.pos(), u.scent, u.get_type_of_scent() ); overmap_buffer.set_scent( u.global_omt_location(), u.scent ); } @@ -1676,7 +1623,7 @@ bool game::cancel_activity_or_ignore_query( const distraction_type type, const s if( cancel_auto_move( u, text ) ) { return true; } else { - u.set_destination( u.get_auto_move_route(), player_activity( activity_id( "ACT_TRAVELLING" ) ) ); + u.set_destination( u.get_auto_move_route(), player_activity( ACT_TRAVELLING ) ); return false; } } @@ -1720,7 +1667,7 @@ bool game::cancel_activity_query( const std::string &text ) if( cancel_auto_move( u, text ) ) { return true; } else { - u.set_destination( u.get_auto_move_route(), player_activity( activity_id( "ACT_TRAVELLING" ) ) ); + u.set_destination( u.get_auto_move_route(), player_activity( ACT_TRAVELLING ) ); return false; } } @@ -1956,7 +1903,7 @@ int game::inventory_item_menu( item_location locThisItem, int iStartX, int iWidt std::vector vDummy; const bool bHPR = get_auto_pickup().has_rule( &oThisItem ); - const hint_rating rate_drop_item = u.weapon.has_flag( "NO_UNWIELD" ) ? HINT_CANT : HINT_GOOD; + const hint_rating rate_drop_item = u.weapon.has_flag( flag_NO_UNWIELD ) ? HINT_CANT : HINT_GOOD; int max_text_length = 0; uilist action_menu; @@ -2405,7 +2352,7 @@ vehicle *game::remoteveh() tripoint vp; remote_veh_string >> vp.x >> vp.y >> vp.z; vehicle *veh = veh_pointer_or_null( m.veh_at( vp ) ); - if( veh && veh->fuel_left( "battery", true ) > 0 ) { + if( veh && veh->fuel_left( fuel_type_battery, true ) > 0 ) { remoteveh_cache = veh; } else { remoteveh_cache = nullptr; @@ -3250,7 +3197,7 @@ void game::draw_ter( const tripoint ¢er, const bool looking, const bool draw draw_critter( critter, center ); } - if( u.has_active_bionic( bionic_id( "bio_scent_vision" ) ) && u.view_offset.z == 0 ) { + if( u.has_active_bionic( bio_scent_vision ) && u.view_offset.z == 0 ) { tripoint tmp = center; int &realx = tmp.x; int &realy = tmp.y; @@ -3675,7 +3622,7 @@ std::unordered_set game::get_fishable_locations( int distance, const t // Mark this point as visited. visited.emplace( current_point ); - if( m.has_flag( "FISHABLE", current_point ) ) { + if( m.has_flag( flag_FISHABLE, current_point ) ) { fishable_terrain.emplace( current_point ); to_check.push( current_point + point_south ); to_check.push( current_point + point_north ); @@ -4129,7 +4076,7 @@ void game::monmove() } if( !critter.is_dead() && - u.has_active_bionic( bionic_id( "bio_alarm" ) ) && + u.has_active_bionic( bio_alarm ) && u.get_power_level() >= 25_kJ && rl_dist( u.pos(), critter.pos() ) <= 5 && !critter.is_hallucination() ) { @@ -4137,7 +4084,7 @@ void game::monmove() add_msg( m_warning, _( "Your motion alarm goes off!" ) ); cancel_activity_or_ignore_query( distraction_type::motion_alarm, _( "Your motion alarm goes off!" ) ); - if( u.has_effect( efftype_id( "sleep" ) ) ) { + if( u.has_effect( effect_sleep ) ) { u.wake_up(); } } @@ -4164,7 +4111,7 @@ void game::monmove() if( !guy.has_effect( effect_npc_suspend ) ) { guy.process_turn(); } - while( !guy.is_dead() && ( !guy.in_sleep_state() || guy.activity.id() == "ACT_OPERATION" ) && + while( !guy.is_dead() && ( !guy.in_sleep_state() || guy.activity.id() == ACT_OPERATION ) && guy.moves > 0 && turns < 10 ) { int moves = guy.moves; guy.move(); @@ -4307,13 +4254,13 @@ void game::knockback( std::vector &traj, int force, int stun, int dam_ break; } targ->setpos( traj[i] ); - if( m.has_flag( "LIQUID", targ->pos() ) && !targ->can_drown() && !targ->is_dead() ) { + if( m.has_flag( flag_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( flag_LIQUID, targ->pos() ) && targ->has_flag( MF_AQUATIC ) && !targ->is_dead() ) { targ->die( nullptr ); if( u.sees( *targ ) ) { @@ -4458,7 +4405,7 @@ void game::knockback( std::vector &traj, int force, int stun, int dam_ knockback( traj, force_remaining, stun, dam_mult ); break; } - if( m.has_flag( "LIQUID", u.pos() ) && force_remaining < 1 ) { + if( m.has_flag( flag_LIQUID, u.pos() ) && force_remaining < 1 ) { avatar_action::swim( m, u, u.pos() ); } else { u.setpos( traj[i] ); @@ -4469,7 +4416,7 @@ void game::knockback( std::vector &traj, int force, int stun, int dam_ void game::use_computer( const tripoint &p ) { - if( u.has_trait( trait_id( "ILLITERATE" ) ) ) { + if( u.has_trait( trait_ILLITERATE ) ) { add_msg( m_info, _( "You can not read a computer screen!" ) ); return; } @@ -4478,7 +4425,7 @@ void game::use_computer( const tripoint &p ) add_msg( m_info, _( "You can not see a computer screen!" ) ); return; } - if( u.has_trait( trait_id( "HYPEROPIC" ) ) && !u.worn_with_flag( "FIX_FARSIGHT" ) && + if( u.has_trait( trait_HYPEROPIC ) && !u.worn_with_flag( flag_FIX_FARSIGHT ) && !u.has_effect( effect_contacts ) && !u.has_bionic( bionic_id( "bio_eye_optic" ) ) ) { add_msg( m_info, _( "You'll need to put on reading glasses before you can see the screen." ) ); return; @@ -4487,7 +4434,7 @@ void game::use_computer( const tripoint &p ) computer *used = m.computer_at( p ); if( used == nullptr ) { - if( m.has_flag( "CONSOLE", p ) ) { //Console without map data + if( m.has_flag( flag_CONSOLE, p ) ) { //Console without map data add_msg( m_bad, _( "The console doesn't display anything coherent." ) ); } else { dbg( D_ERROR ) << "game:use_computer: Tried to use computer at (" << @@ -4801,7 +4748,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( flag_LIQUID, p ) ) && critter_at( p ) == nullptr; } @@ -4834,8 +4781,8 @@ bool game::revive_corpse( const tripoint &p, item &it ) // Failed reanimation due to corpse being too burned return false; } - if( it.has_flag( "FIELD_DRESS" ) || it.has_flag( "FIELD_DRESS_FAILED" ) || - it.has_flag( "QUARTERED" ) ) { + if( it.has_flag( flag_FIELD_DRESS ) || it.has_flag( flag_FIELD_DRESS_FAILED ) || + it.has_flag( flag_QUARTERED ) ) { // Failed reanimation due to corpse being butchered return false; } @@ -5042,7 +4989,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( flag_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( LIQUID ) ) { @@ -5091,7 +5038,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( flag_SWIMMABLE, u.pos() ) ) { if( veh->velocity > 0 ) { fling_creature( &u, veh->face.dir(), veh->velocity / static_cast( 100 ) ); } else { @@ -5102,7 +5049,6 @@ void game::moving_vehicle_dismount( const tripoint &dest_loc ) void game::control_vehicle() { - static const itype_id fuel_type_animal( "animal" ); int veh_part = -1; vehicle *veh = remoteveh(); if( veh == nullptr ) { @@ -5441,10 +5387,10 @@ void game::examine( const tripoint &examp ) return; } - if( m.has_flag( "CONSOLE", examp ) && !u.is_mounted() ) { + if( m.has_flag( flag_CONSOLE, examp ) && !u.is_mounted() ) { use_computer( examp ); return; - } else if( m.has_flag( "CONSOLE", examp ) && u.is_mounted() ) { + } else if( m.has_flag( flag_CONSOLE, examp ) && u.is_mounted() ) { add_msg( m_warning, _( "You cannot use a console while mounted." ) ); } const furn_t &xfurn_t = m.furn( examp ).obj(); @@ -5497,9 +5443,9 @@ void game::examine( const tripoint &examp ) add_msg( fire_fuel ); } - if( m.has_flag( "SEALED", examp ) ) { + if( m.has_flag( flag_SEALED, examp ) ) { if( none ) { - if( m.has_flag( "UNSTABLE", examp ) ) { + if( m.has_flag( flag_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 ) ); @@ -5508,7 +5454,7 @@ void game::examine( const tripoint &examp ) } else { //examp has no traps, is a container and doesn't have a special examination function if( m.tr_at( examp ).is_null() && m.i_at( examp ).empty() && - m.has_flag( "CONTAINER", examp ) && none ) { + m.has_flag( flag_CONTAINER, examp ) && none ) { add_msg( _( "It is empty." ) ); } else if( ( m.has_flag( TFLAG_FIRE_CONTAINER, examp ) && xfurn_t.examine == &iexamine::fireplace ) || @@ -7867,12 +7813,12 @@ static void butcher_submenu( const std::vector &corpses, in }; const bool enough_light = g->u.fine_detail_vision_mod() <= 4; - const int factor = g->u.max_quality( quality_id( "BUTCHER" ) ); + const int factor = g->u.max_quality( qual_BUTCHER ); const std::string msgFactor = factor > INT_MIN ? string_format( _( "Your best tool has %d butchering." ), factor ) : _( "You have no butchering tool." ); - const int factorD = g->u.max_quality( quality_id( "CUT_FINE" ) ); + const int factorD = g->u.max_quality( qual_CUT_FINE ); const std::string msgFactorD = factorD > INT_MIN ? string_format( _( "Your best tool has %d fine cutting." ), factorD ) : _( "You have no fine cutting tool." ); @@ -7966,25 +7912,25 @@ static void butcher_submenu( const std::vector &corpses, in smenu.query(); switch( smenu.ret ) { case BUTCHER: - g->u.assign_activity( activity_id( "ACT_BUTCHER" ), 0, true ); + g->u.assign_activity( ACT_BUTCHER, 0, true ); break; case BUTCHER_FULL: - g->u.assign_activity( activity_id( "ACT_BUTCHER_FULL" ), 0, true ); + g->u.assign_activity( ACT_BUTCHER_FULL, 0, true ); break; case F_DRESS: - g->u.assign_activity( activity_id( "ACT_FIELD_DRESS" ), 0, true ); + g->u.assign_activity( ACT_FIELD_DRESS, 0, true ); break; case SKIN: - g->u.assign_activity( activity_id( "ACT_SKIN" ), 0, true ); + g->u.assign_activity( ACT_SKIN, 0, true ); break; case QUARTER: - g->u.assign_activity( activity_id( "ACT_QUARTER" ), 0, true ); + g->u.assign_activity( ACT_QUARTER, 0, true ); break; case DISMEMBER: - g->u.assign_activity( activity_id( "ACT_DISMEMBER" ), 0, true ); + g->u.assign_activity( ACT_DISMEMBER, 0, true ); break; case DISSECT: - g->u.assign_activity( activity_id( "ACT_DISSECT" ), 0, true ); + g->u.assign_activity( ACT_DISSECT, 0, true ); break; default: return; @@ -7999,13 +7945,13 @@ void game::butcher() return; } - const int factor = u.max_quality( quality_id( "BUTCHER" ) ); - const int factorD = u.max_quality( quality_id( "CUT_FINE" ) ); + const int factor = u.max_quality( qual_BUTCHER ); + const int factorD = u.max_quality( qual_CUT_FINE ); const std::string no_knife_msg = _( "You don't have a butchering tool." ); 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( flag_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 ) { @@ -8204,7 +8150,7 @@ void game::butcher() case BUTCHER_OTHER: switch( indexer_index ) { case MULTISALVAGE: - u.assign_activity( activity_id( "ACT_LONGSALVAGE" ), 0, salvage_tool_index ); + u.assign_activity( ACT_LONGSALVAGE, 0, salvage_tool_index ); break; case MULTIBUTCHER: butcher_submenu( corpses ); @@ -8252,7 +8198,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) item *it = loc.get_item(); // bows etc do not need to reload. select favorite ammo for them instead - if( it->has_flag( "RELOAD_AND_SHOOT" ) ) { + if( it->has_flag( flag_RELOAD_AND_SHOOT ) ) { item::reload_option opt = u.select_ammo( *it, prompt ); if( !opt ) { return; @@ -8295,7 +8241,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) } bool use_loc = true; - if( !it->has_flag( "ALLOWS_REMOTE_USE" ) ) { + if( !it->has_flag( flag_ALLOWS_REMOTE_USE ) ) { it = &u.i_at( loc.obtain( u ) ); use_loc = false; } @@ -8329,7 +8275,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) moves += 2500; } - u.assign_activity( activity_id( "ACT_RELOAD" ), moves, opt.qty() ); + u.assign_activity( ACT_RELOAD, moves, opt.qty() ); if( use_loc ) { u.activity.targets.emplace_back( loc ); } else { @@ -8717,11 +8663,12 @@ std::vector game::get_dangerous_tile( const tripoint &dest_loc ) co return u.immune_to( bp, { DT_CUT, 10 } ); }; - if( m.has_flag( "ROUGH", dest_loc ) && !m.has_flag( "ROUGH", u.pos() ) && !boardable && + if( m.has_flag( flag_ROUGH, dest_loc ) && !m.has_flag( flag_ROUGH, u.pos() ) && !boardable && ( u.get_armor_bash( bp_foot_l ) < 5 || u.get_armor_bash( bp_foot_r ) < 5 ) ) { 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 || - g->m.veh_at( dest_loc ) ) && + } else if( m.has_flag( flag_SHARP, dest_loc ) && !m.has_flag( flag_SHARP, u.pos() ) && + !( u.in_vehicle || + g->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 ) ); } @@ -8924,8 +8871,8 @@ bool game::walk_move( const tripoint &dest_loc ) // 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( flag_FUNGUS, u.pos() ) || + m.has_flag_ter_or_furn( flag_FUNGUS, dest_loc ); //fungal furniture has no slowing effect on mycus characters const bool slowed = ( ( !u.has_trait( trait_PARKOUR ) && ( mcost_to > 2 || mcost_from > 2 ) ) || mcost_to > 4 || mcost_from > 4 ) && @@ -8952,7 +8899,7 @@ bool game::walk_move( const tripoint &dest_loc ) } } } - if( !u.is_mounted() && u.has_trait( trait_id( "LEG_TENT_BRACE" ) ) && + if( !u.is_mounted() && u.has_trait( trait_LEG_TENT_BRACE ) && ( !u.footwear_factor() || ( u.footwear_factor() == .5 && one_in( 2 ) ) ) ) { // DX and IN are long suits for Cephalopods, @@ -8962,18 +8909,18 @@ bool game::walk_move( const tripoint &dest_loc ) ///\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( flag_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 ); } } - if( !u.has_artifact_with( AEP_STEALTH ) && !u.has_trait( trait_id( "DEBUG_SILENT" ) ) ) { + if( !u.has_artifact_with( AEP_STEALTH ) && !u.has_trait( trait_DEBUG_SILENT ) ) { int volume = u.is_stealthy() ? 3 : 6; volume *= u.mutation_value( "noise_modifier" ); if( volume > 0 ) { if( u.is_wearing( "rm13_armor_on" ) ) { volume = 2; - } else if( u.has_bionic( bionic_id( "bio_ankles" ) ) ) { + } else if( u.has_bionic( bio_ankles ) ) { volume = 12; } if( u.movement_mode_is( CMM_RUN ) ) { @@ -9077,22 +9024,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( flag_ROUGH, dest_loc ) && ( !u.in_vehicle ) && ( !u.is_mounted() ) ) { if( one_in( 5 ) && u.get_armor_bash( bp_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( flag_ROUGH, dest_loc ) ? m.tername( dest_loc ) : m.furnname( dest_loc ) ); u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_CUT, 1 ) ); } if( one_in( 5 ) && u.get_armor_bash( bp_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( flag_ROUGH, dest_loc ) ? m.tername( dest_loc ) : m.furnname( dest_loc ) ); u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_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( flag_SHARP, dest_loc ) && !one_in( 3 ) && !x_in_y( 1 + u.dex_cur / 2.0, 40 ) && ( !u.in_vehicle && !g->m.veh_at( dest_loc ) ) && ( !u.has_trait( trait_PARKOUR ) || one_in( 4 ) ) ) { if( u.is_mounted() ) { @@ -9104,7 +9051,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( flag_SHARP, dest_loc ) ? m.tername( dest_loc ) : m.furnname( dest_loc ) ); if( ( u.has_trait( trait_INFRESIST ) ) && ( one_in( 1024 ) ) ) { u.add_effect( effect_tetanus, 1_turns, num_bp, true ); @@ -9115,7 +9062,7 @@ point game::place_player( const tripoint &dest_loc ) } } } - if( m.has_flag( "UNSTABLE", dest_loc ) && !u.is_mounted() ) { + if( m.has_flag( flag_UNSTABLE, dest_loc ) && !u.is_mounted() ) { u.add_effect( effect_bouldering, 1_turns, num_bp, true ); } else if( u.has_effect( effect_bouldering ) ) { u.remove_effect( effect_bouldering ); @@ -9127,7 +9074,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( flag_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() ) { @@ -9231,7 +9178,7 @@ point game::place_player( const tripoint &dest_loc ) } const std::string pulp_butcher = get_option( "AUTO_PULP_BUTCHER" ); - if( pulp_butcher == "butcher" && u.max_quality( quality_id( "BUTCHER" ) ) > INT_MIN ) { + if( pulp_butcher == "butcher" && u.max_quality( qual_BUTCHER ) > INT_MIN ) { std::vector corpses; for( item &it : m.i_at( u.pos() ) ) { @@ -9239,7 +9186,7 @@ point game::place_player( const tripoint &dest_loc ) } if( !corpses.empty() ) { - u.assign_activity( activity_id( "ACT_BUTCHER" ), 0, true ); + u.assign_activity( ACT_BUTCHER, 0, true ); for( item *it : corpses ) { u.activity.targets.emplace_back( map_cursor( u.pos() ), it ); } @@ -9249,7 +9196,7 @@ point game::place_player( const tripoint &dest_loc ) for( const auto &maybe_corpse : m.i_at( pos ) ) { if( maybe_corpse.is_corpse() && maybe_corpse.can_revive() && !maybe_corpse.get_mtype()->bloodType().obj().has_acid ) { - u.assign_activity( activity_id( "ACT_PULP" ), calendar::INDEFINITELY_LONG, 0 ); + u.assign_activity( ACT_PULP, calendar::INDEFINITELY_LONG, 0 ); u.activity.placement = g->m.getabs( pos ); u.activity.auto_resume = true; u.activity.str_values.push_back( "auto_pulp_no_acid" ); @@ -9289,12 +9236,12 @@ 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() ) && !u.is_mounted() ) { + if( m.has_flag( flag_SWIMMABLE, u.pos() ) && !u.is_mounted() ) { u.drench( 40, { { bp_foot_l, bp_foot_r, bp_leg_l, bp_leg_r } }, false ); } // List items here - if( !m.has_flag( "SEALED", u.pos() ) ) { + if( !m.has_flag( flag_SEALED, u.pos() ) ) { if( get_option( "NO_AUTO_PICKUP_ZONES_LIST_ITEMS" ) || !g->check_zone( zone_type_id( "NO_AUTO_PICKUP" ), u.pos() ) ) { if( u.is_blind() && !m.i_at( u.pos() ).empty() ) { @@ -9372,7 +9319,7 @@ point game::place_player( const tripoint &dest_loc ) if( ( vp1.part_with_feature( "CONTROL_ANIMAL", true ) || vp1.part_with_feature( "CONTROLS", true ) ) && u.in_vehicle && !u.is_mounted() ) { add_msg( _( "There are vehicle controls here." ) ); - if( !u.has_trait( trait_id( "WAYFARER" ) ) ) { + if( !u.has_trait( trait_WAYFARER ) ) { add_msg( m_info, _( "%s to drive." ), press_x( ACTION_CONTROL_VEHICLE ) ); } } else if( vp1.part_with_feature( "CONTROLS", true ) && u.in_vehicle && @@ -9421,7 +9368,7 @@ void game::place_player_overmap( const tripoint &om_dest ) bool game::phasing_move( const tripoint &dest_loc ) { - if( !u.has_active_bionic( bionic_id( "bio_probability_travel" ) ) || + if( !u.has_active_bionic( bio_probability_travel ) || u.get_power_level() < 250_kJ ) { return false; } @@ -9442,7 +9389,8 @@ bool game::phasing_move( const tripoint &dest_loc ) //add 1 to tunnel distance for each impassable tile in the line tunneldist += 1; //Being dimensionally anchored prevents quantum shenanigans. - if( u.worn_with_flag( "DIMENSIONAL_ANCHOR" ) || u.has_effect_with_flag( "DIMENSIONAL_ANCHOR" ) ) { + if( u.worn_with_flag( flag_DIMENSIONAL_ANCHOR ) || + u.has_effect_with_flag( flag_DIMENSIONAL_ANCHOR ) ) { u.add_msg_if_player( m_info, _( "You are repelled by the barrier!" ) ); u.mod_power_level( -250_kJ ); //cost of tunneling one tile. return false; @@ -9529,13 +9477,13 @@ bool game::grabbed_furn_move( const tripoint &dp ) return liquid_item.made_of_from_type( 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( flag_NOITEM, fdest ) && + !m.has_flag( flag_SWIMMABLE, fdest ) && + !m.has_flag( flag_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" ); + const bool src_item_ok = m.furn( fpos ).obj().has_flag( flag_CONTAINER ) || + m.furn( fpos ).obj().has_flag( flag_FIRE_CONTAINER ) || + m.furn( fpos ).obj().has_flag( flag_SEALED ); const int fire_intensity = m.get_field_intensity( fpos, fd_fire ); time_duration fire_age = m.get_field_age( fpos, fd_fire ); @@ -9698,7 +9646,7 @@ void game::on_move_effects() } } - if( u.has_active_bionic( bionic_id( "bio_jointservo" ) ) ) { + if( u.has_active_bionic( bio_jointservo ) ) { if( u.movement_mode_is( CMM_RUN ) ) { u.mod_power_level( -55_J ); } else { @@ -9837,7 +9785,7 @@ void game::fling_creature( Creature *c, const int &dir, float flvel, bool contro } // Fall down to the ground - always on the last reached tile - if( !m.has_flag( "SWIMMABLE", c->pos() ) ) { + if( !m.has_flag( flag_SWIMMABLE, c->pos() ) ) { const trap_id trap_under_creature = m.tr_at( c->pos() ).loadid; // Didn't smash into a wall or a floor so only take the fall damage if( thru && trap_under_creature == tr_ledge ) { @@ -9914,13 +9862,13 @@ void game::vertical_move( int movez, bool force ) } // > and < are used for diving underwater. - if( m.has_flag( "SWIMMABLE", u.pos() ) && m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { + if( m.has_flag( flag_SWIMMABLE, u.pos() ) && m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { if( movez == -1 ) { if( u.is_underwater() ) { add_msg( m_info, _( "You are already underwater!" ) ); return; } - if( u.worn_with_flag( "FLOTATION" ) ) { + if( u.worn_with_flag( flag_FLOTATION ) ) { add_msg( m_info, _( "You can't dive while wearing a flotation device." ) ); return; } @@ -10095,7 +10043,7 @@ void game::vertical_move( int movez, bool force ) for( monster &critter : all_monsters() ) { // if its a ladder instead of stairs - most zombies cant climb that. // unless that have a special flag to allow them to do so. - if( ( m.has_flag( "DIFFICULT_Z", u.pos() ) && !critter.climbs() ) || + if( ( m.has_flag( flag_DIFFICULT_Z, u.pos() ) && !critter.climbs() ) || critter.has_effect( effect_ridden ) || critter.has_effect( effect_tied ) ) { continue; @@ -10127,7 +10075,7 @@ void game::vertical_move( int movez, bool force ) } if( m.has_zlevels() && abs( movez ) == 1 ) { - bool ladder = m.has_flag( "DIFFICULT_Z", u.pos() ); + bool ladder = m.has_flag( flag_DIFFICULT_Z, u.pos() ); for( monster &critter : all_monsters() ) { if( ladder && !critter.climbs() ) { continue; @@ -10242,7 +10190,7 @@ void game::vertical_move( int movez, bool force ) void game::start_hauling( const tripoint &pos ) { - u.assign_activity( activity_id( "ACT_MOVE_ITEMS" ) ); + u.assign_activity( ACT_MOVE_ITEMS ); // Whether the destination is inside a vehicle (not supported) u.activity.values.push_back( 0 ); // Destination relative to the player @@ -10280,8 +10228,8 @@ cata::optional game::find_or_make_stairs( map &mp, const int z_after, Creature *blocking_creature = nullptr; for( const tripoint &dest : m.points_in_rectangle( omtile_align_start, omtile_align_end ) ) { if( rl_dist( u.pos(), dest ) <= best && - ( ( movez == -1 && mp.has_flag( "GOES_UP", dest ) ) || - ( movez == 1 && ( mp.has_flag( "GOES_DOWN", dest ) || + ( ( movez == -1 && mp.has_flag( flag_GOES_UP, dest ) ) || + ( movez == 1 && ( mp.has_flag( flag_GOES_DOWN, dest ) || mp.ter( dest ) == t_manhole_cover ) ) || ( ( movez == 2 || movez == -2 ) && mp.ter( dest ) == t_elevator ) ) ) { if( mp.has_zlevels() && critter_at( dest ) ) { @@ -10322,7 +10270,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( flag_GOES_DOWN, *stairs ) ) { if( !query_yn( _( "You may be unable to return back down these stairs. Continue up?" ) ) ) { return cata::nullopt; } @@ -10337,7 +10285,7 @@ cata::optional game::find_or_make_stairs( map &mp, const int z_after, return cata::nullopt; } - if( u.has_trait( trait_id( "WEB_RAPPEL" ) ) ) { + if( u.has_trait( trait_WEB_RAPPEL ) ) { if( query_yn( _( "There is a sheer drop halfway down. Web-descend?" ) ) ) { rope_ladder = true; if( ( rng( 4, 8 ) ) < u.get_skill_level( skill_dodge ) ) { @@ -10639,8 +10587,8 @@ void game::update_stair_monsters() } 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( flag_GOES_DOWN, dest ) ) || + ( !from_below && m.has_flag( flag_GOES_UP, dest ) ) ) { stairx.push_back( dest.x ); stairy.push_back( dest.y ); stairdist.push_back( rl_dist( dest, u.pos() ) ); @@ -10916,8 +10864,8 @@ void game::perhaps_add_random_npc() new_fac_id += tmp->name; // create a new "lone wolf" faction for this one NPC faction *new_solo_fac = faction_manager_ptr->add_new_faction( tmp->name, faction_id( new_fac_id ), - faction_id( "no_faction" ) ); - tmp->set_fac( new_solo_fac ? new_solo_fac->id : faction_id( "no_faction" ) ); + no_faction ); + tmp->set_fac( new_solo_fac ? new_solo_fac->id : no_faction ); // adds the npc to the correct overmap. tripoint submap_spawn = omt_to_sm_copy( spawn_point ); tmp->spawn_at_sm( submap_spawn.x, submap_spawn.y, 0 ); @@ -11429,26 +11377,26 @@ bool check_art_charge_req( item &it ) void game::start_calendar() { - const bool scen_season = scen->has_flag( "SPR_START" ) || scen->has_flag( "SUM_START" ) || - scen->has_flag( "AUT_START" ) || scen->has_flag( "WIN_START" ) || - scen->has_flag( "SUM_ADV_START" ); + const bool scen_season = scen->has_flag( flag_SPR_START ) || scen->has_flag( flag_SUM_START ) || + scen->has_flag( flag_AUT_START ) || scen->has_flag( flag_WIN_START ) || + scen->has_flag( flag_SUM_ADV_START ); if( scen_season ) { // Configured starting date overridden by scenario, calendar::start is left as Spring 1 calendar::start_of_cataclysm = calendar::turn_zero + 1_hours * get_option( "INITIAL_TIME" ); calendar::turn = calendar::turn_zero + 1_hours * get_option( "INITIAL_TIME" ); - if( scen->has_flag( "SPR_START" ) ) { + if( scen->has_flag( flag_SPR_START ) ) { calendar::initial_season = SPRING; - } else if( scen->has_flag( "SUM_START" ) ) { + } else if( scen->has_flag( flag_SUM_START ) ) { calendar::initial_season = SUMMER; calendar::turn += calendar::season_length(); - } else if( scen->has_flag( "AUT_START" ) ) { + } else if( scen->has_flag( flag_AUT_START ) ) { calendar::initial_season = AUTUMN; calendar::turn += calendar::season_length() * 2; - } else if( scen->has_flag( "WIN_START" ) ) { + } else if( scen->has_flag( flag_WIN_START ) ) { calendar::initial_season = WINTER; calendar::turn += calendar::season_length() * 3; - } else if( scen->has_flag( "SUM_ADV_START" ) ) { + } else if( scen->has_flag( flag_SUM_ADV_START ) ) { calendar::initial_season = SUMMER; calendar::turn += calendar::season_length() * 5; } else {