From 5fa9146f831fcdd4706c189b14938fba27fdde8b Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Tue, 25 Feb 2020 20:00:09 +0000 Subject: [PATCH] Revert string centralization (#38321) * Revert "Moved more string consts into single file (#38237)" This reverts commit 49877426cedcb73c7c852c2e4b61dd0320dc5288. * Revert "Moved more string consts into single file (#38220)" This reverts commit d9c6079762217e8a13caeeb76bc1dc9bc752bd84. * Revert "Move string consts into single file (#38195)" This reverts commit b1b48badff60f3c3ba85d4a3683ac2f38fa2b4ed. * Revert "More string consts into single file (#38189)" This reverts commit 4fffd961436b09a5069fd003f4542b78cbce6a5e. * Revert "More string consts into single file (#38183)" This reverts commit 05940bfe3aa1c95c10dc2df49bb2b7a88f23b039. * Revert "Move string consts into single file (#38184)" This reverts commit 19c569826b96f948387d486ea5452985a1ccef1b. * Revert "Move string consts into single file (#38181)" This reverts commit 55cabb794cc7812cba36fb84a893d971dafcf6de. * Revert "Move more string consts into single file (#38175)" This reverts commit 571efb2f8ea22a7a277af2c0cd0621ead2e82fe1. * Revert "Merge pull request #38176 from Ramza13/string_consts_and_more" This reverts commit 9c9835ff081ac75dd73cf3f1ad4c8e4517cd04a9, reversing changes made to 07995cdda539d56aca5a70b73647c4b37ca0925e. * Revert "Move more string consts into single file (#38169)" This reverts commit 07995cdda539d56aca5a70b73647c4b37ca0925e. * Revert "Merge pull request #38168 from Ramza13/even_more_string_consts" This reverts commit 2bf1c1ea18e193f6b1141646c0c6eb72ca24507d, reversing changes made to 24a32c0d1adcb0c223db34421dcd98f15f5a606a. * Revert "Merge pull request #38141 from ZhilkinSerg/sa-2020-02-18" This reverts commit 142295b1dcec10d738326341dcbdabe0fb9fc81e, reversing changes made to f98c67d3c3dd5b19196938a4d8516f5faf069a28. * Revert "Move string consts into single file (#38158)" This reverts commit 50059c8a247e254754008c3ea56f9dcc65d1e8dc. * Revert "Merge pull request #38157 from Ramza13/string_consts_more_flags" This reverts commit 8ec8e78959d7ffb9c5b9b3c01962261ef93db8d0, reversing changes made to 72ef0222a007e067ca4cb9bd6e8a366a9ddc2109. * Revert "Move string_consts" This reverts commit 0a6bf67436fc51f980ddff6d62703dd71ad36cf6. * Revert "Merge pull request #38146 from Ramza13/battery" This reverts commit 9286722b7448888268383770eef1e6ea95b02c25, reversing changes made to e9f1cd7787cef325119e70d6beb26f22700369c1. * Revert "Merge pull request #38134 from AMurkin/rename-blob" This reverts commit 06f72d2b7dae185bfee81df6c15cee6a9d92ec80, reversing changes made to bcfe0741e1a520f2d92e694c09cac08069268d80. * Revert "Yet more string consts moved out (#38130)" This reverts commit b5f18f3574c3a28c396f42d2b827b785a9bdd603. * Revert "Merge pull request #38115 from Ramza13/string_consts_game" This reverts commit 98076577b0b44e25185f5200a83b0705b4dbe18e, reversing changes made to 036465f51720df3142b6e4930474f0ff080cfa13. * Fixup to the picked_up * RE-inline item_location initialization * Update character.h * Update item.cpp * Update item.h * Update item_action.cpp * Update item_factory.cpp * Update point.h * Update safemode_ui.cpp --- src/action.cpp | 6 +- src/activity_handlers.cpp | 42 +-- src/activity_item_handling.cpp | 72 +++-- src/advanced_inv_area.cpp | 7 +- src/advanced_inv_listitem.h | 1 + src/ammo.h | 4 +- src/armor_layers.cpp | 2 +- src/artifact.cpp | 41 ++- src/avatar.cpp | 2 +- src/avatar_action.cpp | 8 +- src/basecamp.cpp | 2 +- src/basecamp.h | 2 + src/bionics.cpp | 2 +- src/bionics.h | 2 + src/cata_string_consts.h | 493 ++++-------------------------- src/cata_tiles.cpp | 2 +- src/cata_tiles.h | 2 + src/cata_variant.h | 2 + src/character.cpp | 165 +++++----- src/character_martial_arts.cpp | 2 + src/character_martial_arts.h | 2 + src/clzones.cpp | 94 +++--- src/computer_session.cpp | 4 +- src/construction.cpp | 5 +- src/consumption.cpp | 14 +- src/crafting.cpp | 10 +- src/creature.cpp | 14 +- src/debug_menu.cpp | 4 +- src/dump.cpp | 2 +- src/editmap.cpp | 5 +- src/event.h | 2 + src/explosion.cpp | 6 +- src/explosion.h | 2 +- src/faction.cpp | 9 +- src/faction_camp.cpp | 2 +- src/fungal_effects.cpp | 2 +- src/game.cpp | 338 +++++++++++--------- src/game.h | 1 + src/game_inventory.cpp | 4 +- src/gamemode_defense.h | 2 + src/handle_action.cpp | 37 +-- src/handle_liquid.cpp | 5 +- src/harvest.h | 1 + src/iexamine.cpp | 50 +-- src/inventory.cpp | 68 ++--- src/inventory_ui.cpp | 6 +- src/item.cpp | 24 +- src/item.h | 1 + src/item_factory.cpp | 57 ++-- src/item_location.cpp | 2 +- src/itype.h | 2 + src/iuse.cpp | 66 ++-- src/iuse.h | 4 +- src/iuse_actor.cpp | 54 ++-- src/iuse_actor.h | 52 ++-- src/lightmap.cpp | 8 +- src/magic_spell_effect.cpp | 5 +- src/magic_teleporter_list.cpp | 3 +- src/map.cpp | 253 +++++++-------- src/map.h | 1 + src/map_extras.cpp | 4 +- src/map_field.cpp | 18 +- src/mapdata.cpp | 2 +- src/mapdata.h | 2 + src/mapgen.cpp | 60 ++-- src/mapgen_functions.cpp | 18 +- src/martialarts.cpp | 2 +- src/material.h | 1 + src/melee.cpp | 164 ++++++---- src/mission_start.cpp | 4 +- src/monattack.cpp | 53 ++-- src/mondeath.cpp | 26 +- src/monexamine.cpp | 14 +- src/monmove.cpp | 56 ++-- src/monster.cpp | 50 +-- src/monstergenerator.cpp | 3 +- src/morale.cpp | 6 +- src/mtype.cpp | 32 +- src/mtype.h | 2 + src/mutation.cpp | 6 +- src/mutation.h | 1 + src/newcharacter.cpp | 53 ++-- src/npc.cpp | 28 +- src/npc_favor.h | 1 + src/npcmove.cpp | 30 +- src/npctalk.cpp | 6 +- src/npctalk_funcs.cpp | 6 +- src/npctrade.cpp | 4 +- src/overmap.cpp | 6 +- src/overmap_ui.cpp | 4 +- src/panels.cpp | 2 +- src/pathfinding.cpp | 5 +- src/pickup.cpp | 12 +- src/player.cpp | 199 ++++++------ src/player.h | 1 + src/player_activity.cpp | 2 +- src/player_activity.h | 2 + src/player_hardcoded_effects.cpp | 4 +- src/profession.cpp | 3 +- src/profession.h | 1 + src/ranged.cpp | 22 +- src/recipe.cpp | 9 +- src/recipe.h | 1 + src/recipe_dictionary.h | 2 + src/requirements.cpp | 2 +- src/requirements.h | 3 + src/savegame_json.cpp | 56 ++-- src/savegame_legacy.cpp | 83 +++-- src/scenario.cpp | 5 +- src/sdltiles.cpp | 13 +- src/sounds.cpp | 194 ++++++------ src/start_location.cpp | 13 +- src/string_id.h | 2 + src/submap.cpp | 5 +- src/suffer.cpp | 20 +- src/teleport.cpp | 8 +- src/trap.h | 3 + src/trapfunc.cpp | 10 +- src/turret.cpp | 26 +- src/type_id.h | 5 - src/uistate.h | 2 + src/veh_interact.cpp | 122 ++++---- src/veh_type.cpp | 35 ++- src/veh_type.h | 2 + src/vehicle.cpp | 391 ++++++++++++------------ src/vehicle_display.cpp | 7 +- src/vehicle_move.cpp | 16 +- src/vehicle_part.cpp | 6 +- src/vehicle_use.cpp | 161 +++++----- src/visitable.cpp | 12 +- src/weather.cpp | 14 +- tests/bionics_test.cpp | 7 +- tests/comestible_test.cpp | 3 +- tests/encumbrance_test.cpp | 5 +- tests/memorial_test.cpp | 15 +- tests/npc_test.cpp | 7 +- tests/reload_option_test.cpp | 3 +- tests/reloading_test.cpp | 3 +- tests/stomach_contents_test.cpp | 27 +- tests/vehicle_drag_test.cpp | 7 +- tests/vehicle_efficiency_test.cpp | 25 +- tests/vehicle_part_test.cpp | 3 +- tests/vehicle_test.cpp | 3 +- tests/vehicle_turrets_test.cpp | 7 +- tests/visitable_remove_test.cpp | 3 +- 145 files changed, 2041 insertions(+), 2300 deletions(-) diff --git a/src/action.cpp b/src/action.cpp index f0597db91ff64..1ddec702f445c 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -579,8 +579,8 @@ int hotkey_for_action( action_id action, const bool restrict_to_printable ) bool can_butcher_at( const tripoint &p ) { // TODO: unify this with game::butcher - const int factor = g->u.max_quality( quality_BUTCHER ); - const int factorD = g->u.max_quality( quality_CUT_FINE ); + const int factor = g->u.max_quality( qual_BUTCHER ); + const int factorD = g->u.max_quality( qual_CUT_FINE ); auto items = g->m.i_at( p ); bool has_item = false; bool has_corpse = false; @@ -650,7 +650,7 @@ static bool can_pickup_at( const tripoint &p ) bool veh_has_items = false; const optional_vpart_position vp = g->m.veh_at( p ); if( vp ) { - const int cargo_part = vp->vehicle().part_with_feature( vp->part_index(), flag_CARGO, false ); + const int cargo_part = vp->vehicle().part_with_feature( vp->part_index(), "CARGO", false ); veh_has_items = cargo_part >= 0 && !vp->vehicle().get_items( cargo_part ).empty(); } return g->m.has_items( p ) || veh_has_items; diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index cb9f9f0fec17f..89f3b1cac29d2 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -370,7 +370,7 @@ static void butcher_cbm_group( const std::string &group, const tripoint &pos, static void set_up_butchery( player_activity &act, player &u, butcher_type action ) { - const int factor = u.max_quality( action == DISSECT ? quality_CUT_FINE : quality_BUTCHER ); + const int factor = u.max_quality( action == DISSECT ? qual_CUT_FINE : qual_BUTCHER ); const item &corpse_item = *act.targets.back(); const mtype &corpse = *corpse_item.get_mtype(); @@ -446,7 +446,7 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio act.targets.pop_back(); return; } - if( !( u.has_quality( quality_SAW_W ) || u.has_quality( quality_SAW_M ) ) ) { + if( !( u.has_quality( qual_SAW_W ) || u.has_quality( qual_SAW_M ) ) ) { u.add_msg_if_player( m_info, _( "For a corpse this big you need a saw to perform a full butchery." ) ); act.targets.pop_back(); @@ -498,11 +498,11 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio } // applies to all butchery actions - const bool is_human = corpse.id == mtype_id::NULL_ID() || ( corpse.in_species( species_HUMAN ) && - !corpse.in_species( species_ZOMBIE ) ); - if( is_human && !( u.has_trait_flag( flag_CANNIBAL ) || - u.has_trait_flag( flag_PSYCHOPATH ) || - u.has_trait_flag( flag_SAPIOVORE ) ) ) { + const bool is_human = corpse.id == mtype_id::NULL_ID() || ( corpse.in_species( HUMAN ) && + !corpse.in_species( ZOMBIE ) ); + if( is_human && !( u.has_trait_flag( trait_flag_CANNIBAL ) || + u.has_trait_flag( trait_flag_PSYCHOPATH ) || + u.has_trait_flag( trait_flag_SAPIOVORE ) ) ) { if( u.is_player() ) { if( query_yn( _( "Would you dare desecrate the mortal remains of a fellow human being?" ) ) ) { @@ -539,7 +539,7 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio int butcher_time_to_cut( const player &u, const item &corpse_item, const butcher_type action ) { const mtype &corpse = *corpse_item.get_mtype(); - const int factor = u.max_quality( action == DISSECT ? quality_CUT_FINE : quality_BUTCHER ); + const int factor = u.max_quality( action == DISSECT ? qual_CUT_FINE : qual_BUTCHER ); int time_to_cut = 0; switch( corpse.size ) { @@ -1038,13 +1038,13 @@ void activity_handlers::butcher_finish( player_activity *act, player *p ) } int skill_level = p->get_skill_level( skill_survival ); - int factor = p->max_quality( action == DISSECT ? quality_CUT_FINE : - quality_BUTCHER ); + int factor = p->max_quality( action == DISSECT ? qual_CUT_FINE : + qual_BUTCHER ); // DISSECT has special case factor calculation and results. if( action == DISSECT ) { skill_level = p->get_skill_level( skill_firstaid ); - skill_level += p->max_quality( quality_CUT_FINE ); + skill_level += p->max_quality( qual_CUT_FINE ); skill_level += p->get_skill_level( skill_electronics ) / 2; add_msg( m_debug, _( "Skill: %s" ), skill_level ); } @@ -1166,7 +1166,7 @@ void activity_handlers::butcher_finish( player_activity *act, player *p ) _( "You did something wrong and hacked the corpse badly. Maybe it's still recoverable." ) ); break; } - corpse_item.set_flag( flag_FIELD_DRESS_FAILED ); + corpse_item.set_flag( "FIELD_DRESS_FAILED" ); g->m.add_splatter( type_gib, p->pos(), rng( corpse->size + 2, ( corpse->size + 1 ) * 2 ) ); g->m.add_splatter( type_blood, p->pos(), rng( corpse->size + 2, ( corpse->size + 1 ) * 2 ) ); @@ -1504,19 +1504,19 @@ void activity_handlers::forage_finish( player_activity *act, player *p ) switch( season_of_year( calendar::turn ) ) { case SPRING: loc = "forage_spring"; - next_ter = ter_underbrush_harvested_spring; + next_ter = ter_str_id( "t_underbrush_harvested_spring" ); break; case SUMMER: loc = "forage_summer"; - next_ter = ter_underbrush_harvested_summer; + next_ter = ter_str_id( "t_underbrush_harvested_summer" ); break; case AUTUMN: loc = "forage_autumn"; - next_ter = ter_underbrush_harvested_autumn; + next_ter = ter_str_id( "t_underbrush_harvested_autumn" ); break; case WINTER: loc = "forage_winter"; - next_ter = ter_underbrush_harvested_winter; + next_ter = ter_str_id( "t_underbrush_harvested_winter" ); break; default: debugmsg( "Invalid season" ); @@ -2362,7 +2362,7 @@ struct weldrig_hack { return false; } - part = veh->part_with_feature( part, flag_WELDRIG, true ); + part = veh->part_with_feature( part, "WELDRIG", true ); return part >= 0; } @@ -2559,7 +2559,7 @@ void activity_handlers::heat_item_finish( player_activity *act, player *p ) return; } item &target = *heat->get_food(); - if( target.item_tags.count( flag_FROZEN ) ) { + if( target.item_tags.count( "FROZEN" ) ) { target.apply_freezerburn(); if( target.has_flag( flag_EATEN_COLD ) ) { target.cold_up(); @@ -2696,7 +2696,7 @@ void activity_handlers::toolmod_add_finish( player_activity *act, player *p ) item &mod = *act->targets[1]; p->add_msg_if_player( m_good, _( "You successfully attached the %1$s to your %2$s." ), mod.tname(), tool.tname() ); - mod.item_tags.insert( flag_IRREMOVABLE ); + mod.item_tags.insert( "IRREMOVABLE" ); tool.contents.push_back( mod ); act->targets[1].remove_item(); } @@ -2860,7 +2860,7 @@ static void rod_fish( player *p, std::vector &fishables ) //if the vector is empty (no fish around) the player is still given a small chance to get a (let us say it was hidden) fish if( fishables.empty() ) { const std::vector fish_group = MonsterGroupManager::GetMonstersFromGroup( - GROUP_FISH ); + mongroup_id( "GROUP_FISH" ) ); const mtype_id fish_mon = random_entry_ref( fish_group ); g->m.add_item_or_charges( p->pos(), item::make_corpse( fish_mon, calendar::turn + rng( 0_turns, 3_hours ) ) ); @@ -3867,7 +3867,7 @@ void activity_handlers::dig_finish( player_activity *act, player *p ) g->m.place_items( "jewelry_front", 20, pos, pos, false, calendar::turn ); for( const auto &it : dropped ) { if( it->is_armor() ) { - it->item_tags.insert( flag_FILTHY ); + it->item_tags.insert( "FILTHY" ); it->set_damage( rng( 1, it->max_damage() - 1 ) ); } } diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index e542aef712239..38cf6f12711ab 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -326,8 +326,7 @@ void put_into_vehicle_or_drop( Character &c, item_drop_reason reason, const std: void put_into_vehicle_or_drop( Character &c, item_drop_reason reason, const std::list &items, const tripoint &where, bool force_ground ) { - const cata::optional vp = g->m.veh_at( where ).part_with_feature( flag_CARGO, - false ); + const cata::optional vp = g->m.veh_at( where ).part_with_feature( "CARGO", false ); if( vp && !force_ground ) { put_into_vehicle( c, reason, items, vp->vehicle(), vp->part_index() ); return; @@ -632,7 +631,7 @@ void activity_handlers::washing_finish( player_activity *act, player *p ) for( const auto &ait : items ) { item *filthy_item = const_cast( &*ait.loc ); - filthy_item->item_tags.erase( flag_FILTHY ); + filthy_item->item_tags.erase( "FILTHY" ); p->on_worn_item_washed( *filthy_item ); } @@ -884,7 +883,7 @@ static int move_cost( const item &it, const tripoint &src, const tripoint &dest tripoint cart_position = g->u.pos() + g->u.grab_point; if( const cata::optional vp = g->m.veh_at( - cart_position ).part_with_feature( flag_CARGO, false ) ) { + cart_position ).part_with_feature( "CARGO", false ) ) { auto veh = vp->vehicle(); auto vstor = vp->part_index(); auto capacity = veh.free_volume( vstor ); @@ -1185,7 +1184,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, activity_to_restore == ACT_MULTIPLE_FISH; bool found_welder = false; for( item *elem : p.inv_dump() ) { - if( elem->has_quality( quality_WELD ) ) { + if( elem->has_quality( qual_WELD ) ) { found_welder = true; } temp_inv += *elem; @@ -1217,7 +1216,7 @@ static bool are_requirements_nearby( const std::vector &loot_spots, temp_inv += elem2; } if( !in_loot_zones ) { - if( const cata::optional vp = g->m.veh_at( elem ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( elem ).part_with_feature( "CARGO", false ) ) { vehicle &src_veh = vp->vehicle(); int src_part = vp->part_index(); @@ -1233,15 +1232,15 @@ static bool are_requirements_nearby( const std::vector &loot_spots, const optional_vpart_position vp = g->m.veh_at( elem ); if( vp ) { vehicle &veh = vp->vehicle(); - const cata::optional weldpart = vp.part_with_feature( flag_WELDRIG, true ); + const cata::optional weldpart = vp.part_with_feature( "WELDRIG", true ); if( weldpart ) { item welder( "welder", 0 ); - welder.charges = veh.fuel_left( fuel_type_battery, true ); - welder.item_tags.insert( flag_PSEUDO ); + welder.charges = veh.fuel_left( "battery", true ); + welder.item_tags.insert( "PSEUDO" ); temp_inv.add_item( welder ); item soldering_iron( "soldering_iron", 0 ); - soldering_iron.charges = veh.fuel_left( fuel_type_battery, true ); - soldering_iron.item_tags.insert( flag_PSEUDO ); + soldering_iron.charges = veh.fuel_left( "battery", true ); + soldering_iron.item_tags.insert( "PSEUDO" ); temp_inv.add_item( soldering_iron ); } } @@ -1401,7 +1400,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe if( act == ACT_MULTIPLE_CHOP_TREES ) { if( g->m.has_flag( flag_TREE, src_loc ) || g->m.ter( src_loc ) == t_trunk || g->m.ter( src_loc ) == t_stump ) { - if( p.has_quality( quality_AXE ) ) { + if( p.has_quality( qual_AXE ) ) { return activity_reason_info::ok( NEEDS_TREE_CHOPPING ); } else { return activity_reason_info::fail( NEEDS_TREE_CHOPPING ); @@ -1437,8 +1436,8 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe if( !b_rack_present || !g->m.has_nearby_table( src_loc, 2 ) ) { return activity_reason_info::fail( NO_ZONE ); } - if( p.has_quality( quality_id( quality_BUTCHER ), 1 ) && ( p.has_quality( quality_SAW_W ) || - p.has_quality( quality_SAW_M ) ) ) { + if( p.has_quality( quality_id( qual_BUTCHER ), 1 ) && ( p.has_quality( qual_SAW_W ) || + p.has_quality( qual_SAW_M ) ) ) { return activity_reason_info::ok( NEEDS_BIG_BUTCHERING ); } else { return activity_reason_info::fail( NEEDS_BIG_BUTCHERING ); @@ -1446,7 +1445,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe } if( ( big_count > 0 && small_count > 0 ) || ( big_count == 0 ) ) { // there are small corpses here, so we can ignore any big corpses here for the moment. - if( p.has_quality( quality_BUTCHER, 1 ) ) { + if( p.has_quality( qual_BUTCHER, 1 ) ) { return activity_reason_info::ok( NEEDS_BUTCHERING ); } else { return activity_reason_info::fail( NEEDS_BUTCHERING ); @@ -1460,7 +1459,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe for( auto &i : g->m.i_at( src_loc ) ) { if( i.typeId() == "log" ) { // do we have an axe? - if( p.has_quality( quality_AXE, 1 ) ) { + if( p.has_quality( qual_AXE, 1 ) ) { return activity_reason_info::ok( NEEDS_CHOPPING ); } else { return activity_reason_info::fail( NEEDS_CHOPPING ); @@ -1507,7 +1506,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe // simple work, pulling up plants, nothing else required. return activity_reason_info::ok( NEEDS_HARVESTING ); } else if( g->m.has_flag( flag_PLOWABLE, src_loc ) && !g->m.has_furn( src_loc ) ) { - if( p.has_quality( quality_DIG, 1 ) ) { + if( p.has_quality( qual_DIG, 1 ) ) { // we have a shovel/hoe already, great return activity_reason_info::ok( NEEDS_TILLING ); } else { @@ -1898,7 +1897,7 @@ static bool tidy_activity( player &p, const tripoint &src_loc, vehicle *dest_veh; int dest_part; if( const cata::optional vp = g->m.veh_at( - loot_src_lot ).part_with_feature( flag_CARGO, + loot_src_lot ).part_with_feature( "CARGO", false ) ) { dest_veh = &vp->vehicle(); dest_part = vp->part_index(); @@ -1938,7 +1937,7 @@ static void fetch_activity( player &p, const tripoint &src_loc, auto items_there = g->m.i_at( src_loc ); vehicle *src_veh = nullptr; int src_part = 0; - if( const cata::optional vp = g->m.veh_at( src_loc ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( src_loc ).part_with_feature( "CARGO", false ) ) { src_veh = &vp->vehicle(); src_part = vp->part_index(); @@ -2047,7 +2046,7 @@ static item *best_quality_item( player &p, const quality_id &qual ) static bool chop_plank_activity( player &p, const tripoint &src_loc ) { - item *best_qual = best_quality_item( p, quality_AXE ); + item *best_qual = best_quality_item( p, qual_AXE ); if( !best_qual ) { return false; } @@ -2143,7 +2142,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) } //nothing to sort? - const cata::optional vp = g->m.veh_at( src_loc ).part_with_feature( flag_CARGO, + const cata::optional vp = g->m.veh_at( src_loc ).part_with_feature( "CARGO", false ); if( ( !vp || vp->vehicle().get_items( vp->part_index() ).empty() ) && g->m.i_at( src_loc ).empty() ) { @@ -2214,7 +2213,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) //Check source for cargo part //map_stack and vehicle_stack are different types but inherit from item_stack // TODO: use one for loop - if( const cata::optional vp = g->m.veh_at( src_loc ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( src_loc ).part_with_feature( "CARGO", false ) ) { src_veh = &vp->vehicle(); src_part = vp->part_index(); @@ -2259,9 +2258,8 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) const tripoint &dest_loc = g->m.getlocal( dest ); //Check destination for cargo part - if( const cata::optional vp = g->m.veh_at( dest_loc ).part_with_feature( - flag_CARGO, - false ) ) { + if( const cata::optional vp = g->m.veh_at( dest_loc ).part_with_feature( "CARGO", + false ) ) { dest_veh = &vp->vehicle(); dest_part = vp->part_index(); } else { @@ -2316,7 +2314,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) static int chop_moves( player &p, item *it ) { // quality of tool - const int quality = it->get_quality( quality_AXE ); + const int quality = it->get_quality( qual_AXE ); // attribute; regular tools - based on STR, powered tools - based on DEX const int attr = it->has_flag( flag_POWERED ) ? p.dex_cur : p.str_cur; @@ -2329,7 +2327,7 @@ static int chop_moves( player &p, item *it ) static bool chop_tree_activity( player &p, const tripoint &src_loc ) { - item *best_qual = best_quality_item( p, quality_AXE ); + item *best_qual = best_quality_item( p, qual_AXE ); if( !best_qual ) { return false; } @@ -2591,21 +2589,21 @@ static bool generic_multi_activity_check_requirement( player &p, const activity_ std::vector> quality_comp_vector; std::vector> tool_comp_vector; if( reason == NEEDS_TILLING ) { - quality_comp_vector.push_back( std::vector { quality_requirement( quality_DIG, 1, 1 ) } ); + quality_comp_vector.push_back( std::vector { quality_requirement( qual_DIG, 1, 1 ) } ); } else if( reason == NEEDS_CHOPPING || reason == NEEDS_TREE_CHOPPING ) { - quality_comp_vector.push_back( std::vector { quality_requirement( quality_AXE, 1, 1 ) } ); + quality_comp_vector.push_back( std::vector { quality_requirement( qual_AXE, 1, 1 ) } ); } else if( reason == NEEDS_PLANTING ) { requirement_comp_vector.push_back( std::vector { item_comp( itype_id( dynamic_cast ( zone->get_options() ).get_seed() ), 1 ) } ); } else if( reason == NEEDS_BUTCHERING || reason == NEEDS_BIG_BUTCHERING ) { - quality_comp_vector.push_back( std::vector { quality_requirement( quality_BUTCHER, 1, 1 ) } ); + quality_comp_vector.push_back( std::vector { quality_requirement( qual_BUTCHER, 1, 1 ) } ); if( reason == NEEDS_BIG_BUTCHERING ) { - quality_comp_vector.push_back( std::vector { quality_requirement( quality_SAW_M, 1, 1 ), quality_requirement( quality_SAW_W, 1, 1 ) } ); + quality_comp_vector.push_back( std::vector { quality_requirement( qual_SAW_M, 1, 1 ), quality_requirement( qual_SAW_W, 1, 1 ) } ); } } else if( reason == NEEDS_FISHING ) { - quality_comp_vector.push_back( std::vector {quality_requirement( quality_FISHING, 1, 1 )} ); + quality_comp_vector.push_back( std::vector {quality_requirement( qual_FISHING, 1, 1 )} ); } // ok, we need a shovel/hoe/axe/etc // this is an activity that only requires this one tool, so we will fetch and wield it. @@ -2681,7 +2679,7 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, if( reason == NEEDS_HARVESTING && g->m.has_flag_furn( flag_GROWTH_HARVEST, src_loc ) ) { iexamine::harvest_plant( p, src_loc, true ); } else if( reason == NEEDS_TILLING && g->m.has_flag( flag_PLOWABLE, src_loc ) && - p.has_quality( quality_DIG, 1 ) && !g->m.has_furn( src_loc ) ) { + p.has_quality( qual_DIG, 1 ) && !g->m.has_furn( src_loc ) ) { p.assign_activity( ACT_CHURN, 18000, -1 ); p.backlog.push_front( act_id ); p.activity.placement = src; @@ -2702,7 +2700,7 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, iexamine::plant_seed( p, src_loc, itype_id( seed ) ); break; } - } else if( reason == NEEDS_CHOPPING && p.has_quality( quality_AXE, 1 ) ) { + } else if( reason == NEEDS_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { if( chop_plank_activity( p, src_loc ) ) { p.backlog.push_front( act_id ); return false; @@ -2731,16 +2729,16 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, // Because some player activities are necessarily not marked as auto-resume. activity_handlers::resume_for_multi_activities( p ); return false; - } else if( reason == NEEDS_TREE_CHOPPING && p.has_quality( quality_AXE, 1 ) ) { + } else if( reason == NEEDS_TREE_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { p.backlog.push_front( act_id ); if( chop_tree_activity( p, src_loc ) ) { return false; } - } else if( reason == NEEDS_FISHING && p.has_quality( quality_FISHING, 1 ) ) { + } else if( reason == NEEDS_FISHING && p.has_quality( qual_FISHING, 1 ) ) { p.backlog.push_front( act_id ); // we dont want to keep repeating the fishing activity, just piggybacking on this functions structure to find requirements. p.activity = player_activity(); - item *best_rod = best_quality_item( p, quality_FISHING ); + item *best_rod = best_quality_item( p, qual_FISHING ); p.assign_activity( ACT_FISH, to_moves( 5_hours ), 0, p.get_item_position( best_rod ), best_rod->tname() ); p.activity.coord_set = g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc ); diff --git a/src/advanced_inv_area.cpp b/src/advanced_inv_area.cpp index 8e3c3e77cc163..2890677790bef 100644 --- a/src/advanced_inv_area.cpp +++ b/src/advanced_inv_area.cpp @@ -40,7 +40,6 @@ #include #include #include -#include "cata_string_consts.h" int advanced_inv_area::get_item_count() const { @@ -81,7 +80,7 @@ void advanced_inv_area::init() off = g->u.grab_point; // Reset position because offset changed pos = g->u.pos() + off; - if( const cata::optional vp = g->m.veh_at( pos ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( pos ).part_with_feature( "CARGO", false ) ) { veh = &vp->vehicle(); vstor = vp->part_index(); @@ -123,7 +122,7 @@ void advanced_inv_area::init() case AIM_NORTH: case AIM_NORTHEAST: { const cata::optional vp = - g->m.veh_at( pos ).part_with_feature( flag_CARGO, false ); + g->m.veh_at( pos ).part_with_feature( "CARGO", false ); if( vp ) { veh = &vp->vehicle(); vstor = vp->part_index(); @@ -399,7 +398,7 @@ void advanced_inv_area::set_container_position() // update the absolute position pos = g->u.pos() + off; // update vehicle information - if( const cata::optional vp = g->m.veh_at( pos ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( pos ).part_with_feature( "CARGO", false ) ) { veh = &vp->vehicle(); vstor = vp->part_index(); diff --git a/src/advanced_inv_listitem.h b/src/advanced_inv_listitem.h index 89e514fef3fa0..55ae22c6997d9 100644 --- a/src/advanced_inv_listitem.h +++ b/src/advanced_inv_listitem.h @@ -18,6 +18,7 @@ class item_category; class advanced_inv_listitem { public: + using itype_id = std::string; /** * Index of the item in the itemstack. */ diff --git a/src/ammo.h b/src/ammo.h index f3e91f4f15b7c..173ab6ff7c88d 100644 --- a/src/ammo.h +++ b/src/ammo.h @@ -5,10 +5,10 @@ #include #include -#include "type_id.h" - class JsonObject; +using itype_id = std::string; + class ammunition_type { friend class DynamicDataLoader; diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index 193354a22d2eb..a8dc810618923 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -311,7 +311,7 @@ std::vector clothing_flags_description( const item &worn_item ) if( worn_item.has_flag( flag_FIT ) ) { description_stack.push_back( _( "It fits you well." ) ); - } else if( worn_item.has_flag( flag_VARSIZE ) ) { + } else if( worn_item.has_flag( "VARSIZE" ) ) { description_stack.push_back( _( "It could be refitted." ) ); } diff --git a/src/artifact.cpp b/src/artifact.cpp index 9cc1f8c6b1066..2c8fa5da7c1da 100644 --- a/src/artifact.cpp +++ b/src/artifact.cpp @@ -24,7 +24,6 @@ #include "units.h" #include "type_id.h" #include "value_ptr.h" -#include "cata_string_consts.h" template inline units::quantity rng( const units::quantity &min, @@ -418,27 +417,27 @@ static const std::array artifact_property_ }; static const std::array artifact_tool_form_data = { { { - translate_marker( "Harp" ), ';', def_c_yellow, material_wood, 5_liter, 7500_ml, 1150_gram, 2100_gram, ARTWEAP_BULK, + translate_marker( "Harp" ), ';', def_c_yellow, material_id( "wood" ), 5_liter, 7500_ml, 1150_gram, 2100_gram, ARTWEAP_BULK, {{ARTWEAP_SPEAR, ARTWEAP_SWORD, ARTWEAP_KNIFE}} }, { - translate_marker( "Staff" ), '/', def_c_brown, material_wood, 1500_ml, 3_liter, 450_gram, 1150_gram, ARTWEAP_CLUB, + translate_marker( "Staff" ), '/', def_c_brown, material_id( "wood" ), 1500_ml, 3_liter, 450_gram, 1150_gram, ARTWEAP_CLUB, {{ARTWEAP_BULK, ARTWEAP_SPEAR, ARTWEAP_KNIFE}} }, { - translate_marker( "Sword" ), '/', def_c_light_blue, material_steel, 2_liter, 3500_ml, 900_gram, 3259_gram, ARTWEAP_SWORD, + translate_marker( "Sword" ), '/', def_c_light_blue, material_id( "steel" ), 2_liter, 3500_ml, 900_gram, 3259_gram, ARTWEAP_SWORD, {{ARTWEAP_BULK, NUM_ARTWEAPS, NUM_ARTWEAPS}} }, { - translate_marker( "Dagger" ), ';', def_c_light_blue, material_steel, 250_ml, 1_liter, 100_gram, 700_gram, ARTWEAP_KNIFE, + translate_marker( "Dagger" ), ';', def_c_light_blue, material_id( "steel" ), 250_ml, 1_liter, 100_gram, 700_gram, ARTWEAP_KNIFE, {{NUM_ARTWEAPS, NUM_ARTWEAPS, NUM_ARTWEAPS}} }, { - translate_marker( "Cube" ), '*', def_c_white, material_steel, 250_ml, 750_ml, 100_gram, 2300_gram, ARTWEAP_BULK, + translate_marker( "Cube" ), '*', def_c_white, material_id( "steel" ), 250_ml, 750_ml, 100_gram, 2300_gram, ARTWEAP_BULK, {{ARTWEAP_SPEAR, NUM_ARTWEAPS, NUM_ARTWEAPS}} } } @@ -455,7 +454,7 @@ static const std::array artifact_weapon_dat static const std::array artifact_armor_form_data = { { // Name color Material Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit { - translate_marker( "Robe" ), def_c_red, material_wool, 1500_ml, 700_gram, 1, 1, 90, 3, 0, 2, 0_ml, -8, 0, -3, + translate_marker( "Robe" ), def_c_red, material_id( "wool" ), 1500_ml, 700_gram, 1, 1, 90, 3, 0, 2, 0_ml, -8, 0, -3, { { bp_torso, bp_leg_l, bp_leg_r } }, false, {{ ARMORMOD_LIGHT, ARMORMOD_BULKY, ARMORMOD_POCKETED, ARMORMOD_FURRED, @@ -465,7 +464,7 @@ static const std::array artifact_arm }, { - translate_marker( "Coat" ), def_c_brown, material_leather, 3500_ml, 1600_gram, 2, 2, 80, 2, 1, 4, 1_liter, -6, 0, -3, + translate_marker( "Coat" ), def_c_brown, material_id( "leather" ), 3500_ml, 1600_gram, 2, 2, 80, 2, 1, 4, 1_liter, -6, 0, -3, { bp_torso }, false, {{ ARMORMOD_LIGHT, ARMORMOD_POCKETED, ARMORMOD_FURRED, ARMORMOD_PADDED, @@ -475,7 +474,7 @@ static const std::array artifact_arm }, { - translate_marker( "Mask" ), def_c_white, material_wood, 1_liter, 100_gram, 2, 2, 50, 2, 1, 2, 0_ml, 2, 0, -2, + translate_marker( "Mask" ), def_c_white, material_id( "wood" ), 1_liter, 100_gram, 2, 2, 50, 2, 1, 2, 0_ml, 2, 0, -2, { { bp_eyes, bp_mouth } }, false, {{ ARMORMOD_FURRED, ARMORMOD_FURRED, ARMORMOD_NULL, ARMORMOD_NULL, @@ -486,7 +485,7 @@ static const std::array artifact_arm // Name color Materials Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit { - translate_marker( "Helm" ), def_c_dark_gray, material_silver, 1500_ml, 700_gram, 2, 2, 85, 3, 0, 1, 0_ml, 8, 0, -2, + translate_marker( "Helm" ), def_c_dark_gray, material_id( "silver" ), 1500_ml, 700_gram, 2, 2, 85, 3, 0, 1, 0_ml, 8, 0, -2, { bp_head }, false, {{ ARMORMOD_BULKY, ARMORMOD_FURRED, ARMORMOD_PADDED, ARMORMOD_PLATED, @@ -496,7 +495,7 @@ static const std::array artifact_arm }, { - translate_marker( "Gloves" ), def_c_light_blue, material_leather, 500_ml, 100_gram, 1, 1, 90, 3, 1, 2, 0_ml, -4, 0, -2, + translate_marker( "Gloves" ), def_c_light_blue, material_id( "leather" ), 500_ml, 100_gram, 1, 1, 90, 3, 1, 2, 0_ml, -4, 0, -2, { { bp_hand_l, bp_hand_r } }, true, {{ ARMORMOD_BULKY, ARMORMOD_FURRED, ARMORMOD_PADDED, ARMORMOD_PLATED, @@ -507,7 +506,7 @@ static const std::array artifact_arm // Name color Materials Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit { - translate_marker( "Boots" ), def_c_blue, material_leather, 1500_ml, 250_gram, 1, 1, 75, 3, 1, 3, 0_ml, 4, 0, -1, + translate_marker( "Boots" ), def_c_blue, material_id( "leather" ), 1500_ml, 250_gram, 1, 1, 75, 3, 1, 3, 0_ml, 4, 0, -1, { { bp_foot_l, bp_foot_r } }, true, {{ ARMORMOD_LIGHT, ARMORMOD_BULKY, ARMORMOD_PADDED, ARMORMOD_PLATED, @@ -517,7 +516,7 @@ static const std::array artifact_arm }, { - translate_marker( "Ring" ), def_c_light_green, material_silver, 0_ml, 4_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, + translate_marker( "Ring" ), def_c_light_green, material_id( "silver" ), 0_ml, 4_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} } @@ -530,44 +529,44 @@ static const std::array artifact_arm */ static const std::array artifact_armor_mod_data = { { { - "", def_c_white, material_null, 0_ml, 0_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false, + "", def_c_white, material_id( "null" ), 0_ml, 0_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, // Description; "It is ..." or "They are ..." { - translate_marker( "very thin and light." ), def_c_white, material_null, + translate_marker( "very thin and light." ), def_c_white, material_id( "null" ), // Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto -1_liter, -950_gram, -2, -2, -1, -1, -1, -1, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "extremely bulky." ), def_c_white, material_null, + translate_marker( "extremely bulky." ), def_c_white, material_id( "null" ), 2_liter, 1150_gram, 2, 2, 1, 1, 0, 1, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "covered in pockets." ), def_c_white, material_null, + translate_marker( "covered in pockets." ), def_c_white, material_id( "null" ), 250_ml, 150_gram, 1, 1, 0, 0, 0, 0, 4_liter, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "disgustingly furry." ), def_c_white, material_wool, + translate_marker( "disgustingly furry." ), def_c_white, material_id( "wool" ), // Vol Wgt Enc MaxEnc Dmg Cut Env Wrm Sto 1_liter, 250_gram, 1, 1, 1, 1, 1, 3, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "leather-padded." ), def_c_white, material_leather, + translate_marker( "leather-padded." ), def_c_white, material_id( "leather" ), 1_liter, 450_gram, 1, 1, 1, 1, 0, 1, -750_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "plated in iron." ), def_c_white, material_iron, + translate_marker( "plated in iron." ), def_c_white, material_id( "iron" ), 1_liter, 1400_gram, 3, 3, 2, 2, 0, 1, -1_liter, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, @@ -942,7 +941,7 @@ std::string new_natural_artifact( artifact_natural_property prop ) def.sym = ":"; def.color = c_yellow; - def.materials.push_back( material_stone ); + def.materials.push_back( material_id( "stone" ) ); def.volume = rng( shape_data.volume_min, shape_data.volume_max ); def.weight = rng( shape_data.weight_min, shape_data.weight_max ); def.melee[DT_BASH] = 0; diff --git a/src/avatar.cpp b/src/avatar.cpp index dea5853d96a54..c52af877b5dcc 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -1354,7 +1354,7 @@ void avatar::upgrade_stat_prompt( const Character::stat &stat ) faction *avatar::get_faction() const { - return g->faction_manager_ptr->get( faction_your_followers ); + return g->faction_manager_ptr->get( faction_id( "your_followers" ) ); } void avatar::set_movement_mode( character_movemode new_mode ) diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 9bd38c5ea9c0c..029d69fdd1b66 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -304,7 +304,7 @@ bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz ) } else if( veh1 != veh0 ) { add_msg( m_info, _( "There is another vehicle in the way." ) ); return false; - } else if( !vp1.part_with_feature( flag_BOARDABLE, true ) ) { + } else if( !vp1.part_with_feature( "BOARDABLE", true ) ) { add_msg( m_info, _( "That part of the vehicle is currently unsafe." ) ); return false; } @@ -679,9 +679,9 @@ bool avatar_action::fire_check( avatar &you, const map &m, const targeting_data } if( mode_map.second->has_flag( flag_MOUNTED_GUN ) ) { - const bool v_mountable = static_cast( m.veh_at( you.pos() ).part_with_feature( flag_MOUNTABLE, + const bool v_mountable = static_cast( m.veh_at( you.pos() ).part_with_feature( "MOUNTABLE", true ) ); - bool t_mountable = m.has_flag_ter_or_furn( flag_MOUNTABLE, you.pos() ); + bool t_mountable = m.has_flag_ter_or_furn( "MOUNTABLE", you.pos() ); if( !t_mountable && !v_mountable ) { messages.push_back( string_format( _( "You must stand near acceptable terrain or furniture to use this %s. A table, a mound of dirt, a broken window, etc." ), @@ -1138,7 +1138,7 @@ void avatar_action::unload( avatar &you ) it = &you.i_at( loc.obtain( you ) ); } if( you.unload( *it ) ) { - if( it->has_flag( flag_MAG_DESTROY ) && it->ammo_remaining() == 0 ) { + if( it->has_flag( "MAG_DESTROY" ) && it->ammo_remaining() == 0 ) { you.remove_item( *it ); } } diff --git a/src/basecamp.cpp b/src/basecamp.cpp index e3d5ca2a7fdfb..2223f36e4c935 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -623,7 +623,7 @@ void basecamp::form_crafting_inventory( map &target_map ) for( basecamp_resource &bcp_r : resources ) { bcp_r.consumed = 0; item camp_item( bcp_r.fake_id, 0 ); - camp_item.item_tags.insert( flag_PSEUDO ); + camp_item.item_tags.insert( "PSEUDO" ); if( bcp_r.ammo_id != "NULL" ) { for( basecamp_fuel &bcp_f : fuels ) { if( bcp_f.ammo_id == bcp_r.ammo_id ) { diff --git a/src/basecamp.h b/src/basecamp.h index ea37bad461df3..6347425b33b38 100644 --- a/src/basecamp.h +++ b/src/basecamp.h @@ -42,6 +42,8 @@ struct expansion_data { using npc_ptr = shared_ptr_fast; using comp_list = std::vector; using Group_tag = std::string; +using itype_id = std::string; + namespace catacurses { class window; diff --git a/src/bionics.cpp b/src/bionics.cpp index 3af1b992c8cdf..4f27c2ed3d613 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -539,7 +539,7 @@ bool Character::activate_bionic( int b, bool eff_only ) } } else if( bio.id == bio_magnet ) { static const std::set affected_materials = - { material_iron, material_steel }; + { material_id( "iron" ), material_id( "steel" ) }; // Remember all items that will be affected, then affect them // Don't "snowball" by affecting some items multiple times std::vector> affected; diff --git a/src/bionics.h b/src/bionics.h index b0c08f3892481..c1da377933a68 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -21,6 +21,8 @@ class player; class JsonObject; class JsonIn; class JsonOut; +using itype_id = std::string; + struct bionic_data { bionic_data(); diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 3410037bdc561..56b56993c83e4 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -3,7 +3,8 @@ #define STRING_CONSTS_H #include "type_id.h" -#include "itype.h" +#include "player_activity.h" + static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" ); static const activity_id ACT_AIM( "ACT_AIM" ); @@ -103,6 +104,7 @@ static const activity_id ACT_WAIT_WEATHER( "ACT_WAIT_WEATHER" ); static const activity_id ACT_WASH( "ACT_WASH" ); static const activity_id ACT_WEAR( "ACT_WEAR" ); + static const bionic_id bio_adrenaline( "bio_adrenaline" ); static const bionic_id bio_ads( "bio_ads" ); static const bionic_id bio_advreactor( "bio_advreactor" ); @@ -717,8 +719,12 @@ static const trait_id trait_WOOLALLERGY( "WOOLALLERGY" ); static const trait_id trait_XS( "XS" ); static const trait_id trait_XXXL( "XXXL" ); -static const mongroup_id GROUP_ANT( "GROUP_ANT" ); -static const mongroup_id GROUP_ANT_ACID( "GROUP_ANT_ACID" ); +static const trait_id debug_nodmg( "DEBUG_NODMG" ); + +static const std::string trait_flag_CANNIBAL( "CANNIBAL" ); +static const std::string trait_flag_PSYCHOPATH( "PSYCHOPATH" ); +static const std::string trait_flag_SAPIOVORE( "SAPIOVORE" ); + static const mongroup_id GROUP_BLOB( "GROUP_BLOB" ); static const mongroup_id GROUP_BREATHER( "GROUP_BREATHER" ); static const mongroup_id GROUP_BREATHER_HUB( "GROUP_BREATHER_HUB" ); @@ -822,7 +828,6 @@ static const mtype_id mon_hologram( "mon_hologram" ); static const mtype_id mon_horse( "mon_horse" ); static const mtype_id mon_hound_tindalos_afterimage( "mon_hound_tindalos_afterimage" ); static const mtype_id mon_jabberwock( "mon_jabberwock" ); -static const mtype_id mon_laserturret( "mon_laserturret" ); static const mtype_id mon_leech_blossom( "mon_leech_blossom" ); static const mtype_id mon_leech_root_drone( "mon_leech_root_drone" ); static const mtype_id mon_leech_root_runner( "mon_leech_root_runner" ); @@ -834,7 +839,6 @@ static const mtype_id mon_marloss_zealot_m( "mon_marloss_zealot_m" ); static const mtype_id mon_mink( "mon_mink" ); static const mtype_id mon_moose( "mon_moose" ); static const mtype_id mon_muskrat( "mon_muskrat" ); -static const mtype_id mon_null( "mon_null" ); static const mtype_id mon_opossum( "mon_opossum" ); static const mtype_id mon_otter( "mon_otter" ); static const mtype_id mon_pheasant( "mon_pheasant" ); @@ -900,7 +904,6 @@ static const mtype_id mon_zombie_hazmat( "mon_zombie_hazmat" ); static const mtype_id mon_zombie_hulk( "mon_zombie_hulk" ); static const mtype_id mon_zombie_hunter( "mon_zombie_hunter" ); static const mtype_id mon_zombie_jackson( "mon_zombie_jackson" ); -static const mtype_id mon_zombie_kevlar_2( "mon_zombie_kevlar_2" ); static const mtype_id mon_zombie_master( "mon_zombie_master" ); static const mtype_id mon_zombie_military_pilot( "mon_zombie_military_pilot" ); static const mtype_id mon_zombie_necro( "mon_zombie_necro" ); @@ -921,14 +924,10 @@ static const mtype_id mon_zombie_technician( "mon_zombie_technician" ); static const mtype_id mon_zombie_tough( "mon_zombie_tough" ); static const mtype_id mon_zombie_waif( "mon_zombie_waif" ); + static const std::string flag_ACID( "ACID" ); -static const std::string flag_ACID_IMMUNE( "ACID_IMMUNE" ); 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_ADVANCED_PLANTER( "ADVANCED_PLANTER" ); -static const std::string flag_AISLE( "AISLE" ); -static const std::string flag_ALARMCLOCK( "ALARMCLOCK" ); static const std::string flag_ALARMED( "ALARMED" ); static const std::string flag_ALLERGEN_EGG( "ALLERGEN_EGG" ); static const std::string flag_ALLERGEN_FRUIT( "ALLERGEN_FRUIT" ); @@ -937,149 +936,83 @@ 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_ALLERGEN_WOOL( "ALLERGEN_WOOL" ); -static const std::string flag_ALLOW_OUTSIDE( "ALLOW_OUTSIDE" ); -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_ALTERNATOR( "ALTERNATOR" ); static const std::string flag_ALWAYS_TWOHAND( "ALWAYS_TWOHAND" ); static const std::string flag_ANESTHESIA( "ANESTHESIA" ); -static const std::string flag_ANIMAL_CTRL( "ANIMAL_CTRL" ); -static const std::string flag_ARMOR( "ARMOR" ); 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_AUTOCLAVE( "AUTOCLAVE" ); static const std::string flag_AUTODOC( "AUTODOC" ); static const std::string flag_AUTODOC_COUCH( "AUTODOC_COUCH" ); -static const std::string flag_AUTOPILOT( "AUTOPILOT" ); static const std::string flag_BAD_DAY( "BAD_DAY" ); static const std::string flag_BAROMETER( "BAROMETER" ); static const std::string flag_BARRICADABLE_DOOR( "BARRICADABLE_DOOR" ); static const std::string flag_BARRICADABLE_DOOR_DAMAGED( "BARRICADABLE_DOOR_DAMAGED" ); static const std::string flag_BARRICADABLE_DOOR_REINFORCED( "BARRICADABLE_DOOR_REINFORCED" ); static const std::string flag_BARRICADABLE_WINDOW_CURTAINS( "BARRICADABLE_WINDOW_CURTAINS" ); -static const std::string flag_BASH_IMMUNE( "BASH_IMMUNE" ); -static const std::string flag_BATTERY_MOUNT( "BATTERY_MOUNT" ); -static const std::string flag_BED( "BED" ); -static const std::string flag_BEEPER( "BEEPER" ); -static const std::string flag_BELTABLE( "BELTABLE" ); static const std::string flag_BELTED( "BELTED" ); -static const std::string flag_BIKE_RACK_VEH( "BIKE_RACK_VEH" ); -static const std::string flag_BIO_IMMUNE( "BIO_IMMUNE" ); static const std::string flag_BIPOD( "BIPOD" ); static const std::string flag_BIRD( "BIRD" ); static const std::string flag_BLIND( "BLIND" ); static const std::string flag_BLIND_EASY( "BLIND_EASY" ); 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_BLOCK_WIND( "BLOCK_WIND" ); static const std::string flag_BLOCKSDOOR( "BLOCKSDOOR" ); -static const std::string flag_BOARDABLE( "BOARDABLE" ); -static const std::string flag_BOARDED( "BOARDED" ); 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" ); -static const std::string flag_CAMERA( "CAMERA" ); -static const std::string flag_CAMERA_CONTROL( "CAMERA_CONTROL" ); 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_CAPTURE_MONSTER_VEH( "CAPTURE_MONSTER_VEH" ); -static const std::string flag_CARGO( "CARGO" ); -static const std::string flag_CARGO_LOCKING( "CARGO_LOCKING" ); static const std::string flag_CARNIVORE_OK( "CARNIVORE_OK" ); static const std::string flag_CASING( "CASING" ); static const std::string flag_CATTLE( "CATTLE" ); static const std::string flag_CHALLENGE( "CHALLENGE" ); static const std::string flag_CHARGEDIM( "CHARGEDIM" ); -static const std::string flag_CHEMLAB( "CHEMLAB" ); -static const std::string flag_CHIMES( "CHIMES" ); static const std::string flag_CITY_START( "CITY_START" ); -static const std::string flag_CLIMATE_CONTROL( "CLIMATE_CONTROL" ); static const std::string flag_CLIMB_SIMPLE( "CLIMB_SIMPLE" ); static const std::string flag_CLIMBABLE( "CLIMBABLE" ); static const std::string flag_COLD( "COLD" ); -static const std::string flag_COLD_IMMUNE( "COLD_IMMUNE" ); static const std::string flag_COLLAPSES( "COLLAPSES" ); static const std::string flag_COLLAPSIBLE_STOCK( "COLLAPSIBLE_STOCK" ); -static const std::string flag_COLLAR( "COLLAR" ); static const std::string flag_CONDUCTIVE( "CONDUCTIVE" ); static const std::string flag_CONSOLE( "CONSOLE" ); static const std::string flag_CONSUMABLE( "CONSUMABLE" ); static const std::string flag_CONTAINER( "CONTAINER" ); -static const std::string flag_CONTROL_ANIMAL( "CONTROL_ANIMAL" ); -static const std::string flag_CONTROLS( "CONTROLS" ); static const std::string flag_COOKED( "COOKED" ); -static const std::string flag_COOLER( "COOLER" ); static const std::string flag_CORPSE( "CORPSE" ); -static const std::string flag_COVERED( "COVERED" ); -static const std::string flag_CRAFTRIG( "CRAFTRIG" ); -static const std::string flag_CRASH_TERRAIN_AROUND( "CRASH_TERRAIN_AROUND" ); -static const std::string flag_CTRL_ELECTRONIC( "CTRL_ELECTRONIC" ); static const std::string flag_CURRENT( "CURRENT" ); -static const std::string flag_CURTAIN( "CURTAIN" ); -static const std::string flag_CUT_IMMUNE( "CUT_IMMUNE" ); static const std::string flag_DANGEROUS( "DANGEROUS" ); static const std::string flag_DEAF( "DEAF" ); static const std::string flag_DEEP_WATER( "DEEP_WATER" ); static const std::string flag_DESTROY_ITEM( "DESTROY_ITEM" ); -static const std::string flag_DETERGENT( "DETERGENT" ); static const std::string flag_DIAMOND( "DIAMOND" ); static const std::string flag_DIFFICULT_Z( "DIFFICULT_Z" ); static const std::string flag_DIG_TOOL( "DIG_TOOL" ); static const std::string flag_DIGGABLE( "DIGGABLE" ); 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_DIRTY( "DIRTY" ); static const std::string flag_DISABLE_SIGHTS( "DISABLE_SIGHTS" ); -static const std::string flag_DISHWASHER( "DISHWASHER" ); static const std::string flag_DONT_REMOVE_ROTTEN( "DONT_REMOVE_ROTTEN" ); -static const std::string flag_DOOR( "DOOR" ); -static const std::string flag_DOOR_MOTOR( "DOOR_MOTOR" ); 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_E_ALTERNATOR( "E_ALTERNATOR" ); -static const std::string flag_E_COLD_START( "E_COLD_START" ); -static const std::string flag_E_COMBUSTION( "E_COMBUSTION" ); -static const std::string flag_E_HEATER( "E_HEATER" ); -static const std::string flag_E_HIGHER_SKILL( "E_HIGHER_SKILL" ); -static const std::string flag_E_STARTS_INSTANTLY( "E_STARTS_INSTANTLY" ); static const std::string flag_EASY_DECONSTRUCT( "EASY_DECONSTRUCT" ); static const std::string flag_EATEN_COLD( "EATEN_COLD" ); static const std::string flag_EATEN_HOT( "EATEN_HOT" ); static const std::string flag_EDIBLE_FROZEN( "EDIBLE_FROZEN" ); -static const std::string flag_EFFECT_ACID_IMMUNE( "EFFECT_ACID_IMMUNE" ); -static const std::string flag_EFFECT_BASH_IMMUNE( "EFFECT_BASH_IMMUNE" ); -static const std::string flag_EFFECT_BIO_IMMUNE( "EFFECT_BIO_IMMUNE" ); -static const std::string flag_EFFECT_COLD_IMMUNE( "EFFECT_COLD_IMMUNE" ); -static const std::string flag_EFFECT_CUT_IMMUNE( "EFFECT_CUT_IMMUNE" ); -static const std::string flag_EFFECT_ELECTRIC_IMMUNE( "EFFECT_ELECTRIC_IMMUNE" ); -static const std::string flag_EFFECT_FEATHER_FALL( "EFFECT_FEATHER_FALL" ); -static const std::string flag_EFFECT_HEAT_IMMUNE( "EFFECT_HEAT_IMMUNE" ); static const std::string flag_EFFECT_INVISIBLE( "EFFECT_INVISIBLE" ); static const std::string flag_EFFECT_NIGHT_VISION( "EFFECT_NIGHT_VISION" ); -static const std::string flag_EFFECT_STAB_IMMUNE( "EFFECT_STAB_IMMUNE" ); -static const std::string flag_ELECTRIC_IMMUNE( "ELECTRIC_IMMUNE" ); static const std::string flag_EMITTER( "EMITTER" ); -static const std::string flag_ENGINE( "ENGINE" ); static const std::string flag_ETHEREAL_ITEM( "ETHEREAL_ITEM" ); -static const std::string flag_EXTRA_DRAG( "EXTRA_DRAG" ); static const std::string flag_FAKE_MILL( "FAKE_MILL" ); static const std::string flag_FAKE_SMOKE( "FAKE_SMOKE" ); static const std::string flag_FANCY( "FANCY" ); -static const std::string flag_FAUCET( "FAUCET" ); static const std::string flag_FELINE( "FELINE" ); static const std::string flag_FERTILIZER( "FERTILIZER" ); static const std::string flag_FIELD_DRESS( "FIELD_DRESS" ); static const std::string flag_FIELD_DRESS_FAILED( "FIELD_DRESS_FAILED" ); static const std::string flag_FILTHY( "FILTHY" ); -static const std::string flag_FIN( "FIN" ); static const std::string flag_FIRE( "FIRE" ); static const std::string flag_FIRE_100( "FIRE_100" ); static const std::string flag_FIRE_20( "FIRE_20" ); @@ -1101,25 +1034,16 @@ static const std::string flag_FLAMMABLE_ASH( "FLAMMABLE_ASH" ); static const std::string flag_FLASH_PROTECTION( "FLASH_PROTECTION" ); static const std::string flag_FLAT( "FLAT" ); static const std::string flag_FLAT_SURF( "FLAT_SURF" ); -static const std::string flag_FLOATS( "FLOATS" ); static const std::string flag_FLOTATION( "FLOTATION" ); static const std::string flag_FLOWER( "FLOWER" ); -static const std::string flag_FOLDABLE( "FOLDABLE" ); static const std::string flag_FORAGE_HALLU( "FORAGE_HALLU" ); static const std::string flag_FORAGE_POISON( "FORAGE_POISON" ); -static const std::string flag_FORGE( "FORGE" ); -static const std::string flag_FRAGILE( "FRAGILE" ); static const std::string flag_FRAGILE_MELEE( "FRAGILE_MELEE" ); -static const std::string flag_FREEZER( "FREEZER" ); static const std::string flag_FREEZERBURN( "FREEZERBURN" ); -static const std::string flag_FRIDGE( "FRIDGE" ); static const std::string flag_FROZEN( "FROZEN" ); -static const std::string flag_FUEL_TANK( "FUEL_TANK" ); -static const std::string flag_FULL_BOARD( "FULL_BOARD" ); static const std::string flag_FULL_MAGAZINE( "FULL_MAGAZINE" ); static const std::string flag_FUNGAL_VECTOR( "FUNGAL_VECTOR" ); static const std::string flag_FUNGUS( "FUNGUS" ); -static const std::string flag_FUNNEL( "FUNNEL" ); static const std::string flag_GAS_DISCOUNT( "GAS_DISCOUNT" ); static const std::string flag_GAS_PROOF( "GAS_PROOF" ); static const std::string flag_GIBBED( "GIBBED" ); @@ -1129,17 +1053,12 @@ static const std::string flag_GOES_UP( "GOES_UP" ); static const std::string flag_GROWTH_HARVEST( "GROWTH_HARVEST" ); static const std::string flag_GROWTH_MATURE( "GROWTH_MATURE" ); static const std::string flag_GROWTH_SEEDLING( "GROWTH_SEEDLING" ); -static const std::string flag_HALF_BOARD( "HALF_BOARD" ); -static const std::string flag_HARNESS_any( "HARNESS_any" ); -static const std::string flag_HEAT_IMMUNE( "HEAT_IMMUNE" ); static const std::string flag_HELI_CRASH( "HELI_CRASH" ); static const std::string flag_HELMET_COMPAT( "HELMET_COMPAT" ); static const std::string flag_HIDDEN_HALLU( "HIDDEN_HALLU" ); static const std::string flag_HIDDEN_ITEM( "HIDDEN_ITEM" ); static const std::string flag_HIDDEN_POISON( "HIDDEN_POISON" ); -static const std::string flag_HIDE_PLACE( "HIDE_PLACE" ); static const std::string flag_HOOD( "HOOD" ); -static const std::string flag_HORN( "HORN" ); static const std::string flag_HOT( "HOT" ); static const std::string flag_HURT_WHEN_WIELDED( "HURT_WHEN_WIELDED" ); static const std::string flag_HYGROMETER( "HYGROMETER" ); @@ -1148,15 +1067,11 @@ 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_INTERNAL( "INTERNAL" ); 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" ); static const std::string flag_IS_PET_ARMOR( "IS_PET_ARMOR" ); static const std::string flag_IS_UPS( "IS_UPS" ); -static const std::string flag_KILN( "KILN" ); static const std::string flag_KITCHEN( "KITCHEN" ); static const std::string flag_LADDER( "LADDER" ); static const std::string flag_LEAK_ALWAYS( "LEAK_ALWAYS" ); @@ -1164,13 +1079,10 @@ static const std::string flag_LEAK_DAM( "LEAK_DAM" ); static const std::string flag_LIQUID( "LIQUID" ); static const std::string flag_LIQUIDCONT( "LIQUIDCONT" ); static const std::string flag_LITCIG( "LITCIG" ); -static const std::string flag_LOCKABLE_CARGO( "LOCKABLE_CARGO" ); static const std::string flag_LOCKED( "LOCKED" ); static const std::string flag_LONE_START( "LONE_START" ); -static const std::string flag_LOW_FINAL_AIR_DRAG( "LOW_FINAL_AIR_DRAG" ); 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" ); @@ -1182,183 +1094,111 @@ 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" ); static const std::string flag_MINEABLE( "MINEABLE" ); static const std::string flag_MOUNTABLE( "MOUNTABLE" ); static const std::string flag_MOUNTED_GUN( "MOUNTED_GUN" ); -static const std::string flag_MUFFLER( "MUFFLER" ); -static const std::string flag_MUSCLE_ARMS( "MUSCLE_ARMS" ); -static const std::string flag_MUSCLE_LEGS( "MUSCLE_LEGS" ); static const std::string flag_MUSHY( "MUSHY" ); static const std::string flag_MYCUS_OK( "MYCUS_OK" ); static const std::string flag_NANOFAB_TEMPLATE( "NANOFAB_TEMPLATE" ); static const std::string flag_NEED_ACTIVE_TO_MELEE( "NEED_ACTIVE_TO_MELEE" ); -static const std::string flag_NEEDS_BATTERY_MOUNT( "NEEDS_BATTERY_MOUNT" ); -static const std::string flag_NEEDS_JACKING( "NEEDS_JACKING" ); 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_NEEDS_WHEEL_MOUNT_HEAVY( "NEEDS_WHEEL_MOUNT_HEAVY" ); -static const std::string flag_NEEDS_WHEEL_MOUNT_LIGHT( "NEEDS_WHEEL_MOUNT_LIGHT" ); -static const std::string flag_NEEDS_WHEEL_MOUNT_MEDIUM( "NEEDS_WHEEL_MOUNT_MEDIUM" ); 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_DISEASE( "NO_DISEASE" ); 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" ); -static const std::string flag_NO_RADIATION( "NO_RADIATION" ); static const std::string flag_NO_RELOAD( "NO_RELOAD" ); static const std::string flag_NO_REPAIR( "NO_REPAIR" ); static const std::string flag_NO_RESIZE( "NO_RESIZE" ); -static const std::string flag_NO_ROOF_NEEDED( "NO_ROOF_NEEDED" ); 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_THIRST( "NO_THIRST" ); 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_NOINSTALL( "NOINSTALL" ); static const std::string flag_NOITEM( "NOITEM" ); static const std::string flag_NON_FOULING( "NON-FOULING" ); -static const std::string flag_NONBELTABLE( "NONBELTABLE" ); 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_OBSTACLE( "OBSTACLE" ); -static const std::string flag_ON_CONTROLS( "ON_CONTROLS" ); -static const std::string flag_ON_ROOF( "ON_ROOF" ); static const std::string flag_ONLY_ONE( "ONLY_ONE" ); -static const std::string flag_OPAQUE( "OPAQUE" ); -static const std::string flag_OPENABLE( "OPENABLE" ); static const std::string flag_OPENCLOSE_INSIDE( "OPENCLOSE_INSIDE" ); static const std::string flag_ORGANIC( "ORGANIC" ); static const std::string flag_OUTER( "OUTER" ); static const std::string flag_OVERSIZE( "OVERSIZE" ); static const std::string flag_PARTIAL_DEAF( "PARTIAL_DEAF" ); -static const std::string flag_PERMEABLE( "PERMEABLE" ); 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" ); -static const std::string flag_PLANTER( "PLANTER" ); static const std::string flag_PLOWABLE( "PLOWABLE" ); static const std::string flag_POCKETS( "POCKETS" ); -static const std::string flag_POWER_TRANSFER( "POWER_TRANSFER" ); static const std::string flag_POWERARMOR_COMPATIBLE( "POWERARMOR_COMPATIBLE" ); static const std::string flag_POWERED( "POWERED" ); -static const std::string flag_PRED1( "PRED1" ); -static const std::string flag_PRED2( "PRED2" ); -static const std::string flag_PRED3( "PRED3" ); -static const std::string flag_PRED4( "PRED4" ); static const std::string flag_PRIMITIVE_RANGED_WEAPON( "PRIMITIVE_RANGED_WEAPON" ); static const std::string flag_PROCESSING( "PROCESSING" ); static const std::string flag_PROCESSING_RESULT( "PROCESSING_RESULT" ); -static const std::string flag_PROTRUSION( "PROTRUSION" ); -static const std::string flag_PSEUDO( "PSEUDO" ); -static const std::string flag_PSYCHOPATH( "PSYCHOPATH" ); -static const std::string flag_PSYSHIELD_PARTIAL( "PSYSHIELD_PARTIAL" ); static const std::string flag_PULPED( "PULPED" ); static const std::string flag_PUMP_ACTION( "PUMP_ACTION" ); static const std::string flag_PUMP_RAIL_COMPATIBLE( "PUMP_RAIL_COMPATIBLE" ); static const std::string flag_QUARTERED( "QUARTERED" ); -static const std::string flag_RAD_PROOF( "RAD_PROOF" ); static const std::string flag_RAD_RESIST( "RAD_RESIST" ); static const std::string flag_RADIO_ACTIVATION( "RADIO_ACTIVATION" ); static const std::string flag_RADIO_CONTAINER( "RADIO_CONTAINER" ); static const std::string flag_RADIO_INVOKE_PROC( "RADIO_INVOKE_PROC" ); static const std::string flag_RADIO_MOD( "RADIO_MOD" ); -static const std::string flag_RADIO_MODABLE( "RADIO_MODABLE" ); static const std::string flag_RADIOACTIVE( "RADIOACTIVE" ); static const std::string flag_RADIOCARITEM( "RADIOCARITEM" ); static const std::string flag_RADIOSIGNAL_1( "RADIOSIGNAL_1" ); static const std::string flag_RADIOSIGNAL_2( "RADIOSIGNAL_2" ); static const std::string flag_RADIOSIGNAL_3( "RADIOSIGNAL_3" ); static const std::string flag_RAIN_PROTECT( "RAIN_PROTECT" ); -static const std::string flag_RAINPROOF( "RAINPROOF" ); -static const std::string flag_RAMP( "RAMP" ); static const std::string flag_RAMP_END( "RAMP_END" ); static const std::string flag_RAW( "RAW" ); static const std::string flag_REACH_ATTACK( "REACH_ATTACK" ); static const std::string flag_REACH3( "REACH3" ); -static const std::string flag_REAPER( "REAPER" ); -static const std::string flag_REBREATHER( "REBREATHER" ); static const std::string flag_RECHARGE( "RECHARGE" ); static const std::string flag_REDUCED_BASHING( "REDUCED_BASHING" ); static const std::string flag_REDUCED_WEIGHT( "REDUCED_WEIGHT" ); static const std::string flag_RELOAD_AND_SHOOT( "RELOAD_AND_SHOOT" ); static const std::string flag_RELOAD_EJECT( "RELOAD_EJECT" ); static const std::string flag_RELOAD_ONE( "RELOAD_ONE" ); -static const std::string flag_REMOTE_CONTROLS( "REMOTE_CONTROLS" ); -static const std::string flag_REQUIRES_BALANCE( "REQUIRES_BALANCE" ); 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" ); -static const std::string flag_ROOF( "ROOF" ); static const std::string flag_ROUGH( "ROUGH" ); static const std::string flag_RUBBLE( "RUBBLE" ); static const std::string flag_SAFE_FUEL_OFF( "SAFE_FUEL_OFF" ); static const std::string flag_SAFECRACK( "SAFECRACK" ); static const std::string flag_SALT_WATER( "SALT_WATER" ); -static const std::string flag_SAPIOVORE( "SAPIOVORE" ); -static const std::string flag_SCEN_ONLY( "SCEN_ONLY" ); -static const std::string flag_SCOOP( "SCOOP" ); static const std::string flag_SEALED( "SEALED" ); -static const std::string flag_SEAT( "SEAT" ); -static const std::string flag_SEATBELT( "SEATBELT" ); static const std::string flag_SECRET( "SECRET" ); -static const std::string flag_SECURITY( "SECURITY" ); -static const std::string flag_SELF_JACK( "SELF_JACK" ); static const std::string flag_SEMITANGIBLE( "SEMITANGIBLE" ); static const std::string flag_SHARP( "SHARP" ); -static const std::string flag_SHORT( "SHORT" ); static const std::string flag_SHRUB( "SHRUB" ); -static const std::string flag_SIGN( "SIGN" ); static const std::string flag_SILENT( "SILENT" ); -static const std::string flag_MULTISQUARE( "MULTISQUARE" ); -static const std::string flag_CONE_LIGHT( "CONE_LIGHT" ); -static const std::string flag_CIRCLE_LIGHT( "CIRCLE_LIGHT" ); -static const std::string flag_AISLE_LIGHT( "AISLE_LIGHT" ); -static const std::string flag_ROCKWHEEL( "ROCKWHEEL" ); -static const std::string flag_PLOW( "PLOW" ); -static const std::string flag_ROADHEAD( "ROADHEAD" ); -static const std::string flag_DOME_LIGHT( "DOME_LIGHT" ); -static const std::string flag_ATOMIC_LIGHT( "ATOMIC_LIGHT" ); static const std::string flag_SKINNED( "SKINNED" ); static const std::string flag_SKINTIGHT( "SKINTIGHT" ); static const std::string flag_SLEEP_AID( "SLEEP_AID" ); static const std::string flag_SLOW_WIELD( "SLOW_WIELD" ); -static const std::string flag_SLOWS_MOVEMENT( "SLOWS_MOVEMENT" ); static const std::string flag_SLOWS_THIRST( "SLOWS_THIRST" ); static const std::string flag_SMOKABLE( "SMOKABLE" ); static const std::string flag_SMOKED( "SMOKED" ); -static const std::string flag_SOLAR_PANEL( "SOLAR_PANEL" ); -static const std::string flag_SPACE_HEATER( "SPACE_HEATER" ); static const std::string flag_SPEAR( "SPEAR" ); 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_STAB_IMMUNE( "STAB_IMMUNE" ); -static const std::string flag_STABLE( "STABLE" ); -static const std::string flag_STEERABLE( "STEERABLE" ); -static const std::string flag_STEREO( "STEREO" ); 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" ); @@ -1368,26 +1208,13 @@ 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_TOWEL( "TOWEL" ); -static const std::string flag_TRACK( "TRACK" ); -static const std::string flag_TRACKED( "TRACKED" ); -static const std::string flag_TRADER_AVOID( "TRADER_AVOID" ); -static const std::string flag_TRANSFORM_TERRAIN( "TRANSFORM_TERRAIN" ); -static const std::string flag_TRANSLOCATOR( "TRANSLOCATOR" ); static const std::string flag_TRANSPARENT( "TRANSPARENT" ); static const std::string flag_TREE( "TREE" ); -static const std::string flag_TURRET( "TURRET" ); -static const std::string flag_TURRET_CONTROLS( "TURRET_CONTROLS" ); -static const std::string flag_TURRET_MOUNT( "TURRET_MOUNT" ); -static const std::string flag_TWO_WAY_RADIO( "TWO_WAY_RADIO" ); static const std::string flag_UNARMED_BONUS( "UNARMED_BONUS" ); static const std::string flag_UNARMED_WEAPON( "UNARMED_WEAPON" ); static const std::string flag_UNBREAKABLE_MELEE( "UNBREAKABLE_MELEE" ); @@ -1395,49 +1222,27 @@ 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_UNMOUNT_ON_DAMAGE( "UNMOUNT_ON_DAMAGE" ); -static const std::string flag_UNMOUNT_ON_MOVE( "UNMOUNT_ON_MOVE" ); -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" ); static const std::string flag_USE_EAT_VERB( "USE_EAT_VERB" ); -static const std::string flag_USE_PLAYER_ENERGY( "USE_PLAYER_ENERGY" ); -static const std::string flag_USE_TANKS( "USE_TANKS" ); static const std::string flag_USE_UPS( "USE_UPS" ); static const std::string flag_USES_BIONIC_POWER( "USES_BIONIC_POWER" ); static const std::string flag_VARSIZE( "VARSIZE" ); static const std::string flag_VEHICLE( "VEHICLE" ); -static const std::string flag_VISION( "VISION" ); static const std::string flag_WAIST( "WAIST" ); static const std::string flag_WALL( "WALL" ); -static const std::string flag_WASHING_MACHINE( "WASHING_MACHINE" ); -static const std::string flag_WATCH( "WATCH" ); static const std::string flag_WATER_EXTINGUISH( "WATER_EXTINGUISH" ); static const std::string flag_WATER_FRIENDLY( "WATER_FRIENDLY" ); -static const std::string flag_WATER_PURIFIER( "WATER_PURIFIER" ); -static const std::string flag_WATER_WHEEL( "WATER_WHEEL" ); static const std::string flag_WATERPROOF( "WATERPROOF" ); static const std::string flag_WATERPROOF_GUN( "WATERPROOF_GUN" ); -static const std::string flag_WELDRIG( "WELDRIG" ); static const std::string flag_WET( "WET" ); -static const std::string flag_WHEEL( "WHEEL" ); -static const std::string flag_WHEEL_MOUNT_HEAVY( "WHEEL_MOUNT_HEAVY" ); -static const std::string flag_WHEEL_MOUNT_LIGHT( "WHEEL_MOUNT_LIGHT" ); -static const std::string flag_WHEEL_MOUNT_MEDIUM( "WHEEL_MOUNT_MEDIUM" ); static const std::string flag_WHIP( "WHIP" ); static const std::string flag_WIN_START( "WIN_START" ); static const std::string flag_WIND_EXTINGUISH( "WIND_EXTINGUISH" ); -static const std::string flag_WIND_POWERED( "WIND_POWERED" ); -static const std::string flag_WIND_TURBINE( "WIND_TURBINE" ); -static const std::string flag_WINDOW( "WINDOW" ); -static const std::string flag_WINDOW_CURTAIN( "WINDOW_CURTAIN" ); -static const std::string flag_WINDSHIELD( "WINDSHIELD" ); -static const std::string flag_wooled( "wooled" ); -static const std::string flag_WORKBENCH( "WORKBENCH" ); static const std::string flag_WRITE_MESSAGE( "WRITE_MESSAGE" ); static const std::string flag_YOUNG( "YOUNG" ); -static const std::string flag_ZOOM( "ZOOM" ); + static const skill_id skill_archery( "archery" ); static const skill_id skill_barter( "barter" ); @@ -1466,25 +1271,27 @@ static const skill_id skill_tailor( "tailor" ); static const skill_id skill_throw( "throw" ); static const skill_id skill_traps( "traps" ); static const skill_id skill_unarmed( "unarmed" ); -static const skill_id skill_weapon( "weapon" ); +static const skill_id weapon_skill( "weapon" ); + + +static const quality_id qual_ANESTHESIA( "ANESTHESIA" ); +static const quality_id qual_AXE( "AXE" ); +static const quality_id qual_BUTCHER( "BUTCHER" ); +static const quality_id qual_CUT( "CUT" ); +static const quality_id qual_CUT_FINE( "CUT_FINE" ); +static const quality_id qual_DIG( "DIG" ); +static const quality_id qual_DRILL( "DRILL" ); +static const quality_id qual_FISHING( "FISHING" ); +static const quality_id qual_HAMMER( "HAMMER" ); +static const quality_id qual_JACK( "JACK" ); +static const quality_id qual_LIFT( "LIFT" ); +static const quality_id qual_PRY( "PRY" ); +static const quality_id qual_SAW_M( "SAW_M" ); +static const quality_id qual_SAW_W( "SAW_W" ); +static const quality_id qual_SCREW_FINE( "SCREW_FINE" ); +static const quality_id qual_SELF_JACK( "SELF_JACK" ); +static const quality_id qual_WELD( "WELD" ); -static const quality_id quality_ANESTHESIA( "ANESTHESIA" ); -static const quality_id quality_AXE( "AXE" ); -static const quality_id quality_BUTCHER( "BUTCHER" ); -static const quality_id quality_CUT( "CUT" ); -static const quality_id quality_CUT_FINE( "CUT_FINE" ); -static const quality_id quality_DIG( "DIG" ); -static const quality_id quality_DRILL( "DRILL" ); -static const quality_id quality_FISHING( "FISHING" ); -static const quality_id quality_HAMMER( "HAMMER" ); -static const quality_id quality_JACK( "JACK" ); -static const quality_id quality_LIFT( "LIFT" ); -static const quality_id quality_PRY( "PRY" ); -static const quality_id quality_SAW_M( "SAW_M" ); -static const quality_id quality_SAW_W( "SAW_W" ); -static const quality_id quality_SCREW_FINE( "SCREW_FINE" ); -static const quality_id quality_SELF_JACK( "SELF_JACK" ); -static const quality_id quality_WELD( "WELD" ); static const zone_type_id zone_investigate_only( "NPC_INVESTIGATE_ONLY" ); static const zone_type_id zone_no_investigate( "NPC_NO_INVESTIGATE" ); @@ -1496,22 +1303,8 @@ 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 zone_type_LOOT_CUSTOM( "LOOT_CUSTOM" ); -static const zone_type_id zone_type_NO_NPC_PICKUP( "NO_NPC_PICKUP" ); -static const zone_type_id zone_type_NPC_RETREAT( "NPC_RETREAT" ); -static const zone_type_id zone_type_NPC_NO_INVESTIGATE( "NPC_NO_INVESTIGATE" ); -static const zone_type_id zone_type_NPC_INVESTIGATE_ONLY( "NPC_INVESTIGATE_ONLY" ); -static const zone_type_id zone_type_SOURCE_FIREWOOD( "SOURCE_FIREWOOD" ); -static const zone_type_id zone_type_VEHICLE_PATROL( "VEHICLE_PATROL" ); -static const zone_type_id zone_type_CAMP_STORAGE( "CAMP_STORAGE" ); -static const zone_type_id zone_type_LOOT_PDRINK( "LOOT_PDRINK" ); -static const zone_type_id zone_type_LOOT_DRINK( "LOOT_DRINK" ); -static const zone_type_id zone_type_LOOT_PFOOD( "LOOT_PFOOD" ); -static const zone_type_id zone_type_LOOT_FOOD( "LOOT_FOOD" ); -static const zone_type_id zone_type_CAMP_FOOD( "CAMP_FOOD" ); static const zone_type_id z_camp_food( "CAMP_FOOD" ); static const zone_type_id z_camp_storage( "CAMP_STORAGE" ); @@ -1526,10 +1319,8 @@ static const itype_id fuel_type_animal( "animal" ); static const itype_id fuel_type_battery( "battery" ); static const itype_id fuel_type_muscle( "muscle" ); static const itype_id fuel_type_none( "null" ); -static const itype_id fuel_type_plut_cell( "plut_cell" ); +static const itype_id fuel_type_plutonium_cell( "plut_cell" ); static const itype_id fuel_type_sun_light( "sunlight" ); -static const itype_id fuel_type_water( "water" ); -static const itype_id fuel_type_water_clean( "water_clean" ); static const itype_id fuel_type_wind( "wind" ); static const fault_id fault_belt( "fault_engine_belt_drive" ); @@ -1571,219 +1362,53 @@ static const matype_id style_tiger( "style_tiger" ); static const matype_id style_wingchun( "style_wingchun" ); static const matype_id style_zui_quan( "style_zui_quan" ); -static const species_id species_BLOB( "BLOB" ); -static const species_id species_FISH( "FISH" ); -static const species_id species_FUNGUS( "FUNGUS" ); -static const species_id species_HALLUCINATION( "HALLUCINATION" ); -static const species_id species_HUMAN( "HUMAN" ); -static const species_id species_INSECT( "INSECT" ); -static const species_id species_LEECH_PLANT( "LEECH_PLANT" ); -static const species_id species_MAMMAL( "MAMMAL" ); -static const species_id species_MOLLUSK( "MOLLUSK" ); -static const species_id species_PLANT( "PLANT" ); -static const species_id species_ROBOT( "ROBOT" ); -static const species_id species_SPIDER( "SPIDER" ); -static const species_id species_ZOMBIE( "ZOMBIE" ); +static const species_id ABERRATION( "ABERRATION" ); +static const species_id BLOB( "BLOB" ); +static const species_id FISH( "FISH" ); +static const species_id FUNGUS( "FUNGUS" ); +static const species_id HALLUCINATION( "HALLUCINATION" ); +static const species_id HUMAN( "HUMAN" ); +static const species_id INSECT( "INSECT" ); +static const species_id LEECH_PLANT( "LEECH_PLANT" ); +static const species_id MAMMAL( "MAMMAL" ); +static const species_id MOLLUSK( "MOLLUSK" ); +static const species_id PLANT( "PLANT" ); +static const species_id ROBOT( "ROBOT" ); +static const species_id SPIDER( "SPIDER" ); +static const species_id ZOMBIE( "ZOMBIE" ); -static const matec_id matec_no_technique_id( "" ); -static const matec_id matec_RAPID( "RAPID" ); -static const matec_id matec_tec_none( "tec_none" ); -static const matec_id matec_VORPAL( "VORPAL" ); -static const matec_id matec_WBLOCK_1( "WBLOCK_1" ); -static const matec_id matec_WBLOCK_2( "WBLOCK_2" ); -static const matec_id matec_WBLOCK_3( "WBLOCK_3" ); -static const matec_id matec_WHIP_DISARM( "WHIP_DISARM" ); +static const matec_id tec_none( "tec_none" ); +static const matec_id WBLOCK_1( "WBLOCK_1" ); +static const matec_id WBLOCK_2( "WBLOCK_2" ); +static const matec_id WBLOCK_3( "WBLOCK_3" ); +static const matec_id WHIP_DISARM( "WHIP_DISARM" ); -static const ter_str_id ter_bridge( "t_bridge" ); -static const ter_str_id ter_chainfence( "t_chainfence" ); -static const ter_str_id ter_clay( "t_clay" ); -static const ter_str_id ter_claymound( "t_claymound" ); -static const ter_str_id ter_conveyor( "t_conveyor" ); static const ter_str_id ter_dirt( "t_dirt" ); -static const ter_str_id ter_dirtfloor( "t_dirtfloor" ); -static const ter_str_id ter_dirtmound( "t_dirtmound" ); -static const ter_str_id ter_dirtmoundfloor( "t_dirtmoundfloor" ); -static const ter_str_id ter_elevator( "t_elevator" ); -static const ter_str_id ter_gas_pump( "t_gas_pump" ); -static const ter_str_id ter_gas_pump_a( "t_gas_pump_a" ); -static const ter_str_id ter_gas_tank( "t_gas_tank" ); -static const ter_str_id ter_golf_hole( "t_golf_hole" ); -static const ter_str_id ter_grass( "t_grass" ); static const ter_str_id ter_grass_dead( "t_grass_dead" ); -static const ter_str_id ter_grass_golf( "t_grass_golf" ); -static const ter_str_id ter_grass_long( "t_grass_long" ); -static const ter_str_id ter_grass_tall( "t_grass_tall" ); -static const ter_str_id ter_grass_white( "t_grass_white" ); -static const ter_str_id ter_grate( "t_grate" ); -static const ter_str_id ter_grave( "t_grave" ); -static const ter_str_id ter_grave_new( "t_grave_new" ); -static const ter_str_id ter_guardrail_bg_dp( "t_guardrail_bg_dp" ); -static const ter_str_id ter_machinery_electronic( "t_machinery_electronic" ); -static const ter_str_id ter_machinery_heavy( "t_machinery_heavy" ); -static const ter_str_id ter_machinery_light( "t_machinery_light" ); -static const ter_str_id ter_machinery_old( "t_machinery_old" ); -static const ter_str_id ter_metal_floor( "t_metal_floor" ); -static const ter_str_id ter_moss( "t_moss" ); -static const ter_str_id ter_nanofab_body( "t_nanofab_body" ); -static const ter_str_id ter_ov_smreb_cage( "t_ov_smreb_cage" ); -static const ter_str_id ter_palisade_gate_o( "t_palisade_gate_o" ); -static const ter_str_id ter_pavement( "t_pavement" ); -static const ter_str_id ter_pit( "t_pit" ); -static const ter_str_id ter_pit_corpsed( "t_pit_corpsed" ); -static const ter_str_id ter_pit_covered( "t_pit_covered" ); -static const ter_str_id ter_pit_glass( "t_pit_glass" ); -static const ter_str_id ter_pit_shallow( "t_pit_shallow" ); -static const ter_str_id ter_pit_spiked( "t_pit_spiked" ); -static const ter_str_id ter_pit_spiked_covered( "t_pit_spiked_covered" ); -static const ter_str_id ter_plut_generator( "t_plut_generator" ); -static const ter_str_id ter_railroad_rubble( "t_railroad_rubble" ); -static const ter_str_id ter_railroad_tie( "t_railroad_tie" ); -static const ter_str_id ter_railroad_tie_d( "t_railroad_tie_d" ); -static const ter_str_id ter_railroad_tie_d1( "t_railroad_tie_d1" ); -static const ter_str_id ter_railroad_tie_d2( "t_railroad_tie_d2" ); -static const ter_str_id ter_railroad_tie_h( "t_railroad_tie_h" ); -static const ter_str_id ter_railroad_tie_v( "t_railroad_tie_v" ); -static const ter_str_id ter_railroad_track( "t_railroad_track" ); -static const ter_str_id ter_railroad_track_d( "t_railroad_track_d" ); -static const ter_str_id ter_railroad_track_d_on_tie( "t_railroad_track_d_on_tie" ); -static const ter_str_id ter_railroad_track_d1( "t_railroad_track_d1" ); -static const ter_str_id ter_railroad_track_d2( "t_railroad_track_d2" ); -static const ter_str_id ter_railroad_track_h( "t_railroad_track_h" ); -static const ter_str_id ter_railroad_track_h_on_tie( "t_railroad_track_h_on_tie" ); -static const ter_str_id ter_railroad_track_on_tie( "t_railroad_track_on_tie" ); -static const ter_str_id ter_railroad_track_v( "t_railroad_track_v" ); -static const ter_str_id ter_railroad_track_v_on_tie( "t_railroad_track_v_on_tie" ); -static const ter_str_id ter_rootcellar( "t_rootcellar" ); -static const ter_str_id ter_sand( "t_sand" ); -static const ter_str_id ter_sandbox( "t_sandbox" ); -static const ter_str_id ter_sandmound( "t_sandmound" ); -static const ter_str_id ter_sewage( "t_sewage" ); -static const ter_str_id ter_shrub( "t_shrub" ); -static const ter_str_id ter_shrub_blackberry( "t_shrub_blackberry" ); -static const ter_str_id ter_shrub_blackberry_harvested( "t_shrub_blackberry_harvested" ); -static const ter_str_id ter_shrub_blueberry( "t_shrub_blueberry" ); -static const ter_str_id ter_shrub_blueberry_harvested( "t_shrub_blueberry_harvested" ); -static const ter_str_id ter_shrub_grape( "t_shrub_grape" ); -static const ter_str_id ter_shrub_grape_harvested( "t_shrub_grape_harvested" ); -static const ter_str_id ter_shrub_huckleberry( "t_shrub_huckleberry" ); -static const ter_str_id ter_shrub_huckleberry_harvested( "t_shrub_huckleberry_harvested" ); -static const ter_str_id ter_shrub_hydrangea( "t_shrub_hydrangea" ); -static const ter_str_id ter_shrub_hydrangea_harvested( "t_shrub_hydrangea_harvested" ); -static const ter_str_id ter_shrub_lilac( "t_shrub_lilac" ); -static const ter_str_id ter_shrub_lilac_harvested( "t_shrub_lilac_harvested" ); -static const ter_str_id ter_shrub_peanut( "t_shrub_peanut" ); -static const ter_str_id ter_shrub_peanut_harvested( "t_shrub_peanut_harvested" ); -static const ter_str_id ter_shrub_raspberry( "t_shrub_raspberry" ); -static const ter_str_id ter_shrub_raspberry_harvested( "t_shrub_raspberry_harvested" ); -static const ter_str_id ter_shrub_rose( "t_shrub_rose" ); -static const ter_str_id ter_shrub_rose_harvested( "t_shrub_rose_harvested" ); -static const ter_str_id ter_shrub_strawberry( "t_shrub_strawberry" ); -static const ter_str_id ter_shrub_strawberry_harvested( "t_shrub_strawberry_harvested" ); -static const ter_str_id ter_slide( "t_slide" ); static const ter_str_id ter_stump( "t_stump" ); -static const ter_str_id ter_swater_dp( "t_swater_dp" ); -static const ter_str_id ter_swater_sh( "t_swater_sh" ); -static const ter_str_id ter_tree_birch_harvested( "t_tree_birch_harvested" ); static const ter_str_id ter_tree_dead( "t_tree_dead" ); static const ter_str_id ter_tree_deadpine( "t_tree_deadpine" ); -static const ter_str_id ter_tree_hickory_dead( "t_tree_hickory_dead" ); +static const ter_str_id ter_tree_birch_harvested( "t_tree_birch_harvested" ); static const ter_str_id ter_tree_willow_harvested( "t_tree_willow_harvested" ); +static const ter_str_id ter_tree_hickory_dead( "t_tree_hickory_dead" ); static const ter_str_id ter_trunk( "t_trunk" ); -static const ter_str_id ter_underbrush( "t_underbrush" ); -static const ter_str_id ter_underbrush_harvested_autumn( "t_underbrush_harvested_autumn" ); -static const ter_str_id ter_underbrush_harvested_spring( "t_underbrush_harvested_spring" ); -static const ter_str_id ter_underbrush_harvested_summer( "t_underbrush_harvested_summer" ); -static const ter_str_id ter_underbrush_harvested_winter( "t_underbrush_harvested_winter" ); -static const ter_str_id ter_utility_light( "t_utility_light" ); -static const ter_str_id ter_water_dp( "t_water_dp" ); -static const ter_str_id ter_water_moving_dp( "t_water_moving_dp" ); -static const ter_str_id ter_water_moving_sh( "t_water_moving_sh" ); -static const ter_str_id ter_water_pool( "t_water_pool" ); -static const ter_str_id ter_water_sh( "t_water_sh" ); - -static const material_id material_acidchitin( "acidchitin" ); -static const material_id material_alien_resin( "alien_resin" ); -static const material_id material_all( "all" ); -static const material_id material_bean( "bean" ); -static const material_id material_bone( "bone" ); -static const material_id material_budget_steel( "budget_steel" ); -static const material_id material_cac2powder( "cac2powder" ); -static const material_id material_chitin( "chitin" ); -static const material_id material_cotton( "cotton" ); -static const material_id material_egg( "egg" ); -static const material_id material_faux_fur( "faux_fur" ); -static const material_id material_flesh( "flesh" ); -static const material_id material_fruit( "fruit" ); -static const material_id material_fur( "fur" ); -static const material_id material_garlic( "garlic" ); -static const material_id material_glass( "glass" ); -static const material_id material_hardsteel( "hardsteel" ); -static const material_id material_hflesh( "hflesh" ); -static const material_id material_honey( "honey" ); -static const material_id material_hydrocarbons( "hydrocarbons" ); -static const material_id material_iflesh( "iflesh" ); -static const material_id material_iron( "iron" ); -static const material_id material_junk( "junk" ); -static const material_id material_kevlar( "kevlar" ); -static const material_id material_kevlar_rigid( "kevlar_rigid" ); -static const material_id material_leather( "leather" ); -static const material_id material_lycra( "lycra" ); -static const material_id material_milk( "milk" ); -static const material_id material_mushroom( "mushroom" ); -static const material_id material_neoprene( "neoprene" ); -static const material_id material_nomex( "nomex" ); -static const material_id material_null( "null" ); -static const material_id material_nut( "nut" ); -static const material_id material_nylon( "nylon" ); -static const material_id material_oil( "oil" ); -static const material_id material_paper( "paper" ); -static const material_id material_plastic( "plastic" ); -static const material_id material_powder( "powder" ); -static const material_id material_silver( "silver" ); -static const material_id material_steel( "steel" ); -static const material_id material_stone( "stone" ); -static const material_id material_tomato( "tomato" ); -static const material_id material_veggy( "veggy" ); -static const material_id material_wheat( "wheat" ); -static const material_id material_wood( "wood" ); -static const material_id material_wool( "wool" ); - -static const oter_str_id oter_forest( "forest" ); -static const oter_str_id oter_forest_thick( "forest_thick" ); static const std::string part_location_structure( "structure" ); static const std::string part_location_center( "center" ); static const std::string part_location_onroof( "on_roof" ); -static const vpart_id vpart_frame_vertical( "frame_vertical" ); -static const vpart_id vpart_frame_vertical_2( "frame_vertical_2" ); -static const vpart_id vpart_halfboard_horizontal( "halfboard_horizontal" ); -static const vpart_id vpart_horn_bicycle( "horn_bicycle" ); -static const vpart_id vpart_seat( "seat" ); -static const vpart_id vpart_storage_battery( "storage_battery" ); -static const vpart_id vpart_turret_mount( "turret_mount" ); -static const vpart_id vpart_wheel_mount_heavy( "wheel_mount_heavy" ); -static const vpart_id vpart_wheel_mount_heavy_steerable( "wheel_mount_heavy_steerable" ); -static const vpart_id vpart_wheel_mount_light( "wheel_mount_light" ); -static const vpart_id vpart_wheel_mount_light_steerable( "wheel_mount_light_steerable" ); -static const vpart_id vpart_wheel_mount_medium( "wheel_mount_medium" ); -static const vpart_id vpart_wheel_mount_medium_steerable( "wheel_mount_medium_steerable" ); -static const vpart_id vpart_wheel_wide( "wheel_wide" ); - static const std::string GUN_MODE_VAR_NAME( "item::mode" ); static const std::string CLOTHING_MOD_VAR_PREFIX( "clothing_mod_" ); -static const faction_id faction_amf( "amf" ); -static const faction_id faction_your_followers( "your_followers" ); -static const faction_id faction_no_faction( "no_faction" ); +static const faction_id your_followers( "your_followers" ); +static const faction_id no_faction( "no_faction" ); static const std::string errstring( "ERROR" ); -static const ammotype ammo_battery( "battery" ); static const ammotype ammo_bolt( "bolt" ); -static const ammotype ammo_money( "money" ); -static const ammotype ammo_plutonium( "plutonium" ); +static const ammotype ammo_battery( "ammo_battery" ); static const ammotype ammo_reactor_slurry( "reactor_slurry" ); +static const ammotype ammo_plutonium( "plutonium" ); static const std::string title_BIONICS = translate_marker( "BIONICS" ); static const std::string title_EFFECTS = translate_marker( "EFFECTS" ); @@ -1793,11 +1418,7 @@ static const std::string title_SPEED = translate_marker( "SPEED" ); static const std::string title_STATS = translate_marker( "STATS" ); static const std::string title_TRAITS = translate_marker( "TRAITS" ); -const vitamin_id vitamin_calcium( "calcium" ); const vitamin_id vitamin_iron( "iron" ); -const vitamin_id vitamin_vitA( "vitA" ); -const vitamin_id vitamin_vitB( "vitB" ); -const vitamin_id vitamin_vitC( "vitC" ); static const std::string null_item_id( "null" ); diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 4d0228049613b..0ae953c69f1a3 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -2600,7 +2600,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, g->u.memorize_tile( g->m.getabs( p ), vpname, subtile, rotation ); } if( !overridden ) { - const cata::optional cargopart = vp.part_with_feature( flag_CARGO, true ); + const cata::optional cargopart = vp.part_with_feature( "CARGO", true ); const bool draw_highlight = cargopart && !veh.get_items( cargopart->part_index() ).empty(); const bool ret = draw_from_id_string( vpname, C_VEHICLE_PART, empty_string, p, subtile, rotation, ll, nv_goggles_activated, height_3d ); diff --git a/src/cata_tiles.h b/src/cata_tiles.h index a1692164f2c66..45ec9194ce19c 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -28,6 +28,8 @@ class player; class pixel_minimap; class JsonObject; +using itype_id = std::string; + extern void set_displaybuffer_rendertarget(); /** Structures */ diff --git a/src/cata_variant.h b/src/cata_variant.h index a59efee418d94..c02701cd6fc92 100644 --- a/src/cata_variant.h +++ b/src/cata_variant.h @@ -18,6 +18,8 @@ enum body_part : int; enum class mutagen_technique : int; enum hp_part : int; +using itype_id = std::string; + // cata_variant is a variant-like type that stores a variety of different cata // types. All types are stored by converting them to a string. diff --git a/src/character.cpp b/src/character.cpp index fb1c6eb1d2377..e0b710d537c62 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -68,6 +68,7 @@ #include "vitamin.h" #include "vpart_position.h" + // *INDENT-OFF* Character::Character() : @@ -183,7 +184,7 @@ field_type_id Character::gibType() const bool Character::in_species( const species_id &spec ) const { - return spec == species_HUMAN; + return spec == HUMAN; } bool Character::is_warm() const @@ -1939,6 +1940,7 @@ int Character::best_nearby_lifting_assist() const int Character::best_nearby_lifting_assist( const tripoint &world_pos ) const { + const quality_id LIFT( "LIFT" ); int mech_lift = 0; if( is_mounted() ) { auto mons = mounted_creature.get(); @@ -1946,9 +1948,9 @@ int Character::best_nearby_lifting_assist( const tripoint &world_pos ) const mech_lift = mons->mech_str_addition() + 10; } } - return std::max( { this->max_quality( quality_LIFT ), mech_lift, - map_selector( this->pos(), PICKUP_RANGE ).max_quality( quality_LIFT ), - vehicle_selector( world_pos, 4, true, true ).max_quality( quality_LIFT ) + return std::max( { this->max_quality( LIFT ), mech_lift, + map_selector( this->pos(), PICKUP_RANGE ).max_quality( LIFT ), + vehicle_selector( world_pos, 4, true, true ).max_quality( LIFT ) } ); } @@ -2138,8 +2140,8 @@ ret_val Character::can_wear( const item &it, bool with_equip_change ) cons return ret_val::make_failure( _( "Putting on a %s would be tricky." ), it.tname() ); } - if( has_trait( trait_WOOLALLERGY ) && ( it.made_of( material_wool ) || - it.item_tags.count( flag_wooled ) ) ) { + if( has_trait( trait_WOOLALLERGY ) && ( it.made_of( material_id( "wool" ) ) || + it.item_tags.count( "wooled" ) ) ) { return ret_val::make_failure( _( "Can't wear that, it's made of wool!" ) ); } @@ -2158,8 +2160,8 @@ ret_val Character::can_wear( const item &it, bool with_equip_change ) cons } } if( it.covers( bp_head ) && !it.has_flag( flag_SEMITANGIBLE ) && - !it.made_of( material_wool ) && !it.made_of( material_cotton ) && - !it.made_of( material_nomex ) && !it.made_of( material_leather ) && + !it.made_of( material_id( "wool" ) ) && !it.made_of( material_id( "cotton" ) ) && + !it.made_of( material_id( "nomex" ) ) && !it.made_of( material_id( "leather" ) ) && ( has_trait( trait_HORNS_POINTED ) || has_trait( trait_ANTENNAE ) || has_trait( trait_ANTLERS ) ) ) { return ret_val::make_failure( _( "Cannot wear a helmet over %s." ), @@ -2284,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( flag_NO_UNWIELD ) ) { + if( it.has_flag( "NO_UNWIELD" ) ) { return ret_val::make_failure( _( "You cannot unwield your %s." ), it.tname() ); } @@ -2619,9 +2621,9 @@ void Character::do_skill_rust() SkillLevel &skill_level_obj = pair.second; if( aSkill.is_combat_skill() && - ( ( has_trait_flag( flag_PRED2 ) && calendar::once_every( 8_hours ) ) || - ( has_trait_flag( flag_PRED3 ) && calendar::once_every( 4_hours ) ) || - ( has_trait_flag( flag_PRED4 ) && calendar::once_every( 3_hours ) ) ) ) { + ( ( has_trait_flag( "PRED2" ) && calendar::once_every( 8_hours ) ) || + ( has_trait_flag( "PRED3" ) && calendar::once_every( 4_hours ) ) || + ( has_trait_flag( "PRED4" ) && calendar::once_every( 3_hours ) ) ) ) { // Their brain is optimized to remember this if( one_in( 13 ) ) { // They've already passed the roll to avoid rust at @@ -2845,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( flag_SEMITANGIBLE ) ) { + if( it.has_flag( "SEMITANGIBLE" ) ) { encumber_val = 0; layering_encumbrance = 0; } @@ -2928,7 +2930,7 @@ bool Character::in_climate_control() if( w.active && w.is_power_armor() ) { return true; } - if( worn_with_flag( flag_CLIMATE_CONTROL ) ) { + if( worn_with_flag( "CLIMATE_CONTROL" ) ) { return true; } } @@ -2963,13 +2965,13 @@ int Character::get_wind_resistance( body_part bp ) const for( auto &i : worn ) { if( i.covers( bp ) ) { - if( i.made_of( material_leather ) || i.made_of( material_plastic ) || - i.made_of( material_bone ) || - i.made_of( material_chitin ) || i.made_of( material_nomex ) ) { + if( i.made_of( material_id( "leather" ) ) || i.made_of( material_id( "plastic" ) ) || + i.made_of( material_id( "bone" ) ) || + i.made_of( material_id( "chitin" ) ) || i.made_of( material_id( "nomex" ) ) ) { penalty = 10; // 90% effective - } else if( i.made_of( material_cotton ) ) { + } else if( i.made_of( material_id( "cotton" ) ) ) { penalty = 30; - } else if( i.made_of( material_wool ) ) { + } else if( i.made_of( material_id( "wool" ) ) ) { penalty = 40; } else { penalty = 1; // 99% effective @@ -3586,7 +3588,7 @@ std::pair Character::get_fatigue_description() const void Character::mod_thirst( int nthirst ) { - if( has_trait_flag( flag_NO_THIRST ) ) { + if( has_trait_flag( "NO_THIRST" ) ) { return; } set_thirst( std::max( -100, thirst + nthirst ) ); @@ -4003,6 +4005,7 @@ void Character::update_needs( int rate_multiplier ) mod_sleep_deprivation( fatigue_roll * 5 ); } + if( npc_no_food && get_fatigue() > TIRED ) { set_fatigue( TIRED ); set_sleep_deprivation( 0 ); @@ -4369,7 +4372,7 @@ void Character::check_needs_extremes() void Character::get_sick() { // NPCs are too dumb to handle infections now - if( is_npc() || has_trait_flag( flag_NO_DISEASE ) ) { + if( is_npc() || has_trait_flag( "NO_DISEASE" ) ) { // In a shocking twist, disease immunity prevents diseases. return; } @@ -4486,7 +4489,7 @@ void Character::update_bodytemp() const bool has_climate_control = in_climate_control(); const bool use_floor_warmth = can_use_floor_warmth(); const furn_id furn_at_pos = g->m.furn( pos() ); - const cata::optional boardable = vp.part_with_feature( flag_BOARDABLE, true ); + const cata::optional boardable = vp.part_with_feature( "BOARDABLE", true ); // Temperature norms // Ambient normal temperature is lower while asleep const int ambient_norm = has_sleep ? 3100 : 1900; @@ -4988,8 +4991,8 @@ Character::comfort_response_t Character::base_comfort_value( const tripoint &p ) comfort += 1 + static_cast( comfort_level::slightly_comfortable ); // Note: shelled individuals can still use sleeping aids! } else if( vp ) { - const cata::optional carg = vp.part_with_feature( flag_CARGO, false ); - const cata::optional board = vp.part_with_feature( flag_BOARDABLE, true ); + const cata::optional carg = vp.part_with_feature( "CARGO", false ); + const cata::optional board = vp.part_with_feature( "BOARDABLE", true ); if( carg ) { const vehicle_stack items = vp->vehicle().get_items( carg->part_index() ); for( const item &items_it : items ) { @@ -5427,7 +5430,7 @@ nc_color Character::symbol_color() const bool Character::is_immune_field( const field_type_id &fid ) const { // Obviously this makes us invincible - if( has_trait( trait_DEBUG_NODMG ) ) { + if( has_trait( debug_nodmg ) ) { return true; } // Check to see if we are immune @@ -5497,34 +5500,34 @@ bool Character::is_immune_damage( const damage_type dt ) const case DT_TRUE: return false; case DT_BIOLOGICAL: - return has_effect_with_flag( flag_EFFECT_BIO_IMMUNE ) || - worn_with_flag( flag_BIO_IMMUNE ); + return has_effect_with_flag( "EFFECT_BIO_IMMUNE" ) || + worn_with_flag( "BIO_IMMUNE" ); case DT_BASH: - return has_effect_with_flag( flag_EFFECT_BASH_IMMUNE ) || - worn_with_flag( flag_BASH_IMMUNE ); + return has_effect_with_flag( "EFFECT_BASH_IMMUNE" ) || + worn_with_flag( "BASH_IMMUNE" ); case DT_CUT: - return has_effect_with_flag( flag_EFFECT_CUT_IMMUNE ) || - worn_with_flag( flag_CUT_IMMUNE ); + return has_effect_with_flag( "EFFECT_CUT_IMMUNE" ) || + worn_with_flag( "CUT_IMMUNE" ); case DT_ACID: return has_trait( trait_ACIDPROOF ) || - has_effect_with_flag( flag_EFFECT_ACID_IMMUNE ) || - worn_with_flag( flag_ACID_IMMUNE ); + has_effect_with_flag( "EFFECT_ACID_IMMUNE" ) || + worn_with_flag( "ACID_IMMUNE" ); case DT_STAB: - return has_effect_with_flag( flag_EFFECT_STAB_IMMUNE ) || - worn_with_flag( flag_STAB_IMMUNE ); + return has_effect_with_flag( "EFFECT_STAB_IMMUNE" ) || + worn_with_flag( "STAB_IMMUNE" ); case DT_HEAT: return has_trait( trait_M_SKIN2 ) || has_trait( trait_M_SKIN3 ) || - has_effect_with_flag( flag_EFFECT_HEAT_IMMUNE ) || - worn_with_flag( flag_HEAT_IMMUNE ); + has_effect_with_flag( "EFFECT_HEAT_IMMUNE" ) || + worn_with_flag( "HEAT_IMMUNE" ); case DT_COLD: - return has_effect_with_flag( flag_EFFECT_COLD_IMMUNE ) || - worn_with_flag( flag_COLD_IMMUNE ); + return has_effect_with_flag( "EFFECT_COLD_IMMUNE" ) || + worn_with_flag( "COLD_IMMUNE" ); case DT_ELECTRIC: return has_active_bionic( bio_faraday ) || - worn_with_flag( flag_ELECTRIC_IMMUNE ) || + worn_with_flag( "ELECTRIC_IMMUNE" ) || has_artifact_with( AEP_RESIST_ELECTRICITY ) || - has_effect_with_flag( flag_EFFECT_ELECTRIC_IMMUNE ); + has_effect_with_flag( "EFFECT_ELECTRIC_IMMUNE" ); default: return true; } @@ -5533,7 +5536,7 @@ bool Character::is_immune_damage( const damage_type dt ) const bool Character::is_rad_immune() const { bool has_helmet = false; - return ( is_wearing_power_armor( &has_helmet ) && has_helmet ) || worn_with_flag( flag_RAD_PROOF ); + return ( is_wearing_power_armor( &has_helmet ) && has_helmet ) || worn_with_flag( "RAD_PROOF" ); } int Character::throw_range( const item &it ) const @@ -5563,7 +5566,7 @@ int Character::throw_range( const item &it ) const static_cast( tmp.weight() / 15_gram ) ); ret -= tmp.volume() / 1_liter; - static const std::set affected_materials = { material_iron, material_steel }; + static const std::set affected_materials = { material_id( "iron" ), material_id( "steel" ) }; if( has_active_bionic( bio_railgun ) && tmp.made_of_any( affected_materials ) ) { ret *= 2; } @@ -5581,7 +5584,7 @@ int Character::throw_range( const item &it ) const return ret; } -const std::vector Character::fleshy = { material_flesh, material_hflesh }; +const std::vector Character::fleshy = { material_id( "flesh" ), material_id( "hflesh" ) }; bool Character::made_of( const material_id &m ) const { // TODO: check for mutations that change this. @@ -5699,7 +5702,7 @@ bool Character::sees_with_specials( const Creature &critter ) const { // electroreceptors grants vision of robots and electric monsters through walls if( has_trait( trait_ELECTRORECEPTORS ) && - ( critter.in_species( species_ROBOT ) || critter.has_flag( MF_ELECTRIC ) ) ) { + ( critter.in_species( ROBOT ) || critter.has_flag( MF_ELECTRIC ) ) ) { return true; } @@ -6462,7 +6465,7 @@ void Character::set_rad( int new_rad ) void Character::mod_rad( int mod ) { - if( has_trait_flag( flag_NO_RADIATION ) ) { + if( has_trait_flag( "NO_RADIATION" ) ) { return; } set_rad( std::max( 0, get_rad() + mod ) ); @@ -7507,7 +7510,7 @@ bool Character::armor_absorb( damage_unit &du, item &armor ) m_info ); } - return armor.mod_damage( armor.has_flag( flag_FRAGILE ) ? + return armor.mod_damage( armor.has_flag( "FRAGILE" ) ? rng( 2 * itype::damage_scale, 3 * itype::damage_scale ) : itype::damage_scale, du.type ); } @@ -7805,8 +7808,8 @@ void Character::rooted() if( ( has_trait( trait_ROOTS2 ) || has_trait( trait_ROOTS3 ) ) && g->m.has_flag( flag_PLOWABLE, pos() ) && shoe_factor != 1.0 ) { if( one_in( 96 ) ) { - vitamin_mod( vitamin_iron, 1, true ); - vitamin_mod( vitamin_calcium, 1, true ); + vitamin_mod( vitamin_id( "iron" ), 1, true ); + vitamin_mod( vitamin_id( "calcium" ), 1, true ); } if( get_thirst() <= -2000 && x_in_y( 75, 425 ) ) { mod_thirst( -1 ); @@ -7953,7 +7956,7 @@ bool Character::covered_with_flag( const std::string &flag, const body_part_set bool Character::is_waterproof( const body_part_set &parts ) const { - return covered_with_flag( flag_WATERPROOF, parts ); + return covered_with_flag( "WATERPROOF", parts ); } void Character::update_morale() @@ -8313,7 +8316,7 @@ int Character::warmth( body_part bp ) const warmth = i.get_warmth(); // Wool items do not lose their warmth due to being wet. // Warmth is reduced by 0 - 66% based on wetness. - if( !i.made_of( material_wool ) ) { + if( !i.made_of( material_id( "wool" ) ) ) { warmth *= 1.0 - 0.66 * body_wetness[bp] / drench_capacity[bp]; } ret += warmth; @@ -8340,17 +8343,17 @@ int Character::bonus_item_warmth( body_part bp ) const // If the player is not wielding anything big, check if hands can be put in pockets if( ( bp == bp_hand_l || bp == bp_hand_r ) && weapon.volume() < 500_ml ) { - ret += bestwarmth( worn, flag_POCKETS ); + ret += bestwarmth( worn, "POCKETS" ); } // If the player's head is not encumbered, check if hood can be put up if( bp == bp_head && encumb( bp_head ) < 10 ) { - ret += bestwarmth( worn, flag_HOOD ); + ret += bestwarmth( worn, "HOOD" ); } // If the player's mouth is not encumbered, check if collar can be put up if( bp == bp_mouth && encumb( bp_mouth ) < 10 ) { - ret += bestwarmth( worn, flag_COLLAR ); + ret += bestwarmth( worn, "COLLAR" ); } return ret; @@ -8359,26 +8362,26 @@ int Character::bonus_item_warmth( body_part bp ) const bool Character::can_use_floor_warmth() const { return in_sleep_state() || - has_activity( ACT_WAIT ) || - has_activity( ACT_WAIT_NPC ) || - has_activity( ACT_WAIT_STAMINA ) || - has_activity( ACT_AUTODRIVE ) || - has_activity( ACT_READ ) || - has_activity( ACT_SOCIALIZE ) || - has_activity( ACT_MEDITATE ) || - has_activity( ACT_FISH ) || - has_activity( ACT_GAME ) || - has_activity( ACT_HAND_CRANK ) || - has_activity( ACT_HEATING ) || - has_activity( ACT_VIBE ) || - has_activity( ACT_TRY_SLEEP ) || - has_activity( ACT_OPERATION ) || - has_activity( ACT_TREE_COMMUNION ) || - has_activity( ACT_EAT_MENU ) || - has_activity( ACT_CONSUME_FOOD_MENU ) || - has_activity( ACT_CONSUME_DRINK_MENU ) || - has_activity( ACT_CONSUME_MEDS_MENU ) || - has_activity( ACT_STUDY_SPELL ); + has_activity( activity_id( "ACT_WAIT" ) ) || + has_activity( activity_id( "ACT_WAIT_NPC" ) ) || + has_activity( activity_id( "ACT_WAIT_STAMINA" ) ) || + has_activity( activity_id( "ACT_AUTODRIVE" ) ) || + has_activity( activity_id( "ACT_READ" ) ) || + has_activity( activity_id( "ACT_SOCIALIZE" ) ) || + has_activity( activity_id( "ACT_MEDITATE" ) ) || + has_activity( activity_id( "ACT_FISH" ) ) || + has_activity( activity_id( "ACT_GAME" ) ) || + has_activity( activity_id( "ACT_HAND_CRANK" ) ) || + has_activity( activity_id( "ACT_HEATING" ) ) || + has_activity( activity_id( "ACT_VIBE" ) ) || + has_activity( activity_id( "ACT_TRY_SLEEP" ) ) || + has_activity( activity_id( "ACT_OPERATION" ) ) || + has_activity( activity_id( "ACT_TREE_COMMUNION" ) ) || + has_activity( activity_id( "ACT_EAT_MENU" ) ) || + has_activity( activity_id( "ACT_CONSUME_FOOD_MENU" ) ) || + has_activity( activity_id( "ACT_CONSUME_DRINK_MENU" ) ) || + has_activity( activity_id( "ACT_CONSUME_MEDS_MENU" ) ) || + has_activity( activity_id( "ACT_STUDY_SPELL" ) ); } int Character::floor_bedding_warmth( const tripoint &pos ) @@ -8389,7 +8392,7 @@ int Character::floor_bedding_warmth( const tripoint &pos ) int floor_bedding_warmth = 0; const optional_vpart_position vp = g->m.veh_at( pos ); - const cata::optional boardable = vp.part_with_feature( flag_BOARDABLE, true ); + const cata::optional boardable = vp.part_with_feature( "BOARDABLE", true ); // Search the floor for bedding if( furn_at_pos != f_null ) { floor_bedding_warmth += furn_at_pos.obj().floor_bedding_warmth; @@ -8627,10 +8630,10 @@ bool Character::has_fire( const int quantity ) const if( g->m.has_nearby_fire( pos() ) ) { return true; - } else if( has_item_with_flag( flag_FIRE ) ) { + } else if( has_item_with_flag( "FIRE" ) ) { return true; - } else if( has_item_with_flag( flag_FIRESTARTER ) ) { - auto firestarters = all_items_with_flag( flag_FIRESTARTER ); + } else if( has_item_with_flag( "FIRESTARTER" ) ) { + auto firestarters = all_items_with_flag( "FIRESTARTER" ); for( auto &i : firestarters ) { if( has_charges( i->typeId(), quantity ) ) { return true; @@ -8686,10 +8689,10 @@ void Character::use_fire( const int quantity ) if( g->m.has_nearby_fire( pos() ) ) { return; - } else if( has_item_with_flag( flag_FIRE ) ) { + } else if( has_item_with_flag( "FIRE" ) ) { return; - } else if( has_item_with_flag( flag_FIRESTARTER ) ) { - auto firestarters = all_items_with_flag( flag_FIRESTARTER ); + } else if( has_item_with_flag( "FIRESTARTER" ) ) { + auto firestarters = all_items_with_flag( "FIRESTARTER" ); for( auto &i : firestarters ) { if( has_charges( i->typeId(), quantity ) ) { use_charges( i->typeId(), quantity ); diff --git a/src/character_martial_arts.cpp b/src/character_martial_arts.cpp index 7739f8005d2bc..074bc552f98f7 100644 --- a/src/character_martial_arts.cpp +++ b/src/character_martial_arts.cpp @@ -7,6 +7,8 @@ #include "output.h" #include "cata_string_consts.h" +using itype_id = std::string; + character_martial_arts::character_martial_arts() { diff --git a/src/character_martial_arts.h b/src/character_martial_arts.h index 904837f6f4286..bd47591dc3ee0 100644 --- a/src/character_martial_arts.h +++ b/src/character_martial_arts.h @@ -13,6 +13,8 @@ class item; class JsonOut; class JsonIn; +using itype_id = std::string; + class character_martial_arts { private: diff --git a/src/clzones.cpp b/src/clzones.cpp index d80e523807dfc..8355b4be7b6f8 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -38,19 +38,19 @@ zone_manager::zone_manager() { - types.emplace( zone_type_NO_AUTO_PICKUP, + types.emplace( zone_type_id( "NO_AUTO_PICKUP" ), zone_type( translate_marker( "No Auto Pickup" ), translate_marker( "You won't auto-pickup items inside the zone." ) ) ); - types.emplace( zone_type_NO_NPC_PICKUP, + types.emplace( zone_type_id( "NO_NPC_PICKUP" ), zone_type( translate_marker( "No NPC Pickup" ), translate_marker( "Friendly NPCs don't pickup items inside the zone." ) ) ); - types.emplace( zone_type_NPC_RETREAT, + types.emplace( zone_type_id( "NPC_RETREAT" ), zone_type( translate_marker( "NPC Retreat" ), translate_marker( "When fleeing, friendly NPCs will attempt to retreat toward this zone if it is within 60 tiles." ) ) ); - types.emplace( zone_type_NPC_NO_INVESTIGATE, + types.emplace( zone_type_id( "NPC_NO_INVESTIGATE" ), zone_type( translate_marker( "NPC Ignore Sounds" ), translate_marker( "Friendly NPCs won't investigate unseen sounds coming from this zone." ) ) ); - types.emplace( zone_type_NPC_INVESTIGATE_ONLY, + types.emplace( zone_type_id( "NPC_INVESTIGATE_ONLY" ), zone_type( translate_marker( "NPC Investigation Area" ), translate_marker( "Friendly NPCs will investigate unseen sounds only if they come from inside this area." ) ) ); @@ -58,35 +58,35 @@ zone_manager::zone_manager() types.emplace( zone.id, zone ); } - types.emplace( zone_type_SOURCE_FIREWOOD, + types.emplace( zone_type_id( "SOURCE_FIREWOOD" ), zone_type( translate_marker( "Source: Firewood" ), translate_marker( "Source for firewood or other flammable materials in this zone may be used to automatically refuel fires. " "This will be done to maintain light during long-running tasks such as crafting, reading or waiting." ) ) ); - types.emplace( zone_type_CONSTRUCTION_BLUEPRINT, + types.emplace( zone_type_id( "CONSTRUCTION_BLUEPRINT" ), zone_type( translate_marker( "Construction: Blueprint" ), translate_marker( "Designate a blueprint zone for construction." ) ) ); - types.emplace( zone_type_FARM_PLOT, + types.emplace( zone_type_id( "FARM_PLOT" ), zone_type( translate_marker( "Farm: Plot" ), translate_marker( "Designate a farm plot for tilling and planting." ) ) ); - types.emplace( zone_type_CHOP_TREES, + types.emplace( zone_type_id( "CHOP_TREES" ), zone_type( translate_marker( "Chop Trees" ), translate_marker( "Designate an area to chop down trees." ) ) ); - types.emplace( zone_type_FISHING_SPOT, + types.emplace( zone_type_id( "FISHING_SPOT" ), zone_type( translate_marker( "Fishing Spot" ), translate_marker( "Designate an area to fish from." ) ) ); - types.emplace( zone_type_VEHICLE_DECONSTRUCT, + types.emplace( zone_type_id( "VEHICLE_DECONSTRUCT" ), zone_type( translate_marker( "Vehicle Deconstruct Zone" ), translate_marker( "Any vehicles in this area are marked for deconstruction." ) ) ); - types.emplace( zone_type_VEHICLE_REPAIR, + types.emplace( zone_type_id( "VEHICLE_REPAIR" ), zone_type( translate_marker( "Vehicle Repair Zone" ), translate_marker( "Any vehicles in this area are marked for repair work." ) ) ); - types.emplace( zone_type_VEHICLE_PATROL, + types.emplace( zone_type_id( "VEHICLE_PATROL" ), zone_type( translate_marker( "Vehicle Patrol Zone" ), translate_marker( "Vehicles with an autopilot will patrol in this zone." ) ) ); - types.emplace( zone_type_CAMP_STORAGE, + types.emplace( zone_type_id( "CAMP_STORAGE" ), zone_type( translate_marker( "Basecamp: Storage" ), translate_marker( "Items in this zone will be added to a basecamp's inventory for use by it's workers." ) ) ); - types.emplace( zone_type_CAMP_FOOD, + types.emplace( zone_type_id( "CAMP_FOOD" ), zone_type( translate_marker( "Basecamp: Food" ), translate_marker( "Items in this zone will be added to a basecamp's food supply in the Distribute Food mission." ) ) ); @@ -138,11 +138,11 @@ void zone_type::load( const JsonObject &jo, const std::string & ) shared_ptr_fast zone_options::create( const zone_type_id &type ) { - if( type == zone_type_FARM_PLOT ) { + if( type == zone_type_id( "FARM_PLOT" ) ) { return make_shared_fast(); - } else if( type == zone_type_CONSTRUCTION_BLUEPRINT ) { + } else if( type == zone_type_id( "CONSTRUCTION_BLUEPRINT" ) ) { return make_shared_fast(); - } else if( type == zone_type_LOOT_CUSTOM ) { + } else if( type == zone_type_id( "LOOT_CUSTOM" ) ) { return make_shared_fast(); } @@ -151,11 +151,11 @@ shared_ptr_fast zone_options::create( const zone_type_id &type ) bool zone_options::is_valid( const zone_type_id &type, const zone_options &options ) { - if( type == zone_type_FARM_PLOT ) { + if( type == zone_type_id( "FARM_PLOT" ) ) { return dynamic_cast( &options ) != nullptr; - } else if( type == zone_type_CONSTRUCTION_BLUEPRINT ) { + } else if( type == zone_type_id( "CONSTRUCTION_BLUEPRINT" ) ) { return dynamic_cast( &options ) != nullptr; - } else if( type == zone_type_LOOT_CUSTOM ) { + } else if( type == zone_type_id( "LOOT_CUSTOM" ) ) { return dynamic_cast( &options ) != nullptr; } @@ -604,7 +604,7 @@ std::unordered_set zone_manager::get_point_set_loot( const tripoint &w if( ( !zone ) || ( zone->get_type().str().substr( 0, 4 ) != "LOOT" ) ) { continue; } - if( npc_search && ( has( zone_type_NO_NPC_PICKUP, elem ) ) ) { + if( npc_search && ( has( zone_type_id( "NO_NPC_PICKUP" ), elem ) ) ) { continue; } res.insert( elem ); @@ -660,10 +660,10 @@ bool zone_manager::has_loot_dest_near( const tripoint &where ) const { for( const auto &ztype : get_manager().get_types() ) { const zone_type_id &type = ztype.first; - if( type == zone_type_CAMP_FOOD || type == zone_type_FARM_PLOT || - type == zone_type_LOOT_UNSORTED || type == zone_type_LOOT_IGNORE || - type == zone_type_CONSTRUCTION_BLUEPRINT || - type == zone_type_NO_AUTO_PICKUP || type == zone_type_NO_NPC_PICKUP ) { + if( type == zone_type_id( "CAMP_FOOD" ) || type == zone_type_id( "FARM_PLOT" ) || + type == zone_type_id( "LOOT_UNSORTED" ) || type == zone_type_id( "LOOT_IGNORE" ) || + type == zone_type_id( "CONSTRUCTION_BLUEPRINT" ) || + type == zone_type_id( "NO_AUTO_PICKUP" ) || type == zone_type_id( "NO_NPC_PICKUP" ) ) { continue; } if( has_near( type, where ) ) { @@ -691,7 +691,7 @@ const zone_data *zone_manager::get_zone_at( const tripoint &where, const zone_ty bool zone_manager::custom_loot_has( const tripoint &where, const item *it ) const { - auto zone = get_zone_at( where, zone_type_LOOT_CUSTOM ); + auto zone = get_zone_at( where, zone_type_id( "LOOT_CUSTOM" ) ); if( !zone || !it ) { return false; } @@ -711,7 +711,7 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, for( auto &point : point_set ) { if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { - if( it && has( zone_type_LOOT_CUSTOM, point ) ) { + if( it && has( zone_type_id( "LOOT_CUSTOM" ), point ) ) { if( custom_loot_has( point, it ) ) { near_point_set.insert( point ); } @@ -726,7 +726,7 @@ std::unordered_set zone_manager::get_near( const zone_type_id &type, for( auto &point : vzone_set ) { if( point.z == where.z ) { if( square_dist( point, where ) <= range ) { - if( it && has( zone_type_LOOT_CUSTOM, point ) ) { + if( it && has( zone_type_id( "LOOT_CUSTOM" ), point ) ) { if( custom_loot_has( point, it ) ) { near_point_set.insert( point ); } @@ -783,20 +783,20 @@ zone_type_id zone_manager::get_near_zone_type_for_item( const item &it, { const item_category &cat = it.get_category(); - if( has_near( zone_type_LOOT_CUSTOM, where, range ) ) { - for( const auto elem : get_near( zone_type_LOOT_CUSTOM, where, range, &it ) ) { + if( has_near( zone_type_id( "LOOT_CUSTOM" ), where, range ) ) { + for( const auto elem : get_near( zone_type_id( "LOOT_CUSTOM" ), where, range, &it ) ) { ( void )elem; - return zone_type_LOOT_CUSTOM; + return zone_type_id( "LOOT_CUSTOM" ); } } if( it.has_flag( flag_FIREWOOD ) ) { - if( has_near( zone_type_LOOT_WOOD, where, range ) ) { - return zone_type_LOOT_WOOD; + if( has_near( zone_type_id( "LOOT_WOOD" ), where, range ) ) { + return zone_type_id( "LOOT_WOOD" ); } } if( it.is_corpse() ) { - if( has_near( zone_type_LOOT_CORPSE, where, range ) ) { - return zone_type_LOOT_CORPSE; + if( has_near( zone_type_id( "LOOT_CORPSE" ), where, range ) ) { + return zone_type_id( "LOOT_CORPSE" ); } } @@ -814,20 +814,20 @@ zone_type_id zone_manager::get_near_zone_type_for_item( const item &it, // skip food without comestible, like MREs if( const item *it_food = it.get_food() ) { - if( it_food->get_comestible()->comesttype == comesttype_DRINK ) { - if( !preserves && it_food->goes_bad() && has_near( zone_type_LOOT_PDRINK, where, range ) ) { - return zone_type_LOOT_PDRINK; - } else if( has_near( zone_type_LOOT_DRINK, where, range ) ) { - return zone_type_LOOT_DRINK; + if( it_food->get_comestible()->comesttype == "DRINK" ) { + if( !preserves && it_food->goes_bad() && has_near( zone_type_id( "LOOT_PDRINK" ), where, range ) ) { + return zone_type_id( "LOOT_PDRINK" ); + } else if( has_near( zone_type_id( "LOOT_DRINK" ), where, range ) ) { + return zone_type_id( "LOOT_DRINK" ); } } - if( !preserves && it_food->goes_bad() && has_near( zone_type_LOOT_PFOOD, where, range ) ) { - return zone_type_LOOT_PFOOD; + if( !preserves && it_food->goes_bad() && has_near( zone_type_id( "LOOT_PFOOD" ), where, range ) ) { + return zone_type_id( "LOOT_PFOOD" ); } } - return zone_type_LOOT_FOOD; + return zone_type_id( "LOOT_FOOD" ); } return zone_type_id(); @@ -912,11 +912,11 @@ void zone_manager::add( const std::string &name, const zone_type_id &type, const zone_data new_zone = zone_data( name, type, fac, invert, enabled, start, end, options ); //the start is a vehicle tile with cargo space if( const cata::optional vp = g->m.veh_at( g->m.getlocal( - start ) ).part_with_feature( flag_CARGO, false ) ) { + start ) ).part_with_feature( "CARGO", false ) ) { // TODO:Allow for loot zones on vehicles to be larger than 1x1 if( start == end && query_yn( _( "Bind this zone to the cargo part here?" ) ) ) { // TODO: refactor zone options for proper validation code - if( type == zone_type_FARM_PLOT || type == zone_type_CONSTRUCTION_BLUEPRINT ) { + if( type == zone_type_id( "FARM_PLOT" ) || type == zone_type_id( "CONSTRUCTION_BLUEPRINT" ) ) { popup( _( "You cannot add that type of zone to a vehicle." ), PF_NONE ); return; } @@ -1178,7 +1178,7 @@ void zone_manager::revert_vzones() for( auto zone : removed_vzones ) { //Code is copied from add() to avoid yn query if( const cata::optional vp = g->m.veh_at( g->m.getlocal( - zone.get_start_point() ) ).part_with_feature( flag_CARGO, false ) ) { + zone.get_start_point() ) ).part_with_feature( "CARGO", false ) ) { zone.set_is_vehicle( true ); vp->vehicle().loot_zones.emplace( vp->mount(), zone ); vp->vehicle().zones_dirty = false; diff --git a/src/computer_session.cpp b/src/computer_session.cpp index 5651403228f60..6bdb08a48b142 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -718,8 +718,8 @@ void computer_session::action_blood_anal() const mtype *mt = blood.get_mtype(); if( mt == nullptr || mt->id == mtype_id::NULL_ID() ) { print_line( _( "Result: Human blood, no pathogens found." ) ); - } else if( mt->in_species( species_ZOMBIE ) ) { - if( mt->in_species( species_HUMAN ) ) { + } else if( mt->in_species( ZOMBIE ) ) { + if( mt->in_species( HUMAN ) ) { print_line( _( "Result: Human blood. Unknown pathogen found." ) ); } else { print_line( _( "Result: Unknown blood type. Unknown pathogen found." ) ); diff --git a/src/construction.cpp b/src/construction.cpp index 1472f5712ee19..39ac794f4a534 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1077,7 +1077,7 @@ void construct::done_grave( const tripoint &p ) g->u.getID(), it.get_mtype()->id, it.get_corpse_name() ); } } - if( g->u.has_quality( quality_CUT ) ) { + if( g->u.has_quality( qual_CUT ) ) { iuse::handle_ground_graffiti( g->u, nullptr, _( "Inscribe something on the grave?" ), p ); } else { add_msg( m_neutral, @@ -1105,7 +1105,8 @@ static vpart_id vpart_from_item( const std::string &item_id ) } } debugmsg( "item %s used by construction is not base item of any vehicle part!", item_id.c_str() ); - return vpart_frame_vertical_2; + static const vpart_id frame_id( "frame_vertical_2" ); + return frame_id; } void construct::done_vehicle( const tripoint &p ) diff --git a/src/consumption.cpp b/src/consumption.cpp index 06efa585df865..06821eb763823 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -135,7 +135,7 @@ static std::map compute_default_effective_vitamins( // TODO: put this loop into a function and utilize it again for bionics for( const auto &mat : mut.vitamin_absorb_multi ) { // this is where we are able to check if the food actually is changed by the trait - if( mat.first == material_all || it.made_of( mat.first ) ) { + if( mat.first == material_id( "all" ) || it.made_of( mat.first ) ) { const std::map &mat_vit_map = mat.second; for( auto &vit : res ) { auto vit_factor = mat_vit_map.find( vit.first ); @@ -530,7 +530,7 @@ ret_val Character::can_eat( const item &food ) const return ret_val::make_failure( _( "That doesn't look edible in its current form." ) ); } - if( food.item_tags.count( flag_DIRTY ) ) { + if( food.item_tags.count( "DIRTY" ) ) { return ret_val::make_failure( _( "This is full of dirt after being on the ground." ) ); } @@ -632,7 +632,7 @@ ret_val Character::will_eat( const item &food, bool interactive ) } const bool carnivore = has_trait( trait_CARNIVORE ); - if( food.has_flag( flag_CANNIBALISM ) && !has_trait_flag( flag_CANNIBAL ) ) { + if( food.has_flag( flag_CANNIBALISM ) && !has_trait_flag( "CANNIBAL" ) ) { add_consequence( _( "The thought of eating human flesh makes you feel sick." ), CANNIBALISM ); } @@ -1245,8 +1245,8 @@ hint_rating Character::rate_action_eat( const item &it ) const bool Character::can_feed_reactor_with( const item &it ) const { static const std::set acceptable = {{ - ammo_reactor_slurry, - ammo_plutonium + ammotype( "reactor_slurry" ), + ammotype( "plutonium" ) } }; @@ -1441,10 +1441,10 @@ int Character::get_acquirable_energy( const item &it, rechargeable_cbm cbm ) con int amount = ( consumed_vol / 250_ml + consumed_mass / 1_gram ) / 9; // TODO: JSONize. - if( it.made_of( material_leather ) ) { + if( it.made_of( material_id( "leather" ) ) ) { amount /= 4; } - if( it.made_of( material_wood ) ) { + if( it.made_of( material_id( "wood" ) ) ) { amount /= 2; } diff --git a/src/crafting.cpp b/src/crafting.cpp index 78774615b05ea..31769f7dfea2d 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -173,7 +173,7 @@ static float workbench_crafting_speed_multiplier( const item &craft, const tripo allowed_mass = f.workbench->allowed_mass; allowed_volume = f.workbench->allowed_volume; } else if( const cata::optional vp = g->m.veh_at( - loc ).part_with_feature( flag_WORKBENCH, true ) ) { + loc ).part_with_feature( "WORKBENCH", true ) ) { // Vehicle workbench const vpart_info &vp_info = vp->part().info(); if( const cata::optional &wb_info = vp_info.get_workbench_info() ) { @@ -455,7 +455,7 @@ std::vector player::get_eligible_containers_for_crafting() const } } - if( const cata::optional vp = g->m.veh_at( loc ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( loc ).part_with_feature( "CARGO", true ) ) { for( const auto &it : vp->vehicle().get_items( vp->part_index() ) ) { if( is_container_eligible_for_crafting( it, false ) ) { @@ -642,7 +642,7 @@ static item_location set_item_map( const tripoint &loc, item &newit ) */ static item_location set_item_map_or_vehicle( const player &p, const tripoint &loc, item &newit ) { - if( const cata::optional vp = g->m.veh_at( loc ).part_with_feature( flag_CARGO, + if( const cata::optional vp = g->m.veh_at( loc ).part_with_feature( "CARGO", false ) ) { if( const cata::optional it = vp->vehicle().add_item( vp->part_index(), @@ -710,7 +710,7 @@ void player::start_craft( craft_command &command, const tripoint &loc ) target = adj; } } else if( const cata::optional vp = g->m.veh_at( - adj ).part_with_feature( flag_WORKBENCH, true ) ) { + adj ).part_with_feature( "WORKBENCH", true ) ) { if( const cata::optional &wb_info = vp->part().info().get_workbench_info() ) { if( wb_info->multiplier > best_bench_multi ) { best_bench_multi = wb_info->multiplier; @@ -2248,7 +2248,7 @@ void player::complete_disassemble( item_location &target, const recipe &dis ) } if( filthy ) { - act_item.item_tags.insert( flag_FILTHY ); + act_item.item_tags.insert( "FILTHY" ); } for( std::list::iterator a = dis_item.components.begin(); a != dis_item.components.end(); diff --git a/src/creature.cpp b/src/creature.cpp index af653b025360a..06a64e2e8f3f4 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -48,17 +48,17 @@ const std::map Creature::size_map = { }; const std::set Creature::cmat_flesh{ - material_flesh, material_iflesh + material_id( "flesh" ), material_id( "iflesh" ) }; const std::set Creature::cmat_fleshnveg{ - material_flesh, material_iflesh, material_veggy + material_id( "flesh" ), material_id( "iflesh" ), material_id( "veggy" ) }; const std::set Creature::cmat_flammable{ - material_paper, material_powder, material_wood, - material_cotton, material_wool + material_id( "paper" ), material_id( "powder" ), material_id( "wood" ), + material_id( "cotton" ), material_id( "wool" ) }; const std::set Creature::cmat_flameres{ - material_stone, material_kevlar, material_steel + material_id( "stone" ), material_id( "kevlar" ), material_id( "steel" ) }; Creature::Creature() @@ -684,13 +684,13 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack } } if( proj.proj_effects.count( "INCENDIARY" ) ) { - if( made_of( material_veggy ) || made_of_any( cmat_flammable ) ) { + if( made_of( material_id( "veggy" ) ) || made_of_any( cmat_flammable ) ) { add_effect( effect_onfire, rng( 2_turns, 6_turns ), bp_hit ); } else if( made_of_any( cmat_flesh ) && one_in( 4 ) ) { add_effect( effect_onfire, rng( 1_turns, 4_turns ), bp_hit ); } } else if( proj.proj_effects.count( "IGNITE" ) ) { - if( made_of( material_veggy ) || made_of_any( cmat_flammable ) ) { + if( made_of( material_id( "veggy" ) ) || made_of_any( cmat_flammable ) ) { add_effect( effect_onfire, 6_turns, bp_hit ); } else if( made_of_any( cmat_flesh ) ) { add_effect( effect_onfire, 10_turns, bp_hit ); diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 6db651603ad41..a4d1b1d81cadc 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1130,8 +1130,8 @@ void debug() new_fac_id += temp->name; // create a new "lone wolf" faction for this one NPC faction *new_solo_fac = g->faction_manager_ptr->add_new_faction( temp->name, - faction_id( new_fac_id ), faction_no_faction ); - temp->set_fac( new_solo_fac ? new_solo_fac->id : faction_no_faction ); + faction_id( new_fac_id ), faction_id( "no_faction" ) ); + temp->set_fac( new_solo_fac ? new_solo_fac->id : faction_id( "no_faction" ) ); g->load_npcs(); } break; diff --git a/src/dump.cpp b/src/dump.cpp index 6eee7c7c69afb..34c85d62329cd 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -122,7 +122,7 @@ bool game::dump_stats( const std::string &what, dump_mode mode, item obj( e ); if( bp == num_bp || obj.covers( bp ) ) { if( obj.has_flag( flag_VARSIZE ) ) { - obj.item_tags.insert( flag_FIT ); + obj.item_tags.insert( "FIT" ); } dump( obj ); } diff --git a/src/editmap.cpp b/src/editmap.cpp index 4fe9872e3b8db..622b95d34a317 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -50,7 +50,6 @@ #include "shadowcasting.h" #include "string_id.h" #include "colony.h" -#include "cata_string_consts.h" static constexpr tripoint editmap_boundary_min( 0, 0, -OVERMAP_DEPTH ); static constexpr tripoint editmap_boundary_max( MAPSIZE_X, MAPSIZE_Y, OVERMAP_HEIGHT + 1 ); @@ -643,7 +642,7 @@ void editmap::update_view_with_help( const std::string &txt, const std::string & } map_stack target_stack = g->m.i_at( target ); const int target_stack_size = target_stack.size(); - if( !g->m.has_flag( flag_CONTAINER, target ) && target_stack_size > 0 ) { + if( !g->m.has_flag( "CONTAINER", target ) && target_stack_size > 0 ) { trim_and_print( w_info, point( 1, off ), getmaxx( w_info ), c_light_gray, _( "There is a %s there." ), target_stack.begin()->tname() ); @@ -1630,7 +1629,7 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu ) const int veh_part = vp->part_index(); char part_mod = 0; const vpart_id &vp_id = veh.part_id_string( veh_part, part_mod ); - const cata::optional cargopart = vp.part_with_feature( flag_CARGO, true ); + const cata::optional cargopart = vp.part_with_feature( "CARGO", true ); bool draw_highlight = cargopart && !veh.get_items( cargopart->part_index() ).empty(); int veh_dir = veh.face.dir(); g->draw_vpart_override( map_p, vp_id, part_mod, veh_dir, draw_highlight, vp->mount() ); diff --git a/src/event.h b/src/event.h index 422f03ac9ae71..9720143303469 100644 --- a/src/event.h +++ b/src/event.h @@ -10,6 +10,8 @@ #include "enum_conversions.h" #include "type_id.h" +using itype_id = std::string; + // An event is something to be passed via the event_bus to subscribers // interested in being notified about events. // diff --git a/src/explosion.cpp b/src/explosion.cpp index ec067f2e26236..a9836a893df07 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -546,7 +546,7 @@ void flashbang( const tripoint &p, bool player_immune ) } } for( monster &critter : g->all_monsters() ) { - if( critter.type->in_species( species_ROBOT ) ) { + if( critter.type->in_species( ROBOT ) ) { continue; } // TODO: can the following code be called for all types of creatures @@ -620,7 +620,7 @@ void emp_blast( const tripoint &p ) int x = p.x; int y = p.y; const bool sight = g->u.sees( p ); - if( g->m.has_flag( flag_CONSOLE, point( x, y ) ) ) { + if( g->m.has_flag( "CONSOLE", point( x, y ) ) ) { if( sight ) { add_msg( _( "The %s is rendered non-functional!" ), g->m.tername( point( x, y ) ) ); } @@ -721,7 +721,7 @@ void emp_blast( const tripoint &p ) // TODO: More effects? //e-handcuffs effects if( g->u.weapon.typeId() == "e_handcuffs" && g->u.weapon.charges > 0 ) { - g->u.weapon.item_tags.erase( flag_NO_UNWIELD ); + g->u.weapon.item_tags.erase( "NO_UNWIELD" ); g->u.weapon.charges = 0; g->u.weapon.active = false; add_msg( m_good, _( "The %s on your wrists spark briefly, then release your hands!" ), diff --git a/src/explosion.h b/src/explosion.h index 5ab28b0b11ce6..2010f8adc61a2 100644 --- a/src/explosion.h +++ b/src/explosion.h @@ -5,7 +5,7 @@ #include #include -#include "type_id.h" +using itype_id = std::string; struct tripoint; class JsonObject; diff --git a/src/faction.cpp b/src/faction.cpp index f0d95f947c3ca..788fadeeb7710 100644 --- a/src/faction.cpp +++ b/src/faction.cpp @@ -32,7 +32,6 @@ #include "pimpl.h" #include "type_id.h" #include "point.h" -#include "cata_string_consts.h" namespace npc_factions { @@ -416,7 +415,7 @@ faction *faction_manager::add_new_faction( const std::string &name_new, const fa faction *faction_manager::get( const faction_id &id, const bool complain ) { if( id.is_null() ) { - return get( faction_no_faction ); + return get( faction_id( "no_faction" ) ); } for( auto &elem : factions ) { if( elem.first == id ) { @@ -546,8 +545,8 @@ int npc::faction_display( const catacurses::window &fac_w, const int width ) con } std::string can_see; nc_color see_color; - bool u_has_radio = g->u.has_item_with_flag( flag_TWO_WAY_RADIO, true ); - bool guy_has_radio = has_item_with_flag( flag_TWO_WAY_RADIO, true ); + bool u_has_radio = g->u.has_item_with_flag( "TWO_WAY_RADIO", true ); + bool guy_has_radio = has_item_with_flag( "TWO_WAY_RADIO", true ); // TODO: NPCS on mission contactable same as travelling if( has_companion_mission() && mission != NPC_MISSION_TRAVELLING ) { can_see = _( "Not interactable while on a mission" ); @@ -707,7 +706,7 @@ void faction_manager::display() const } std::vector valfac; // Factions that we know of. for( const auto &elem : g->faction_manager_ptr->all() ) { - if( elem.second.known_by_u && elem.second.id != faction_your_followers ) { + if( elem.second.known_by_u && elem.second.id != faction_id( "your_followers" ) ) { valfac.push_back( &elem.second ); } } diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 6b54ffa94e3b0..e0d9a5dce0064 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -3605,7 +3605,7 @@ std::string camp_car_description( vehicle *car ) { std::string entry = string_format( _( "Name: %s\n" ), right_justify( car->name, 25 ) ); entry += _( "---- Engines ----\n" ); - for( const vpart_reference &vpr : car->get_any_parts( flag_ENGINE ) ) { + for( const vpart_reference &vpr : car->get_any_parts( "ENGINE" ) ) { const vehicle_part &pt = vpr.part(); const vpart_info &vp = pt.info(); entry += string_format( _( "Engine: %s\n" ), right_justify( vp.name(), 25 ) ); diff --git a/src/fungal_effects.cpp b/src/fungal_effects.cpp index 516d796de5093..5cb1c65ad39ad 100644 --- a/src/fungal_effects.cpp +++ b/src/fungal_effects.cpp @@ -40,7 +40,7 @@ void fungal_effects::fungalize( const tripoint &p, Creature *origin, double spor if( monster *const mon_ptr = g->critter_at( p ) ) { monster &critter = *mon_ptr; if( gm.u.sees( p ) && - !critter.type->in_species( species_FUNGUS ) ) { + !critter.type->in_species( FUNGUS ) ) { add_msg( _( "The %s is covered in tiny spores!" ), critter.name() ); } if( !critter.make_fungus() ) { diff --git a/src/game.cpp b/src/game.cpp index 4c21e2a3249c1..1d84557d1c8bf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -143,7 +143,6 @@ #include "string_id.h" #include "colony.h" #include "item.h" -#include "cata_string_consts.h" class inventory; @@ -171,6 +170,60 @@ 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__) @@ -695,17 +748,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( flag_LONE_START ) ) ) { + !g->scen->has_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( flag_SUR_START ); + get_option( "BLACK_ROAD" ) || g->scen->has_flag( "SUR_START" ); // Surrounded start ones if( spawn_near ) { - start_loc.surround_with_monsters( omtstart, GROUP_ZOMBIE, 70 ); + start_loc.surround_with_monsters( omtstart, mongroup_id( "GROUP_ZOMBIE" ), 70 ); } m.spawn_monsters( !spawn_near ); // Static monsters @@ -725,18 +778,18 @@ bool game::start_game() u.set_highest_cat_level(); //Calculate mutation drench protection stats u.drench_mut_calc(); - if( scen->has_flag( flag_FIRE_START ) ) { + if( scen->has_flag( "FIRE_START" ) ) { start_loc.burn( omtstart, 3, 3 ); } - if( scen->has_flag( flag_INFECTED ) ) { + if( scen->has_flag( "INFECTED" ) ) { u.add_effect( effect_infected, 1_turns, random_body_part(), true ); } - if( scen->has_flag( flag_BAD_DAY ) ) { + if( scen->has_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( flag_HELI_CRASH ) ) { + if( scen->has_flag( "HELI_CRASH" ) ) { start_loc.handle_heli_crash( u ); bool success = false; for( auto v : m.get_vehicles() ) { @@ -894,8 +947,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_NPC_STARTING_NPC ); - tmp->set_fac( faction_no_faction ); + tmp->toggle_trait( trait_id( "NPC_STARTING_NPC" ) ); + tmp->set_fac( faction_id( "no_faction" ) ); //One random starting NPC mission tmp->add_new_mission( mission::reserve_random( ORIGIN_OPENER_NPC, tmp->global_omt_location(), tmp->getID() ) ); @@ -1375,7 +1428,7 @@ bool game::do_turn() sfx::do_hearing_loss(); } - if( !u.has_effect( effect_sleep ) ) { + if( !u.has_effect( efftype_id( "sleep" ) ) ) { if( u.moves > 0 || uquit == QUIT_WATCH ) { while( u.moves > 0 || uquit == QUIT_WATCH ) { cleanup_dead(); @@ -1422,7 +1475,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( ACT_AIM ) && + if( u.activity && !u.has_activity( activity_id( "ACT_AIM" ) ) && u.activity.moves_left > 0 && !u.activity.is_distraction_ignored( distraction_type::hostile_spotted ) ) { Creature *hostile_critter = is_hostile_very_close(); @@ -1446,8 +1499,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( bio_scent_mask ) && - !u.has_trait( trait_DEBUG_NOSCENT ) ) { + if( !u.has_active_bionic( bionic_id( "bio_scent_mask" ) ) && + !u.has_trait( trait_id( "DEBUG_NOSCENT" ) ) ) { scent.set( u.pos(), u.scent, u.get_type_of_scent() ); overmap_buffer.set_scent( u.global_omt_location(), u.scent ); } @@ -1623,7 +1676,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( ACT_TRAVELLING ) ); + u.set_destination( u.get_auto_move_route(), player_activity( activity_id( "ACT_TRAVELLING" ) ) ); return false; } } @@ -1667,7 +1720,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( ACT_TRAVELLING ) ); + u.set_destination( u.get_auto_move_route(), player_activity( activity_id( "ACT_TRAVELLING" ) ) ); return false; } } @@ -1791,7 +1844,7 @@ void game::remove_npc_follower( const character_id &id ) static void update_faction_api( npc *guy ) { if( guy->get_faction_ver() < 2 ) { - guy->set_fac( faction_your_followers ); + guy->set_fac( your_followers ); guy->set_faction_ver( 2 ); } } @@ -1903,7 +1956,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( flag_NO_UNWIELD ) ? HINT_CANT : HINT_GOOD; + const hint_rating rate_drop_item = u.weapon.has_flag( "NO_UNWIELD" ) ? HINT_CANT : HINT_GOOD; int max_text_length = 0; uilist action_menu; @@ -2352,7 +2405,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( fuel_type_battery, true ) > 0 ) { + if( veh && veh->fuel_left( "battery", true ) > 0 ) { remoteveh_cache = veh; } else { remoteveh_cache = nullptr; @@ -2644,7 +2697,7 @@ void game::load( const save_t &name ) // The vehicle stores the IDs of the boarded players, so update it, too. if( u.in_vehicle ) { if( const cata::optional vp = m.veh_at( - u.pos() ).part_with_feature( flag_BOARDABLE, true ) ) { + u.pos() ).part_with_feature( "BOARDABLE", true ) ) { vp->part().passenger_id = u.getID(); } } @@ -3197,7 +3250,7 @@ void game::draw_ter( const tripoint ¢er, const bool looking, const bool draw draw_critter( critter, center ); } - if( u.has_active_bionic( bio_scent_vision ) && u.view_offset.z == 0 ) { + if( u.has_active_bionic( bionic_id( "bio_scent_vision" ) ) && u.view_offset.z == 0 ) { tripoint tmp = center; int &realx = tmp.x; int &realy = tmp.y; @@ -3622,7 +3675,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( flag_FISHABLE, current_point ) ) { + if( m.has_flag( "FISHABLE", current_point ) ) { fishable_terrain.emplace( current_point ); to_check.push( current_point + point_south ); to_check.push( current_point + point_north ); @@ -3948,7 +4001,7 @@ void game::mon_info_update( ) monster &critter = *new_seen_mon.back(); cancel_activity_or_ignore_query( distraction_type::hostile_spotted, string_format( _( "%s spotted!" ), critter.name() ) ); - if( u.has_trait( trait_id( "M_DEFENDER" ) ) && critter.type->in_species( species_PLANT ) ) { + if( u.has_trait( trait_id( "M_DEFENDER" ) ) && critter.type->in_species( PLANT ) ) { add_msg( m_warning, _( "We have detected a %s - an enemy of the Mycus!" ), critter.name() ); if( !u.has_effect( effect_adrenaline_mycus ) ) { u.add_effect( effect_adrenaline_mycus, 30_minutes ); @@ -4076,7 +4129,7 @@ void game::monmove() } if( !critter.is_dead() && - u.has_active_bionic( bio_alarm ) && + u.has_active_bionic( bionic_id( "bio_alarm" ) ) && u.get_power_level() >= 25_kJ && rl_dist( u.pos(), critter.pos() ) <= 5 && !critter.is_hallucination() ) { @@ -4084,7 +4137,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( effect_sleep ) ) { + if( u.has_effect( efftype_id( "sleep" ) ) ) { u.wake_up(); } } @@ -4111,7 +4164,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(); @@ -4254,13 +4307,13 @@ void game::knockback( std::vector &traj, int force, int stun, int dam_ break; } targ->setpos( traj[i] ); - if( m.has_flag( flag_LIQUID, targ->pos() ) && !targ->can_drown() && !targ->is_dead() ) { + if( m.has_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( flag_LIQUID, targ->pos() ) && targ->has_flag( MF_AQUATIC ) && + if( !m.has_flag( "LIQUID", targ->pos() ) && targ->has_flag( MF_AQUATIC ) && !targ->is_dead() ) { targ->die( nullptr ); if( u.sees( *targ ) ) { @@ -4405,7 +4458,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( flag_LIQUID, u.pos() ) && force_remaining < 1 ) { + if( m.has_flag( "LIQUID", u.pos() ) && force_remaining < 1 ) { avatar_action::swim( m, u, u.pos() ); } else { u.setpos( traj[i] ); @@ -4416,7 +4469,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_ILLITERATE ) ) { + if( u.has_trait( trait_id( "ILLITERATE" ) ) ) { add_msg( m_info, _( "You can not read a computer screen!" ) ); return; } @@ -4425,8 +4478,8 @@ void game::use_computer( const tripoint &p ) add_msg( m_info, _( "You can not see a computer screen!" ) ); return; } - if( u.has_trait( trait_HYPEROPIC ) && !u.worn_with_flag( flag_FIX_FARSIGHT ) && - !u.has_effect( effect_contacts ) && !u.has_bionic( bio_eye_optic ) ) { + if( u.has_trait( trait_id( "HYPEROPIC" ) ) && !u.worn_with_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; } @@ -4434,7 +4487,7 @@ void game::use_computer( const tripoint &p ) computer *used = m.computer_at( p ); if( used == nullptr ) { - if( m.has_flag( flag_CONSOLE, p ) ) { //Console without map data + if( m.has_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 (" << @@ -4748,7 +4801,7 @@ bool game::swap_critters( Creature &a, Creature &b ) bool game::is_empty( const tripoint &p ) { - return ( m.passable( p ) || m.has_flag( flag_LIQUID, p ) ) && + return ( m.passable( p ) || m.has_flag( "LIQUID", p ) ) && critter_at( p ) == nullptr; } @@ -4781,8 +4834,8 @@ bool game::revive_corpse( const tripoint &p, item &it ) // Failed reanimation due to corpse being too burned return false; } - if( it.has_flag( flag_FIELD_DRESS ) || it.has_flag( flag_FIELD_DRESS_FAILED ) || - it.has_flag( flag_QUARTERED ) ) { + if( it.has_flag( "FIELD_DRESS" ) || it.has_flag( "FIELD_DRESS_FAILED" ) || + it.has_flag( "QUARTERED" ) ) { // Failed reanimation due to corpse being butchered return false; } @@ -4989,14 +5042,14 @@ 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( flag_NOITEM, point( x, y ) ) ) { + if( m.has_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 ) ) { it = items.erase( it ); continue; } - if( it->made_of( material_glass ) && one_in( 2 ) ) { + if( it->made_of( material_id( "glass" ) ) && one_in( 2 ) ) { if( can_see ) { add_msg( m_warning, _( "A %s shatters!" ), it->tname() ); } else { @@ -5038,7 +5091,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( flag_SWIMMABLE, u.pos() ) ) { + if( !m.has_flag( "SWIMMABLE", u.pos() ) ) { if( veh->velocity > 0 ) { fling_creature( &u, veh->face.dir(), veh->velocity / static_cast( 100 ) ); } else { @@ -5049,6 +5102,7 @@ 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 ) { @@ -5058,14 +5112,14 @@ void game::control_vehicle() } } if( veh != nullptr && veh->player_in_control( u ) && - veh->avail_part_with_feature( veh_part, flag_CONTROLS, true ) >= 0 ) { + veh->avail_part_with_feature( veh_part, "CONTROLS", true ) >= 0 ) { veh->use_controls( u.pos() ); } else if( veh && veh->player_in_control( u ) && - veh->avail_part_with_feature( veh_part, flag_CONTROL_ANIMAL, true ) >= 0 ) { + veh->avail_part_with_feature( veh_part, "CONTROL_ANIMAL", true ) >= 0 ) { u.controlling_vehicle = false; add_msg( m_info, _( "You let go of the reins." ) ); - } else if( veh && ( veh->avail_part_with_feature( veh_part, flag_CONTROLS, true ) >= 0 || - ( veh->avail_part_with_feature( veh_part, flag_CONTROL_ANIMAL, true ) >= 0 && + } else if( veh && ( veh->avail_part_with_feature( veh_part, "CONTROLS", true ) >= 0 || + ( veh->avail_part_with_feature( veh_part, "CONTROL_ANIMAL", true ) >= 0 && veh->has_engine_type( fuel_type_animal, false ) && veh->has_harnessed_animal() ) ) && u.in_vehicle ) { if( !veh->interact_vehicle_locked() ) { @@ -5090,8 +5144,7 @@ void game::control_vehicle() cata::optional vehicle_controls; for( const tripoint elem : m.points_in_radius( g->u.pos(), 1 ) ) { if( const optional_vpart_position vp = m.veh_at( elem ) ) { - const cata::optional controls = vp.value().part_with_feature( flag_CONTROLS, - true ); + const cata::optional controls = vp.value().part_with_feature( "CONTROLS", true ); if( controls ) { num_valid_controls++; vehicle_position = elem; @@ -5109,7 +5162,7 @@ void game::control_vehicle() } const optional_vpart_position vp = m.veh_at( *vehicle_position ); if( vp ) { - vehicle_controls = vp.value().part_with_feature( flag_CONTROLS, true ); + vehicle_controls = vp.value().part_with_feature( "CONTROLS", true ); if( !vehicle_controls ) { add_msg( _( "The vehicle doesn't have controls there." ) ); return; @@ -5388,10 +5441,10 @@ void game::examine( const tripoint &examp ) return; } - if( m.has_flag( flag_CONSOLE, examp ) && !u.is_mounted() ) { + if( m.has_flag( "CONSOLE", examp ) && !u.is_mounted() ) { use_computer( examp ); return; - } else if( m.has_flag( flag_CONSOLE, examp ) && u.is_mounted() ) { + } else if( m.has_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(); @@ -5444,9 +5497,9 @@ void game::examine( const tripoint &examp ) add_msg( fire_fuel ); } - if( m.has_flag( flag_SEALED, examp ) ) { + if( m.has_flag( "SEALED", examp ) ) { if( none ) { - if( m.has_flag( flag_UNSTABLE, examp ) ) { + if( m.has_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 ) ); @@ -5455,7 +5508,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( flag_CONTAINER, examp ) && none ) { + m.has_flag( "CONTAINER", examp ) && none ) { add_msg( _( "It is empty." ) ); } else if( ( m.has_flag( TFLAG_FIRE_CONTAINER, examp ) && xfurn_t.examine == &iexamine::fireplace ) || @@ -5807,9 +5860,9 @@ void game::print_items_info( const tripoint &lp, const catacurses::window &w_loo { if( !m.sees_some_items( lp, u ) ) { return; - } else if( m.has_flag( flag_CONTAINER, lp ) && !m.could_see_items( lp, u ) ) { + } else if( m.has_flag( "CONTAINER", lp ) && !m.could_see_items( lp, u ) ) { mvwprintw( w_look, point( column, ++line ), _( "You cannot see what is inside of it." ) ); - } else if( u.has_effect( effect_blind ) || u.worn_with_flag( flag_BLIND ) ) { + } else if( u.has_effect( effect_blind ) || u.worn_with_flag( "BLIND" ) ) { mvwprintz( w_look, point( column, ++line ), c_yellow, _( "There's something there, but you can't see what it is." ) ); return; @@ -6172,7 +6225,7 @@ void game::zones_manager() as_m.entries.emplace_back( 1, true, '1', _( "Edit name" ) ); as_m.entries.emplace_back( 2, true, '2', _( "Edit type" ) ); as_m.entries.emplace_back( 3, zone.get_options().has_options(), '3', - zone.get_type() == zone_type_LOOT_CUSTOM ? _( "Edit filter" ) : _( "Edit options" ) ); + zone.get_type() == zone_type_id( "LOOT_CUSTOM" ) ? _( "Edit filter" ) : _( "Edit options" ) ); as_m.entries.emplace_back( 4, !zone.get_is_vehicle(), '4', _( "Edit position" ) ); as_m.query(); @@ -7816,12 +7869,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_BUTCHER ); + const int factor = g->u.max_quality( quality_id( "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_CUT_FINE ); + const int factorD = g->u.max_quality( quality_id( "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." ); @@ -7915,25 +7968,25 @@ static void butcher_submenu( const std::vector &corpses, in smenu.query(); switch( smenu.ret ) { case BUTCHER: - g->u.assign_activity( ACT_BUTCHER, 0, true ); + g->u.assign_activity( activity_id( "ACT_BUTCHER" ), 0, true ); break; case BUTCHER_FULL: - g->u.assign_activity( ACT_BUTCHER_FULL, 0, true ); + g->u.assign_activity( activity_id( "ACT_BUTCHER_FULL" ), 0, true ); break; case F_DRESS: - g->u.assign_activity( ACT_FIELD_DRESS, 0, true ); + g->u.assign_activity( activity_id( "ACT_FIELD_DRESS" ), 0, true ); break; case SKIN: - g->u.assign_activity( ACT_SKIN, 0, true ); + g->u.assign_activity( activity_id( "ACT_SKIN" ), 0, true ); break; case QUARTER: - g->u.assign_activity( ACT_QUARTER, 0, true ); + g->u.assign_activity( activity_id( "ACT_QUARTER" ), 0, true ); break; case DISMEMBER: - g->u.assign_activity( ACT_DISMEMBER, 0, true ); + g->u.assign_activity( activity_id( "ACT_DISMEMBER" ), 0, true ); break; case DISSECT: - g->u.assign_activity( ACT_DISSECT, 0, true ); + g->u.assign_activity( activity_id( "ACT_DISSECT" ), 0, true ); break; default: return; @@ -7948,13 +8001,13 @@ void game::butcher() return; } - const int factor = u.max_quality( quality_BUTCHER ); - const int factorD = u.max_quality( quality_CUT_FINE ); + const int factor = u.max_quality( quality_id( "BUTCHER" ) ); + const int factorD = u.max_quality( quality_id( "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( flag_SEALED, u.pos() ) ) { + if( m.has_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 ) { @@ -8153,7 +8206,7 @@ void game::butcher() case BUTCHER_OTHER: switch( indexer_index ) { case MULTISALVAGE: - u.assign_activity( ACT_LONGSALVAGE, 0, salvage_tool_index ); + u.assign_activity( activity_id( "ACT_LONGSALVAGE" ), 0, salvage_tool_index ); break; case MULTIBUTCHER: butcher_submenu( corpses ); @@ -8201,7 +8254,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( flag_RELOAD_AND_SHOOT ) ) { + if( it->has_flag( "RELOAD_AND_SHOOT" ) ) { item::reload_option opt = u.select_ammo( *it, prompt ); if( !opt ) { return; @@ -8244,7 +8297,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) } bool use_loc = true; - if( !it->has_flag( flag_ALLOWS_REMOTE_USE ) ) { + if( !it->has_flag( "ALLOWS_REMOTE_USE" ) ) { it = &u.i_at( loc.obtain( u ) ); use_loc = false; } @@ -8278,7 +8331,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) moves += 2500; } - u.assign_activity( ACT_RELOAD, moves, opt.qty() ); + u.assign_activity( activity_id( "ACT_RELOAD" ), moves, opt.qty() ); if( use_loc ) { u.activity.targets.emplace_back( loc ); } else { @@ -8369,7 +8422,7 @@ void game::reload_weapon( bool try_everything ) if( veh && ( turret = veh->turret_query( u.pos() ) ) && turret.can_reload() ) { item::reload_option opt = g->u.select_ammo( *turret.base(), true ); if( opt ) { - g->u.assign_activity( activity_id( ACT_RELOAD ), opt.moves(), opt.qty() ); + g->u.assign_activity( activity_id( "ACT_RELOAD" ), opt.moves(), opt.qty() ); g->u.activity.targets.emplace_back( turret.base() ); g->u.activity.targets.push_back( std::move( opt.ammo ) ); } @@ -8453,8 +8506,7 @@ void game::wield( item_location &loc ) m.add_item( pos, to_wield ); break; case item_location::type::vehicle: { - const cata::optional vp = g->m.veh_at( pos ).part_with_feature( flag_CARGO, - false ); + const cata::optional vp = g->m.veh_at( pos ).part_with_feature( "CARGO", false ); // If we fail to return the item to the vehicle for some reason, add it to the map instead. if( !vp || !( vp->vehicle().add_item( vp->part_index(), to_wield ) ) ) { m.add_item( pos, to_wield ); @@ -8646,7 +8698,7 @@ std::vector game::get_dangerous_tile( const tripoint &dest_loc ) co if( !u.is_blind() ) { const trap &tr = m.tr_at( dest_loc ); - const bool boardable = static_cast( m.veh_at( dest_loc ).part_with_feature( flag_BOARDABLE, + const bool boardable = static_cast( m.veh_at( dest_loc ).part_with_feature( "BOARDABLE", true ) ); // HACK: Hack for now, later ledge should stop being a trap // Note: in non-z-level mode, ledges obey different rules and so should be handled as regular traps @@ -8667,12 +8719,11 @@ std::vector game::get_dangerous_tile( const tripoint &dest_loc ) co return u.immune_to( bp, { DT_CUT, 10 } ); }; - if( m.has_flag( flag_ROUGH, dest_loc ) && !m.has_flag( flag_ROUGH, u.pos() ) && !boardable && + if( m.has_flag( "ROUGH", dest_loc ) && !m.has_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( flag_SHARP, dest_loc ) && !m.has_flag( flag_SHARP, u.pos() ) && - !( u.in_vehicle || - g->m.veh_at( 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 ) ) && u.dex_cur < 78 && !std::all_of( sharp_bps.begin(), sharp_bps.end(), sharp_bp_check ) ) { harmful_stuff.emplace_back( m.name( dest_loc ) ); } @@ -8836,11 +8887,11 @@ bool game::walk_move( const tripoint &dest_loc ) if( u.is_mounted() ) { auto crit = u.mounted_creature.get(); if( !crit->has_flag( MF_RIDEABLE_MECH ) && - ( m.has_flag_ter_or_furn( flag_MOUNTABLE, dest_loc ) || - m.has_flag_ter_or_furn( flag_BARRICADABLE_DOOR, dest_loc ) || - m.has_flag_ter_or_furn( flag_OPENCLOSE_INSIDE, dest_loc ) || - m.has_flag_ter_or_furn( flag_BARRICADABLE_DOOR_DAMAGED, dest_loc ) || - m.has_flag_ter_or_furn( flag_BARRICADABLE_DOOR_REINFORCED, dest_loc ) ) ) { + ( m.has_flag_ter_or_furn( "MOUNTABLE", dest_loc ) || + m.has_flag_ter_or_furn( "BARRICADABLE_DOOR", dest_loc ) || + m.has_flag_ter_or_furn( "OPENCLOSE_INSIDE", dest_loc ) || + m.has_flag_ter_or_furn( "BARRICADABLE_DOOR_DAMAGED", dest_loc ) || + m.has_flag_ter_or_furn( "BARRICADABLE_DOOR_REINFORCED", dest_loc ) ) ) { add_msg( m_warning, _( "You cannot pass obstacles whilst mounted." ) ); return false; } @@ -8875,8 +8926,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( flag_FUNGUS, u.pos() ) || - m.has_flag_ter_or_furn( flag_FUNGUS, + const bool fungus = m.has_flag_ter_or_furn( "FUNGUS", u.pos() ) || + m.has_flag_ter_or_furn( "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 ) && @@ -8903,7 +8954,7 @@ bool game::walk_move( const tripoint &dest_loc ) } } } - if( !u.is_mounted() && u.has_trait( trait_LEG_TENT_BRACE ) && + if( !u.is_mounted() && u.has_trait( trait_id( "LEG_TENT_BRACE" ) ) && ( !u.footwear_factor() || ( u.footwear_factor() == .5 && one_in( 2 ) ) ) ) { // DX and IN are long suits for Cephalopods, @@ -8913,18 +8964,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( flag_SWIMMABLE, dest_loc ) && one_in( 80 + u.dex_cur + u.int_cur ) ) { + if( !m.has_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_DEBUG_SILENT ) ) { + if( !u.has_artifact_with( AEP_STEALTH ) && !u.has_trait( trait_id( "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( bio_ankles ) ) { + } else if( u.has_bionic( bionic_id( "bio_ankles" ) ) ) { volume = 12; } if( u.movement_mode_is( CMM_RUN ) ) { @@ -9028,22 +9079,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( flag_ROUGH, dest_loc ) && ( !u.in_vehicle ) && ( !u.is_mounted() ) ) { + if( m.has_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( flag_ROUGH, dest_loc ) ? m.tername( dest_loc ) : m.furnname( + m.has_flag_ter( "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( flag_ROUGH, dest_loc ) ? m.tername( dest_loc ) : m.furnname( + m.has_flag_ter( "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( flag_SHARP, dest_loc ) && !one_in( 3 ) && !x_in_y( 1 + u.dex_cur / 2.0, 40 ) && + if( m.has_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() ) { @@ -9055,7 +9106,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( flag_SHARP, dest_loc ) ? m.tername( dest_loc ) : m.furnname( + m.has_flag_ter( "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 ); @@ -9066,7 +9117,7 @@ point game::place_player( const tripoint &dest_loc ) } } } - if( m.has_flag( flag_UNSTABLE, dest_loc ) && !u.is_mounted() ) { + if( m.has_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 ); @@ -9078,7 +9129,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( flag_SWIMMABLE, dest_loc ) && u.has_effect( effect_onfire ) ) { + if( m.has_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() ) { @@ -9182,7 +9233,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_BUTCHER ) > INT_MIN ) { + if( pulp_butcher == "butcher" && u.max_quality( quality_id( "BUTCHER" ) ) > INT_MIN ) { std::vector corpses; for( item &it : m.i_at( u.pos() ) ) { @@ -9190,7 +9241,7 @@ point game::place_player( const tripoint &dest_loc ) } if( !corpses.empty() ) { - u.assign_activity( ACT_BUTCHER, 0, true ); + u.assign_activity( activity_id( "ACT_BUTCHER" ), 0, true ); for( item *it : corpses ) { u.activity.targets.emplace_back( map_cursor( u.pos() ), it ); } @@ -9200,7 +9251,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( ACT_PULP, calendar::INDEFINITELY_LONG, 0 ); + u.assign_activity( activity_id( "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" ); @@ -9227,7 +9278,7 @@ point game::place_player( const tripoint &dest_loc ) } // If the new tile is a boardable part, board it - if( vp1.part_with_feature( flag_BOARDABLE, true ) && !u.is_mounted() ) { + if( vp1.part_with_feature( "BOARDABLE", true ) && !u.is_mounted() ) { m.board_vehicle( u.pos(), &u ); } @@ -9240,14 +9291,14 @@ point game::place_player( const tripoint &dest_loc ) m.creature_on_trap( u ); } // Drench the player if swimmable - if( m.has_flag( flag_SWIMMABLE, u.pos() ) && !u.is_mounted() ) { + if( m.has_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( flag_SEALED, u.pos() ) ) { + if( !m.has_flag( "SEALED", u.pos() ) ) { if( get_option( "NO_AUTO_PICKUP_ZONES_LIST_ITEMS" ) || - !g->check_zone( zone_type_NO_AUTO_PICKUP, u.pos() ) ) { + !g->check_zone( zone_type_id( "NO_AUTO_PICKUP" ), u.pos() ) ) { if( u.is_blind() && !m.i_at( u.pos() ).empty() ) { add_msg( _( "There's something here, but you can't see what it is." ) ); } else if( m.has_items( u.pos() ) ) { @@ -9320,13 +9371,13 @@ point game::place_player( const tripoint &dest_loc ) } } - if( ( vp1.part_with_feature( flag_CONTROL_ANIMAL, true ) || - vp1.part_with_feature( flag_CONTROLS, true ) ) && u.in_vehicle && !u.is_mounted() ) { + 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_WAYFARER ) ) { + if( !u.has_trait( trait_id( "WAYFARER" ) ) ) { add_msg( m_info, _( "%s to drive." ), press_x( ACTION_CONTROL_VEHICLE ) ); } - } else if( vp1.part_with_feature( flag_CONTROLS, true ) && u.in_vehicle && + } else if( vp1.part_with_feature( "CONTROLS", true ) && u.in_vehicle && u.is_mounted() ) { add_msg( _( "There are vehicle controls here but you cannot reach them whilst mounted." ) ); } @@ -9372,7 +9423,7 @@ void game::place_player_overmap( const tripoint &om_dest ) bool game::phasing_move( const tripoint &dest_loc ) { - if( !u.has_active_bionic( bio_probability_travel ) || + if( !u.has_active_bionic( bionic_id( "bio_probability_travel" ) ) || u.get_power_level() < 250_kJ ) { return false; } @@ -9393,8 +9444,7 @@ 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( flag_DIMENSIONAL_ANCHOR ) || - u.has_effect_with_flag( flag_DIMENSIONAL_ANCHOR ) ) { + if( u.worn_with_flag( "DIMENSIONAL_ANCHOR" ) || u.has_effect_with_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; @@ -9427,7 +9477,7 @@ bool game::phasing_move( const tripoint &dest_loc ) u.moves -= 100; //tunneling costs 100 moves u.setpos( dest ); - if( m.veh_at( u.pos() ).part_with_feature( flag_BOARDABLE, true ) ) { + if( m.veh_at( u.pos() ).part_with_feature( "BOARDABLE", true ) ) { m.board_vehicle( u.pos(), &u ); } @@ -9466,7 +9516,7 @@ bool game::grabbed_furn_move( const tripoint &dp ) critter_at( fdest ) == nullptr && critter_at( fdest ) == nullptr && ( !pulling_furniture || is_empty( u.pos() + dp ) ) && - ( !has_floor || m.has_flag( flag_FLAT, fdest ) ) && + ( !has_floor || m.has_flag( "FLAT", fdest ) ) && !m.has_furn( fdest ) && !m.veh_at( fdest ) && ( !has_floor || m.tr_at( fdest ).is_null() ) @@ -9481,13 +9531,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( flag_NOITEM, fdest ) && - !m.has_flag( flag_SWIMMABLE, fdest ) && - !m.has_flag( flag_DESTROY_ITEM, fdest ) && + const bool dst_item_ok = !m.has_flag( "NOITEM", fdest ) && + !m.has_flag( "SWIMMABLE", fdest ) && + !m.has_flag( "DESTROY_ITEM", fdest ) && only_liquid_items; - 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 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 int fire_intensity = m.get_field_intensity( fpos, fd_fire ); time_duration fire_age = m.get_field_age( fpos, fd_fire ); @@ -9650,7 +9700,7 @@ void game::on_move_effects() } } - if( u.has_active_bionic( bio_jointservo ) ) { + if( u.has_active_bionic( bionic_id( "bio_jointservo" ) ) ) { if( u.movement_mode_is( CMM_RUN ) ) { u.mod_power_level( -55_J ); } else { @@ -9789,7 +9839,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( flag_SWIMMABLE, c->pos() ) ) { + if( !m.has_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 ) { @@ -9866,13 +9916,13 @@ void game::vertical_move( int movez, bool force ) } // > and < are used for diving underwater. - if( m.has_flag( flag_SWIMMABLE, u.pos() ) && m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { + if( m.has_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( flag_FLOTATION ) ) { + if( u.worn_with_flag( "FLOTATION" ) ) { add_msg( m_info, _( "You can't dive while wearing a flotation device." ) ); return; } @@ -9896,7 +9946,7 @@ void game::vertical_move( int movez, bool force ) bool climbing = false; int move_cost = 100; tripoint stairs( u.posx(), u.posy(), u.posz() + movez ); - if( m.has_zlevels() && !force && movez == 1 && !m.has_flag( flag_GOES_UP, u.pos() ) ) { + if( m.has_zlevels() && !force && movez == 1 && !m.has_flag( "GOES_UP", u.pos() ) ) { // Climbing if( m.has_floor_or_support( stairs ) ) { add_msg( m_info, _( "You can't climb here - there's a ceiling above your head." ) ); @@ -9934,10 +9984,10 @@ void game::vertical_move( int movez, bool force ) } } - if( !force && movez == -1 && !m.has_flag( flag_GOES_DOWN, u.pos() ) ) { + if( !force && movez == -1 && !m.has_flag( "GOES_DOWN", u.pos() ) ) { add_msg( m_info, _( "You can't go down here!" ) ); return; - } else if( !climbing && !force && movez == 1 && !m.has_flag( flag_GOES_UP, u.pos() ) ) { + } else if( !climbing && !force && movez == 1 && !m.has_flag( "GOES_UP", u.pos() ) ) { add_msg( m_info, _( "You can't go up here!" ) ); return; } @@ -10047,7 +10097,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( flag_DIFFICULT_Z, u.pos() ) && !critter.climbs() ) || + if( ( m.has_flag( "DIFFICULT_Z", u.pos() ) && !critter.climbs() ) || critter.has_effect( effect_ridden ) || critter.has_effect( effect_tied ) ) { continue; @@ -10079,7 +10129,7 @@ void game::vertical_move( int movez, bool force ) } if( m.has_zlevels() && abs( movez ) == 1 ) { - bool ladder = m.has_flag( flag_DIFFICULT_Z, u.pos() ); + bool ladder = m.has_flag( "DIFFICULT_Z", u.pos() ); for( monster &critter : all_monsters() ) { if( ladder && !critter.climbs() ) { continue; @@ -10194,7 +10244,7 @@ void game::vertical_move( int movez, bool force ) void game::start_hauling( const tripoint &pos ) { - u.assign_activity( ACT_MOVE_ITEMS ); + u.assign_activity( activity_id( "ACT_MOVE_ITEMS" ) ); // Whether the destination is inside a vehicle (not supported) u.activity.values.push_back( 0 ); // Destination relative to the player @@ -10232,8 +10282,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( flag_GOES_UP, dest ) ) || - ( movez == 1 && ( mp.has_flag( flag_GOES_DOWN, dest ) || + ( ( movez == -1 && mp.has_flag( "GOES_UP", dest ) ) || + ( movez == 1 && ( mp.has_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 ) ) { @@ -10274,7 +10324,7 @@ cata::optional game::find_or_make_stairs( map &mp, const int z_after, } if( movez > 0 ) { - if( !mp.has_flag( flag_GOES_DOWN, *stairs ) ) { + if( !mp.has_flag( "GOES_DOWN", *stairs ) ) { if( !query_yn( _( "You may be unable to return back down these stairs. Continue up?" ) ) ) { return cata::nullopt; } @@ -10289,7 +10339,7 @@ cata::optional game::find_or_make_stairs( map &mp, const int z_after, return cata::nullopt; } - if( u.has_trait( trait_WEB_RAPPEL ) ) { + if( u.has_trait( trait_id( "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 ) ) { @@ -10591,8 +10641,8 @@ void game::update_stair_monsters() } for( const tripoint &dest : m.points_on_zlevel( u.posz() ) ) { - if( ( from_below && m.has_flag( flag_GOES_DOWN, dest ) ) || - ( !from_below && m.has_flag( flag_GOES_UP, dest ) ) ) { + if( ( from_below && m.has_flag( "GOES_DOWN", dest ) ) || + ( !from_below && m.has_flag( "GOES_UP", dest ) ) ) { stairx.push_back( dest.x ); stairy.push_back( dest.y ); stairdist.push_back( rl_dist( dest, u.pos() ) ); @@ -10868,8 +10918,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_no_faction ); - tmp->set_fac( new_solo_fac ? new_solo_fac->id : faction_no_faction ); + faction_id( "no_faction" ) ); + tmp->set_fac( new_solo_fac ? new_solo_fac->id : faction_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 ); @@ -11381,26 +11431,26 @@ bool check_art_charge_req( item &it ) void game::start_calendar() { - 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 ); + 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" ); 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( flag_SPR_START ) ) { + if( scen->has_flag( "SPR_START" ) ) { calendar::initial_season = SPRING; - } else if( scen->has_flag( flag_SUM_START ) ) { + } else if( scen->has_flag( "SUM_START" ) ) { calendar::initial_season = SUMMER; calendar::turn += calendar::season_length(); - } else if( scen->has_flag( flag_AUT_START ) ) { + } else if( scen->has_flag( "AUT_START" ) ) { calendar::initial_season = AUTUMN; calendar::turn += calendar::season_length() * 2; - } else if( scen->has_flag( flag_WIN_START ) ) { + } else if( scen->has_flag( "WIN_START" ) ) { calendar::initial_season = WINTER; calendar::turn += calendar::season_length() * 3; - } else if( scen->has_flag( flag_SUM_ADV_START ) ) { + } else if( scen->has_flag( "SUM_ADV_START" ) ) { calendar::initial_season = SUMMER; calendar::turn += calendar::season_length() * 5; } else { diff --git a/src/game.h b/src/game.h index faded5a8863ee..b267103adb732 100644 --- a/src/game.h +++ b/src/game.h @@ -93,6 +93,7 @@ enum target_mode : int; struct special_game; +using itype_id = std::string; class avatar; class event_bus; class kill_tracker; diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 885c18ea4a26b..c04c896ac48d0 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1518,7 +1518,7 @@ static item_location autodoc_internal( player &u, player &patient, } else { const inventory &crafting_inv = u.crafting_inventory(); std::vector a_filter = crafting_inv.items_with( []( const item & it ) { - return it.has_quality( quality_ANESTHESIA ); + return it.has_quality( qual_ANESTHESIA ); } ); std::vector b_filter = crafting_inv.items_with( []( const item & it ) { return it.has_flag( flag_ANESTHESIA ); // legacy @@ -1615,7 +1615,7 @@ class bionic_install_preset: public inventory_selector_preset } else if( it->has_flag( flag_NO_STERILE ) ) { // NOLINTNEXTLINE(cata-text-style): single space after the period for symmetry return _( "/!\\ CBM is not sterile. /!\\ Please use autoclave to sterilize." ); - } else if( it->has_fault( fault_bionic_salvaged ) ) { + } else if( it->has_fault( fault_id( "fault_bionic_salvaged" ) ) ) { return _( "CBM already deployed. Please reset to factory state." ); } else if( pa.has_bionic( bid ) ) { return _( "CBM already installed" ); diff --git a/src/gamemode_defense.h b/src/gamemode_defense.h index 19bb2012c4d48..0c787b346634c 100644 --- a/src/gamemode_defense.h +++ b/src/gamemode_defense.h @@ -11,6 +11,8 @@ #include "type_id.h" enum action_id : int; +using itype_id = std::string; + enum defense_style { DEFENSE_CUSTOM = 0, DEFENSE_EASY, diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 1095bbaf4ac55..77101c16ce721 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -408,8 +408,9 @@ static void pldrive( int x, int y ) return; } if( !remote ) { - const bool has_animal_controls = veh->part_with_feature( part, flag_CONTROL_ANIMAL, true ) >= 0; - const bool has_controls = veh->part_with_feature( part, flag_CONTROLS, true ) >= 0; + static const itype_id fuel_type_animal( "animal" ); + const bool has_animal_controls = veh->part_with_feature( part, "CONTROL_ANIMAL", true ) >= 0; + const bool has_controls = veh->part_with_feature( part, "CONTROLS", true ) >= 0; const bool has_animal = veh->has_engine_type( fuel_type_animal, false ) && veh->has_harnessed_animal(); if( !has_controls && !has_animal_controls ) { @@ -422,7 +423,7 @@ static void pldrive( int x, int y ) return; } } else { - if( empty( veh->get_avail_parts( flag_REMOTE_CONTROLS ) ) ) { + if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) { add_msg( m_info, _( "Can't drive this vehicle remotely. It has no working controls." ) ); return; } @@ -486,7 +487,7 @@ static void open() } } else { // If there are any OPENABLE parts here, they must be already open - if( const cata::optional already_open = vp.part_with_feature( flag_OPENABLE, + if( const cata::optional already_open = vp.part_with_feature( "OPENABLE", true ) ) { const std::string name = already_open->info().name(); add_msg( m_info, _( "That %s is already open." ), name ); @@ -708,7 +709,7 @@ static void smash() u.practice( skill_melee, rng( 0, 1 ) * rng( 0, 1 ) ); } const int vol = u.weapon.volume() / units::legacy_volume_factor; - if( u.weapon.made_of( material_glass ) && + if( u.weapon.made_of( material_id( "glass" ) ) && rng( 0, vol + 3 ) < vol ) { add_msg( m_bad, _( "Your %s shatters!" ), u.weapon.tname() ); for( auto &elem : u.weapon.contents ) { @@ -1032,32 +1033,32 @@ static void loot() player &u = g->u; int flags = 0; auto &mgr = zone_manager::get_manager(); - const bool has_fertilizer = u.has_item_with_flag( flag_FERTILIZER ); + const bool has_fertilizer = u.has_item_with_flag( "FERTILIZER" ); // Manually update vehicle cache. // In theory this would be handled by the related activity (activity_on_turn_move_loot()) // but with a stale cache we never get that far. mgr.cache_vzones(); - flags |= g->check_near_zone( zone_type_LOOT_UNSORTED, u.pos() ) ? SortLoot : 0; - if( g->check_near_zone( zone_type_FARM_PLOT, u.pos() ) ) { + flags |= g->check_near_zone( zone_type_id( "LOOT_UNSORTED" ), u.pos() ) ? SortLoot : 0; + if( g->check_near_zone( zone_type_id( "FARM_PLOT" ), u.pos() ) ) { flags |= FertilizePlots; flags |= MultiFarmPlots; } - flags |= g->check_near_zone( zone_type_CONSTRUCTION_BLUEPRINT, + flags |= g->check_near_zone( zone_type_id( "CONSTRUCTION_BLUEPRINT" ), u.pos() ) ? ConstructPlots : 0; - flags |= g->check_near_zone( zone_type_CHOP_TREES, u.pos() ) ? Multichoptrees : 0; - flags |= g->check_near_zone( zone_type_LOOT_WOOD, u.pos() ) ? Multichopplanks : 0; - flags |= g->check_near_zone( zone_type_VEHICLE_DECONSTRUCT, + flags |= g->check_near_zone( zone_type_id( "CHOP_TREES" ), u.pos() ) ? Multichoptrees : 0; + flags |= g->check_near_zone( zone_type_id( "LOOT_WOOD" ), u.pos() ) ? Multichopplanks : 0; + flags |= g->check_near_zone( zone_type_id( "VEHICLE_DECONSTRUCT" ), u.pos() ) ? Multideconvehicle : 0; - flags |= g->check_near_zone( zone_type_VEHICLE_REPAIR, u.pos() ) ? Multirepairvehicle : 0; - flags |= g->check_near_zone( zone_type_LOOT_CORPSE, u.pos() ) ? MultiButchery : 0; + flags |= g->check_near_zone( zone_type_id( "VEHICLE_REPAIR" ), u.pos() ) ? Multirepairvehicle : 0; + flags |= g->check_near_zone( zone_type_id( "LOOT_CORPSE" ), u.pos() ) ? MultiButchery : 0; if( flags == 0 ) { add_msg( m_info, _( "There is no compatible zone nearby." ) ); add_msg( m_info, _( "Compatible zones are %s and %s" ), - mgr.get_name_from_type( zone_type_LOOT_UNSORTED ), - mgr.get_name_from_type( zone_type_FARM_PLOT ) ); + mgr.get_name_from_type( zone_type_id( "LOOT_UNSORTED" ) ), + mgr.get_name_from_type( zone_type_id( "FARM_PLOT" ) ) ); return; } @@ -1277,7 +1278,7 @@ static void fire() return; } - if( vp.part_with_feature( flag_CONTROLS, true ) ) { + if( vp.part_with_feature( "CONTROLS", true ) ) { if( vp->vehicle().turrets_aim_and_fire() ) { return; } @@ -1411,7 +1412,7 @@ static void cast_spell() return; } - if( sp.energy_source() == hp_energy && !u.has_quality( quality_CUT ) ) { + if( sp.energy_source() == hp_energy && !u.has_quality( qual_CUT ) ) { add_msg( m_bad, _( "You cannot cast Blood Magic without a cutting implement." ) ); return; } diff --git a/src/handle_liquid.cpp b/src/handle_liquid.cpp index 029c6922cbe37..cfdad43df3832 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -33,7 +33,6 @@ #include "optional.h" #include "player_activity.h" #include "string_formatter.h" -#include "cata_string_consts.h" #define dbg(x) DebugLog((x),D_GAME) << __FILE__ << ":" << __LINE__ << ": " @@ -302,11 +301,11 @@ static bool perform_liquid_transfer( item &liquid, const tripoint *const source_ const auto create_activity = [&]() { if( source_veh != nullptr ) { - g->u.assign_activity( ACT_FILL_LIQUID ); + g->u.assign_activity( activity_id( "ACT_FILL_LIQUID" ) ); serialize_liquid_source( g->u.activity, *source_veh, part_num, liquid ); return true; } else if( source_pos != nullptr ) { - g->u.assign_activity( ACT_FILL_LIQUID ); + g->u.assign_activity( activity_id( "ACT_FILL_LIQUID" ) ); serialize_liquid_source( g->u.activity, *source_pos, liquid ); return true; } else if( source_mon != nullptr ) { diff --git a/src/harvest.h b/src/harvest.h index 830d50d346314..b55f6ce28d4bd 100644 --- a/src/harvest.h +++ b/src/harvest.h @@ -13,6 +13,7 @@ #include "translations.h" #include "type_id.h" +using itype_id = std::string; class JsonObject; // Could be reused for butchery diff --git a/src/iexamine.cpp b/src/iexamine.cpp index f6e376203ff0f..9b28fb0040348 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -108,7 +108,7 @@ void iexamine::cvdmachine( player &p, const tripoint & ) { // Select an item to which it is possible to apply a diamond coating auto loc = g->inv_map_splice( []( const item & e ) { - return ( e.is_melee( DT_CUT ) || e.is_melee( DT_STAB ) ) && e.made_of( material_steel ) && + return ( e.is_melee( DT_CUT ) || e.is_melee( DT_STAB ) ) && e.made_of( material_id( "steel" ) ) && !e.has_flag( flag_DIAMOND ) && !e.has_flag( flag_NO_CVD ); }, _( "Apply diamond coating" ), 1, _( "You don't have a suitable item to coat with diamond" ) ); @@ -136,7 +136,7 @@ void iexamine::cvdmachine( player &p, const tripoint & ) p.invalidate_crafting_inventory(); // Apply flag to item - loc->item_tags.insert( flag_DIAMOND ); + loc->item_tags.insert( "DIAMOND" ); add_msg( m_good, _( "You apply a diamond coating to your %s" ), loc->type_name() ); p.mod_moves( -to_turns( 10_seconds ) ); } @@ -149,7 +149,7 @@ void iexamine::nanofab( player &p, const tripoint &examp ) bool table_exists = false; tripoint spawn_point; for( const auto &valid_location : g->m.points_in_radius( examp, 1 ) ) { - if( g->m.ter( valid_location ) == ter_nanofab_body ) { + if( g->m.ter( valid_location ) == ter_str_id( "t_nanofab_body" ) ) { spawn_point = valid_location; table_exists = true; break; @@ -188,7 +188,7 @@ void iexamine::nanofab( player &p, const tripoint &examp ) p.invalidate_crafting_inventory(); if( new_item.is_armor() && new_item.has_flag( flag_VARSIZE ) ) { - new_item.item_tags.insert( flag_FIT ); + new_item.item_tags.insert( "FIT" ); } g->m.add_item_or_charges( spawn_point, new_item ); @@ -881,9 +881,9 @@ void iexamine::intercom( player &p, const tripoint &examp ) void iexamine::rubble( player &p, const tripoint &examp ) { int moves; - if( p.has_quality( quality_DIG, 3 ) || p.has_trait( trait_BURROW ) ) { + if( p.has_quality( qual_DIG, 3 ) || p.has_trait( trait_BURROW ) ) { moves = to_moves( 1_minutes ); - } else if( p.has_quality( quality_DIG, 2 ) ) { + } else if( p.has_quality( qual_DIG, 2 ) ) { moves = to_moves( 2_minutes ); } else { add_msg( m_info, _( "If only you had a shovel…" ) ); @@ -1262,7 +1262,7 @@ void iexamine::locked_object( player &p, const tripoint &examp ) { auto prying_items = p.crafting_inventory().items_with( []( const item & it ) -> bool { item temporary_item( it.type ); - return temporary_item.has_quality( quality_PRY, 1 ); + return temporary_item.has_quality( qual_PRY, 1 ); } ); if( prying_items.empty() ) { @@ -1273,7 +1273,7 @@ void iexamine::locked_object( player &p, const tripoint &examp ) // Sort by their quality level. std::sort( prying_items.begin(), prying_items.end(), []( const item * a, const item * b ) -> bool { - return a->get_quality( quality_PRY ) > b->get_quality( quality_PRY ); + return a->get_quality( qual_PRY ) > b->get_quality( qual_PRY ); } ); //~ %1$s: terrain/furniture name, %2$s: prying tool name @@ -1669,7 +1669,7 @@ void iexamine::flower_dahlia( player &p, const tripoint &examp ) return; } - bool can_get_root = p.has_quality( quality_DIG ) || p.has_trait( trait_BURROW ); + bool can_get_root = p.has_quality( qual_DIG ) || p.has_trait( trait_BURROW ); if( can_get_root ) { if( !query_yn( _( "Pick %s?" ), g->m.furnname( examp ) ) ) { @@ -2129,7 +2129,7 @@ void iexamine::harvest_plant( player &p, const tripoint &examp, bool from_activi ret_val iexamine::can_fertilize( player &p, const tripoint &tile, const itype_id &fertilizer ) { - if( !g->m.has_flag_furn( flag_PLANT, tile ) ) { + if( !g->m.has_flag_furn( "PLANT", tile ) ) { return ret_val::make_failure( _( "Tile isn't a plant" ) ); } if( g->m.i_at( tile ).size() > 1 ) { @@ -2267,7 +2267,7 @@ void iexamine::kiln_empty( player &p, const tripoint &examp ) return; } - static const std::set kilnable{ material_wood, material_bone }; + static const std::set kilnable{ material_id( "wood" ), material_id( "bone" ) }; bool fuel_present = false; auto items = g->m.i_at( examp ); for( const item &i : items ) { @@ -2396,7 +2396,7 @@ void iexamine::arcfurnace_empty( player &p, const tripoint &examp ) return; } - static const std::set arcfurnaceable{ material_cac2powder }; + static const std::set arcfurnaceable{ material_id( "cac2powder" ) }; bool fuel_present = false; auto items = g->m.i_at( examp ); for( const item &i : items ) { @@ -3197,7 +3197,7 @@ void iexamine::tree_hickory( player &p, const tripoint &examp ) if( harvest_common( p, examp, false, false ) ) { g->m.ter_set( examp, g->m.get_ter_transforms_into( examp ) ); } - if( !p.has_quality( quality_DIG ) ) { + if( !p.has_quality( qual_DIG ) ) { p.add_msg_if_player( m_info, _( "You have no tool to dig with…" ) ); return; } @@ -3224,12 +3224,12 @@ static item_location maple_tree_sap_container() void iexamine::tree_maple( player &p, const tripoint &examp ) { - if( !p.has_quality( quality_DRILL ) ) { + if( !p.has_quality( qual_DRILL ) ) { add_msg( m_info, _( "You need a tool to drill the crust to tap this maple tree." ) ); return; } - if( !p.has_quality( quality_HAMMER ) ) { + if( !p.has_quality( qual_HAMMER ) ) { add_msg( m_info, _( "You need a tool to hammer the spile into the crust to tap this maple tree." ) ); return; @@ -3302,7 +3302,7 @@ void iexamine::tree_maple_tapped( player &p, const tripoint &examp ) switch( selectmenu.ret ) { case REMOVE_TAP: { - if( !p.has_quality( quality_HAMMER ) ) { + if( !p.has_quality( qual_HAMMER ) ) { add_msg( m_info, _( "You need a hammering tool to remove the spile from the crust." ) ); return; } @@ -3786,7 +3786,7 @@ static int getNearPumpCount( const tripoint &p ) int result = 0; for( const tripoint &tmp : g->m.points_in_radius( p, 12 ) ) { const auto t = g->m.ter( tmp ); - if( t == ter_gas_pump || t == ter_gas_pump_a ) { + if( t == ter_str_id( "t_gas_pump" ) || t == ter_str_id( "t_gas_pump_a" ) ) { result++; } } @@ -3800,7 +3800,7 @@ cata::optional iexamine::getNearFilledGasTank( const tripoint ¢er, gas_units = 0; for( const tripoint &tmp : g->m.points_in_radius( center, SEEX * 2 ) ) { - if( g->m.ter( tmp ) != ter_gas_tank ) { + if( g->m.ter( tmp ) != ter_str_id( "t_gas_tank" ) ) { continue; } @@ -3846,7 +3846,7 @@ static int findBestGasDiscount( player &p ) for( size_t i = 0; i < p.inv.size(); i++ ) { item &it = p.inv.find_item( i ); - if( it.has_flag( flag_GAS_DISCOUNT ) ) { + if( it.has_flag( "GAS_DISCOUNT" ) ) { int q = getGasDiscountCardQuality( it ); if( q > discount ) { @@ -3906,7 +3906,7 @@ cata::optional iexamine::getGasPumpByNumber( const tripoint &p, int nu int k = 0; for( const tripoint &tmp : g->m.points_in_radius( p, 12 ) ) { const auto t = g->m.ter( tmp ); - if( ( t == ter_gas_pump || t == ter_gas_pump_a ) && number == k++ ) { + if( ( t == ter_str_id( "t_gas_pump" ) || t == ter_str_id( "t_gas_pump_a" ) ) && number == k++ ) { return tmp; } } @@ -3970,11 +3970,11 @@ static void turnOnSelectedPump( const tripoint &p, int number ) int k = 0; for( const tripoint &tmp : g->m.points_in_radius( p, 12 ) ) { const auto t = g->m.ter( tmp ); - if( t == ter_gas_pump || t == ter_gas_pump_a ) { + if( t == ter_str_id( "t_gas_pump" ) || t == ter_str_id( "t_gas_pump_a" ) ) { if( number == k++ ) { - g->m.ter_set( tmp, ter_gas_pump_a ); + g->m.ter_set( tmp, ter_str_id( "t_gas_pump_a" ) ); } else { - g->m.ter_set( tmp, ter_gas_pump ); + g->m.ter_set( tmp, ter_str_id( "t_gas_pump" ) ); } } } @@ -4462,7 +4462,7 @@ void iexamine::autodoc( player &p, const tripoint &examp ) } else { const inventory &crafting_inv = p.crafting_inventory(); std::vector a_filter = crafting_inv.items_with( []( const item & it ) { - return it.has_quality( quality_ANESTHESIA ); + return it.has_quality( qual_ANESTHESIA ); } ); std::vector b_filter = crafting_inv.items_with( []( const item & it ) { return it.has_flag( flag_ANESTHESIA ); // legacy @@ -5658,7 +5658,7 @@ void iexamine::workbench_internal( player &p, const tripoint &examp, pgettext( "in progress craft", "You start working on the %s." ), pgettext( "in progress craft", " starts working on the %s." ), selected_craft->tname() ); - p.assign_activity( ACT_CRAFT ); + p.assign_activity( activity_id( "ACT_CRAFT" ) ); p.activity.targets.push_back( crafts[amenu2.ret] ); p.activity.values.push_back( 0 ); // Not a long craft break; diff --git a/src/inventory.cpp b/src/inventory.cpp index e3f84bb228fc5..0fd2e43331f1c 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -439,7 +439,7 @@ void inventory::form_from_map( map &m, std::vector pts, const Characte if( type != nullptr ) { const itype *ammo = f.crafting_ammo_item_type(); item furn_item( type, calendar::turn, 0 ); - furn_item.item_tags.insert( flag_PSEUDO ); + furn_item.item_tags.insert( "PSEUDO" ); furn_item.charges = ammo ? count_charges_in_list( ammo, m.i_at( p ) ) : 0; add_item( furn_item ); } @@ -506,14 +506,14 @@ void inventory::form_from_map( map &m, std::vector pts, const Characte //Adds faucet to kitchen stuff; may be horribly wrong to do such.... //ShouldBreak into own variable - const cata::optional kpart = vp.part_with_feature( flag_KITCHEN, true ); - const cata::optional faupart = vp.part_with_feature( flag_FAUCET, true ); - const cata::optional weldpart = vp.part_with_feature( flag_WELDRIG, true ); - const cata::optional craftpart = vp.part_with_feature( flag_CRAFTRIG, true ); - const cata::optional forgepart = vp.part_with_feature( flag_FORGE, true ); - const cata::optional kilnpart = vp.part_with_feature( flag_KILN, true ); - const cata::optional chempart = vp.part_with_feature( flag_CHEMLAB, true ); - const cata::optional cargo = vp.part_with_feature( flag_CARGO, true ); + const cata::optional kpart = vp.part_with_feature( "KITCHEN", true ); + const cata::optional faupart = vp.part_with_feature( "FAUCET", true ); + const cata::optional weldpart = vp.part_with_feature( "WELDRIG", true ); + const cata::optional craftpart = vp.part_with_feature( "CRAFTRIG", true ); + const cata::optional forgepart = vp.part_with_feature( "FORGE", true ); + const cata::optional kilnpart = vp.part_with_feature( "KILN", true ); + const cata::optional chempart = vp.part_with_feature( "CHEMLAB", true ); + const cata::optional cargo = vp.part_with_feature( "CARGO", true ); if( cargo ) { const auto items = veh->get_items( cargo->part_index() ); @@ -532,70 +532,70 @@ void inventory::form_from_map( map &m, std::vector pts, const Characte if( kpart ) { item hotplate( "hotplate", 0 ); - hotplate.charges = veh->fuel_left( fuel_type_battery, true ); - hotplate.item_tags.insert( flag_PSEUDO ); + hotplate.charges = veh->fuel_left( "battery", true ); + hotplate.item_tags.insert( "PSEUDO" ); add_item( hotplate ); item pot( "pot", 0 ); - pot.item_tags.insert( flag_PSEUDO ); + pot.item_tags.insert( "PSEUDO" ); add_item( pot ); item pan( "pan", 0 ); - pan.item_tags.insert( flag_PSEUDO ); + pan.item_tags.insert( "PSEUDO" ); add_item( pan ); } if( weldpart ) { item welder( "welder", 0 ); - welder.charges = veh->fuel_left( fuel_type_battery, true ); - welder.item_tags.insert( flag_PSEUDO ); + welder.charges = veh->fuel_left( "battery", true ); + welder.item_tags.insert( "PSEUDO" ); add_item( welder ); item soldering_iron( "soldering_iron", 0 ); - soldering_iron.charges = veh->fuel_left( fuel_type_battery, true ); - soldering_iron.item_tags.insert( flag_PSEUDO ); + soldering_iron.charges = veh->fuel_left( "battery", true ); + soldering_iron.item_tags.insert( "PSEUDO" ); add_item( soldering_iron ); } if( craftpart ) { item vac_sealer( "vac_sealer", 0 ); - vac_sealer.charges = veh->fuel_left( fuel_type_battery, true ); - vac_sealer.item_tags.insert( flag_PSEUDO ); + vac_sealer.charges = veh->fuel_left( "battery", true ); + vac_sealer.item_tags.insert( "PSEUDO" ); add_item( vac_sealer ); item dehydrator( "dehydrator", 0 ); - dehydrator.charges = veh->fuel_left( fuel_type_battery, true ); - dehydrator.item_tags.insert( flag_PSEUDO ); + dehydrator.charges = veh->fuel_left( "battery", true ); + dehydrator.item_tags.insert( "PSEUDO" ); add_item( dehydrator ); item food_processor( "food_processor", 0 ); - food_processor.charges = veh->fuel_left( fuel_type_battery, true ); - food_processor.item_tags.insert( flag_PSEUDO ); + food_processor.charges = veh->fuel_left( "battery", true ); + food_processor.item_tags.insert( "PSEUDO" ); add_item( food_processor ); item press( "press", 0 ); - press.charges = veh->fuel_left( fuel_type_battery, true ); - press.item_tags.insert( flag_PSEUDO ); + press.charges = veh->fuel_left( "battery", true ); + press.item_tags.insert( "PSEUDO" ); add_item( press ); } if( forgepart ) { item forge( "forge", 0 ); - forge.charges = veh->fuel_left( fuel_type_battery, true ); - forge.item_tags.insert( flag_PSEUDO ); + forge.charges = veh->fuel_left( "battery", true ); + forge.item_tags.insert( "PSEUDO" ); add_item( forge ); } if( kilnpart ) { item kiln( "kiln", 0 ); - kiln.charges = veh->fuel_left( fuel_type_battery, true ); - kiln.item_tags.insert( flag_PSEUDO ); + kiln.charges = veh->fuel_left( "battery", true ); + kiln.item_tags.insert( "PSEUDO" ); add_item( kiln ); } if( chempart ) { item chemistry_set( "chemistry_set", 0 ); - chemistry_set.charges = veh->fuel_left( fuel_type_battery, true ); - chemistry_set.item_tags.insert( flag_PSEUDO ); + chemistry_set.charges = veh->fuel_left( "battery", true ); + chemistry_set.item_tags.insert( "PSEUDO" ); add_item( chemistry_set ); item electrolysis_kit( "electrolysis_kit", 0 ); - electrolysis_kit.charges = veh->fuel_left( fuel_type_battery, true ); - electrolysis_kit.item_tags.insert( flag_PSEUDO ); + electrolysis_kit.charges = veh->fuel_left( "battery", true ); + electrolysis_kit.item_tags.insert( "PSEUDO" ); add_item( electrolysis_kit ); } } @@ -876,7 +876,7 @@ void inventory::rust_iron_items() { for( auto &elem : items ) { for( auto &elem_stack_iter : elem ) { - if( elem_stack_iter.made_of( material_iron ) && + if( elem_stack_iter.made_of( material_id( "iron" ) ) && !elem_stack_iter.has_flag( flag_WATERPROOF_GUN ) && !elem_stack_iter.has_flag( flag_WATERPROOF ) && elem_stack_iter.damage() < elem_stack_iter.max_damage() / 2 && diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index b14ced5285c12..656d92230a2c0 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -41,7 +41,6 @@ #include #include #include -#include "cata_string_consts.h" /** The maximum distance from the screen edge, to snap a window to it */ static const size_t max_win_snap_distance = 4; @@ -651,7 +650,7 @@ void inventory_column::set_stack_favorite( const item_location &location, bool f } } else if( location.where() == item_location::type::vehicle ) { const cata::optional vp = g->m.veh_at( - location.position() ).part_with_feature( flag_CARGO, true ); + location.position() ).part_with_feature( "CARGO", true ); assert( vp ); auto items = vp->vehicle().get_items( vp->part_index() ); @@ -1185,8 +1184,7 @@ void inventory_selector::add_map_items( const tripoint &target ) void inventory_selector::add_vehicle_items( const tripoint &target ) { - const cata::optional vp = g->m.veh_at( target ).part_with_feature( flag_CARGO, - true ); + const cata::optional vp = g->m.veh_at( target ).part_with_feature( "CARGO", true ); if( !vp ) { return; } diff --git a/src/item.cpp b/src/item.cpp index f16a4ce6a33d4..b18dd7409fbf6 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1106,7 +1106,7 @@ void item::basic_info( std::vector &info, const iteminfo_query *parts, } else if( idescription != item_vars.end() ) { info.push_back( iteminfo( "DESCRIPTION", idescription->second ) ); } else { - if( has_flag( flag_MAGIC_FOCUS ) ) { + if( has_flag( "MAGIC_FOCUS" ) ) { info.push_back( iteminfo( "DESCRIPTION", _( "This item is a magical focus. " "You can cast spells with it in your hand." ) ) ); @@ -1438,7 +1438,7 @@ void item::food_info( const item *food_item, std::vector &info, if( food_item->has_flag( flag_CANNIBALISM ) && parts->test( iteminfo_parts::FOOD_CANNIBALISM ) ) { - if( !g->u.has_trait_flag( flag_CANNIBAL ) ) { + if( !g->u.has_trait_flag( trait_flag_CANNIBAL ) ) { info.emplace_back( "DESCRIPTION", _( "* This food contains human flesh." ) ); } else { @@ -2556,7 +2556,7 @@ void item::qualities_info( std::vector &info, const iteminfo_query *pa { auto name_quality = [&info]( const std::pair &q ) { std::string str; - if( q.first == quality_JACK || q.first == quality_LIFT ) { + if( q.first == qual_JACK || q.first == qual_LIFT ) { str = string_format( _( "Has level %1$d %2$s quality and " "is rated at %3$d %4$s" ), q.second, q.first.obj().name, @@ -2736,7 +2736,7 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, } if( is_armor() && g->u.has_trait( trait_WOOLALLERGY ) && - ( made_of( material_wool ) || item_tags.count( flag_wooled ) ) ) { + ( made_of( material_id( "wool" ) ) || item_tags.count( "wooled" ) ) ) { info.push_back( iteminfo( "DESCRIPTION", _( "* This clothing will give you an allergic " "reaction." ) ) ); @@ -3460,7 +3460,7 @@ nc_color item::color_in_inventory() const } else if( has_flag( flag_LITCIG ) ) { ret = c_red; } else if( is_armor() && u.has_trait( trait_WOOLALLERGY ) && - ( made_of( material_wool ) || item_tags.count( flag_wooled ) ) ) { + ( made_of( material_id( "wool" ) ) || item_tags.count( "wooled" ) ) ) { ret = c_red; } else if( is_filthy() || item_tags.count( "DIRTY" ) ) { ret = c_brown; @@ -5204,7 +5204,7 @@ bool item::ready_to_revive( const tripoint &pos ) const bool item::is_money() const { - return ammo_types().count( ammo_money ); + return ammo_types().count( ammotype( "money" ) ); } bool item::count_by_charges() const @@ -5703,7 +5703,7 @@ bool item::is_gun() const bool item::is_firearm() const { - static const std::string primitive_flag( flag_PRIMITIVE_RANGED_WEAPON ); + static const std::string primitive_flag( "PRIMITIVE_RANGED_WEAPON" ); return is_gun() && !has_flag( primitive_flag ); } @@ -6397,7 +6397,7 @@ gun_type_type item::gun_type() const // TODO: move to JSON and remove extraction of this from "GUN" (via skill id) //and from "GUNMOD" (via "mod_targets") in lang/extract_json_strings.py if( gun_skill() == skill_archery ) { - if( ammo_types().count( ammo_bolt ) || typeId() == "bullet_crossbow" ) { + if( ammo_types().count( ammotype( "bolt" ) ) || typeId() == "bullet_crossbow" ) { return gun_type_type( translate_marker_context( "gun_type_type", "crossbow" ) ); } else { return gun_type_type( translate_marker_context( "gun_type_type", "bow" ) ); @@ -8669,14 +8669,14 @@ bool item::process_corpse( player *carrier, const tripoint &pos ) if( rng( 0, volume() / units::legacy_volume_factor ) > burnt && g->revive_corpse( pos, *this ) ) { if( carrier == nullptr ) { if( g->u.sees( pos ) ) { - if( corpse->in_species( species_ROBOT ) ) { + if( corpse->in_species( ROBOT ) ) { add_msg( m_warning, _( "A nearby robot has repaired itself and stands up!" ) ); } else { add_msg( m_warning, _( "A nearby corpse rises and moves towards you!" ) ); } } } else { - if( corpse->in_species( species_ROBOT ) ) { + if( corpse->in_species( ROBOT ) ) { carrier->add_msg_if_player( m_warning, _( "Oh dear god, a robot you're carrying has started moving!" ) ); } else { @@ -8886,7 +8886,7 @@ cata::optional item::get_cable_target( Character *p, const tripoint &p } const optional_vpart_position vp_pos = g->m.veh_at( pos ); if( vp_pos ) { - const cata::optional seat = vp_pos.part_with_feature( flag_BOARDABLE, true ); + const cata::optional seat = vp_pos.part_with_feature( "BOARDABLE", true ); if( seat && p == seat->vehicle().get_passenger( seat->part_index() ) ) { return pos; } @@ -9419,7 +9419,7 @@ bool item::has_infinite_charges() const skill_id item::contextualize_skill( const skill_id &id ) const { if( id->is_contextual_skill() ) { - if( id == skill_weapon ) { + if( id == weapon_skill ) { if( is_gun() ) { return gun_skill(); } else if( is_melee() ) { diff --git a/src/item.h b/src/item.h index 47eb4085e896f..0cdaf4d78434d 100644 --- a/src/item.h +++ b/src/item.h @@ -72,6 +72,7 @@ enum m_size : int; enum class side : int; class body_part_set; +using itype_id = std::string; struct fire_data; struct damage_instance; struct damage_unit; diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 5f9e751afc461..28915f185e7ff 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -47,7 +47,6 @@ #include "units.h" #include "cata_utility.h" #include "flat_set.h" -#include "cata_string_consts.h" class player; struct tripoint; @@ -227,8 +226,8 @@ void Item_factory::finalize_pre( itype &obj ) } const auto &mats = obj.materials; - if( std::find( mats.begin(), mats.end(), material_hydrocarbons ) == mats.end() && - std::find( mats.begin(), mats.end(), material_oil ) == mats.end() ) { + if( std::find( mats.begin(), mats.end(), material_id( "hydrocarbons" ) ) == mats.end() && + std::find( mats.begin(), mats.end(), material_id( "oil" ) ) == mats.end() ) { const auto &ammo_effects = obj.ammo->ammo_effects; obj.ammo->cookoff = ammo_effects.count( "INCENDIARY" ) > 0 || ammo_effects.count( "COOKOFF" ) > 0; @@ -2114,31 +2113,31 @@ static void set_allergy_flags( itype &item_template ) static const std::vector all_pairs = {{ // First allergens: // An item is an allergen even if it has trace amounts of allergenic material - std::make_pair( material_hflesh, flag_CANNIBALISM ), - - std::make_pair( material_hflesh, flag_ALLERGEN_MEAT ), - std::make_pair( material_iflesh, flag_ALLERGEN_MEAT ), - std::make_pair( material_flesh, flag_ALLERGEN_MEAT ), - std::make_pair( material_wheat, flag_ALLERGEN_WHEAT ), - std::make_pair( material_fruit, flag_ALLERGEN_FRUIT ), - std::make_pair( material_veggy, flag_ALLERGEN_VEGGY ), - std::make_pair( material_bean, flag_ALLERGEN_VEGGY ), - std::make_pair( material_tomato, flag_ALLERGEN_VEGGY ), - std::make_pair( material_garlic, flag_ALLERGEN_VEGGY ), - std::make_pair( material_nut, flag_ALLERGEN_VEGGY ), - std::make_pair( material_mushroom, flag_ALLERGEN_VEGGY ), - std::make_pair( material_milk, flag_ALLERGEN_MILK ), - std::make_pair( material_egg, flag_ALLERGEN_EGG ), - std::make_pair( material_junk, flag_ALLERGEN_JUNK ), + std::make_pair( material_id( "hflesh" ), "CANNIBALISM" ), + + std::make_pair( material_id( "hflesh" ), "ALLERGEN_MEAT" ), + std::make_pair( material_id( "iflesh" ), "ALLERGEN_MEAT" ), + std::make_pair( material_id( "flesh" ), "ALLERGEN_MEAT" ), + std::make_pair( material_id( "wheat" ), "ALLERGEN_WHEAT" ), + std::make_pair( material_id( "fruit" ), "ALLERGEN_FRUIT" ), + std::make_pair( material_id( "veggy" ), "ALLERGEN_VEGGY" ), + std::make_pair( material_id( "bean" ), "ALLERGEN_VEGGY" ), + std::make_pair( material_id( "tomato" ), "ALLERGEN_VEGGY" ), + std::make_pair( material_id( "garlic" ), "ALLERGEN_VEGGY" ), + std::make_pair( material_id( "nut" ), "ALLERGEN_VEGGY" ), + std::make_pair( material_id( "mushroom" ), "ALLERGEN_VEGGY" ), + std::make_pair( material_id( "milk" ), "ALLERGEN_MILK" ), + std::make_pair( material_id( "egg" ), "ALLERGEN_EGG" ), + std::make_pair( material_id( "junk" ), "ALLERGEN_JUNK" ), // Not food, but we can keep it here - std::make_pair( material_wool, flag_ALLERGEN_WOOL ), + std::make_pair( material_id( "wool" ), "ALLERGEN_WOOL" ), // Now "made of". Those flags should not be passed - std::make_pair( material_flesh, flag_CARNIVORE_OK ), - std::make_pair( material_hflesh, flag_CARNIVORE_OK ), - std::make_pair( material_iflesh, flag_CARNIVORE_OK ), - std::make_pair( material_milk, flag_CARNIVORE_OK ), - std::make_pair( material_egg, flag_CARNIVORE_OK ), - std::make_pair( material_honey, flag_URSINE_HONEY ), + std::make_pair( material_id( "flesh" ), "CARNIVORE_OK" ), + std::make_pair( material_id( "hflesh" ), "CARNIVORE_OK" ), + std::make_pair( material_id( "iflesh" ), "CARNIVORE_OK" ), + std::make_pair( material_id( "milk" ), "CARNIVORE_OK" ), + std::make_pair( material_id( "egg" ), "CARNIVORE_OK" ), + std::make_pair( material_id( "honey" ), "URSINE_HONEY" ), } }; @@ -2156,11 +2155,11 @@ void hflesh_to_flesh( itype &item_template ) { auto &mats = item_template.materials; const auto old_size = mats.size(); - mats.erase( std::remove( mats.begin(), mats.end(), material_hflesh ), mats.end() ); + mats.erase( std::remove( mats.begin(), mats.end(), material_id( "hflesh" ) ), mats.end() ); // Only add "flesh" material if not already present if( old_size != mats.size() && - std::find( mats.begin(), mats.end(), material_flesh ) == mats.end() ) { - mats.push_back( material_flesh ); + std::find( mats.begin(), mats.end(), material_id( "flesh" ) ) == mats.end() ) { + mats.push_back( material_id( "flesh" ) ); } } diff --git a/src/item_location.cpp b/src/item_location.cpp index 5dd52acfc6e2e..903cd46cdf293 100644 --- a/src/item_location.cpp +++ b/src/item_location.cpp @@ -423,7 +423,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl if( auto label = part_pos.get_label() ) { res = colorize( *label, c_light_blue ) + " "; } - if( auto cargo_part = part_pos.part_with_feature( flag_CARGO, true ) ) { + if( auto cargo_part = part_pos.part_with_feature( "CARGO", true ) ) { res += cargo_part->part().name(); } else { debugmsg( "item in vehicle part without cargo storage" ); diff --git a/src/itype.h b/src/itype.h index 563bbba6812ce..976c9de821cd2 100644 --- a/src/itype.h +++ b/src/itype.h @@ -36,6 +36,8 @@ enum art_effect_active : int; enum art_charge : int; enum art_charge_req : int; enum art_effect_passive : int; +using itype_id = std::string; + class gun_modifier_data { private: diff --git a/src/iuse.cpp b/src/iuse.cpp index 2ef6f265bf322..84c01d2318be1 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -149,19 +149,19 @@ static extended_photo_def photo_def_for_camera_point( const tripoint &aim_point, std::vector &monster_vec, std::vector &player_vec ); static const std::vector camera_ter_whitelist_flags = { - flag_HIDE_PLACE, flag_FUNGUS, flag_TREE, flag_PERMEABLE, flag_SHRUB, - flag_PLACE_ITEM, flag_GROWTH_HARVEST, flag_GROWTH_MATURE, flag_GOES_UP, - flag_GOES_DOWN, flag_RAMP, flag_SHARP, flag_SIGN, flag_CLIMBABLE + "HIDE_PLACE", "FUNGUS", "TREE", "PERMEABLE", "SHRUB", + "PLACE_ITEM", "GROWTH_HARVEST", "GROWTH_MATURE", "GOES_UP", + "GOES_DOWN", "RAMP", "SHARP", "SIGN", "CLIMBABLE" }; static const std::vector camera_ter_whitelist_types = { - ter_pit_covered, ter_grave_new, ter_grave, ter_pit, - ter_pit_shallow, ter_pit_corpsed, ter_pit_spiked, - ter_pit_spiked_covered, ter_pit_glass, ter_pit_glass, ter_utility_light + ter_str_id( "t_pit_covered" ), ter_str_id( "t_grave_new" ), ter_str_id( "t_grave" ), ter_str_id( "t_pit" ), + ter_str_id( "t_pit_shallow" ), ter_str_id( "t_pit_corpsed" ), ter_str_id( "t_pit_spiked" ), + ter_str_id( "t_pit_spiked_covered" ), ter_str_id( "t_pit_glass" ), ter_str_id( "t_pit_glass" ), ter_str_id( "t_utility_light" ) }; void remove_radio_mod( item &it, player &p ) { - if( !it.has_flag( flag_RADIO_MOD ) ) { + if( !it.has_flag( "RADIO_MOD" ) ) { return; } p.add_msg_if_player( _( "You remove the radio modification from your %s!" ), it.tname() ); @@ -179,7 +179,7 @@ void remove_radio_mod( item &it, player &p ) static bool check_litcig( player &u ) { auto cigs = u.items_with( []( const item & it ) { - return it.active && it.has_flag( flag_LITCIG ); + return it.active && it.has_flag( "LITCIG" ); } ); if( cigs.empty() ) { return true; @@ -463,7 +463,7 @@ int iuse::fungicide( player *p, item *it, bool, const tripoint & ) if( monster *const mon_ptr = g->critter_at( dest ) ) { monster &critter = *mon_ptr; if( g->u.sees( dest ) && - !critter.type->in_species( species_FUNGUS ) ) { + !critter.type->in_species( FUNGUS ) ) { add_msg( m_warning, _( "The %s is covered in tiny spores!" ), critter.name() ); } @@ -674,7 +674,7 @@ int iuse::poison( player *p, item *it, bool, const tripoint & ) // NPCs have a magical sense of what is inedible // Players can abuse the crafting menu instead... - if( !it->has_flag( flag_HIDDEN_POISON ) && + if( !it->has_flag( "HIDDEN_POISON" ) && ( p->is_npc() || !p->query_yn( _( "Are you sure you want to eat this? It looks poisonous…" ) ) ) ) { return 0; @@ -1462,7 +1462,7 @@ int iuse::radio_mod( player *p, item *, bool, const tripoint & ) } auto filter = []( const item & itm ) { - return itm.has_flag( flag_RADIO_MODABLE ); + return itm.has_flag( "RADIO_MODABLE" ); }; // note: if !p->is_npc() then p is avatar @@ -1498,7 +1498,7 @@ int iuse::radio_mod( player *p, item *, bool, const tripoint & ) return 0; } - if( modded.has_flag( flag_RADIO_MOD ) && modded.has_flag( newtag ) ) { + if( modded.has_flag( "RADIO_MOD" ) && modded.has_flag( newtag ) ) { p->add_msg_if_player( _( "This item has been modified this way already." ) ); return 0; } @@ -1855,7 +1855,7 @@ int iuse::pack_cbm( player *p, item *it, bool, const tripoint & ) const int success = p->get_skill_level( skill_firstaid ) - rng( 0, 6 ); if( success > 0 ) { p->add_msg_if_player( m_good, _( "You carefully prepare the CBM for sterilization." ) ); - bionic.get_item()->unset_flag( flag_NO_PACKED ); + bionic.get_item()->unset_flag( "NO_PACKED" ); } else { p->add_msg_if_player( m_bad, _( "You fail to properly prepare the CBM." ) ); } @@ -2326,7 +2326,7 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos ) // The iexamine function for crate supplies a hammer object. // So this stops the player (A)ctivating a Hammer with a Crowbar in their backpack // then managing to open a door. - const int pry_level = it->get_quality( quality_PRY ); + const int pry_level = it->get_quality( quality_id( "PRY" ) ); if( pry_level < pry_quality ) { p->add_msg_if_player( _( "You can't get sufficient leverage to open that with your %s." ), @@ -2520,7 +2520,7 @@ static digging_moves_and_byproducts dig_pit_moves_and_byproducts( player *p, ite constexpr double baseline_dig_quality = 3; // Get the dig quality of the tool. - const int quality = it->get_quality( quality_DIG ); + const int quality = it->get_quality( qual_DIG ); // Dig quality affects the dig rate linearly relative to baseline dig quality const double tool_dig_rate = dig_rate_kg_min * quality / baseline_dig_quality; @@ -2578,7 +2578,7 @@ int iuse::dig( player *p, item *it, bool t, const tripoint & ) const bool can_deepen = g->m.has_flag( flag_DIGGABLE_CAN_DEEPEN, dig_point ); const bool grave = g->m.ter( dig_point ) == t_grave; - if( !p->crafting_inventory().has_quality( quality_DIG, 2 ) ) { + if( !p->crafting_inventory().has_quality( qual_DIG, 2 ) ) { if( can_deepen ) { p->add_msg_if_player( _( "You can't deepen this pit without a proper shovel." ) ); return 0; @@ -3448,7 +3448,7 @@ int iuse::granade_act( player *p, item *it, bool t, const tripoint &pos ) explosion_handler::draw_explosion( pos, explosion_radius, c_light_cyan ); for( const tripoint &dest : g->m.points_in_radius( pos, explosion_radius ) ) { monster *const mon = g->critter_at( dest, true ); - if( mon && ( mon->type->in_species( species_INSECT ) || mon->is_hallucination() ) ) { + if( mon && ( mon->type->in_species( INSECT ) || mon->is_hallucination() ) ) { mon->die_in_explosion( nullptr ); } } @@ -3786,7 +3786,7 @@ int iuse::pheromone( player *p, item *it, bool, const tripoint &pos ) continue; } monster &critter = *mon_ptr; - if( critter.type->in_species( species_ZOMBIE ) && critter.friendly == 0 && + if( critter.type->in_species( ZOMBIE ) && critter.friendly == 0 && rng( 0, 500 ) > critter.get_hp() ) { converts++; critter.anger = 0; @@ -4611,7 +4611,7 @@ int iuse::lumber( player *p, item *it, bool t, const tripoint & ) static int chop_moves( player *p, item *it ) { // quality of tool - const int quality = it->get_quality( quality_AXE ); + const int quality = it->get_quality( qual_AXE ); // attribute; regular tools - based on STR, powered tools - based on DEX const int attr = it->has_flag( flag_POWERED ) ? p->dex_cur : p->str_cur; @@ -5591,7 +5591,7 @@ int iuse::unfold_generic( player *p, item *it, bool, const tripoint & ) g->m.destroy_vehicle( veh ); return 0; } - const bool can_float = size( veh->get_avail_parts( flag_FLOATS ) ) > 2; + const bool can_float = size( veh->get_avail_parts( "FLOATS" ) ) > 2; const auto invalid_pos = []( const tripoint & pp, bool can_float ) { return ( g->m.has_flag_ter( TFLAG_DEEP_WATER, pp ) && !can_float ) || @@ -5946,7 +5946,7 @@ int iuse::seed( player *p, item *it, bool, const tripoint & ) bool iuse::robotcontrol_can_target( player *p, const monster &m ) { return !m.is_dead() - && m.type->in_species( species_ROBOT ) + && m.type->in_species( ROBOT ) && m.friendly == 0 && rl_dist( p->pos(), m.pos() ) <= 10; } @@ -6027,7 +6027,7 @@ int iuse::robotcontrol( player *p, item *it, bool, const tripoint & ) p->moves -= to_moves( 1_seconds ); int f = 0; //flag to check if you have robotic allies for( monster &critter : g->all_monsters() ) { - if( critter.friendly != 0 && critter.type->in_species( species_ROBOT ) ) { + if( critter.friendly != 0 && critter.type->in_species( ROBOT ) ) { p->add_msg_if_player( _( "A following %s goes into passive mode." ), critter.name() ); critter.add_effect( effect_docile, 1_turns, num_bp, true ); @@ -7097,7 +7097,7 @@ static extended_photo_def photo_def_for_camera_point( const tripoint &aim_point, creature = guy; player_vec.push_back( guy ); } else { - if( mon->is_hallucination() || mon->type->in_species( species_HALLUCINATION ) ) { + if( mon->is_hallucination() || mon->type->in_species( HALLUCINATION ) ) { continue; // do not include hallucinations } pose = _( "stands" ); @@ -7506,7 +7506,7 @@ int iuse::camera( player *p, item *it, bool, const tripoint & ) // shoot past small monsters and hallucinations if( trajectory_point != aim_point && ( z.type->size <= MS_SMALL || z.is_hallucination() || - z.type->in_species( species_HALLUCINATION ) ) ) { + z.type->in_species( HALLUCINATION ) ) ) { continue; } if( !aim_bounds.is_point_inside( trajectory_point ) ) { @@ -7518,7 +7518,7 @@ int iuse::camera( player *p, item *it, bool, const tripoint & ) } // get an special message if the target is a hallucination if( trajectory_point == aim_point && ( z.is_hallucination() || - z.type->in_species( species_HALLUCINATION ) ) ) { + z.type->in_species( HALLUCINATION ) ) ) { p->add_msg_if_player( _( "Strange… there's nothing in the center of picture?" ) ); } } else if( guy ) { @@ -8068,7 +8068,7 @@ static bool hackveh( player &p, item &it, vehicle &veh ) if( !veh.is_locked || !veh.has_security_working() ) { return true; } - const bool advanced = !empty( veh.get_avail_parts( flag_REMOTE_CONTROLS ) ); + const bool advanced = !empty( veh.get_avail_parts( "REMOTE_CONTROLS" ) ); if( advanced && veh.is_alarm_on ) { p.add_msg_if_player( m_bad, _( "This vehicle's security system has locked you out!" ) ); return false; @@ -8130,7 +8130,7 @@ static vehicle *pickveh( const tripoint ¢er, bool advanced ) for( auto &veh : g->m.get_vehicles() ) { auto &v = veh.v; if( rl_dist( center, v->global_pos3() ) < 40 && - v->fuel_left( fuel_type_battery, true ) > 0 && + v->fuel_left( "battery", true ) > 0 && ( !empty( v->get_avail_parts( advctrl ) ) || ( !advanced && !empty( v->get_avail_parts( ctrl ) ) ) ) ) { vehs.push_back( v ); @@ -8171,7 +8171,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos ) } else if( remote == nullptr ) { p->add_msg_if_player( _( "Lost contact with the vehicle." ) ); stop = true; - } else if( remote->fuel_left( fuel_type_battery, true ) == 0 ) { + } else if( remote->fuel_left( "battery", true ) == 0 ) { p->add_msg_if_player( m_bad, _( "The vehicle's battery died." ) ); stop = true; } @@ -8225,7 +8225,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos ) } } } else if( choice == 1 ) { - const auto rctrl_parts = veh->get_avail_parts( flag_REMOTE_CONTROLS ); + const auto rctrl_parts = veh->get_avail_parts( "REMOTE_CONTROLS" ); // Revert to original behaviour if we can't find remote controls. if( empty( rctrl_parts ) ) { veh->use_controls( pos ); @@ -8309,7 +8309,7 @@ int iuse::autoclave( player *p, item *it, bool t, const tripoint &pos ) it->erase_var( "CYCLETIME" ); for( item &bio : it->contents ) { if( bio.is_bionic() && !bio.has_flag( flag_NO_PACKED ) ) { - bio.unset_flag( flag_NO_STERILE ); + bio.unset_flag( "NO_STERILE" ); } } } else { @@ -8644,9 +8644,9 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) has_tools = false; } - if( !cinv.has_quality( quality_SCREW_FINE ) ) { + if( !cinv.has_quality( qual_SCREW_FINE ) ) { p->add_msg_if_player( m_warning, _( "You need an item with %s of 1 or more to disassemble this." ), - quality_SCREW_FINE.obj().name ); + qual_SCREW_FINE.obj().name ); has_tools = false; } @@ -9319,7 +9319,7 @@ int iuse::wash_items( player *p, bool soft_items, bool hard_items ) crafting_inv.charges_of( "detergent" ) ); const inventory_filter_preset preset( [soft_items, hard_items]( const item_location & location ) { - return location->has_flag( flag_FILTHY ) && ( ( soft_items && location->is_soft() ) || + return location->has_flag( "FILTHY" ) && ( ( soft_items && location->is_soft() ) || ( hard_items && !location->is_soft() ) ); } ); auto make_raw_stats = [available_water, available_cleanser]( diff --git a/src/iuse.h b/src/iuse.h index d53f18e96f4d8..8758cdfe881c6 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -6,7 +6,6 @@ #include #include -#include "type_id.h" #include "clone_ptr.h" #include "units.h" @@ -18,6 +17,7 @@ class monster; template class ret_val; struct iteminfo; +using itype_id = std::string; struct tripoint; // iuse methods returning a bool indicating whether to consume a charge of the item being used. @@ -297,7 +297,7 @@ class iuse_actor /** * Finalizes the actor. Must be called after all items are loaded. */ - virtual void finalize( const itype_id & ) { } + virtual void finalize( const itype_id &/*my_item_type*/ ) { } }; struct use_function { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index d1b6c1142c9a1..aa816181127b4 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -145,7 +145,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons } const bool possess = p.has_item( it ) || - ( it.has_flag( flag_ALLOWS_REMOTE_USE ) && square_dist( p.pos(), pos ) == 1 ); + ( it.has_flag( "ALLOWS_REMOTE_USE" ) && square_dist( p.pos(), pos ) == 1 ); if( possess && need_worn && !p.is_worn( it ) ) { p.add_msg_if_player( m_info, _( "You need to wear the %1$s before activating it." ), it.tname() ); @@ -269,7 +269,7 @@ void iuse_transform::finalize( const itype_id & ) void iuse_transform::info( const item &it, std::vector &dump ) const { item dummy( target, calendar::turn, std::max( ammo_qty, 1 ) ); - if( it.has_flag( flag_FIT ) ) { + if( it.has_flag( "FIT" ) ) { dummy.item_tags.insert( "FIT" ); } dump.emplace_back( "TOOL", string_format( _( "Turns into: %s" ), @@ -812,7 +812,7 @@ int place_monster_iuse::use( player &p, item &it, bool, const tripoint & ) const newmon.friendly = -1; } // TODO: add a flag instead of monster id or something? - if( newmon.type->id == mon_laserturret && !g->is_in_sunlight( newmon.pos() ) ) { + if( newmon.type->id == mtype_id( "mon_laserturret" ) && !g->is_in_sunlight( newmon.pos() ) ) { p.add_msg_if_player( _( "A flashing LED on the laser turret appears to indicate low light." ) ); } return 1; @@ -1056,21 +1056,21 @@ void deploy_furn_actor::info( const item &, std::vector &dump ) const if( the_furn.workbench.has_value() ) { can_function_as.emplace_back( _( "a crafting station" ) ); } - if( the_furn.has_flag( flag_BUTCHER_EQ ) ) { + if( the_furn.has_flag( "BUTCHER_EQ" ) ) { can_function_as.emplace_back( _( "a place to hang corpses for butchering" ) ); } - if( the_furn.has_flag( flag_FLAT_SURF ) ) { + if( the_furn.has_flag( "FLAT_SURF" ) ) { can_function_as.emplace_back( _( "a flat surface to butcher onto or eat meals from" ) ); } - if( the_furn.has_flag( flag_CAN_SIT ) ) { + if( the_furn.has_flag( "CAN_SIT" ) ) { can_function_as.emplace_back( _( "a place to sit" ) ); } - if( the_furn.has_flag( flag_HIDE_PLACE ) ) { + if( the_furn.has_flag( "HIDE_PLACE" ) ) { can_function_as.emplace_back( _( "a place to hide" ) ); } - if( the_furn.has_flag( flag_FIRE_CONTAINER ) ) { + if( the_furn.has_flag( "FIRE_CONTAINER" ) ) { can_function_as.emplace_back( _( "a safe place to contain a fire" ) ); } if( the_furn.crafting_pseudo_item == "char_smoker" ) { @@ -1864,8 +1864,8 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const for( auto &it : items ) { const auto mt = it.get_mtype(); - if( it.is_corpse() && mt->in_species( species_ZOMBIE ) && mt->made_of( material_flesh ) && - mt->in_species( species_HUMAN ) && it.active && !it.has_var( "zlave" ) ) { + if( it.is_corpse() && mt->in_species( ZOMBIE ) && mt->made_of( material_id( "flesh" ) ) && + mt->in_species( HUMAN ) && it.active && !it.has_var( "zlave" ) ) { corpses.push_back( &it ); } } @@ -1878,9 +1878,9 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const int tolerance_level = 9; if( p.has_trait( trait_PSYCHOPATH ) || p.has_trait( trait_SAPIOVORE ) ) { tolerance_level = 0; - } else if( p.has_trait_flag( flag_PRED4 ) ) { + } else if( p.has_trait_flag( "PRED4" ) ) { tolerance_level = 5; - } else if( p.has_trait_flag( flag_PRED3 ) ) { + } else if( p.has_trait_flag( "PRED3" ) ) { tolerance_level = 7; } @@ -1924,9 +1924,9 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const if( p.has_trait( trait_PACIFIST ) ) { moraleMalus *= 5; maxMalus *= 3; - } else if( p.has_trait_flag( flag_PRED1 ) ) { + } else if( p.has_trait_flag( "PRED1" ) ) { moraleMalus /= 4; - } else if( p.has_trait_flag( flag_PRED2 ) ) { + } else if( p.has_trait_flag( "PRED2" ) ) { moraleMalus /= 5; } @@ -2448,7 +2448,7 @@ int cast_spell_actor::use( player &p, item &it, bool, const tripoint & ) const cast_spell.values.emplace_back( 0 ); } cast_spell.name = casting.id().c_str(); - if( it.has_flag( flag_USE_PLAYER_ENERGY ) ) { + if( it.has_flag( "USE_PLAYER_ENERGY" ) ) { // [2] this value overrides the mana cost if set to 0 cast_spell.values.emplace_back( 1 ); charges = 0; @@ -3107,7 +3107,7 @@ bool repair_item_actor::can_repair_target( player &pl, const item &fix, } return false; } - if( fix.count_by_charges() || fix.has_flag( flag_NO_REPAIR ) ) { + if( fix.count_by_charges() || fix.has_flag( "NO_REPAIR" ) ) { if( print_msg ) { pl.add_msg_if_player( m_info, _( "You cannot repair this type of item." ) ); } @@ -3128,14 +3128,14 @@ bool repair_item_actor::can_repair_target( player &pl, const item &fix, return false; } - const bool can_be_refitted = fix.has_flag( flag_VARSIZE ); - if( can_be_refitted && !fix.has_flag( flag_FIT ) ) { + const bool can_be_refitted = fix.has_flag( "VARSIZE" ); + if( can_be_refitted && !fix.has_flag( "FIT" ) ) { return true; } const bool resizing_matters = fix.get_encumber( pl ) != 0; const bool small = pl.has_trait( trait_SMALL2 ) || pl.has_trait( trait_SMALL_OK ); - const bool can_resize = small != fix.has_flag( flag_UNDERSIZE ); + const bool can_resize = small != fix.has_flag( "UNDERSIZE" ); if( can_be_refitted && resizing_matters && can_resize ) { return true; } @@ -3152,7 +3152,7 @@ bool repair_item_actor::can_repair_target( player &pl, const item &fix, return false; } - if( fix.has_flag( flag_PRIMITIVE_RANGED_WEAPON ) || !fix.reinforceable() ) { + if( fix.has_flag( "PRIMITIVE_RANGED_WEAPON" ) || !fix.reinforceable() ) { if( print_msg ) { pl.add_msg_if_player( m_info, _( "You cannot improve your %s any more this way." ), fix.tname() ); @@ -3343,7 +3343,7 @@ repair_item_actor::attempt_hint repair_item_actor::repair( player &pl, item &too if( action == RT_REFIT ) { if( roll == SUCCESS ) { - if( !fix->has_flag( flag_FIT ) ) { + if( !fix->has_flag( "FIT" ) ) { pl.add_msg_if_player( m_good, _( "You take your %s in, improving the fit." ), fix->tname() ); fix->item_tags.insert( "FIT" ); @@ -3380,7 +3380,7 @@ repair_item_actor::attempt_hint repair_item_actor::repair( player &pl, item &too } if( action == RT_REINFORCE ) { - if( fix->has_flag( flag_PRIMITIVE_RANGED_WEAPON ) || !fix->reinforceable() ) { + if( fix->has_flag( "PRIMITIVE_RANGED_WEAPON" ) || !fix->reinforceable() ) { pl.add_msg_if_player( m_info, _( "You cannot improve your %s any more this way." ), fix->tname() ); return AS_CANT; @@ -4004,8 +4004,8 @@ int place_trap_actor::use( player &p, item &it, bool, const tripoint & ) const } } - const bool has_shovel = p.has_quality( quality_DIG, 3 ); - const bool is_diggable = g->m.has_flag( flag_DIGGABLE, pos ); + const bool has_shovel = p.has_quality( quality_id( "DIG" ), 3 ); + const bool is_diggable = g->m.has_flag( "DIGGABLE", pos ); bool bury = false; if( could_bury && has_shovel && is_diggable ) { bury = query_yn( _( bury_question ) ); @@ -4144,9 +4144,9 @@ ret_val install_bionic_actor::can_use( const Character &p, const item &it, !p.has_trait( trait_DEBUG_BIONICS ) ) { return ret_val::make_failure( _( "You can't self-install bionics." ) ); } else if( !p.has_trait( trait_DEBUG_BIONICS ) ) { - if( it.has_flag( flag_FILTHY ) ) { + if( it.has_flag( "FILTHY" ) ) { return ret_val::make_failure( _( "You can't install a filthy CBM!" ) ); - } else if( it.has_flag( flag_NO_STERILE ) ) { + } else if( it.has_flag( "NO_STERILE" ) ) { return ret_val::make_failure( _( "This CBM is not sterile, you can't install it." ) ); } else if( it.has_fault( fault_bionic_salvaged ) ) { return ret_val::make_failure( @@ -4422,7 +4422,7 @@ int deploy_tent_actor::use( player &p, item &it, bool, const tripoint & ) const add_msg( m_info, _( "The %s is in the way." ), c->disp_name() ); return 0; } - if( g->m.impassable( dest ) || !g->m.has_flag( flag_FLAT, dest ) ) { + if( g->m.impassable( dest ) || !g->m.has_flag( "FLAT", dest ) ) { add_msg( m_info, _( "The %s in that direction isn't suitable for placing the %s." ), g->m.name( dest ), it.tname() ); return 0; diff --git a/src/iuse_actor.h b/src/iuse_actor.h index 0cc1c1fff1d96..a2b80e28091cd 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -22,7 +22,6 @@ class npc_template; #include "type_id.h" #include "units.h" #include "optional.h" -#include "cata_string_consts.h" class Character; class item; @@ -34,6 +33,7 @@ enum hp_part : int; enum body_part : int; class JsonObject; +using itype_id = std::string; struct furn_t; struct itype; class item_location; @@ -502,23 +502,23 @@ class salvage_actor : public iuse_actor /** Materials it can cut */ std::set material_whitelist = { - material_acidchitin, - material_alien_resin, - material_bone, - material_chitin, - material_cotton, - material_faux_fur, - material_fur, - material_kevlar, - material_kevlar_rigid, - material_leather, - material_lycra, - material_neoprene, - material_nomex, - material_nylon, - material_plastic, - material_wood, - material_wool + material_id( "acidchitin" ), + material_id( "alien_resin" ), + material_id( "bone" ), + material_id( "chitin" ), + material_id( "cotton" ), + material_id( "faux_fur" ), + material_id( "fur" ), + material_id( "kevlar" ), + material_id( "kevlar_rigid" ), + material_id( "leather" ), + material_id( "lycra" ), + material_id( "neoprene" ), + material_id( "nomex" ), + material_id( "nylon" ), + material_id( "plastic" ), + material_id( "wood" ), + material_id( "wool" ) }; bool try_to_cut_up( player &p, item &it ) const; @@ -549,14 +549,14 @@ class inscribe_actor : public iuse_actor // Materials it can write on std::set material_whitelist = { - material_wood, - material_plastic, - material_glass, - material_chitin, - material_iron, - material_steel, - material_silver, - material_bone + material_id( "wood" ), + material_id( "plastic" ), + material_id( "glass" ), + material_id( "chitin" ), + material_id( "iron" ), + material_id( "steel" ), + material_id( "silver" ), + material_id( "bone" ) }; // How will the inscription be described diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 01b5668cb8b79..d1c758ee44057 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -458,7 +458,7 @@ void map::generate_lightmap( const int zlev ) if( !inbounds( pp ) ) { continue; } - if( vp.has_feature( VPFLAG_CARGO ) && !vp.has_feature( flag_COVERED ) ) { + if( vp.has_feature( VPFLAG_CARGO ) && !vp.has_feature( "COVERED" ) ) { add_light_from_items( pp, v->get_items( static_cast( p ) ).begin(), v->get_items( static_cast( p ) ).end() ); } @@ -1188,10 +1188,10 @@ void map::build_seen_cache( const tripoint &origin, const int target_z ) const tripoint mirror_pos = vp.pos(); // We can utilize the current state of the seen cache to determine // if the player can see the mirror from their position. - if( !vp.info().has_flag( flag_CAMERA ) && + if( !vp.info().has_flag( "CAMERA" ) && seen_cache[mirror_pos.x][mirror_pos.y] < LIGHT_TRANSPARENCY_SOLID + 0.1 ) { continue; - } else if( !vp.info().has_flag( flag_CAMERA_CONTROL ) ) { + } else if( !vp.info().has_flag( "CAMERA_CONTROL" ) ) { mirrors.emplace_back( static_cast( vp.part_index() ) ); } else { if( square_dist( origin, mirror_pos ) <= 1 && veh->camera_on ) { @@ -1201,7 +1201,7 @@ void map::build_seen_cache( const tripoint &origin, const int target_z ) } for( int mirror : mirrors ) { - bool is_camera = veh->part_info( mirror ).has_flag( flag_CAMERA ); + bool is_camera = veh->part_info( mirror ).has_flag( "CAMERA" ); if( is_camera && cam_control < 0 ) { continue; // Player not at camera control, so cameras don't work } diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 2f4de55b4efe7..f31dd3a640b85 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -44,7 +44,6 @@ #include "translations.h" #include "timed_event.h" #include "teleport.h" -#include "cata_string_consts.h" namespace spell_detail { @@ -663,13 +662,13 @@ void spell_effect::spawn_ethereal_item( const spell &sp, Creature &caster, const item granted( sp.effect_data(), calendar::turn ); if( !granted.is_comestible() && !( sp.has_flag( spell_flag::PERMANENT ) && sp.is_max_level() ) ) { granted.set_var( "ethereal", to_turns( sp.duration_turns() ) ); - granted.set_flag( flag_ETHEREAL_ITEM ); + granted.set_flag( "ETHEREAL_ITEM" ); } if( granted.count_by_charges() && sp.damage() > 0 ) { granted.charges = sp.damage(); } if( g->u.can_wear( granted ).success() ) { - granted.set_flag( flag_FIT ); + granted.set_flag( "FIT" ); g->u.wear_item( granted, false ); } else if( !g->u.is_armed() ) { g->u.weapon = granted; diff --git a/src/magic_teleporter_list.cpp b/src/magic_teleporter_list.cpp index a528b6b25a5f3..4f9499c4fcfc1 100644 --- a/src/magic_teleporter_list.cpp +++ b/src/magic_teleporter_list.cpp @@ -23,7 +23,6 @@ #include "color.h" #include "string_formatter.h" #include "translations.h" -#include "cata_string_consts.h" static bool popup_string( std::string &result, std::string &title ) { @@ -62,7 +61,7 @@ static cata::optional find_valid_teleporters_omt( const tripoint &omt_ tinymap checker; checker.load( sm_pt, true ); for( const tripoint &p : checker.points_on_zlevel() ) { - if( checker.has_flag_furn( flag_TRANSLOCATOR, p ) ) { + if( checker.has_flag_furn( "TRANSLOCATOR", p ) ) { return checker.getabs( p ); } } diff --git a/src/map.cpp b/src/map.cpp index b44be3402d31f..bc3cf7d1dfe4e 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -83,7 +83,13 @@ #include "string_id.h" #include "construction.h" #include "flat_set.h" -#include "cata_string_consts.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" ); #define dbg(x) DebugLog((x),D_MAP) << __FILE__ << ":" << __LINE__ << ": " @@ -622,7 +628,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac } veh.handle_trap( wheel_p, w ); - if( !has_flag( flag_SEALED, wheel_p ) ) { + if( !has_flag( "SEALED", wheel_p ) ) { const float wheel_area = veh.parts[ w ].wheel_area(); // Damage is calculated based on the weight of the vehicle, @@ -849,7 +855,7 @@ void map::register_vehicle_zone( vehicle *veh, const int zlev ) bool map::deregister_vehicle_zone( zone_data &zone ) { if( const cata::optional vp = veh_at( getlocal( - zone.get_start_point() ) ).part_with_feature( flag_CARGO, false ) ) { + zone.get_start_point() ) ).part_with_feature( "CARGO", false ) ) { auto bounds = vp->vehicle().loot_zones.equal_range( vp->mount() ); for( auto it = bounds.first; it != bounds.second; it++ ) { if( &zone == &( it->second ) ) { @@ -1152,7 +1158,7 @@ bool map::displace_vehicle( vehicle &veh, const tripoint &dp ) bool map::displace_water( const tripoint &p ) { // Check for shallow water - if( has_flag( flag_SWIMMABLE, p ) && !has_flag( TFLAG_DEEP_WATER, p ) ) { + if( has_flag( "SWIMMABLE", p ) && !has_flag( TFLAG_DEEP_WATER, p ) ) { int dis_places = 0; int sel_place = 0; for( int pass = 0; pass < 2; pass++ ) { @@ -1262,7 +1268,7 @@ void map::furn_set( const tripoint &p, const furn_id &new_furniture ) c->remove_effect( effect_crushed ); } } - if( new_t.has_flag( flag_EMITTER ) ) { + if( new_t.has_flag( "EMITTER" ) ) { field_furn_locs.push_back( p ); } if( old_t.transparent != new_t.transparent ) { @@ -1315,7 +1321,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( flag_PLANT ) ) { + if( f.has_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 ) { @@ -1558,14 +1564,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( 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." ) ); + 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." ) ); return result; } @@ -1802,7 +1808,7 @@ int map::climb_difficulty( const tripoint &p ) const int best_difficulty = INT_MAX; int blocks_movement = 0; - if( has_flag( flag_LADDER, p ) ) { + if( has_flag( "LADDER", p ) ) { // Really easy, but you have to stand on the tile return 1; } else if( has_flag( TFLAG_RAMP, p ) ) { @@ -1821,7 +1827,7 @@ int map::climb_difficulty( const tripoint &p ) const best_difficulty = std::min( best_difficulty, 7 ); } - if( best_difficulty > 5 && has_flag( flag_CLIMBABLE, pt ) ) { + if( best_difficulty > 5 && has_flag( "CLIMBABLE", pt ) ) { best_difficulty = 5; } } @@ -1914,7 +1920,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( flag_TINY ) && !frn.has_flag( flag_NOCOLLIDE ) ) { + if( !frn.has_flag( "TINY" ) && !frn.has_flag( "NOCOLLIDE" ) ) { return SS_BAD_SUPPORT; } } @@ -1961,13 +1967,13 @@ void map::drop_furniture( const tripoint &p ) // Approximate weight/"bulkiness" based on strength to drag int weight; - if( frn_obj.has_flag( flag_TINY ) || frn_obj.has_flag( flag_NOCOLLIDE ) ) { + if( frn_obj.has_flag( "TINY" ) || frn_obj.has_flag( "NOCOLLIDE" ) ) { weight = 5; } else { weight = frn_obj.is_movable() ? frn_obj.move_str_req : 20; } - if( frn_obj.has_flag( flag_ROUGH ) || frn_obj.has_flag( flag_SHARP ) ) { + if( frn_obj.has_flag( "ROUGH" ) || frn_obj.has_flag( "SHARP" ) ) { weight += 5; } @@ -2117,12 +2123,12 @@ bool map::can_put_items( const tripoint &p ) const return true; } const optional_vpart_position vp = veh_at( p ); - return static_cast( vp.part_with_feature( flag_CARGO, true ) ); + return static_cast( vp.part_with_feature( "CARGO", true ) ); } bool map::can_put_items_ter_furn( const tripoint &p ) const { - return !has_flag( flag_NOITEM, p ) && !has_flag( flag_SEALED, p ); + return !has_flag( "NOITEM", p ) && !has_flag( "SEALED", p ); } bool map::has_flag_ter( const std::string &flag, const tripoint &p ) const @@ -2368,12 +2374,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( flag_CURRENT, p ) && !has_flag( TFLAG_DEEP_WATER, p ); + return has_flag( "CURRENT", p ) && !has_flag( TFLAG_DEEP_WATER, p ); } bool map::is_divable( const tripoint &p ) const { - return has_flag( flag_SWIMMABLE, p ) && has_flag( TFLAG_DEEP_WATER, p ); + return has_flag( "SWIMMABLE", p ) && has_flag( TFLAG_DEEP_WATER, p ); } bool map::is_outside( const tripoint &p ) const @@ -2418,9 +2424,9 @@ bool map::is_last_ter_wall( const bool no_furn, const point &p, if( no_furn && has_furn( point( x2, y2 ) ) ) { loop = false; result = false; - } else if( !has_flag_ter( flag_FLAT, point( x2, y2 ) ) ) { + } else if( !has_flag_ter( "FLAT", point( x2, y2 ) ) ) { loop = false; - if( !has_flag_ter( flag_WALL, point( x2, y2 ) ) ) { + if( !has_flag_ter( "WALL", point( x2, y2 ) ) ) { result = false; } } @@ -2433,7 +2439,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( flag_TINDER ) ) { + if( i.has_flag( "TINDER" ) ) { return true; } } @@ -2463,11 +2469,11 @@ bool map::is_flammable( const tripoint &p ) return true; } - if( has_flag( flag_FLAMMABLE, p ) ) { + if( has_flag( "FLAMMABLE", p ) ) { return true; } - if( has_flag( flag_FLAMMABLE_ASH, p ) ) { + if( has_flag( "FLAMMABLE_ASH", p ) ) { return true; } @@ -2574,7 +2580,7 @@ bool map::has_nearby_fire( const tripoint &p, int radius ) if( get_field( pt, fd_fire ) != nullptr ) { return true; } - if( has_flag_ter_or_furn( flag_USABLE_FIRE, p ) ) { + if( has_flag_ter_or_furn( "USABLE_FIRE", p ) ) { return true; } } @@ -2585,10 +2591,10 @@ 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( flag_FLAT_SURF, pt ) ) { + if( has_flag( "FLAT_SURF", pt ) ) { return true; } - if( vp && ( vp->vehicle().has_part( flag_KITCHEN ) || vp->vehicle().has_part( flag_FLAT_SURF ) ) ) { + if( vp && ( vp->vehicle().has_part( "KITCHEN" ) || vp->vehicle().has_part( "FLAT_SURF" ) ) ) { return true; } } @@ -2599,10 +2605,10 @@ 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( flag_CAN_SIT, pt ) ) { + if( has_flag( "CAN_SIT", pt ) ) { return true; } - if( vp && vp->vehicle().has_part( flag_SEAT ) ) { + if( vp && vp->vehicle().has_part( "SEAT" ) ) { return true; } } @@ -2613,7 +2619,7 @@ bool map::mop_spills( const tripoint &p ) { bool retval = false; - if( !has_flag( flag_LIQUIDCONT, p ) ) { + if( !has_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 ); @@ -2666,14 +2672,17 @@ bool map::mop_spills( const tripoint &p ) int map::collapse_check( const tripoint &p ) { + const bool collapses = has_flag( "COLLAPSES", p ); + const bool supports_roof = has_flag( "SUPPORTS_ROOF", p ); + 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( flag_SUPPORTS_ROOF, pbelow ) ) { + if( has_flag( "SUPPORTS_ROOF", pbelow ) ) { num_supports += 1; - if( has_flag( flag_WALL, pbelow ) ) { + if( has_flag( "WALL", pbelow ) ) { num_supports = 2; } if( tbelow == pbelow ) { @@ -2688,17 +2697,17 @@ int map::collapse_check( const tripoint &p ) continue; } - if( has_flag( flag_COLLAPSES, p ) ) { - if( has_flag( flag_COLLAPSES, t ) ) { + if( collapses ) { + if( has_flag( "COLLAPSES", t ) ) { num_supports++; - } else if( has_flag( flag_SUPPORTS_ROOF, t ) ) { + } else if( has_flag( "SUPPORTS_ROOF", t ) ) { num_supports += 2; } - } else if( has_flag( flag_SUPPORTS_ROOF, p ) ) { - if( has_flag( flag_SUPPORTS_ROOF, t ) ) { - if( has_flag( flag_WALL, t ) ) { + } else if( supports_roof ) { + if( has_flag( "SUPPORTS_ROOF", t ) ) { + if( has_flag( "WALL", t ) ) { num_supports += 4; - } else if( !has_flag( flag_COLLAPSES, t ) ) { + } else if( !has_flag( "COLLAPSES", t ) ) { num_supports += 3; } } @@ -2713,15 +2722,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( flag_SUPPORTS_ROOF, p ); - const bool wall = was_supporting || has_flag( flag_WALL, p ); + const bool supports = was_supporting || has_flag( "SUPPORTS_ROOF", p ); + const bool wall = was_supporting || has_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( flag_SUPPORTS_ROOF, p ); + const bool still_supports = has_flag( "SUPPORTS_ROOF", p ); // If something supporting the roof collapsed, see what else collapses if( supports && !still_supports ) { @@ -2734,12 +2743,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( flag_WALL, tz ) ) { + if( zlevels && wall && p == t && has_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( flag_SUPPORTS_ROOF, t ) && has_flag( flag_COLLAPSES, t ) ) ) { + if( p != t && ( has_flag( "SUPPORTS_ROOF", t ) && has_flag( "COLLAPSES", t ) ) ) { collapse_at( t, silent ); } // this tile used to support a roof, now it doesn't, which means there is only @@ -2923,7 +2932,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( flag_BLOCKSDOOR ) ) { + m.furn( tripoint( adj_x, adj_y, p.z ) ).obj().has_flag( "BLOCKSDOOR" ) ) { return true; } } @@ -2977,7 +2986,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) } // TODO: what if silent is true? - if( has_flag( flag_ALARMED, p ) && !g->timed_events.queued( TIMED_EVENT_WANTED ) ) { + if( has_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 @@ -3022,7 +3031,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( flag_SUPPORTS_ROOF, below ) ) { + if( !zlevels || has_flag( "SUPPORTS_ROOF", below ) ) { if( bash->str_min_supported != -1 ) { smin = bash->str_min_supported; } @@ -3062,12 +3071,12 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) } // Clear out any partially grown seeds - if( has_flag_ter_or_furn( flag_PLANT, p ) ) { + if( has_flag_ter_or_furn( "PLANT", p ) ) { i_clear( p ); } - if( ( smash_furn && has_flag_furn( flag_FUNGUS, p ) ) || - ( smash_ter && has_flag_ter( flag_FUNGUS, p ) ) ) { + if( ( smash_furn && has_flag_furn( "FUNGUS", p ) ) || + ( smash_ter && has_flag_ter( "FUNGUS", p ) ) ) { fungal_effects( *g, *this ).create_spores( p ); } @@ -3084,8 +3093,7 @@ 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( flag_SUPPORTS_ROOF, p ) && - !has_flag( flag_INDOORS, p ); + const bool will_collapse = smash_ter && has_flag( "SUPPORTS_ROOF", p ) && !has_flag( "INDOORS", p ); const bool tent = smash_furn && !bash->tent_centers.empty(); // Special code to collapse the tent if destroyed @@ -3165,7 +3173,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( flag_SUPPORTS_ROOF ) ) { + if( bash->bash_below && ter_below.has_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; @@ -3194,7 +3202,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( flag_SUPPORTS_ROOF, p ) ) { + if( will_collapse && !has_flag( "SUPPORTS_ROOF", p ) ) { collapse_at( p, params.silent, true, bash->explosive > 0 ); } @@ -3219,7 +3227,7 @@ bash_params map::bash( const tripoint &p, const int str, } bool bashed_sealed = false; - if( has_flag( flag_SEALED, p ) ) { + if( has_flag( "SEALED", p ) ) { bash_ter_furn( p, bsh ); bashed_sealed = true; } @@ -3255,7 +3263,7 @@ void map::bash_items( const tripoint &p, bash_params ¶ms ) bool smashed_glass = false; for( auto bashed_item = bashed_items.begin(); bashed_item != bashed_items.end(); ) { // the check for active suppresses Molotovs smashing themselves with their own explosion - if( bashed_item->made_of( material_glass ) && !bashed_item->active && one_in( 2 ) ) { + if( bashed_item->made_of( material_id( "glass" ) ) && !bashed_item->active && one_in( 2 ) ) { params.did_bash = true; smashed_glass = true; for( const item &bashed_content : bashed_item->contents ) { @@ -3393,7 +3401,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( flag_ALARMED, p ) && !g->timed_events.queued( TIMED_EVENT_WANTED ) ) { + if( has_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 ) ); @@ -3678,7 +3686,7 @@ bool map::hit_with_fire( const tripoint &p ) } // non passable but flammable terrain, set it on fire - if( has_flag( flag_FLAMMABLE, p ) || has_flag( flag_FLAMMABLE_ASH, p ) ) { + if( has_flag( "FLAMMABLE", p ) || has_flag( "FLAMMABLE_ASH", p ) ) { add_field( p, fd_fire, 3 ); } return true; @@ -3689,7 +3697,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( flag_OPENCLOSE_INSIDE, p ) && !inside ) { + if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) { return false; } @@ -3698,8 +3706,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_SCHIZOPHRENIC ) || g->u.has_artifact_with( AEP_SCHIZO ) ) - && one_in( 50 ) && !ter.has_flag( flag_TRANSPARENT ) ) { + if( ( g->u.has_trait( trait_id( "SCHIZOPHRENIC" ) ) || g->u.has_artifact_with( AEP_SCHIZO ) ) + && one_in( 50 ) && !ter.has_flag( "TRANSPARENT" ) ) { tripoint mp = p + -2 * g->u.pos().xy() + tripoint( 2 * p.x, 2 * p.y, p.z ); g->spawn_hallucination( mp ); } @@ -3707,7 +3715,7 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only return true; } else if( furn.open ) { - if( has_flag( flag_OPENCLOSE_INSIDE, p ) && !inside ) { + if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) { return false; } @@ -3780,7 +3788,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( flag_OPENCLOSE_INSIDE, p ) && !inside ) { + if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) { return false; } @@ -3957,8 +3965,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( flag_SWIMMABLE, p ) ) || - has_flag( flag_DESTROY_ITEM, p ) ) { + if( ( new_item.made_of( LIQUID ) && has_flag( "SWIMMABLE", p ) ) || + has_flag( "DESTROY_ITEM", p ) ) { return null_item_reference(); } @@ -3970,10 +3978,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( flag_DESTROY_ITEM, p ) ) { + if( !inbounds( p ) || has_flag( "DESTROY_ITEM", p ) ) { return ret; } - const bool swimmable = has_flag( flag_SWIMMABLE, p ); + const bool swimmable = has_flag( "SWIMMABLE", p ); for( const item &new_item : new_items ) { if( new_item.made_of( LIQUID ) && swimmable ) { @@ -4015,7 +4023,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( flag_VARSIZE ) ) { + if( one_in( 3 ) && new_item.has_flag( "VARSIZE" ) ) { new_item.item_tags.insert( "FIT" ); } @@ -4049,12 +4057,12 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) } // Some tiles destroy items (e.g. lava) - if( has_flag( flag_DESTROY_ITEM, e ) ) { + if( has_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( flag_SWIMMABLE, e ) ) { + if( obj.made_of_from_type( LIQUID ) && has_flag( "SWIMMABLE", e ) ) { return false; } @@ -4082,7 +4090,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( flag_NO_DROP ) ) { + if( obj.has_flag( "NO_DROP" ) ) { return null_item_reference(); } @@ -4091,11 +4099,10 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow ) return null_item_reference(); } - if( ( !has_flag( flag_NOITEM, pos ) || ( has_flag( flag_LIQUIDCONT, pos ) && - obj.made_of( LIQUID ) ) ) + if( ( !has_flag( "NOITEM", pos ) || ( has_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( flag_DROP_ACTION_ONLY_IF_LIQUID ) ) { + if( obj.made_of( LIQUID ) || !obj.has_flag( "DROP_ACTION_ONLY_IF_LIQUID" ) ) { if( obj.on_drop( pos, *this ) ) { return null_item_reference(); } @@ -4120,14 +4127,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( flag_DROP_ACTION_ONLY_IF_LIQUID ) ) { + if( obj.made_of( LIQUID ) || !obj.has_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( flag_NOITEM, e ) || has_flag( flag_SEALED, e ) ) { + has_flag( "NOITEM", e ) || has_flag( "SEALED", e ) ) { continue; } return place_item( e ); @@ -4152,16 +4159,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( flag_SWIMMABLE, p ) ) { + if( new_item.made_of( LIQUID ) && has_flag( "SWIMMABLE", p ) ) { return null_item_reference(); } - if( has_flag( flag_DESTROY_ITEM, p ) ) { + if( has_flag( "DESTROY_ITEM", p ) ) { return null_item_reference(); } - 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() ) { + if( new_item.has_flag( "ACT_IN_FIRE" ) && get_field( p, fd_fire ) != nullptr ) { + if( new_item.has_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 ); @@ -4189,7 +4196,7 @@ item &map::add_item( const tripoint &p, item new_item ) item map::water_from( const tripoint &p ) { - if( has_flag( flag_SALT_WATER, p ) ) { + if( has_flag( "SALT_WATER", p ) ) { return item( "salt_water", 0, item::INFINITE_CHARGES ); } @@ -4330,7 +4337,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( flag_NO_PACKED ) ) { + if( !n.has_flag( "NO_PACKED" ) ) { n.item_tags.erase( no_sterile ); } autoclave_finished = true; @@ -4347,9 +4354,9 @@ 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( flag_RECHARGE, true ) ) { + cur_veh.has_part( "RECHARGE", true ) ) { for( auto &n : cur_veh.get_items( part ) ) { - if( !n.has_flag( flag_RECHARGE ) && !n.has_flag( flag_USE_UPS ) ) { + if( !n.has_flag( "RECHARGE" ) && !n.has_flag( "USE_UPS" ) ) { continue; } // TODO: BATTERIES this should be rewritten when vehicle power and items both use energy quantities @@ -4363,7 +4370,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part ) if( n.is_battery() ) { n.set_energy( 1_kJ ); } else { - n.ammo_set( fuel_type_battery, n.ammo_remaining() + 1 ); + n.ammo_set( "battery", n.ammo_remaining() + 1 ); } } @@ -4486,7 +4493,7 @@ void map::process_items_in_vehicles( submap ¤t_submap, const int gridz, void map::process_items_in_vehicle( vehicle &cur_veh, submap ¤t_submap, const int /*gridz*/, map::map_process_func processor, const std::string &signal ) { - const bool engine_heater_is_on = cur_veh.has_part( flag_E_HEATER, true ) && cur_veh.engine_on; + const bool engine_heater_is_on = cur_veh.has_part( "E_HEATER", true ) && cur_veh.engine_on; for( const vpart_reference &vp : cur_veh.get_any_parts( VPFLAG_FLUIDTANK ) ) { vp.part().process_contents( vp.pos(), engine_heater_is_on ); } @@ -4635,7 +4642,7 @@ std::list map::use_amount_square( const tripoint &p, const itype_id &type, return ret; } - if( const cata::optional vp = veh_at( p ).part_with_feature( flag_CARGO, true ) ) { + if( const cata::optional vp = veh_at( p ).part_with_feature( "CARGO", true ) ) { std::list tmp = use_amount_stack( vp->vehicle().get_items( vp->part_index() ), type, quantity, filter ); ret.splice( ret.end(), tmp ); @@ -4678,7 +4685,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( flag_LIQUIDCONT, p ) ) { + if( m->has_flag( "LIQUIDCONT", p ) ) { auto item_list = m->i_at( p ); auto current_item = item_list.begin(); for( ; current_item != item_list.end(); ++current_item ) { @@ -4781,13 +4788,13 @@ std::list map::use_charges( const tripoint &origin, const int range, continue; } - const cata::optional kpart = vp.part_with_feature( flag_FAUCET, true ); - const cata::optional weldpart = vp.part_with_feature( flag_WELDRIG, true ); - const cata::optional craftpart = vp.part_with_feature( flag_CRAFTRIG, true ); - const cata::optional forgepart = vp.part_with_feature( flag_FORGE, true ); - const cata::optional kilnpart = vp.part_with_feature( flag_KILN, true ); - const cata::optional chempart = vp.part_with_feature( flag_CHEMLAB, true ); - const cata::optional cargo = vp.part_with_feature( flag_CARGO, true ); + const cata::optional kpart = vp.part_with_feature( "FAUCET", true ); + const cata::optional weldpart = vp.part_with_feature( "WELDRIG", true ); + const cata::optional craftpart = vp.part_with_feature( "CRAFTRIG", true ); + const cata::optional forgepart = vp.part_with_feature( "FORGE", true ); + const cata::optional kilnpart = vp.part_with_feature( "KILN", true ); + const cata::optional chempart = vp.part_with_feature( "CHEMLAB", true ); + const cata::optional cargo = vp.part_with_feature( "CARGO", true ); if( kpart ) { // we have a faucet, now to see what to drain itype_id ftype = "null"; @@ -4941,7 +4948,7 @@ std::list > map::get_rc_items( const tripoint &p ) } auto items = i_at( pos ); for( auto &elem : items ) { - if( elem.has_flag( flag_RADIO_ACTIVATION ) || elem.has_flag( flag_RADIO_CONTAINER ) ) { + if( elem.has_flag( "RADIO_ACTIVATION" ) || elem.has_flag( "RADIO_CONTAINER" ) ) { rc_pairs.push_back( std::make_pair( pos, &elem ) ); } } @@ -6254,7 +6261,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( flag_SEALED, t ) || has_flag( flag_LIQUIDCONT, t ); + return !has_flag( "SEALED", t ) || has_flag( "LIQUIDCONT", t ); } std::vector map::get_dir_circle( const tripoint &f, const tripoint &t ) const @@ -6774,7 +6781,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( flag_PLANT ) ) { + if( !furn.has_flag( "PLANT" ) ) { return; } // Can't use item_stack::only_item() since there might be fertilizer @@ -6792,15 +6799,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( flag_GROWTH_HARVEST ) ) { + !furn.has_flag( "GROWTH_HARVEST" ) ) { if( seed->age() < plantEpoch * 2 ) { - if( has_flag_furn( flag_GROWTH_SEEDLING, p ) ) { + if( has_flag_furn( "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( flag_FERTILIZER ); + return it.has_flag( "FERTILIZER" ); } ); if( fertilizer != items.end() ) { items.erase( fertilizer ); @@ -6809,13 +6816,13 @@ void map::grow_plant( const tripoint &p ) rotten_item_spawn( *seed, p ); furn_set( p, furn_str_id( furn.plant->transform ) ); } else if( seed->age() < plantEpoch * 3 * furn.plant->growth_multiplier ) { - if( has_flag_furn( flag_GROWTH_MATURE, p ) ) { + if( has_flag_furn( "GROWTH_MATURE", p ) ) { return; } // Remove fertilizer if any map_stack::iterator fertilizer = std::find_if( items.begin(), items.end(), []( const item & it ) { - return it.has_flag( flag_FERTILIZER ); + return it.has_flag( "FERTILIZER" ); } ); if( fertilizer != items.end() ) { items.erase( fertilizer ); @@ -6823,17 +6830,17 @@ void map::grow_plant( const tripoint &p ) rotten_item_spawn( *seed, p ); //You've skipped the seedling stage so roll monsters twice - if( !has_flag_furn( flag_GROWTH_SEEDLING, p ) ) { + if( !has_flag_furn( "GROWTH_SEEDLING", p ) ) { rotten_item_spawn( *seed, p ); } furn_set( p, furn_str_id( furn.plant->transform ) ); } else { //You've skipped two stages so roll monsters two times - if( has_flag_furn( flag_GROWTH_SEEDLING, p ) ) { + if( has_flag_furn( "GROWTH_SEEDLING", p ) ) { rotten_item_spawn( *seed, p ); rotten_item_spawn( *seed, p ); //One stage change - } else if( has_flag_furn( flag_GROWTH_MATURE, p ) ) { + } else if( has_flag_furn( "GROWTH_MATURE", p ) ) { rotten_item_spawn( *seed, p ); //Goes from seed to harvest in one check } else { @@ -6974,7 +6981,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( flag_PLANT ) ) { + if( fid.has_flag( "PLANT" ) ) { i_clear( p ); furn_set( p, f_null ); } @@ -6982,13 +6989,13 @@ void map::rad_scorch( const tripoint &p, const time_duration &time_since_last_ac const ter_id tid = ter( p ); // TODO: De-hardcode this static const std::map dies_into {{ - {t_grass, ter_dirt}, - {t_tree_young, ter_dirt}, - {t_tree_pine, ter_tree_deadpine}, - {t_tree_birch, ter_tree_birch_harvested}, - {t_tree_willow, ter_tree_willow_harvested}, - {t_tree_hickory, ter_tree_hickory_dead}, - {t_tree_hickory_harvested, ter_tree_hickory_dead}, + {t_grass, ter_str_id( "t_dirt" )}, + {t_tree_young, ter_str_id( "t_dirt" )}, + {t_tree_pine, ter_str_id( "t_tree_deadpine" )}, + {t_tree_birch, ter_str_id( "t_tree_birch_harvested" )}, + {t_tree_willow, ter_str_id( "t_tree_willow_harvested" )}, + {t_tree_hickory, ter_str_id( "t_tree_hickory_dead" )}, + {t_tree_hickory_harvested, ter_str_id( "t_tree_hickory_dead" )}, }}; const auto iter = dies_into.find( tid ); @@ -6998,10 +7005,10 @@ void map::rad_scorch( const tripoint &p, const time_duration &time_since_last_ac } const ter_t &tr = tid.obj(); - if( tr.has_flag( flag_SHRUB ) ) { + if( tr.has_flag( "SHRUB" ) ) { ter_set( p, t_dirt ); - } else if( tr.has_flag( flag_TREE ) ) { - ter_set( p, ter_tree_dead ); + } else if( tr.has_flag( "TREE" ) ) { + ter_set( p, ter_str_id( "t_tree_dead" ) ); } } @@ -7041,11 +7048,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( flag_EMITTER ) ) { + if( furn.has_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( flag_DONT_REMOVE_ROTTEN ) ) { + if( !furn.has_flag( "DONT_REMOVE_ROTTEN" ) ) { remove_rotten_items( tmpsub->get_items( { x, y } ), pnt ); } diff --git a/src/map.h b/src/map.h index 8b6a6a87c26c8..7cdb3dcb50a9e 100644 --- a/src/map.h +++ b/src/map.h @@ -69,6 +69,7 @@ struct trap; enum direction : unsigned; enum class special_item_type : int; +using itype_id = std::string; template class visitable; struct regional_settings; diff --git a/src/map_extras.cpp b/src/map_extras.cpp index c228004b8b87d..caf08d0a45d4b 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -304,8 +304,8 @@ static void mx_helicopter( map &m, const tripoint &abs_sub ) 1 ); const auto controls_at = []( vehicle * wreckage, const tripoint & pos ) { - return !wreckage->get_parts_at( pos, flag_CONTROLS, part_status_flag::any ).empty() || - !wreckage->get_parts_at( pos, flag_CTRL_ELECTRONIC, part_status_flag::any ).empty(); + return !wreckage->get_parts_at( pos, "CONTROLS", part_status_flag::any ).empty() || + !wreckage->get_parts_at( pos, "CTRL_ELECTRONIC", part_status_flag::any ).empty(); }; if( wreckage != nullptr ) { diff --git a/src/map_field.cpp b/src/map_field.cpp index e2cb4c7eea861..a7c5529b087cb 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1765,7 +1765,7 @@ void map::monster_in_field( monster &z ) if( z.made_of_any( Creature::cmat_flesh ) ) { dam += 3; } - if( z.made_of( material_veggy ) ) { + if( z.made_of( material_id( "veggy" ) ) ) { dam += 12; } if( z.made_of( LIQUID ) || z.made_of_any( Creature::cmat_flammable ) ) { @@ -1805,7 +1805,7 @@ void map::monster_in_field( monster &z ) z.moves -= rng( 10, 20 ); } // Plants suffer from smoke even worse - if( z.made_of( material_veggy ) ) { + if( z.made_of( material_id( "veggy" ) ) ) { z.moves -= rng( 1, cur.get_field_intensity() * 12 ); } } @@ -1822,7 +1822,7 @@ void map::monster_in_field( monster &z ) } else { z.add_effect( effect_stunned, rng( 1_turns, 5_turns ) ); } - if( z.made_of( material_veggy ) ) { + if( z.made_of( material_id( "veggy" ) ) ) { z.moves -= rng( cur.get_field_intensity() * 5, cur.get_field_intensity() * 12 ); dam += cur.get_field_intensity() * rng( 8, 14 ); } @@ -1864,7 +1864,7 @@ void map::monster_in_field( monster &z ) z.moves -= rng( 0, 15 ); dam += rng( 0, 12 ); } - if( z.made_of( material_veggy ) ) { + if( z.made_of( material_id( "veggy" ) ) ) { z.moves -= rng( cur.get_field_intensity() * 5, cur.get_field_intensity() * 12 ); dam *= cur.get_field_intensity(); } @@ -1879,7 +1879,7 @@ void map::monster_in_field( monster &z ) if( z.made_of_any( Creature::cmat_flesh ) ) { dam += 3; } - if( z.made_of( material_veggy ) ) { + if( z.made_of( material_id( "veggy" ) ) ) { dam += 12; } if( z.made_of( LIQUID ) || z.made_of_any( Creature::cmat_flammable ) ) { @@ -1910,7 +1910,7 @@ void map::monster_in_field( monster &z ) if( z.made_of_any( Creature::cmat_flesh ) ) { dam += 3; } - if( z.made_of( material_veggy ) ) { + if( z.made_of( material_id( "veggy" ) ) ) { dam += 12; } if( z.made_of( LIQUID ) || z.made_of_any( Creature::cmat_flammable ) ) { @@ -1937,7 +1937,7 @@ void map::monster_in_field( monster &z ) } } if( cur_field_type == fd_fungal_haze ) { - if( !z.type->in_species( species_FUNGUS ) && + if( !z.type->in_species( FUNGUS ) && !z.type->has_flag( MF_NO_BREATHE ) && !z.make_fungus() ) { // Don't insta-kill jabberwocks, that's silly @@ -1947,14 +1947,14 @@ void map::monster_in_field( monster &z ) } } if( cur_field_type == fd_fungicidal_gas ) { - if( z.type->in_species( species_FUNGUS ) ) { + if( z.type->in_species( FUNGUS ) ) { const int intensity = cur.get_field_intensity(); z.moves -= rng( 10 * intensity, 30 * intensity ); dam += rng( 4, 7 * intensity ); } } if( cur_field_type == fd_insecticidal_gas ) { - if( z.type->in_species( species_INSECT ) || z.type->in_species( species_SPIDER ) ) { + if( z.type->in_species( INSECT ) || z.type->in_species( SPIDER ) ) { const int intensity = cur.get_field_intensity(); z.moves -= rng( 10 * intensity, 30 * intensity ); dam += rng( 4, 7 * intensity ); diff --git a/src/mapdata.cpp b/src/mapdata.cpp index 7ee95d700cf20..298c59d0cb91c 100644 --- a/src/mapdata.cpp +++ b/src/mapdata.cpp @@ -1303,7 +1303,7 @@ void furn_t::check() const if( !close.is_valid() ) { debugmsg( "invalid furniture %s for closing %s", close.c_str(), id.c_str() ); } - if( has_flag( flag_EMITTER ) ) { + if( has_flag( "EMITTER" ) ) { if( emissions.empty() ) { debugmsg( "furn %s has the EMITTER flag, but no emissions were set", id.c_str() ); } else { diff --git a/src/mapdata.h b/src/mapdata.h index 18fd3da733942..bb1f1d138bad2 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -26,6 +26,8 @@ struct tripoint; using iexamine_function = void ( * )( player &, const tripoint & ); +using itype_id = std::string; + struct map_bash_info { int str_min; // min str(*) required to bash int str_max; // max str required: bash succeeds if str >= random # between str_min & str_max diff --git a/src/mapgen.cpp b/src/mapgen.cpp index e8df1bdc016ff..4e7e55f9f358e 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1353,10 +1353,10 @@ class jmapgen_terrain : public jmapgen_piece void apply( mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y ) const override { dat.m.ter_set( point( x.get(), y.get() ), id ); // Delete furniture if a wall was just placed over it. TODO: need to do anything for fluid, monsters? - if( dat.m.has_flag_ter( flag_WALL, point( x.get(), y.get() ) ) ) { + if( dat.m.has_flag_ter( "WALL", point( x.get(), y.get() ) ) ) { dat.m.furn_set( point( x.get(), y.get() ), f_null ); // and items, unless the wall has PLACE_ITEM flag indicating it stores things. - if( !dat.m.has_flag_ter( flag_PLACE_ITEM, point( x.get(), y.get() ) ) ) { + if( !dat.m.has_flag_ter( "PLACE_ITEM", point( x.get(), y.get() ) ) ) { dat.m.i_clear( tripoint( x.get(), y.get(), dat.m.get_abs_sub().z ) ); } } @@ -1504,7 +1504,7 @@ class jmapgen_sealed_item : public jmapgen_piece return; } - if( furn.has_flag( flag_PLANT ) ) { + if( furn.has_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( flag_PLANT ) ) { + if( furn.has_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() ); @@ -3532,8 +3532,8 @@ void map::draw_lab( mapgendata &dat ) // We determine if a border isn't handled by checking the east-facing // border space where the door normally is -- it should be a wall or door. tripoint east_border( 23, 11, abs_sub.z ); - if( !has_flag_ter( flag_WALL, east_border ) && - !has_flag_ter( flag_DOOR, east_border ) ) { + if( !has_flag_ter( "WALL", east_border ) && + !has_flag_ter( "DOOR", east_border ) ) { // TODO: create a ter_reset function that does ter_set, // furn_set, and i_clear? ter_id lw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; @@ -3790,7 +3790,7 @@ void map::draw_lab( mapgendata &dat ) if( i + j > 10 && i + j < 36 && abs( i - j ) < 13 ) { // Doors and walls get sometimes destroyed: // 100% at the edge, usually in a central cross, occasionally elsewhere. - if( ( has_flag_ter( flag_DOOR, point( i, j ) ) || has_flag_ter( flag_WALL, point( i, j ) ) ) ) { + if( ( has_flag_ter( "DOOR", point( i, j ) ) || has_flag_ter( "WALL", point( i, j ) ) ) ) { if( ( i == 0 || j == 0 || i == 23 || j == 23 ) || ( !one_in( 3 ) && ( i == 11 || i == 12 || j == 11 || j == 12 ) ) || one_in( 4 ) ) { @@ -3803,8 +3803,8 @@ void map::draw_lab( mapgendata &dat ) } // and then randomly destroy 5% of the remaining nonstairs. } else if( one_in( 20 ) && - !has_flag_ter( flag_GOES_DOWN, point( x, y ) ) && - !has_flag_ter( flag_GOES_UP, point( x, y ) ) ) { + !has_flag_ter( "GOES_DOWN", point( x, y ) ) && + !has_flag_ter( "GOES_UP", point( x, y ) ) ) { destroy( { i, j, abs_sub.z } ); // bashed squares can create dirt & floors, but we want rock floors. if( t_dirt == ter( point( i, j ) ) || t_floor == ter( point( i, j ) ) ) { @@ -3882,7 +3882,7 @@ void map::draw_lab( mapgendata &dat ) t_strconc_floor == ter( point( i, j ) ) || t_thconc_floor_olight == ter( point( i, j ) ) ) ) { ter_set( point( i, j ), fluid_type ); - } else if( has_flag_ter( flag_DOOR, point( i, j ) ) && !one_in( 3 ) ) { + } else if( has_flag_ter( "DOOR", point( i, j ) ) && !one_in( 3 ) ) { // We want the actual debris, but not the rubble marker or dirt. make_rubble( { i, j, abs_sub.z } ); ter_set( point( i, j ), fluid_type ); @@ -3907,7 +3907,7 @@ void map::draw_lab( mapgendata &dat ) if( t_thconc_floor == ter( p ) || t_strconc_floor == ter( p ) || t_thconc_floor_olight == ter( p ) ) { ter_set( p, fluid_type ); - } else if( has_flag_ter( flag_DOOR, p ) ) { + } else if( has_flag_ter( "DOOR", p ) ) { // We want the actual debris, but not the rubble marker or dirt. make_rubble( { p, abs_sub.z } ); ter_set( p, fluid_type ); @@ -3947,9 +3947,9 @@ void map::draw_lab( mapgendata &dat ) ARTPROP_GLOWING }; draw_rough_circle( [this]( const point & p ) { - if( has_flag_ter( flag_GOES_DOWN, p ) || - has_flag_ter( flag_GOES_UP, p ) || - has_flag_ter( flag_CONSOLE, p ) ) { + if( has_flag_ter( "GOES_DOWN", p ) || + has_flag_ter( "GOES_UP", p ) || + has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } make_rubble( {p, abs_sub.z } ); @@ -3963,7 +3963,7 @@ void map::draw_lab( mapgendata &dat ) // radioactive accident. case 6: { tripoint center( rng( 6, SEEX * 2 - 7 ), rng( 6, SEEY * 2 - 7 ), abs_sub.z ); - if( has_flag_ter( flag_WALL, center.xy() ) ) { + if( has_flag_ter( "WALL", center.xy() ) ) { // just skip it, we don't want to risk embedding radiation out of sight. break; } @@ -3980,9 +3980,9 @@ void map::draw_lab( mapgendata &dat ) set_radiation( p, 50 ); }, center.xy(), 1 ); draw_circle( [this]( const point & p ) { - if( has_flag_ter( flag_GOES_DOWN, p ) || - has_flag_ter( flag_GOES_UP, p ) || - has_flag_ter( flag_CONSOLE, p ) ) { + if( has_flag_ter( "GOES_DOWN", p ) || + has_flag_ter( "GOES_UP", p ) || + has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } make_rubble( {p, abs_sub.z } ); @@ -4013,14 +4013,14 @@ void map::draw_lab( mapgendata &dat ) for( int i = 0; i < EAST_EDGE; i++ ) { for( int j = 0; j < SOUTH_EDGE; j++ ) { // Create a mostly spread fungal area throughout entire lab. - if( !one_in( 5 ) && ( has_flag( flag_FLAT, point( i, j ) ) ) ) { + if( !one_in( 5 ) && ( has_flag( "FLAT", point( i, j ) ) ) ) { ter_set( point( i, j ), t_fungus_floor_in ); - if( has_flag_furn( flag_ORGANIC, point( i, j ) ) ) { + if( has_flag_furn( "ORGANIC", point( i, j ) ) ) { furn_set( point( i, j ), f_fungal_clump ); } - } else if( has_flag_ter( flag_DOOR, point( i, j ) ) && !one_in( 5 ) ) { + } else if( has_flag_ter( "DOOR", point( i, j ) ) && !one_in( 5 ) ) { ter_set( point( i, j ), t_fungus_floor_in ); - } else if( has_flag_ter( flag_WALL, point( i, j ) ) && one_in( 3 ) ) { + } else if( has_flag_ter( "WALL", point( i, j ) ) && one_in( 3 ) ) { ter_set( point( i, j ), t_fungus_wall ); } } @@ -4029,12 +4029,12 @@ void map::draw_lab( mapgendata &dat ) // Make a portal surrounded by more dense fungal stuff and a fungaloid. draw_rough_circle( [this]( const point & p ) { - if( has_flag_ter( flag_GOES_DOWN, p ) || - has_flag_ter( flag_GOES_UP, p ) || - has_flag_ter( flag_CONSOLE, p ) ) { + if( has_flag_ter( "GOES_DOWN", p ) || + has_flag_ter( "GOES_UP", p ) || + has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } - if( has_flag_ter( flag_WALL, p ) ) { + if( has_flag_ter( "WALL", p ) ) { ter_set( p, t_fungus_wall ); } else { ter_set( p, t_fungus_floor_in ); @@ -4095,7 +4095,7 @@ void map::draw_lab( mapgendata &dat ) // We determine if a border isn't handled by checking the east-facing // border space where the door normally is -- it should be a wall or door. tripoint east_border( 23, 11, abs_sub.z ); - if( !has_flag_ter( flag_WALL, east_border ) && !has_flag_ter( flag_DOOR, east_border ) ) { + if( !has_flag_ter( "WALL", east_border ) && !has_flag_ter( "DOOR", east_border ) ) { // TODO: create a ter_reset function that does ter_set, furn_set, and i_clear? ter_id lw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; ter_id tw_type = tower_lab ? t_reinforced_glass : t_concrete_wall; @@ -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( flag_PLACE_ITEM ) && + !terrain.has_flag( "PLACE_ITEM" ) && !ongrass && - !terrain.has_flag( flag_FLAT ); + !terrain.has_flag( "FLAT" ); }; int px = 0; @@ -6023,7 +6023,7 @@ std::unique_ptr map::add_vehicle_to_map( std::vector frame_indices = veh->all_parts_at_location( "structure" ); //Check for boat type vehicles that should be placeable in deep water - const bool can_float = size( veh->get_avail_parts( flag_FLOATS ) ) > 2; + const bool can_float = size( veh->get_avail_parts( "FLOATS" ) ) > 2; //When hitting a wall, only smash the vehicle once (but walls many times) bool needs_smashing = false; diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 1d57959794a89..da44c07fc3d72 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -1972,7 +1972,7 @@ void mapgen_cave( mapgendata &dat ) m->place_spawns( GROUP_CAVE, 2, point( 6, 6 ), point( 18, 18 ), 1.0 ); } else { // We're above ground! // First, draw a forest - mapgendata forest_mapgen_dat( dat, oter_forest.id() ); + mapgendata forest_mapgen_dat( dat, oter_str_id( "forest" ).id() ); mapgen_forest( forest_mapgen_dat ); // Clear the center with some rocks square( m, t_rock, SEEX - 6, SEEY - 6, SEEX + 5, SEEY + 5 ); @@ -2933,7 +2933,7 @@ void mapgen_forest( mapgendata &dat ) void mapgen_forest_trail_straight( mapgendata &dat ) { map *const m = &dat.m; - mapgendata forest_mapgen_dat( dat, oter_forest_thick.id() ); + mapgendata forest_mapgen_dat( dat, oter_str_id( "forest_thick" ).id() ); mapgen_forest( forest_mapgen_dat ); const auto center_offset = [&dat]() { @@ -2971,7 +2971,7 @@ void mapgen_forest_trail_straight( mapgendata &dat ) void mapgen_forest_trail_curved( mapgendata &dat ) { map *const m = &dat.m; - mapgendata forest_mapgen_dat( dat, oter_forest_thick.id() ); + mapgendata forest_mapgen_dat( dat, oter_str_id( "forest_thick" ).id() ); mapgen_forest( forest_mapgen_dat ); const auto center_offset = [&dat]() { @@ -3017,7 +3017,7 @@ void mapgen_forest_trail_curved( mapgendata &dat ) void mapgen_forest_trail_tee( mapgendata &dat ) { map *const m = &dat.m; - mapgendata forest_mapgen_dat( dat, oter_forest_thick.id() ); + mapgendata forest_mapgen_dat( dat, oter_str_id( "forest_thick" ).id() ); mapgen_forest( forest_mapgen_dat ); const auto center_offset = [&dat]() { @@ -3062,7 +3062,7 @@ void mapgen_forest_trail_tee( mapgendata &dat ) void mapgen_forest_trail_four_way( mapgendata &dat ) { map *const m = &dat.m; - mapgendata forest_mapgen_dat( dat, oter_forest_thick.id() ); + mapgendata forest_mapgen_dat( dat, oter_str_id( "forest_thick" ).id() ); mapgen_forest( forest_mapgen_dat ); const auto center_offset = [&dat]() { @@ -3531,8 +3531,8 @@ static bool is_suitable_for_stairs( const map *const m, const tripoint &p ) const ter_t &p_ter = m->ter( p ).obj(); return - p_ter.has_flag( flag_INDOORS ) && - p_ter.has_flag( flag_FLAT ) && + p_ter.has_flag( "INDOORS" ) && + p_ter.has_flag( "FLAT" ) && m->furn( p ) == f_null; } @@ -3547,8 +3547,8 @@ static void stairs_debug_log( const map *const m, const std::string &msg, const << " terrain: " << p_ter.name() << " movecost: " << p_ter.movecost << " furniture: " << m->furn( p ).to_i() - << " indoors: " << p_ter.has_flag( flag_INDOORS ) - << " flat: " << p_ter.has_flag( flag_FLAT ) + << " indoors: " << p_ter.has_flag( "INDOORS" ) + << " flat: " << p_ter.has_flag( "FLAT" ) ; } diff --git a/src/martialarts.cpp b/src/martialarts.cpp index 8f95899f2972e..a5ae9dc53d148 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( flag_UNARMED_WEAPON ) ) { + if( !strictly_unarmed && !strictly_melee && !it.is_null() && it.has_flag( "UNARMED_WEAPON" ) ) { return true; } diff --git a/src/material.h b/src/material.h index ba110253a9642..60f81f51010ed 100644 --- a/src/material.h +++ b/src/material.h @@ -17,6 +17,7 @@ class material_type; enum damage_type : int; +using itype_id = std::string; class JsonObject; using mat_burn_products = std::vector>; diff --git a/src/melee.cpp b/src/melee.cpp index b477c88540951..5d6633a510d1b 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -56,7 +56,54 @@ #include "vehicle.h" #include "vpart_position.h" #include "mapdata.h" -#include "cata_string_consts.h" + +static const bionic_id bio_cqb( "bio_cqb" ); +static const bionic_id bio_memory( "bio_memory" ); + +static const matec_id tec_none( "tec_none" ); +static const matec_id WBLOCK_1( "WBLOCK_1" ); +static const matec_id WBLOCK_2( "WBLOCK_2" ); +static const matec_id WBLOCK_3( "WBLOCK_3" ); + +static const skill_id skill_stabbing( "stabbing" ); +static const skill_id skill_cutting( "cutting" ); +static const skill_id skill_unarmed( "unarmed" ); +static const skill_id skill_bashing( "bashing" ); +static const skill_id skill_melee( "melee" ); + +static const efftype_id effect_badpoison( "badpoison" ); +static const efftype_id effect_beartrap( "beartrap" ); +static const efftype_id effect_bouldering( "bouldering" ); +static const efftype_id effect_contacts( "contacts" ); +static const efftype_id effect_downed( "downed" ); +static const efftype_id effect_drunk( "drunk" ); +static const efftype_id effect_grabbed( "grabbed" ); +static const efftype_id effect_grabbing( "grabbing" ); +static const efftype_id effect_heavysnare( "heavysnare" ); +static const efftype_id effect_hit_by_player( "hit_by_player" ); +static const efftype_id effect_lightsnare( "lightsnare" ); +static const efftype_id effect_narcosis( "narcosis" ); +static const efftype_id effect_poison( "poison" ); +static const efftype_id effect_stunned( "stunned" ); + +static const trait_id trait_CLAWS( "CLAWS" ); +static const trait_id trait_CLAWS_RETRACT( "CLAWS_RETRACT" ); +static const trait_id trait_CLAWS_ST( "CLAWS_ST" ); +static const trait_id trait_CLAWS_TENTACLE( "CLAWS_TENTACLE" ); +static const trait_id trait_CLUMSY( "CLUMSY" ); +static const trait_id trait_DEBUG_NIGHTVISION( "DEBUG_NIGHTVISION" ); +static const trait_id trait_DEFT( "DEFT" ); +static const trait_id trait_DRUNKEN( "DRUNKEN" ); +static const trait_id trait_HYPEROPIC( "HYPEROPIC" ); +static const trait_id trait_NAILS( "NAILS" ); +static const trait_id trait_POISONOUS2( "POISONOUS2" ); +static const trait_id trait_POISONOUS( "POISONOUS" ); +static const trait_id trait_PROF_SKATER( "PROF_SKATER" ); +static const trait_id trait_THORNS( "THORNS" ); + +static const efftype_id effect_amigara( "amigara" ); + +static const species_id HUMAN( "HUMAN" ); void player_hit_message( player *attacker, const std::string &message, Creature &t, int dam, bool crit = false ); @@ -95,7 +142,7 @@ bool Character::is_armed() const bool Character::unarmed_attack() const { const item &weap = used_weapon(); - return weap.is_null() || weap.has_flag( flag_UNARMED_WEAPON ); + return weap.is_null() || weap.has_flag( "UNARMED_WEAPON" ); } bool player::handle_melee_wear( item &shield, float wear_multiplier ) @@ -109,7 +156,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) } // UNBREAKABLE_MELEE items can't be damaged through melee combat usage. - if( shield.has_flag( flag_UNBREAKABLE_MELEE ) ) { + if( shield.has_flag( "UNBREAKABLE_MELEE" ) ) { return false; } @@ -127,7 +174,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) itype_id weak_comp; itype_id big_comp = "null"; // Fragile items that fall apart easily when used as a weapon due to poor construction quality - if( shield.has_flag( flag_FRAGILE_MELEE ) ) { + if( shield.has_flag( "FRAGILE_MELEE" ) ) { const float fragile_factor = 6; int weak_chip = INT_MAX; units::volume big_vol = 0_ml; @@ -157,7 +204,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) int damage_chance = static_cast( stat_factor * material_factor / wear_multiplier ); // DURABLE_MELEE items are made to hit stuff and they do it well, so they're considered to be a lot tougher // than other weapons made of the same materials. - if( shield.has_flag( flag_DURABLE_MELEE ) ) { + if( shield.has_flag( "DURABLE_MELEE" ) ) { damage_chance *= 4; } @@ -193,7 +240,7 @@ bool player::handle_melee_wear( item &shield, float wear_multiplier ) remove_item( shield ); // Breakdown fragile weapons into components - if( temp.has_flag( flag_FRAGILE_MELEE ) && !temp.components.empty() ) { + if( temp.has_flag( "FRAGILE_MELEE" ) && !temp.components.empty() ) { add_msg_player_or_npc( m_bad, _( "Your %s breaks apart!" ), _( "'s %s breaks apart!" ), str ); @@ -255,7 +302,7 @@ float player::hit_roll() const } // Farsightedness makes us hit worse - if( has_trait( trait_HYPEROPIC ) && !worn_with_flag( flag_FIX_FARSIGHT ) && + if( has_trait( trait_HYPEROPIC ) && !worn_with_flag( "FIX_FARSIGHT" ) && !has_effect( effect_contacts ) ) { hit -= 2.0f; } @@ -290,7 +337,7 @@ std::string Character::get_miss_reason() _( "Your torso encumbrance throws you off-balance." ), roll_remainder( encumb( bp_torso ) / 10.0 ) ); const int farsightedness = 2 * ( has_trait( trait_HYPEROPIC ) && - !worn_with_flag( flag_FIX_FARSIGHT ) && + !worn_with_flag( "FIX_FARSIGHT" ) && !has_effect( effect_contacts ) ); add_miss_reason( _( "You can't hit reliably due to your farsightedness." ), @@ -334,7 +381,8 @@ static void melee_train( player &p, int lo, int hi, const item &weap ) void player::melee_attack( Creature &t, bool allow_special ) { - melee_attack( t, allow_special, matec_no_technique_id ); + static const matec_id no_technique_id( "" ); + melee_attack( t, allow_special, no_technique_id ); } // Melee calculation is in parts. This sets up the attack, then in deal_melee_attack, @@ -436,20 +484,20 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc } else if( has_force_technique ) { technique_id = force_technique; } else { - technique_id = matec_tec_none; + technique_id = tec_none; } // if you have two broken arms you aren't doing any martial arts // and your hits are not going to hurt very much if( get_working_arm_count() < 1 ) { - technique_id = matec_tec_none; + technique_id = tec_none; d.mult_damage( 0.1 ); } const ma_technique &technique = technique_id.obj(); // Handles effects as well; not done in melee_affect_* - if( technique.id != matec_tec_none ) { + if( technique.id != tec_none ) { perform_technique( technique, t, d, move_cost ); } @@ -484,7 +532,7 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc std::string material = "flesh"; if( t.is_monster() ) { const monster *m = dynamic_cast( &t ); - if( m->made_of( material_steel ) ) { + if( m->made_of( material_id( "steel" ) ) ) { material = "steel"; } } @@ -551,10 +599,10 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc void player::reach_attack( const tripoint &p ) { - matec_id force_technique = matec_tec_none; + matec_id force_technique = tec_none; /** @EFFECT_MELEE >5 allows WHIP_DISARM technique */ - if( weapon.has_flag( flag_WHIP ) && ( get_skill_level( skill_melee ) > 5 ) && one_in( 3 ) ) { - force_technique = matec_WHIP_DISARM; + if( weapon.has_flag( "WHIP" ) && ( get_skill_level( skill_melee ) > 5 ) && one_in( 3 ) ) { + force_technique = matec_id( "WHIP_DISARM" ); } Creature *critter = g->critter_at( p ); @@ -581,8 +629,8 @@ void player::reach_attack( const tripoint &p ) /** @EFFECT_STABBING increases ability to reach attack through fences */ } else if( g->m.impassable( p ) && // Fences etc. Spears can stab through those - !( weapon.has_flag( flag_SPEAR ) && - g->m.has_flag( flag_THIN_OBSTACLE, p ) && + !( weapon.has_flag( "SPEAR" ) && + g->m.has_flag( "THIN_OBSTACLE", p ) && x_in_y( skill, 10 ) ) ) { /** @EFFECT_STR increases bash effects when reach attacking past something */ g->m.bash( p, str_cur + weapon.damage_melee( DT_BASH ) ); @@ -711,7 +759,7 @@ float player::get_dodge() const { //If we're asleep or busy we can't dodge if( in_sleep_state() || has_effect( effect_narcosis ) || - has_effect( effect_winded ) ) { + has_effect( efftype_id( "winded" ) ) ) { return 0.0f; } @@ -735,9 +783,9 @@ float player::get_dodge() const } } - if( worn_with_flag( flag_ROLLER_INLINE ) || - worn_with_flag( flag_ROLLER_QUAD ) || - worn_with_flag( flag_ROLLER_ONE ) ) { + if( worn_with_flag( "ROLLER_INLINE" ) || + worn_with_flag( "ROLLER_QUAD" ) || + worn_with_flag( "ROLLER_ONE" ) ) { ret /= has_trait( trait_PROF_SKATER ) ? 2 : 5; } @@ -814,12 +862,12 @@ void player::roll_bash_damage( bool crit, damage_instance &di, bool average, if( left_empty || right_empty ) { float per_hand = 0.0f; for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - if( mut.first->flags.count( flag_NEED_ACTIVE_TO_MELEE ) > 0 && !has_active_mutation( mut.first ) ) { + if( mut.first->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut.first ) ) { continue; } float unarmed_bonus = 0.0f; const int bash_bonus = mut.first->bash_dmg_bonus; - if( mut.first->flags.count( flag_UNARMED_BONUS ) > 0 && bash_bonus > 0 ) { + if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && bash_bonus > 0 ) { unarmed_bonus += std::min( get_skill_level( skill_unarmed ) / 2, 4 ); } per_hand += bash_bonus + unarmed_bonus; @@ -894,16 +942,16 @@ void player::roll_cut_damage( bool crit, damage_instance &di, bool average, cons weap.is_null(); if( left_empty || right_empty ) { float per_hand = 0.0f; - if( has_bionic( bio_razors ) ) { + if( has_bionic( bionic_id( "bio_razors" ) ) ) { per_hand += 2; } for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - if( mut.first->flags.count( flag_NEED_ACTIVE_TO_MELEE ) > 0 && !has_active_mutation( mut.first ) ) { + if( mut.first->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut.first ) ) { continue; } float unarmed_bonus = 0.0f; const int cut_bonus = mut.first->cut_dmg_bonus; - if( mut.first->flags.count( flag_UNARMED_BONUS ) > 0 && cut_bonus > 0 ) { + if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && cut_bonus > 0 ) { unarmed_bonus += std::min( get_skill_level( skill_unarmed ) / 2, 4 ); } per_hand += cut_bonus + unarmed_bonus; @@ -973,7 +1021,7 @@ void player::roll_stab_damage( bool crit, damage_instance &di, bool average, per_hand += .5; } - if( has_bionic( bio_razors ) ) { + if( has_bionic( bionic_id( "bio_razors" ) ) ) { per_hand += 2; } @@ -1095,7 +1143,7 @@ matec_id player::pick_technique( Creature &t, const item &weap, } // Don't apply humanoid-only techniques to non-humanoids - if( tec.human_target && !t.in_species( species_HUMAN ) ) { + if( tec.human_target && !t.in_species( HUMAN ) ) { continue; } // if aoe, check if there are valid targets @@ -1120,7 +1168,7 @@ matec_id player::pick_technique( Creature &t, const item &weap, } } - return random_entry( possible, matec_tec_none ); + return random_entry( possible, tec_none ); } bool player::valid_aoe_technique( Creature &t, const ma_technique &technique ) @@ -1348,7 +1396,7 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama if( technique.knockback_follow ) { const optional_vpart_position vp0 = g->m.veh_at( pos() ); vehicle *const veh0 = veh_pointer_or_null( vp0 ); - bool to_swimmable = g->m.has_flag( flag_SWIMMABLE, prev_pos ); + bool to_swimmable = g->m.has_flag( "SWIMMABLE", prev_pos ); bool to_deepwater = g->m.has_flag( TFLAG_DEEP_WATER, prev_pos ); // Check if it's possible to move to the new tile @@ -1429,7 +1477,7 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama if( has_active_bionic( bio_cqb ) && !martial_arts_data.knows_selected_style() ) { /** @EFFECT_INT slightly increases chance to learn techniques when using CQB bionic */ // Enhanced Memory Banks bionic doubles chance to learn martial art - const int bionic_boost = has_active_bionic( bio_memory ) ? 2 : 1; + const int bionic_boost = has_active_bionic( bionic_id( bio_memory ) ) ? 2 : 1; if( one_in( ( 1400 - ( get_int() * 50 ) ) / bionic_boost ) ) { martial_arts_data.learn_current_style_CQB( is_player() ); } @@ -1439,13 +1487,13 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama static int blocking_ability( const item &shield ) { int block_bonus = 0; - if( shield.has_technique( matec_WBLOCK_3 ) ) { + if( shield.has_technique( WBLOCK_3 ) ) { block_bonus = 10; - } else if( shield.has_technique( matec_WBLOCK_2 ) ) { + } else if( shield.has_technique( WBLOCK_2 ) ) { block_bonus = 6; - } else if( shield.has_technique( matec_WBLOCK_1 ) ) { + } else if( shield.has_technique( WBLOCK_1 ) ) { block_bonus = 4; - } else if( shield.has_flag( flag_BLOCK_WHILE_WORN ) ) { + } else if( shield.has_flag( "BLOCK_WHILE_WORN" ) ) { block_bonus = 2; } return block_bonus; @@ -1459,7 +1507,7 @@ item &player::best_shield() best_value = best_value == 2 ? 0 : best_value; item *best = best_value > 0 ? &weapon : &null_item_reference(); for( item &shield : worn ) { - if( shield.has_flag( flag_BLOCK_WHILE_WORN ) && blocking_ability( shield ) >= best_value ) { + if( shield.has_flag( "BLOCK_WHILE_WORN" ) && blocking_ability( shield ) >= best_value ) { best = &shield; } } @@ -1474,7 +1522,7 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da // TODO: It should probably be moved to the section that regenerates blocks // and to effects that disallow blocking if( blocks_left < 1 || in_sleep_state() || has_effect( effect_narcosis ) || - has_effect( effect_winded ) ) { + has_effect( efftype_id( "winded" ) ) ) { return false; } blocks_left--; @@ -1489,7 +1537,7 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da // Extract this to make it easier to implement shields/multiwield later item &shield = best_shield(); bool conductive_shield = shield.conductive(); - bool unarmed = shield.has_flag( flag_UNARMED_WEAPON ); + bool unarmed = shield.has_flag( "UNARMED_WEAPON" ); // This gets us a number between: // str ~0 + skill 0 = 0 @@ -1638,10 +1686,10 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da // Check if we have any block counters matec_id tec = pick_technique( *source, shield, false, false, true ); - if( tec != matec_tec_none && !is_dead_state() ) { + if( tec != tec_none && !is_dead_state() ) { if( get_stamina() < get_stamina_max() / 3 ) { add_msg( m_bad, _( "You try to counterattack but you are too exhausted!" ) ); - } else if( weapon.made_of( material_glass ) ) { + } else if( weapon.made_of( material_id( "glass" ) ) ) { add_msg( m_bad, _( "The item you are wielding is too fragile to counterattack with!" ) ); } else { melee_attack( *source, false, tec ); @@ -1684,7 +1732,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item std::string target = t.disp_name(); - if( has_active_bionic( bio_shock ) && get_power_level() >= 2_kJ && + if( has_active_bionic( bionic_id( "bio_shock" ) ) && get_power_level() >= 2_kJ && ( !is_armed() || weapon.conductive() ) ) { mod_power_level( -2_kJ ); d.add_damage( DT_ELECTRIC, rng( 2, 10 ) ); @@ -1696,7 +1744,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item } } - if( has_active_bionic( bio_heat_absorb ) && !is_armed() && t.is_warm() ) { + if( has_active_bionic( bionic_id( "bio_heat_absorb" ) ) && !is_armed() && t.is_warm() ) { mod_power_level( 3_kJ ); d.add_damage( DT_COLD, 3 ); if( is_player() ) { @@ -1706,7 +1754,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item } } - if( weapon.has_flag( flag_FLAMING ) ) { + if( weapon.has_flag( "FLAMING" ) ) { d.add_damage( DT_HEAT, rng( 1, 8 ) ); if( is_player() ) { @@ -1717,7 +1765,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item } //Hurting the wielder from poorly-chosen weapons - if( weap.has_flag( flag_HURT_WHEN_WIELDED ) && x_in_y( 2, 3 ) ) { + if( weap.has_flag( "HURT_WHEN_WIELDED" ) && x_in_y( 2, 3 ) ) { add_msg_if_player( m_bad, _( "The %s cuts your hand!" ), weap.tname() ); deal_damage( nullptr, bp_hand_r, damage_instance::physical( 0, weap.damage_melee( DT_CUT ), 0 ) ); if( weap.is_two_handed( *this ) ) { // Hurt left hand too, if it was big @@ -1727,7 +1775,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item const int vol = weap.volume() / 250_ml; // Glass weapons shatter sometimes - if( weap.made_of( material_glass ) && + if( weap.made_of( material_id( "glass" ) ) && /** @EFFECT_STR increases chance of breaking glass weapons (NEGATIVE) */ rng( 0, vol + 8 ) < vol + str_cur ) { if( is_player() ) { @@ -1766,7 +1814,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item static damage_instance hardcoded_mutation_attack( const player &u, const trait_id &id ) { - if( id == trait_BEAK_PECK ) { + if( id == "BEAK_PECK" ) { // method open to improvement, please feel free to suggest // a better way to simulate target's anti-peck efforts /** @EFFECT_DEX increases number of hits with BEAK_PECK */ @@ -1777,15 +1825,15 @@ static damage_instance hardcoded_mutation_attack( const player &u, const trait_i return damage_instance::physical( 0, 0, num_hits * 10 ); } - if( id == trait_ARM_TENTACLES || id == trait_ARM_TENTACLES_4 || id == trait_ARM_TENTACLES_8 ) { + if( id == "ARM_TENTACLES" || id == "ARM_TENTACLES_4" || id == "ARM_TENTACLES_8" ) { int num_attacks = 1; - if( id == trait_ARM_TENTACLES_4 ) { + if( id == "ARM_TENTACLES_4" ) { num_attacks = 3; - } else if( id == trait_ARM_TENTACLES_8 ) { + } else if( id == "ARM_TENTACLES_8" ) { num_attacks = 7; } // Note: we're counting arms, so we want wielded item here, not weapon used for attack - if( u.weapon.is_two_handed( u ) || !u.has_two_arms() || u.worn_with_flag( flag_RESTRICT_HANDS ) ) { + if( u.weapon.is_two_handed( u ) || !u.has_two_arms() || u.worn_with_flag( "RESTRICT_HANDS" ) ) { num_attacks--; } @@ -1806,8 +1854,8 @@ static damage_instance hardcoded_mutation_attack( const player &u, const trait_i return ret; } - if( id == trait_VINES2 || id == trait_VINES3 ) { - const int num_attacks = id == trait_VINES2 ? 2 : 3; + if( id == "VINES2" || id == "VINES3" ) { + const int num_attacks = id == "VINES2" ? 2 : 3; /** @EFFECT_STR increases damage with VINES* */ damage_instance ret; ret.add_damage( DT_BASH, u.get_str() / 2.0f, 0, 1.0f, num_attacks ); @@ -1824,7 +1872,7 @@ std::vector player::mutation_attacks( Creature &t ) const std::string target = t.disp_name(); - const auto usable_body_parts = exclusive_flag_coverage( flag_ALLOWS_NATURAL_ATTACKS ); + const auto usable_body_parts = exclusive_flag_coverage( "ALLOWS_NATURAL_ATTACKS" ); const int unarmed = get_skill_level( skill_unarmed ); for( const auto &pr : my_mutations ) { @@ -1970,7 +2018,7 @@ std::string melee_message( const ma_technique &tec, player &p, const dealt_damag const int cut_dam = ddi.type_damage( DT_CUT ); const int stab_dam = ddi.type_damage( DT_STAB ); - if( tec.id != matec_tec_none ) { + if( tec.id != tec_none ) { std::string message; if( p.is_npc() ) { message = _( tec.npc_message ); @@ -2080,7 +2128,7 @@ void player_hit_message( player *attacker, const std::string &message, int player::attack_speed( const item &weap ) const { const int base_move_cost = weap.attack_time() / 2; - const int melee_skill = has_active_bionic( bio_cqb ) ? BIO_CQB_LEVEL : get_skill_level( + const int melee_skill = has_active_bionic( bionic_id( bio_cqb ) ) ? BIO_CQB_LEVEL : get_skill_level( skill_melee ); /** @EFFECT_MELEE increases melee attack speed */ const int skill_cost = static_cast( ( base_move_cost * ( 15 - melee_skill ) / 15 ) ); @@ -2159,8 +2207,8 @@ double player::melee_value( const item &weap ) const } int move_cost = attack_speed( weap ); - - if( weap.has_technique( matec_RAPID ) ) { + static const matec_id rapid_strike( "RAPID" ); + if( weap.has_technique( rapid_strike ) ) { move_cost /= 2; avg_dmg *= 0.66; } diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 808c93a695205..1e947909cd1f8 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -142,7 +142,7 @@ static tripoint find_potential_computer_point( const tinymap &compmap ) } int wall = 0; for( const tripoint &p2 : compmap.points_in_radius( p, 1 ) ) { - if( compmap.has_flag_ter( flag_WALL, p2 ) ) { + if( compmap.has_flag_ter( "WALL", p2 ) ) { wall++; } } @@ -564,7 +564,7 @@ void mission_start::ranch_scavenger_3( mission *miss ) bay.spawn_item( point( 17, 21 ), "wheel_wide" ); bay.spawn_item( point( 23, 18 ), "v8_combustion" ); bay.furn_set( point( 23, 17 ), furn_str_id( "f_arcade_machine" ) ); - bay.ter_set( point( 23, 16 ), ter_machinery_light ); + bay.ter_set( point( 23, 16 ), ter_str_id( "t_machinery_light" ) ); bay.furn_set( point( 20, 21 ), f_woodstove ); bay.save(); diff --git a/src/monattack.cpp b/src/monattack.cpp index a3aca740be2d4..0e52da8abb402 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -192,7 +192,7 @@ bool mattack::none( monster * ) bool mattack::eat_crop( monster *z ) { for( const auto &p : g->m.points_in_radius( z->pos(), 1 ) ) { - if( g->m.has_flag( flag_PLANT, p ) && one_in( 4 ) ) { + if( g->m.has_flag( "PLANT", p ) && one_in( 4 ) ) { g->m.furn_set( p, furn_str_id( g->m.furn( p )->plant->base ) ); g->m.i_clear( p ); return true; @@ -205,7 +205,7 @@ bool mattack::eat_food( monster *z ) { for( const auto &p : g->m.points_in_radius( z->pos(), 1 ) ) { //Protect crop seeds from carnivores, give omnivores eat_crop special also - if( g->m.has_flag( flag_PLANT, p ) ) { + if( g->m.has_flag( "PLANT", p ) ) { continue; } auto items = g->m.i_at( p ); @@ -672,11 +672,11 @@ bool mattack::pull_metal_weapon( monster *z ) player *foe = dynamic_cast< player * >( target ); if( foe != nullptr ) { // Wielded steel or iron items except for built-in things like bionic claws or monomolecular blade - if( !foe->weapon.has_flag( flag_NO_UNWIELD ) && - ( foe->weapon.made_of( material_iron ) || - foe->weapon.made_of( material_hardsteel ) || - foe->weapon.made_of( material_steel ) || - foe->weapon.made_of( material_budget_steel ) ) ) { + if( !foe->weapon.has_flag( "NO_UNWIELD" ) && + ( foe->weapon.made_of( material_id( "iron" ) ) || + foe->weapon.made_of( material_id( "hardsteel" ) ) || + foe->weapon.made_of( material_id( "steel" ) ) || + foe->weapon.made_of( material_id( "budget_steel" ) ) ) ) { int wp_skill = foe->get_skill_level( skill_melee ); // It takes a while z->moves -= att_cost_pull; @@ -832,7 +832,7 @@ bool mattack::resurrect( monster *z ) for( auto &i : g->m.i_at( p ) ) { const mtype *mt = i.get_mtype(); if( !( i.is_corpse() && i.can_revive() && i.active && mt->has_flag( MF_REVIVES ) && - mt->in_species( species_ZOMBIE ) && !mt->has_flag( MF_NO_NECRO ) ) ) { + mt->in_species( ZOMBIE ) && !mt->has_flag( MF_NO_NECRO ) ) ) { continue; } @@ -873,8 +873,7 @@ bool mattack::resurrect( monster *z ) // Check to see if there are any nearby living zombies to see if we should get angry const bool allies = g->get_creature_if( [&]( const Creature & critter ) { const monster *const zed = dynamic_cast( &critter ); - return zed && zed != z && zed->type->has_flag( MF_REVIVES ) && - zed->type->in_species( species_ZOMBIE ) && + return zed && zed != z && zed->type->has_flag( MF_REVIVES ) && zed->type->in_species( ZOMBIE ) && z->attitude_to( *zed ) == Creature::Attitude::A_FRIENDLY && within_target_range( z, zed, 10 ); } ); @@ -1277,8 +1276,8 @@ bool mattack::growplants( monster *z ) for( const auto &p : g->m.points_in_radius( z->pos(), 3 ) ) { // Only affect natural, dirtlike terrain or trees. - if( !( g->m.has_flag_ter( flag_DIGGABLE, p ) || - g->m.has_flag_ter( flag_TREE, p ) || + if( !( g->m.has_flag_ter( "DIGGABLE", p ) || + g->m.has_flag_ter( "TREE", p ) || g->m.ter( p ) == t_tree_young ) ) { continue; } @@ -2107,7 +2106,7 @@ bool mattack::plant( monster *z ) { fungal_effects fe( *g, g->m ); const tripoint monster_position = z->pos(); - const bool is_fungi = g->m.has_flag_ter( flag_FUNGUS, monster_position ); + const bool is_fungi = g->m.has_flag_ter( "FUNGUS", monster_position ); // Spores taking seed and growing into a fungaloid fe.spread_fungus( monster_position ); if( is_fungi && one_in( 10 + g->num_creatures() / 5 ) ) { @@ -2221,7 +2220,7 @@ bool mattack::formblob( monster *z ) monster &othermon = *( dynamic_cast( critter ) ); // Hit a monster. If it's a blob, give it our speed. Otherwise, blobify it? - if( z->get_speed_base() > 40 && othermon.type->in_species( species_BLOB ) ) { + if( z->get_speed_base() > 40 && othermon.type->in_species( BLOB ) ) { if( othermon.type->id == mon_blob_brain ) { // Brain blobs don't get sped up, they heal at the cost of the other blob. // But only if they are hurt badly. @@ -2240,9 +2239,9 @@ bool mattack::formblob( monster *z ) } else if( othermon.type->id == mon_blob && othermon.get_speed_base() >= 80 ) { poly_keep_speed( othermon, mon_blob_large ); } - } else if( ( othermon.made_of( material_flesh ) || - othermon.made_of( material_veggy ) || - othermon.made_of( material_iflesh ) ) && + } else if( ( othermon.made_of( material_id( "flesh" ) ) || + othermon.made_of( material_id( "veggy" ) ) || + othermon.made_of( material_id( "iflesh" ) ) ) && rng( 0, z->get_hp() ) > rng( othermon.get_hp() / 2, othermon.get_hp() ) ) { didit = blobify( *z, othermon ); } @@ -2279,7 +2278,7 @@ bool mattack::callblobs( monster *z ) std::list allies; std::vector nearby_points = closest_tripoints_first( z->pos(), 3 ); for( monster &candidate : g->all_monsters() ) { - if( candidate.type->in_species( species_BLOB ) && candidate.type->id != mon_blob_brain ) { + if( candidate.type->in_species( BLOB ) && candidate.type->id != mon_blob_brain ) { // Just give the allies consistent assignments. // Don't worry about trying to make the orders optimal. allies.push_back( &candidate ); @@ -2312,7 +2311,7 @@ bool mattack::jackson( monster *z ) std::list allies; std::vector nearby_points = closest_tripoints_first( z->pos(), 3 ); for( monster &candidate : g->all_monsters() ) { - if( candidate.type->in_species( species_ZOMBIE ) && candidate.type->id != mon_zombie_jackson ) { + if( candidate.type->in_species( ZOMBIE ) && candidate.type->id != mon_zombie_jackson ) { // Just give the allies consistent assignments. // Don't worry about trying to make the orders optimal. allies.push_back( &candidate ); @@ -2725,8 +2724,8 @@ bool mattack::stare( monster *z ) z->moves -= 200; if( z->sees( g->u ) ) { //dimensional effects don't take against dimensionally anchored foes. - if( g->u.worn_with_flag( flag_DIMENSIONAL_ANCHOR ) || - g->u.has_effect_with_flag( flag_DIMENSIONAL_ANCHOR ) ) { + if( g->u.worn_with_flag( "DIMENSIONAL_ANCHOR" ) || + g->u.has_effect_with_flag( "DIMENSIONAL_ANCHOR" ) ) { add_msg( m_warning, _( "You feel a strange reverberation across your body." ) ); return true; } @@ -2748,7 +2747,7 @@ bool mattack::fear_paralyze( monster *z ) return false; } if( g->u.sees( *z ) && !g->u.has_effect( effect_fearparalyze ) ) { - if( g->u.has_artifact_with( AEP_PSYSHIELD ) || ( g->u.worn_with_flag( flag_PSYSHIELD_PARTIAL ) && + if( g->u.has_artifact_with( AEP_PSYSHIELD ) || ( g->u.worn_with_flag( "PSYSHIELD_PARTIAL" ) && one_in( 4 ) ) ) { add_msg( _( "The %s probes your mind, but is rebuffed!" ), z->name() ); ///\EFFECT_INT decreases chance of being paralyzed by fear attack @@ -3377,7 +3376,7 @@ bool mattack::searchlight( monster *z ) for( int x = zposx - 24; x < zposx + 24; x++ ) { for( int y = zposy - 24; y < zposy + 24; y++ ) { tripoint dest( x, y, z->posz() ); - if( g->m.ter( dest ) == ter_plut_generator ) { + if( g->m.ter( dest ) == ter_str_id( "t_plut_generator" ) ) { generator_ok = true; } } @@ -4100,8 +4099,8 @@ bool mattack::absorb_meat( monster *z ) auto items = g->m.i_at( p ); for( auto ¤t_item : items ) { const material_id current_item_material = current_item.get_base_material().ident(); - if( current_item_material == material_flesh || - current_item_material == material_hflesh ) { + if( current_item_material == material_id( "flesh" ) || + current_item_material == material_id( "hflesh" ) ) { //We have something meaty! Calculate how much it will heal the monster const int ml_of_meat = units::to_milliliter( current_item.volume() ); const int total_charges = current_item.count(); @@ -4789,7 +4788,7 @@ bool mattack::leech_spawner( monster *z ) const bool u_see = g->u.sees( *z ); std::list allies; for( monster &candidate : g->all_monsters() ) { - if( candidate.in_species( species_LEECH_PLANT ) && !candidate.has_flag( MF_IMMOBILE ) ) { + if( candidate.in_species( LEECH_PLANT ) && !candidate.has_flag( MF_IMMOBILE ) ) { allies.push_back( &candidate ); } } @@ -4822,7 +4821,7 @@ bool mattack::mon_leech_evolution( monster *z ) const bool is_queen = z->has_flag( MF_QUEEN ); std::list queens; for( monster &candidate : g->all_monsters() ) { - if( candidate.in_species( species_LEECH_PLANT ) && candidate.has_flag( MF_QUEEN ) && + if( candidate.in_species( LEECH_PLANT ) && candidate.has_flag( MF_QUEEN ) && rl_dist( z->pos(), candidate.pos() ) < 35 ) { queens.push_back( &candidate ); } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index ad412d8961852..75c6b7a1e1739 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -55,7 +55,7 @@ void mdeath::normal( monster &z ) return; } - if( z.type->in_species( species_ZOMBIE ) ) { + if( z.type->in_species( ZOMBIE ) ) { sfx::play_variant_sound( "mon_death", "zombie_death", sfx::get_heard_volume( z.pos() ) ); } @@ -189,7 +189,7 @@ void mdeath::splatter( monster &z ) item corpse = item::make_corpse( z.type->id, calendar::turn, z.unique_name, z.get_upgrade_time() ); // Set corpse to damage that aligns with being pulped corpse.set_damage( 4000 ); - corpse.set_flag( flag_GIBBED ); + corpse.set_flag( "GIBBED" ); if( z.has_effect( effect_no_ammo ) ) { corpse.set_var( "no_ammo", "no_ammo" ); } @@ -381,8 +381,8 @@ void mdeath::guilt( monster &z ) guilt_tresholds[50] = _( "You regret killing %s." ); guilt_tresholds[25] = _( "You feel remorse for killing %s." ); - if( g->u.has_trait( trait_PSYCHOPATH ) || g->u.has_trait_flag( flag_PRED3 ) || - g->u.has_trait_flag( flag_PRED4 ) || g->u.has_trait( trait_KILLER ) ) { + if( g->u.has_trait( trait_PSYCHOPATH ) || g->u.has_trait_flag( "PRED3" ) || + g->u.has_trait_flag( "PRED4" ) || g->u.has_trait( trait_KILLER ) ) { return; } if( rl_dist( z.pos(), g->u.pos() ) > MAX_GUILT_DISTANCE ) { @@ -401,7 +401,7 @@ void mdeath::guilt( monster &z ) "about their deaths anymore." ), z.name( maxKills ) ); } return; - } else if( ( g->u.has_trait_flag( flag_PRED1 ) ) || ( g->u.has_trait_flag( flag_PRED2 ) ) ) { + } else if( ( g->u.has_trait_flag( "PRED1" ) ) || ( g->u.has_trait_flag( "PRED2" ) ) ) { msg = ( _( "Culling the weak is distasteful, but necessary." ) ); msgtype = m_neutral; } else { @@ -420,13 +420,13 @@ void mdeath::guilt( monster &z ) int maxMalus = -250 * ( 1.0 - ( static_cast( kill_count ) / maxKills ) ); time_duration duration = 30_minutes * ( 1.0 - ( static_cast( kill_count ) / maxKills ) ); time_duration decayDelay = 3_minutes * ( 1.0 - ( static_cast( kill_count ) / maxKills ) ); - if( z.type->in_species( species_ZOMBIE ) ) { + if( z.type->in_species( ZOMBIE ) ) { moraleMalus /= 10; if( g->u.has_trait( trait_PACIFIST ) ) { moraleMalus *= 5; - } else if( g->u.has_trait_flag( flag_PRED1 ) ) { + } else if( g->u.has_trait_flag( "PRED1" ) ) { moraleMalus /= 4; - } else if( g->u.has_trait_flag( flag_PRED2 ) ) { + } else if( g->u.has_trait_flag( "PRED2" ) ) { moraleMalus /= 5; } } @@ -466,7 +466,7 @@ void mdeath::blobsplit( monster &z ) void mdeath::brainblob( monster &z ) { for( monster &critter : g->all_monsters() ) { - if( critter.type->in_species( species_BLOB ) && critter.type->id != mon_blob_brain ) { + if( critter.type->in_species( BLOB ) && critter.type->id != mon_blob_brain ) { critter.remove_effect( effect_controlled ); } } @@ -700,17 +700,17 @@ void mdeath::jabberwock( monster &z ) player *ch = dynamic_cast( z.get_killer() ); bool vorpal = ch && ch->is_player() && - ch->weapon.has_flag( flag_DIAMOND ) && + ch->weapon.has_flag( "DIAMOND" ) && ch->weapon.volume() > 750_ml; - if( vorpal && !ch->weapon.has_technique( matec_VORPAL ) ) { + if( vorpal && !ch->weapon.has_technique( matec_id( "VORPAL" ) ) ) { if( ch->sees( z ) ) { ch->add_msg_if_player( m_info, //~ %s is the possessive form of the monster's name _( "As the flames in %s eyes die out, your weapon seems to shine slightly brighter." ), z.disp_name( true ) ); } - ch->weapon.add_technique( matec_VORPAL ); + ch->weapon.add_technique( matec_id( "VORPAL" ) ); } mdeath::normal( z ); @@ -824,7 +824,7 @@ void make_mon_corpse( monster &z, int damageLvl ) corpse.set_item_temperature( 310.15 ); } corpse.set_damage( damageLvl ); - if( z.has_effect( effect_pacified ) && z.type->in_species( species_ZOMBIE ) ) { + if( z.has_effect( effect_pacified ) && z.type->in_species( ZOMBIE ) ) { // Pacified corpses have a chance of becoming unpacified when regenerating. corpse.set_var( "zlave", one_in( 2 ) ? "zlave" : "mutilated" ); } diff --git a/src/monexamine.cpp b/src/monexamine.cpp index 4790109298fe2..9b358da1ddb7b 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -66,7 +66,7 @@ bool monexamine::pet_menu( monster &z ) uilist amenu; std::string pet_name = z.get_name(); - bool is_zombie = z.type->in_species( species_ZOMBIE ); + bool is_zombie = z.type->in_species( ZOMBIE ); if( is_zombie ) { pet_name = _( "zombie slave" ); } @@ -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( flag_TIE_UP ); + return itm.has_flag( "TIE_UP" ); } ); if( !rope_inv.empty() ) { amenu.addentry( rope, true, 't', _( "Tie" ) ); @@ -118,12 +118,12 @@ bool monexamine::pet_menu( monster &z ) amenu.addentry( milk, true, 'm', _( "Milk %s" ), pet_name ); } if( z.has_flag( MF_PET_MOUNTABLE ) && !z.has_effect( effect_saddled ) && - g->u.has_item_with_flag( flag_TACK ) && g->u.get_skill_level( skill_survival ) >= 1 ) { + g->u.has_item_with_flag( "TACK" ) && g->u.get_skill_level( skill_survival ) >= 1 ) { amenu.addentry( attach_saddle, true, 'h', _( "Tack up %s" ), pet_name ); } else if( z.has_flag( MF_PET_MOUNTABLE ) && z.has_effect( effect_saddled ) ) { amenu.addentry( remove_saddle, true, 'h', _( "Remove tack from %s" ), pet_name ); } else if( z.has_flag( MF_PET_MOUNTABLE ) && !z.has_effect( effect_saddled ) && - g->u.has_item_with_flag( flag_TACK ) && g->u.get_skill_level( skill_survival ) < 1 ) { + g->u.has_item_with_flag( "TACK" ) && g->u.get_skill_level( skill_survival ) < 1 ) { amenu.addentry( remove_saddle, false, 'h', _( "You don't know how to saddle %s" ), pet_name ); } if( z.has_flag( MF_PAY_BOT ) ) { @@ -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( flag_TACK ); + return it.has_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( flag_MECH_BAT ); + return itm.has_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( flag_TIE_UP ); + return itm.has_flag( "TIE_UP" ); } ); if( rope_inv.empty() ) { return; diff --git a/src/monmove.cpp b/src/monmove.cpp index a11fece252eaf..02c928478e0d5 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -52,13 +52,13 @@ bool monster::wander() bool monster::is_immune_field( const field_type_id &fid ) const { if( fid == fd_fungal_haze ) { - return has_flag( MF_NO_BREATHE ) || type->in_species( species_FUNGUS ); + return has_flag( MF_NO_BREATHE ) || type->in_species( FUNGUS ); } if( fid == fd_fungicidal_gas ) { - return !type->in_species( species_FUNGUS ); + return !type->in_species( FUNGUS ); } if( fid == fd_insecticidal_gas ) { - return !type->in_species( species_INSECT ) && !type->in_species( species_SPIDER ); + return !type->in_species( INSECT ) && !type->in_species( SPIDER ); } const field_type &ft = fid.obj(); if( ft.has_fume ) { @@ -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( flag_BURROWABLE, p ) ) { + if( !g->m.has_flag( "BURROWABLE", p ) ) { return false; } - } else if( !( can_climb() && g->m.has_flag( flag_CLIMBABLE, p ) ) ) { + } else if( !( can_climb() && g->m.has_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( flag_DIGGABLE, p ) && !g->m.has_flag( flag_BURROWABLE, p ) ) { + if( digs() && !g->m.has_flag( "DIGGABLE", p ) && !g->m.has_flag( "BURROWABLE", p ) ) { return false; } - if( has_flag( MF_AQUATIC ) && !g->m.has_flag( flag_SWIMMABLE, p ) ) { + if( has_flag( MF_AQUATIC ) && !g->m.has_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( flag_SHARP, p ) && + if( avoid_simple && g->m.has_flag( "SHARP", p ) && !( type->size == MS_TINY || flies() ) ) { return false; } @@ -462,7 +462,7 @@ void monster::plan() friendly = 100; for( auto critter : g->m.get_creatures_in_radius( pos(), 6 ) ) { monster *mon = dynamic_cast( critter ); - if( mon != nullptr && mon->type->in_species( species_ZOMBIE ) ) { + if( mon != nullptr && mon->type->in_species( ZOMBIE ) ) { anger = 100; } else { anger = 0; @@ -553,7 +553,7 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina bool monster::is_aquatic_danger( const tripoint &at_pos ) { return g->m.has_flag_ter( TFLAG_DEEP_WATER, at_pos ) && g->m.has_flag( flag_LIQUID, at_pos ) && - can_drown() && !g->m.veh_at( at_pos ).part_with_feature( flag_BOARDABLE, false ); + can_drown() && !g->m.veh_at( at_pos ).part_with_feature( "BOARDABLE", false ); } bool monster::die_if_drowning( const tripoint &at_pos, const int chance ) @@ -697,7 +697,7 @@ void monster::move() // don't move if a passenger in a moving vehicle auto vp = g->m.veh_at( pos() ); - bool harness_part = static_cast( g->m.veh_at( pos() ).part_with_feature( flag_ANIMAL_CTRL, + bool harness_part = static_cast( g->m.veh_at( pos() ).part_with_feature( "ANIMAL_CTRL", true ) ); if( vp && vp->vehicle().is_moving() && vp->vehicle().get_pet( vp->part_index() ) ) { moves = 0; @@ -1135,40 +1135,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( flag_DIGGABLE, t ) ) ) { + if( flies() || ( digging() && g->m.has_flag( "DIGGABLE", t ) ) ) { movecost = 100; // Swimming monsters move super fast in water } else if( swims() ) { - if( g->m.has_flag( flag_SWIMMABLE, f ) ) { + if( g->m.has_flag( "SWIMMABLE", f ) ) { movecost += 25; } else { movecost += 50 * g->m.move_cost( f ); } - if( g->m.has_flag( flag_SWIMMABLE, t ) ) { + if( g->m.has_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( flag_SWIMMABLE, f ) ) { + if( g->m.has_flag( "SWIMMABLE", f ) ) { movecost += 250; } else { movecost += 50 * g->m.move_cost( f ); } - if( g->m.has_flag( flag_SWIMMABLE, t ) ) { + if( g->m.has_flag( "SWIMMABLE", t ) ) { movecost += 250; } else { movecost += 50 * g->m.move_cost( t ); } movecost /= 2; } else if( climbs() ) { - if( g->m.has_flag( flag_CLIMBABLE, f ) ) { + if( g->m.has_flag( "CLIMBABLE", f ) ) { movecost += 150; } else { movecost += 50 * g->m.move_cost( f ); } - if( g->m.has_flag( flag_CLIMBABLE, t ) ) { + if( g->m.has_flag( "CLIMBABLE", t ) ) { movecost += 150; } else { movecost += 50 * g->m.move_cost( t ); @@ -1255,7 +1255,7 @@ bool monster::bash_at( const tripoint &p ) return false; } - bool flat_ground = g->m.has_flag( flag_ROAD, p ) || g->m.has_flag( flag_FLAT, p ); + bool flat_ground = g->m.has_flag( "ROAD", p ) || g->m.has_flag( "FLAT", p ); if( flat_ground ) { bool can_bash_ter = g->m.is_bashable_ter( p ); bool try_bash_ter = one_in( 50 ); @@ -1415,14 +1415,14 @@ 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( flag_CLIMBABLE, destination ) ) { + if( g->m.has_flag( "CLIMBABLE", destination ) ) { if( g->m.impassable( destination ) && critter == nullptr ) { if( flies() ) { moves -= 100; force = true; if( g->u.sees( *this ) ) { add_msg( _( "The %1$s flies over the %2$s." ), name(), - g->m.has_flag_furn( flag_CLIMBABLE, p ) ? g->m.furnname( p ) : + g->m.has_flag_furn( "CLIMBABLE", p ) ? g->m.furnname( p ) : g->m.tername( p ) ); } } else if( climbs() ) { @@ -1430,7 +1430,7 @@ bool monster::move_to( const tripoint &p, bool force, const float stagger_adjust force = true; if( g->u.sees( *this ) ) { add_msg( _( "The %1$s climbs over the %2$s." ), name(), - g->m.has_flag_furn( flag_CLIMBABLE, p ) ? g->m.furnname( p ) : + g->m.has_flag_furn( "CLIMBABLE", p ) ? g->m.furnname( p ) : g->m.tername( p ) ); } } @@ -1498,17 +1498,15 @@ 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( flag_SHARP, pos() ) && !one_in( 4 ) && - get_armor_cut( bp_torso ) < sharp_damage ) { + if( g->m.has_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( flag_ROUGH, pos() ) && one_in( 6 ) && - get_armor_cut( bp_torso ) < rough_damage ) { + if( g->m.has_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( flag_UNSTABLE, destination ) && on_ground ) { + if( g->m.has_flag( "UNSTABLE", destination ) && on_ground ) { add_effect( effect_bouldering, 1_turns, num_bp, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); @@ -1525,10 +1523,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( flag_DIGGABLE, pos() ); + underwater = g->m.has_flag( "DIGGABLE", pos() ); } // Diggers turn the dirt into dirtmound - if( digging() && g->m.has_flag( flag_DIGGABLE, pos() ) ) { + if( digging() && g->m.has_flag( "DIGGABLE", pos() ) ) { int factor = 0; switch( type->size ) { case MS_TINY: diff --git a/src/monster.cpp b/src/monster.cpp index 9fccb53f8a3f8..1a1594433b278 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -434,16 +434,16 @@ std::string monster::name( unsigned int quantity ) const std::string monster::name_with_armor() const { std::string ret; - if( type->in_species( species_INSECT ) ) { + if( type->in_species( INSECT ) ) { ret = _( "carapace" ); - } else if( made_of( material_veggy ) ) { + } else if( made_of( material_id( "veggy" ) ) ) { ret = _( "thick bark" ); - } else if( made_of( material_bone ) ) { + } else if( made_of( material_id( "bone" ) ) ) { ret = _( "exoskeleton" ); - } else if( made_of( material_flesh ) || made_of( material_hflesh ) || - made_of( material_iflesh ) ) { + } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "hflesh" ) ) || + made_of( material_id( "iflesh" ) ) ) { ret = _( "thick hide" ); - } else if( made_of( material_iron ) || made_of( material_steel ) ) { + } else if( made_of( material_id( "iron" ) ) || made_of( material_id( "steel" ) ) ) { ret = _( "armor plating" ); } else if( made_of( LIQUID ) ) { ret = _( "dense jelly mass" ); @@ -925,7 +925,7 @@ monster_attitude monster::attitude( const Character *u ) const } // Zombies don't understand not attacking NPCs, but dogs and bots should. const npc *np = dynamic_cast< const npc * >( u ); - if( np != nullptr && np->get_attitude() != NPCATT_KILL && !type->in_species( species_ZOMBIE ) ) { + if( np != nullptr && np->get_attitude() != NPCATT_KILL && !type->in_species( ZOMBIE ) ) { return MATT_FRIEND; } if( np != nullptr && np->is_hallucination() ) { @@ -953,14 +953,14 @@ monster_attitude monster::attitude( const Character *u ) const } } - if( type->in_species( species_FUNGUS ) && ( u->has_trait( trait_MYCUS_THRESH ) || - u->has_trait( trait_MYCUS_FRIEND ) ) ) { + if( type->in_species( FUNGUS ) && ( u->has_trait( trait_MYCUS_THRESH ) || + u->has_trait( trait_MYCUS_FRIEND ) ) ) { return MATT_FRIEND; } if( effective_anger >= 10 && - ( ( type->in_species( species_MAMMAL ) && u->has_trait( trait_PHEROMONE_MAMMAL ) ) || - ( type->in_species( species_INSECT ) && u->has_trait( trait_PHEROMONE_INSECT ) ) ) ) { + ( ( type->in_species( MAMMAL ) && u->has_trait( trait_PHEROMONE_MAMMAL ) ) || + ( type->in_species( INSECT ) && u->has_trait( trait_PHEROMONE_INSECT ) ) ) ) { effective_anger -= 20; } @@ -1147,14 +1147,14 @@ bool monster::is_immune_effect( const efftype_id &effect ) const if( effect == effect_bleed ) { return !has_flag( MF_WARM ) || - !made_of( material_flesh ); + !made_of( material_id( "flesh" ) ); } if( effect == effect_paralyzepoison || effect == effect_badpoison || effect == effect_poison ) { return !has_flag( MF_WARM ) || - ( !made_of( material_flesh ) && !made_of( material_iflesh ) ); + ( !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ) ); } if( effect == effect_stunned ) { @@ -1184,7 +1184,7 @@ bool monster::is_immune_damage( const damage_type dt ) const return false; case DT_HEAT: // Ugly hardcode - remove later - return made_of( material_steel ) || made_of( material_stone ); + return made_of( material_id( "steel" ) ) || made_of( material_id( "stone" ) ); case DT_COLD: return false; case DT_ELECTRIC: @@ -1527,8 +1527,8 @@ bool monster::move_effects( bool ) } // non-friendly monster will struggle to get free occasionally. // some monsters cant be tangled up with a net/bolas/lassoo etc. - bool immediate_break = type->in_species( species_FISH ) || type->in_species( species_MOLLUSK ) || - type->in_species( species_ROBOT ) || type->bodytype == "snake" || type->bodytype == "blob"; + bool immediate_break = type->in_species( FISH ) || type->in_species( MOLLUSK ) || + type->in_species( ROBOT ) || type->bodytype == "snake" || type->bodytype == "blob"; if( !immediate_break && rng( 0, 900 ) > type->melee_dice * type->melee_sides * 1.5 ) { if( u_see_me ) { add_msg( _( "The %s struggles to break free of its bonds." ), name() ); @@ -2001,7 +2001,7 @@ void monster::process_turn() explosion_handler::emp_blast( zap ); // Fries electronics due to the intensity of the field } const auto t = g->m.ter( zap ); - if( t == ter_gas_pump || t == ter_gas_pump_a ) { + if( t == ter_str_id( "t_gas_pump" ) || t == ter_str_id( "t_gas_pump_a" ) ) { if( one_in( 4 ) ) { explosion_handler::explosion( pos(), 40, 0.8, true ); if( player_sees ) { @@ -2279,9 +2279,9 @@ void monster::process_one_effect( effect &it, bool is_new ) effect_cache[MOVEMENT_IMPAIRED] = true; } else if( id == effect_onfire ) { int dam = 0; - if( made_of( material_veggy ) ) { + if( made_of( material_id( "veggy" ) ) ) { dam = rng( 10, 20 ); - } else if( made_of( material_flesh ) || made_of( material_iflesh ) ) { + } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "iflesh" ) ) ) { dam = rng( 5, 10 ); } @@ -2378,12 +2378,12 @@ bool monster::make_fungus() } char polypick = 0; const mtype_id &tid = type->id; - if( type->in_species( species_FUNGUS ) ) { // No friendly-fungalizing ;-) + if( type->in_species( FUNGUS ) ) { // No friendly-fungalizing ;-) return true; } - if( !made_of( material_flesh ) && !made_of( material_hflesh ) && - !made_of( material_veggy ) && !made_of( material_iflesh ) && - !made_of( material_bone ) ) { + if( !made_of( material_id( "flesh" ) ) && !made_of( material_id( "hflesh" ) ) && + !made_of( material_id( "veggy" ) ) && !made_of( material_id( "iflesh" ) ) && + !made_of( material_id( "bone" ) ) ) { // No fungalizing robots or weird stuff (mi-gos are technically fungi, blobs are goo) return true; } @@ -2417,7 +2417,7 @@ bool monster::make_fungus() polypick = 7; } else if( tid == mon_zombie_gasbag ) { polypick = 8; - } else if( type->in_species( species_SPIDER ) && get_size() > MS_TINY ) { + } else if( type->in_species( SPIDER ) && get_size() > MS_TINY ) { polypick = 9; } @@ -2827,7 +2827,7 @@ void monster::on_load() if( regen <= 0 ) { if( has_flag( MF_REVIVES ) ) { regen = 1.0f / to_turns( 1_hours ); - } else if( made_of( material_flesh ) || made_of( material_veggy ) ) { + } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "veggy" ) ) ) { // Most living stuff here regen = 0.25f / to_turns( 1_hours ); } diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index c034b8c163e66..810c5750ec77a 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -26,7 +26,6 @@ #include "pathfinding.h" #include "units.h" #include "translations.h" -#include "cata_string_consts.h" namespace io { @@ -1101,7 +1100,7 @@ void mtype::remove_special_attacks( const JsonObject &jo, const std::string &mem void MonsterGenerator::check_monster_definitions() const { for( const auto &mon : mon_templates->get_all() ) { - if( mon.harvest == "null" && !mon.has_flag( MF_ELECTRONIC ) && mon.id != mon_null ) { + if( mon.harvest == "null" && !mon.has_flag( MF_ELECTRONIC ) && mon.id != mtype_id( "mon_null" ) ) { debugmsg( "monster %s has no harvest entry", mon.id.c_str(), mon.harvest.c_str() ); } for( auto &spec : mon.species ) { diff --git a/src/morale.cpp b/src/morale.cpp index 390acc6859f2a..c13b6f34d55ad 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( flag_FANCY ); - const bool super_fancy = it.has_flag( flag_SUPER_FANCY ); - const bool filthy_gear = it.has_flag( flag_FILTHY ); + 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 int sign = ( worn ) ? 1 : -1; const auto update_body_part = [&]( body_part_data & bp_data ) { diff --git a/src/mtype.cpp b/src/mtype.cpp index d9b608349c3b6..fe3780a22e7e3 100644 --- a/src/mtype.cpp +++ b/src/mtype.cpp @@ -22,7 +22,7 @@ mtype::mtype() size = MS_MEDIUM; volume = 62499_ml; weight = 81499_gram; - mat = { material_flesh }; + mat = { material_id( "flesh" ) }; phase = SOLID; def_chance = 0; upgrades = false; @@ -152,13 +152,13 @@ field_type_id mtype::bloodType() const if( has_flag( MF_LARVA ) || has_flag( MF_ARTHROPOD_BLOOD ) ) { return fd_blood_invertebrate; } - if( made_of( material_veggy ) ) { + if( made_of( material_id( "veggy" ) ) ) { return fd_blood_veggy; } - if( made_of( material_iflesh ) ) { + if( made_of( material_id( "iflesh" ) ) ) { return fd_blood_insect; } - if( has_flag( MF_WARM ) && made_of( material_flesh ) ) { + if( has_flag( MF_WARM ) && made_of( material_id( "flesh" ) ) ) { return fd_blood; } return fd_null; @@ -166,16 +166,16 @@ field_type_id mtype::bloodType() const field_type_id mtype::gibType() const { - if( has_flag( MF_LARVA ) || in_species( species_MOLLUSK ) ) { + if( has_flag( MF_LARVA ) || in_species( MOLLUSK ) ) { return fd_gibs_invertebrate; } - if( made_of( material_veggy ) ) { + if( made_of( material_id( "veggy" ) ) ) { return fd_gibs_veggy; } - if( made_of( material_iflesh ) ) { + if( made_of( material_id( "iflesh" ) ) ) { return fd_gibs_insect; } - if( made_of( material_flesh ) ) { + if( made_of( material_id( "flesh" ) ) ) { return fd_gibs_flesh; } // There are other materials not listed here like steel, protoplasmic, powder, null, stone, bone @@ -185,18 +185,18 @@ field_type_id mtype::gibType() const itype_id mtype::get_meat_itype() const { if( has_flag( MF_POISON ) ) { - if( made_of( material_flesh ) || made_of( material_hflesh ) ) { + if( made_of( material_id( "flesh" ) ) || made_of( material_id( "hflesh" ) ) ) { return "meat_tainted"; - } else if( made_of( material_iflesh ) ) { + } else if( made_of( material_id( "iflesh" ) ) ) { //In the future, insects could drop insect flesh rather than plain ol' meat. return "meat_tainted"; - } else if( made_of( material_veggy ) ) { + } else if( made_of( material_id( "veggy" ) ) ) { return "veggy_tainted"; - } else if( made_of( material_bone ) ) { + } else if( made_of( material_id( "bone" ) ) ) { return "bone_tainted"; } } else { - if( made_of( material_flesh ) || made_of( material_hflesh ) ) { + if( made_of( material_id( "flesh" ) ) || made_of( material_id( "hflesh" ) ) ) { if( has_flag( MF_HUMAN ) ) { return "human_flesh"; } else if( has_flag( MF_AQUATIC ) ) { @@ -204,12 +204,12 @@ itype_id mtype::get_meat_itype() const } else { return "meat"; } - } else if( made_of( material_iflesh ) ) { + } else if( made_of( material_id( "iflesh" ) ) ) { //In the future, insects could drop insect flesh rather than plain ol' meat. return "meat"; - } else if( made_of( material_veggy ) ) { + } else if( made_of( material_id( "veggy" ) ) ) { return "veggy"; - } else if( made_of( material_bone ) ) { + } else if( made_of( material_id( "bone" ) ) ) { return "bone"; } } diff --git a/src/mtype.h b/src/mtype.h index dcbfb7d4b9b33..d28bc9f100be2 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -34,6 +34,8 @@ using bodytype_id = std::string; class JsonArray; class JsonObject; +using itype_id = std::string; + // These are triggers which may affect the monster's anger or morale. // They are handled in monster::check_triggers(), in monster.cpp enum class mon_trigger { diff --git a/src/mutation.cpp b/src/mutation.cpp index 09dccd52a9188..3992cd011923c 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( flag_CANT_HEAL_EVERYONE ); + can_use = !med.has_flag( "CANT_HEAL_EVERYONE" ); } if( !can_use ) { @@ -440,7 +440,7 @@ void Character::activate_mutation( const trait_id &mut ) invoke_item( &burrowing_item ); return; // handled when the activity finishes } else if( mut == trait_SLIMESPAWNER ) { - monster *const slime = g->place_critter_around( mon_player_blob, pos(), 1 ); + monster *const slime = g->place_critter_around( mtype_id( "mon_player_blob" ), pos(), 1 ); if( !slime ) { // Oops, no room to divide! add_msg_if_player( m_bad, _( "You focus, but are too hemmed in to birth a new slimespring!" ) ); @@ -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( flag_TREE, p2 ) ) { + if( g->m.has_flag( "TREE", p2 ) ) { adjacent_tree = true; } } diff --git a/src/mutation.h b/src/mutation.h index 8ace795b7801d..363e751363194 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -27,6 +27,7 @@ struct dream; class Trait_group; class item; +using itype_id = std::string; class JsonArray; extern std::vector dreams; diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index 85575999b628c..40851bd7378c3 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( flag_no_auto_equip ) ) { - it.unset_flag( flag_no_auto_equip ); + if( it.has_flag( "no_auto_equip" ) ) { + it.unset_flag( "no_auto_equip" ); inv.push_back( it ); - } else if( it.has_flag( flag_auto_wield ) ) { - it.unset_flag( flag_auto_wield ); + } else if( it.has_flag( "auto_wield" ) ) { + it.unset_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( flag_no_auto_equip ) ) { + if( it.has_flag( "no_auto_equip" ) ) { buffer_inventory += it.display_name() + "\n"; - } else if( it.has_flag( flag_auto_wield ) ) { + } else if( it.has_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( flag_SECRET ) ) { + if( r.has_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( flag_CITY_START ) != b->has_flag( flag_CITY_START ) ) { - return a->has_flag( flag_CITY_START ) < b->has_flag( flag_CITY_START ); + if( !cities_enabled && a->has_flag( "CITY_START" ) != b->has_flag( "CITY_START" ) ) { + return a->has_flag( "CITY_START" ) < b->has_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( flag_CITY_START ) ) { + if( !scenario_sorter.cities_enabled && g->scen->has_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( flag_CITY_START ) && !scenario_sorter.cities_enabled ) { + if( sorted_scens[cur_id]->has_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,12 +1983,11 @@ 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( flag_CITY_START ) && + if( sorted_scens[i] == sorted_scens[cur_id] && ( sorted_scens[i]->has_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( flag_CITY_START ) && - !scenario_sorter.cities_enabled ) ) { + } else if( sorted_scens[i] != sorted_scens[cur_id] && ( sorted_scens[i]->has_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 ); @@ -2038,45 +2037,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( flag_SPR_START ) ) { + if( sorted_scens[cur_id]->has_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( flag_SUM_START ) ) { + } else if( sorted_scens[cur_id]->has_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( flag_AUT_START ) ) { + } else if( sorted_scens[cur_id]->has_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( flag_WIN_START ) ) { + } else if( sorted_scens[cur_id]->has_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( flag_SUM_ADV_START ) ) { + } else if( sorted_scens[cur_id]->has_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( flag_INFECTED ) ) { + if( sorted_scens[cur_id]->has_flag( "INFECTED" ) ) { wprintz( w_flags, c_light_gray, _( "Infected player" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } - if( sorted_scens[cur_id]->has_flag( flag_BAD_DAY ) ) { + if( sorted_scens[cur_id]->has_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( flag_FIRE_START ) ) { + if( sorted_scens[cur_id]->has_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( flag_SUR_START ) ) { + if( sorted_scens[cur_id]->has_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( flag_HELI_CRASH ) ) { + if( sorted_scens[cur_id]->has_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( flag_LONE_START ) ) { + sorted_scens[cur_id]->has_flag( "LONE_START" ) ) { wprintz( w_flags, c_light_gray, _( "No starting NPC" ) ); wprintz( w_flags, c_light_gray, ( "\n" ) ); } @@ -2101,7 +2100,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( flag_CITY_START ) && !scenario_sorter.cities_enabled ) { + if( sorted_scens[cur_id]->has_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 8d267cea57006..c0ec9b68fda0d 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( flag_VARSIZE ) ) { + if( e.has_flag( "VARSIZE" ) ) { e.item_tags.insert( "FIT" ); } } @@ -437,7 +437,7 @@ faction_id npc::get_fac_id() const faction *npc::get_faction() const { if( !my_fac ) { - return g->faction_manager_ptr->get( faction_no_faction ); + return g->faction_manager_ptr->get( faction_id( "no_faction" ) ); } return my_fac; } @@ -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( flag_VARSIZE ) ) { + if( it.has_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( flag_VARSIZE ) ) { + if( !one_in( 3 ) && tmp.has_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( flag_TRADER_AVOID ); + return e.has_flag( "TRADER_AVOID" ); } ), res.end() ); for( auto &it : res ) { it.set_owner( who ); @@ -804,7 +804,7 @@ bool npc::can_read( const item &book, std::vector &fail_reasons ) // Check for conditions that disqualify us if( type->intel > 0 && has_trait( trait_ILLITERATE ) ) { fail_reasons.emplace_back( _( "I can't read!" ) ); - } else if( has_trait( trait_HYPEROPIC ) && !worn_with_flag( flag_FIX_FARSIGHT ) && + } else if( has_trait( trait_HYPEROPIC ) && !worn_with_flag( "FIX_FARSIGHT" ) && !has_effect( effect_contacts ) && !has_bionic( bio_eye_optic ) ) { fail_reasons.emplace_back( _( "I can't read without my glasses." ) ); } else if( fine_detail_vision_mod() > 4 ) { @@ -844,7 +844,7 @@ void npc::finish_read( item &book ) const skill_id &skill = reading->skill; // NPCs dont need to identify the book or learn recipes yet. // NPCs dont read to other NPCs yet. - const bool display_messages = my_fac->id == faction_your_followers && g->u.sees( pos() ); + const bool display_messages = my_fac->id == faction_id( "your_followers" ) && g->u.sees( pos() ); bool continuous = false; //whether to continue reading or not std::set little_learned; // NPCs who learned a little about the skill std::set cant_learn; @@ -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( flag_SPLINT ) ) { + if( it.has_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( flag_SPLINT ) ) ) { + if( iter != worn.end() && !( is_limb_broken( bp_to_hp( bp ) ) && iter->has_flag( "SPLINT" ) ) ) { took_off = takeoff( *iter ); break; } @@ -1278,7 +1278,7 @@ void npc::mutiny() // feel for you, but also reduces their respect for you. my_fac->likes_u = std::max( 0, my_fac->likes_u / 2 + 10 ); my_fac->respects_u -= 5; - set_fac( faction_amf ); + set_fac( faction_id( "amf" ) ); say( _( " Adios, motherfucker!" ), sounds::sound_t::order ); if( seen ) { my_fac->known_by_u = true; @@ -1346,7 +1346,7 @@ void npc::make_angry() } // Make associated faction, if any, angry at the player too. - if( my_fac && my_fac->id != faction_no_faction && my_fac->id != faction_amf ) { + if( my_fac && my_fac->id != faction_id( "no_faction" ) && my_fac->id != faction_id( "amf" ) ) { my_fac->likes_u = std::min( -15, my_fac->likes_u - 5 ); my_fac->respects_u = std::min( -15, my_fac->respects_u - 5 ); } @@ -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( flag_BOMB ) && it.active ) || it.made_of( LIQUID ) ) { + if( it.is_dangerous() || ( it.has_flag( "BOMB" ) && it.active ) || it.made_of( LIQUID ) ) { // NPCs won't be interested in buying active explosives or spilled liquids return -1000; } @@ -1865,7 +1865,7 @@ bool npc::is_ally( const player &p ) const return true; } if( p.is_player() ) { - if( my_fac && my_fac->id == faction_your_followers ) { + if( my_fac && my_fac->id == faction_id( "your_followers" ) ) { return true; } if( faction_api_version < 2 ) { @@ -2673,7 +2673,7 @@ void npc::on_load() has_new_items = true; // for spawned npcs - if( g->m.has_flag( flag_UNSTABLE, pos() ) ) { + if( g->m.has_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/npc_favor.h b/src/npc_favor.h index 0ba8d7b2b1661..6b285da89e270 100644 --- a/src/npc_favor.h +++ b/src/npc_favor.h @@ -6,6 +6,7 @@ #include "type_id.h" +using itype_id = std::string; class JsonIn; class JsonOut; diff --git a/src/npcmove.cpp b/src/npcmove.cpp index e102d9b385c47..6c2e959967ec7 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -159,7 +159,7 @@ static bool clear_shot_reach( const tripoint &from, const tripoint &to, bool che tripoint npc::good_escape_direction( bool include_pos ) { if( path.empty() ) { - zone_type_id retreat_zone = zone_type_NPC_RETREAT; + zone_type_id retreat_zone = zone_type_id( "NPC_RETREAT" ); const tripoint &abs_pos = global_square_location(); const zone_manager &mgr = zone_manager::get_manager(); cata::optional retreat_target = mgr.get_nearest( retreat_zone, abs_pos, 60, @@ -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( flag_FIREWOOD ); + it.has_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( flag_DOOR, p ) ) { + } else if( g->m.passable( p ) && !g->m.has_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 ), @@ -2279,7 +2279,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo moves -= 100; moved = true; } - } else if( get_dex() > 1 && g->m.has_flag_ter_or_furn( flag_CLIMBABLE, p ) ) { + } else if( get_dex() > 1 && g->m.has_flag_ter_or_furn( "CLIMBABLE", p ) ) { ///\EFFECT_DEX_NPC increases chance to climb CLIMBABLE furniture or terrain int climb = get_dex(); if( one_in( climb ) ) { @@ -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( flag_UNSTABLE, pos() ) ) { + if( g->m.has_flag( "UNSTABLE", pos() ) ) { add_effect( effect_bouldering, 1_turns, num_bp, true ); } else if( has_effect( effect_bouldering ) ) { remove_effect( effect_bouldering ); @@ -2719,13 +2719,15 @@ void npc::find_item() continue; } const cata::optional cargo = vp.part_with_feature( VPFLAG_CARGO, true ); + static const std::string locked_string( "LOCKED" ); // TODO: Let player know what parts are safe from NPC thieves - if( !cargo || cargo->has_feature( flag_LOCKED ) ) { + if( !cargo || cargo->has_feature( locked_string ) ) { cache_tile(); continue; } - if( vp.part_with_feature( flag_CARGO_LOCKING, true ) ) { + static const std::string cargo_locking_string( "CARGO_LOCKING" ); + if( vp.part_with_feature( cargo_locking_string, true ) ) { cache_tile(); continue; } @@ -2778,11 +2780,11 @@ void npc::pick_up_item() const cata::optional vp = g->m.veh_at( wanted_item_pos ).part_with_feature( VPFLAG_CARGO, false ); - const bool has_cargo = vp && !vp->has_feature( flag_LOCKED ); + const bool has_cargo = vp && !vp->has_feature( "LOCKED" ); if( ( !g->m.has_items( wanted_item_pos ) && !has_cargo && !g->m.is_harvestable( wanted_item_pos ) && sees( wanted_item_pos ) ) || - ( is_player_ally() && g->check_zone( zone_type_NO_NPC_PICKUP, wanted_item_pos ) ) ) { + ( is_player_ally() && g->check_zone( zone_type_id( "NO_NPC_PICKUP" ), wanted_item_pos ) ) ) { // Items we wanted no longer exist and we can see it // Or player who is leading us doesn't want us to pick it up fetching_item = false; @@ -3330,7 +3332,7 @@ bool npc::alt_attack() } // Are we going to throw this item? - if( !used->active && used->has_flag( flag_NPC_ACTIVATE ) ) { + if( !used->active && used->has_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 @@ -3525,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( flag_NO_PARASITES ) ) { + if( food->parasites && !it.has_flag( "NO_PARASITES" ) ) { return 0.0; } @@ -3813,8 +3815,8 @@ void npc::reach_omt_destination() if( is_player_ally() ) { talk_function::assign_guard( *this ); if( rl_dist( g->u.pos(), pos() ) > SEEX * 2 || !g->u.sees( pos() ) ) { - if( g->u.has_item_with_flag( flag_TWO_WAY_RADIO, true ) && - has_item_with_flag( flag_TWO_WAY_RADIO, true ) ) { + if( g->u.has_item_with_flag( "TWO_WAY_RADIO", true ) && + has_item_with_flag( "TWO_WAY_RADIO", true ) ) { add_msg( m_info, _( "From your two-way radio you hear %s reporting in, " "'I've arrived, boss!'" ), disp_name() ); } @@ -4348,7 +4350,7 @@ bool npc::adjust_worn() }; for( auto &elem : worn ) { - if( !elem.has_flag( flag_SPLINT ) ) { + if( !elem.has_flag( "SPLINT" ) ) { continue; } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 3d4dee38821ed..057d64175f359 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -2064,7 +2064,7 @@ void talk_effect_fun_t::set_change_faction_rep( int rep_change ) { function = [rep_change]( const dialogue & d ) { npc &p = *d.beta; - if( p.get_faction()->id != faction_no_faction ) { + if( p.get_faction()->id != faction_id( "no_faction" ) ) { p.get_faction()->likes_u += rep_change; p.get_faction()->respects_u += rep_change; } @@ -3205,8 +3205,8 @@ std::string give_item_to( npc &p, bool allow_use ) } item &given = *loc; - if( ( &given == &g->u.weapon && given.has_flag( flag_NO_UNWIELD ) ) || ( g->u.is_worn( given ) && - given.has_flag( flag_NO_TAKEOFF ) ) ) { + if( ( &given == &g->u.weapon && given.has_flag( "NO_UNWIELD" ) ) || ( g->u.is_worn( given ) && + given.has_flag( "NO_TAKEOFF" ) ) ) { // Bionic weapon or shackles return _( "How?" ); } diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 0f896eb819ad3..ed70978582e8a 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -690,7 +690,7 @@ void talk_function::follow( npc &p ) { g->add_npc_follower( p.getID() ); p.set_attitude( NPCATT_FOLLOW ); - p.set_fac( faction_your_followers ); + p.set_fac( faction_id( "your_followers" ) ); g->u.cash += p.cash; p.cash = 0; } @@ -753,8 +753,8 @@ void talk_function::leave( npc &p ) new_fac_id += p.name; // create a new "lone wolf" faction for this one NPC faction *new_solo_fac = g->faction_manager_ptr->add_new_faction( p.name, - faction_id( new_fac_id ), faction_no_faction ); - p.set_fac( new_solo_fac ? new_solo_fac->id : faction_no_faction ); + faction_id( new_fac_id ), faction_id( "no_faction" ) ); + p.set_fac( new_solo_fac ? new_solo_fac->id : faction_id( "no_faction" ) ); if( new_solo_fac ) { new_solo_fac->known_by_u = true; } diff --git a/src/npctrade.cpp b/src/npctrade.cpp index ea722164791e2..4a3cbab663727 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( flag_NO_UNWIELD ) + !np.weapon.has_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( flag_NO_UNWIELD ) ) { + if( !seller.weapon.has_flag( "NO_UNWIELD" ) ) { check_item( item_location( seller, &seller.weapon ), 1 ); } diff --git a/src/overmap.cpp b/src/overmap.cpp index 4c04f0e550080..555b786d0b879 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1765,7 +1765,7 @@ bool overmap::generate_sub( const int z ) continue; } mongroup_id ant_group( ter( i.pos + tripoint_above ) == "anthill" ? - GROUP_ANT : GROUP_ANT_ACID ); + "GROUP_ANT" : "GROUP_ANT_ACID" ); add_mon_group( mongroup( ant_group, tripoint( i.pos.x * 2, i.pos.y * 2, z ), ( i.size * 3 ) / 2, rng( 6000, 8000 ) ) ); build_anthill( tripoint( i.pos, z ), i.size ); @@ -1980,8 +1980,8 @@ void overmap::move_hordes() // Check if the monster is a zombie. auto &type = *( this_monster.type ); if( - !type.species.count( species_ZOMBIE ) || // Only add zombies to hordes. - type.id == mon_jabberwock || // Jabberwockies are an exception. + !type.species.count( ZOMBIE ) || // Only add zombies to hordes. + type.id == mtype_id( "mon_jabberwock" ) || // Jabberwockies are an exception. this_monster.get_speed() <= 30 || // So are very slow zombies, like crawling zombies. this_monster.has_effect( effect_pet ) || // "Zombie pet" zlaves are, too. !this_monster.will_join_horde( INT_MAX ) || // So are zombies who won't join a horde of any size. diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 1287fb88ca9e0..4343ce4eeb057 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -478,7 +478,7 @@ void draw( const catacurses::window &w, const catacurses::window &wbar, const tr // Whether showing hordes is currently enabled const bool showhordes = uistate.overmap_show_hordes; - const oter_id forest = oter_forest.id(); + const oter_id forest = oter_str_id( "forest" ).id(); std::string sZoneName; tripoint tripointZone = tripoint( -1, -1, -1 ); @@ -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( flag_SWIMMABLE, g->u.pos() ) ) { + if( is_river_or_lake( oter ) || g->m.has_flag( "SWIMMABLE", g->u.pos() ) ) { ptype.amphibious = true; } } diff --git a/src/panels.cpp b/src/panels.cpp index 28556f76f9d95..0a59e6578bb03 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -867,7 +867,7 @@ static void draw_limb_health( avatar &u, const catacurses::window &w, int limb_i nc_color color = c_light_red; const auto bp = avatar::hp_to_bp( static_cast( limb_index ) ); - if( u.worn_with_flag( flag_SPLINT, bp ) ) { + if( u.worn_with_flag( "SPLINT", bp ) ) { const auto &eff = u.get_effect( effect_mending, bp ); const int mend_perc = eff.is_null() ? 0.0 : 100 * eff.get_duration() / eff.get_max_duration(); diff --git a/src/pathfinding.cpp b/src/pathfinding.cpp index 1b24ec8a85e97..2857b3f6efff8 100644 --- a/src/pathfinding.cpp +++ b/src/pathfinding.cpp @@ -23,7 +23,6 @@ #include "line.h" #include "type_id.h" #include "point.h" -#include "cata_string_consts.h" enum astar_state { ASL_NONE, @@ -335,7 +334,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( flag_OPENCLOSE_INSIDE ) || !furniture.has_flag( flag_OPENCLOSE_INSIDE ) || + ( !terrain.has_flag( "OPENCLOSE_INSIDE" ) || !furniture.has_flag( "OPENCLOSE_INSIDE" ) || !is_outside( cur ) ) ) { // Only try to open INSIDE doors from the inside // To open and then move onto the tile @@ -345,7 +344,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, part = vpobst ? vpobst->part_index() : -1; int dummy = -1; if( doors && veh->part_flag( part, VPFLAG_OPENABLE ) && - ( !veh->part_flag( part, flag_OPENCLOSE_INSIDE ) || + ( !veh->part_flag( part, "OPENCLOSE_INSIDE" ) || veh_at_internal( cur, dummy ) == veh ) ) { // Handle car doors, but don't try to path through curtains newg += 10; // One turn to open, 4 to move there diff --git a/src/pickup.cpp b/src/pickup.cpp index c0abaf506cbf9..2dafb6bba70f4 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( flag_NO_UNWIELD ), 'w', + amenu.addentry( WIELD, !u.weapon.has_flag( "NO_UNWIELD" ), 'w', _( "Dispose of %s and wield %s" ), u.weapon.display_name(), it.display_name() ); } else { @@ -419,7 +419,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) if( min != -1 ) { if( veh != nullptr && get_items_from == prompt ) { - const cata::optional carg = vp.part_with_feature( flag_CARGO, false ); + const cata::optional carg = vp.part_with_feature( "CARGO", false ); const bool veh_has_items = carg && !veh->get_items( carg->part_index() ).empty(); const bool map_has_items = g->m.has_items( p ); if( veh_has_items && map_has_items ) { @@ -433,12 +433,12 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) } } if( get_items_from == from_cargo ) { - const cata::optional carg = vp.part_with_feature( flag_CARGO, false ); + const cata::optional carg = vp.part_with_feature( "CARGO", false ); cargo_part = carg ? carg->part_index() : -1; from_vehicle = cargo_part >= 0; } else { // Nothing to change, default is to pick from ground anyway. - if( g->m.has_flag( flag_SEALED, p ) ) { + if( g->m.has_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_NO_AUTO_PICKUP, p ) ) { + if( g->check_zone( zone_type_id( "NO_AUTO_PICKUP" ), p ) ) { return; - } else if( g->m.has_flag( flag_SEALED, p ) ) { + } else if( g->m.has_flag( "SEALED", p ) ) { return; } } diff --git a/src/player.cpp b/src/player.cpp index 71578f08d6483..fbcf09cb5a310 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -461,8 +461,8 @@ 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( flag_ROAD, pos() ); - const bool on_fungus = g->m.has_flag_ter_or_furn( flag_FUNGUS, pos() ); + const bool on_road = flatground && g->m.has_flag( "ROAD", pos() ); + const bool on_fungus = g->m.has_flag_ter_or_furn( "FUNGUS", pos() ); if( !is_mounted() ) { if( movecost > 100 ) { @@ -501,13 +501,13 @@ int player::run_cost( int base_cost, bool diag ) const movecost *= 1.1f; } - if( worn_with_flag( flag_SLOWS_MOVEMENT ) ) { + if( worn_with_flag( "SLOWS_MOVEMENT" ) ) { movecost *= 1.1f; } - if( worn_with_flag( flag_FIN ) ) { + if( worn_with_flag( "FIN" ) ) { movecost *= 1.5f; } - if( worn_with_flag( flag_ROLLER_INLINE ) ) { + if( worn_with_flag( "ROLLER_INLINE" ) ) { if( on_road ) { movecost *= 0.5f; } else { @@ -516,7 +516,7 @@ int player::run_cost( int base_cost, bool diag ) const } // Quad skates might be more stable than inlines, // but that also translates into a slower speed when on good surfaces. - if( worn_with_flag( flag_ROLLER_QUAD ) ) { + if( worn_with_flag( "ROLLER_QUAD" ) ) { if( on_road ) { movecost *= 0.7f; } else { @@ -525,7 +525,7 @@ int player::run_cost( int base_cost, bool diag ) const } // Skates with only one wheel (roller shoes) are fairly less stable // and fairly slower as well - if( worn_with_flag( flag_ROLLER_ONE ) ) { + if( worn_with_flag( "ROLLER_ONE" ) ) { if( on_road ) { movecost *= 0.85f; } else { @@ -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( flag_DIGGABLE, pos() ) ) { + if( has_trait( trait_ROOTS3 ) && g->m.has_flag( "DIGGABLE", pos() ) ) { movecost += 10 * footwear_factor(); } @@ -594,8 +594,8 @@ int player::swim_speed() const ret -= hand_bonus_mult * ( 20 + str_cur * 4 ); } /** @EFFECT_STR increases swim speed bonus from swim_fins */ - if( worn_with_flag( flag_FIN, bp_foot_l ) || worn_with_flag( flag_FIN, bp_foot_r ) ) { - if( worn_with_flag( flag_FIN, bp_foot_l ) && worn_with_flag( flag_FIN, bp_foot_r ) ) { + if( worn_with_flag( "FIN", bp_foot_l ) || worn_with_flag( "FIN", bp_foot_r ) ) { + if( worn_with_flag( "FIN", bp_foot_l ) && worn_with_flag( "FIN", bp_foot_r ) ) { ret -= ( 15 * str_cur ); } else { ret -= ( 15 * str_cur ) / 2; @@ -618,7 +618,7 @@ int player::swim_speed() const /** @EFFECT_DEX increases swim speed */ ret -= str_cur * 6 + dex_cur * 4; - if( worn_with_flag( flag_FLOTATION ) ) { + if( worn_with_flag( "FLOTATION" ) ) { ret = std::min( ret, 400 ); ret = std::max( ret, 200 ); } @@ -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( flag_RADIO_ACTIVATION ) ) { + if( stack_iter.has_flag( "RADIO_ACTIVATION" ) ) { rc_items.push_back( &stack_iter ); } } for( auto &elem : worn ) { - if( elem.has_flag( flag_RADIO_ACTIVATION ) ) { + if( elem.has_flag( "RADIO_ACTIVATION" ) ) { rc_items.push_back( &elem ); } } if( is_armed() ) { - if( weapon.has_flag( flag_RADIO_ACTIVATION ) ) { + if( weapon.has_flag( "RADIO_ACTIVATION" ) ) { rc_items.push_back( &weapon ); } } @@ -962,7 +962,7 @@ int player::overmap_sight_range( int light_level ) const float multiplier = Character::mutation_value( "overmap_multiplier" ); // Binoculars double your sight range. - const bool has_optic = ( has_item_with_flag( flag_ZOOM ) || has_bionic( bio_eye_optic ) || + const bool has_optic = ( has_item_with_flag( "ZOOM" ) || has_bionic( bio_eye_optic ) || ( is_mounted() && mounted_creature->has_flag( MF_MECH_RECON_VISION ) ) ); if( has_optic ) { @@ -997,10 +997,10 @@ bool player::sight_impaired() const has_effect( effect_darkness ) ) && ( !( has_trait( trait_PER_SLIME_OK ) ) ) ) || ( underwater && !has_bionic( bio_membrane ) && !has_trait( trait_MEMBRANE ) && - !worn_with_flag( flag_SWIM_GOGGLES ) && !has_trait( trait_PER_SLIME_OK ) && + !worn_with_flag( "SWIM_GOGGLES" ) && !has_trait( trait_PER_SLIME_OK ) && !has_trait( trait_CEPH_EYES ) && !has_trait( trait_SEESLEEP ) ) || ( ( has_trait( trait_MYOPIC ) || has_trait( trait_URSINE_EYE ) ) && - !worn_with_flag( flag_FIX_NEARSIGHT ) && + !worn_with_flag( "FIX_NEARSIGHT" ) && !has_effect( effect_contacts ) && !has_bionic( bio_eye_optic ) ) || has_trait( trait_PER_SLIME ) ); @@ -1032,17 +1032,17 @@ bool player::avoid_trap( const tripoint &pos, const trap &tr ) const bool player::has_alarm_clock() const { - return ( has_item_with_flag( flag_ALARMCLOCK, true ) || + return ( has_item_with_flag( "ALARMCLOCK", true ) || ( g->m.veh_at( pos() ) && - !empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( flag_ALARMCLOCK ) ) ) || + !empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( "ALARMCLOCK" ) ) ) || has_bionic( bio_watch ) ); } bool player::has_watch() const { - return ( has_item_with_flag( flag_WATCH, true ) || + return ( has_item_with_flag( "WATCH", true ) || ( g->m.veh_at( pos() ) && - !empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( flag_WATCH ) ) ) || + !empty( g->m.veh_at( pos() )->vehicle().get_avail_parts( "WATCH" ) ) ) || has_bionic( bio_watch ) ); } @@ -1070,7 +1070,7 @@ void player::pause() bp_hand_r } }, true ); - } else if( g->m.has_flag( flag_SWIMMABLE, pos() ) ) { + } else if( g->m.has_flag( "SWIMMABLE", pos() ) ) { drench( 40, { { bp_foot_l, bp_foot_r, bp_leg_l, bp_leg_r } }, false ); } } @@ -1220,6 +1220,8 @@ bool player::is_dead_state() const void player::on_dodge( Creature *source, float difficulty ) { + static const matec_id tec_none( "tec_none" ); + // Each avoided hit consumes an available dodge // When no more available we are likely to fail player::dodge_roll dodges_left--; @@ -1240,7 +1242,7 @@ void player::on_dodge( Creature *source, float difficulty ) if( source && square_dist( pos(), source->pos() ) == 1 ) { matec_id tec = pick_technique( *source, used_weapon(), false, true, false ); - if( tec != matec_tec_none && !is_dead_state() ) { + if( tec != tec_none && !is_dead_state() ) { if( get_stamina() < get_stamina_max() / 3 ) { add_msg( m_bad, _( "You try to counterattack but you are too exhausted!" ) ); } else { @@ -1324,9 +1326,9 @@ void player::on_hit( Creature *source, body_part bp_hit, source->add_effect( effect_blind, 2_turns ); } } - if( worn_with_flag( flag_REQUIRES_BALANCE ) && !has_effect( effect_downed ) ) { + if( worn_with_flag( "REQUIRES_BALANCE" ) && !has_effect( effect_downed ) ) { int rolls = 4; - if( worn_with_flag( flag_ROLLER_ONE ) ) { + if( worn_with_flag( "ROLLER_ONE" ) ) { rolls += 2; } if( has_trait( trait_PROF_SKATER ) ) { @@ -1709,7 +1711,7 @@ void player::apply_damage( Creature *source, body_part hurt, int dam, const bool float player::fall_damage_mod() const { - if( has_effect_with_flag( flag_EFFECT_FEATHER_FALL ) ) { + if( has_effect_with_flag( "EFFECT_FEATHER_FALL" ) ) { return 0.0f; } float ret = 1.0f; @@ -1754,7 +1756,7 @@ int player::impact( const int force, const tripoint &p ) // TODO: Make cushioned items like bike helmets help more float armor_eff = 1.0f; // Shock Absorber CBM heavily reduces damage - const bool shock_absorbers = has_active_bionic( bio_shock_absorber ); + const bool shock_absorbers = has_active_bionic( bionic_id( "bio_shock_absorber" ) ); // Being slammed against things rather than landing means we can't // control the impact as well @@ -1773,14 +1775,14 @@ int player::impact( const int force, const tripoint &p ) // Slamming into vehicles // TODO: Integrate it with vehicle collision function somehow target_name = vp->vehicle().disp_name(); - if( vp.part_with_feature( flag_SHARP, true ) ) { + if( vp.part_with_feature( "SHARP", true ) ) { // Now we're actually getting impaled cut = force; // Lots of fun } mod = slam ? 1.0f : fall_damage_mod(); armor_eff = 0.25f; // Not much - if( !slam && vp->part_with_feature( flag_ROOF, true ) ) { + if( !slam && vp->part_with_feature( "ROOF", true ) ) { // Roof offers better landing than frame or pavement // TODO: Make this not happen with heavy duty/plated roof effective_force /= 2; @@ -1911,7 +1913,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( flag_LIQUID, to ) && g->m.has_flag( TFLAG_DEEP_WATER, to ) ) { + if( g->m.has_flag( "LIQUID", to ) && g->m.has_flag( TFLAG_DEEP_WATER, to ) ) { if( !is_npc() ) { avatar_action::swim( g->m, g->u, to ); } @@ -2378,7 +2380,7 @@ void player::process_items() item *cloak = nullptr; item *power_armor = nullptr; std::vector active_worn_items; - bool weapon_active = weapon.has_flag( flag_USE_UPS ) && + bool weapon_active = weapon.has_flag( "USE_UPS" ) && weapon.charges < weapon.type->maximum_charges(); std::vector active_held_items; int ch_UPS = 0; @@ -2390,18 +2392,18 @@ void player::process_items() } else if( identifier == "adv_UPS_off" ) { ch_UPS += it.ammo_remaining() / 0.6; } - if( it.has_flag( flag_USE_UPS ) && it.charges < it.type->maximum_charges() ) { + if( it.has_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( flag_USE_UPS ) && + if( w.has_flag( "USE_UPS" ) && w.charges < w.type->maximum_charges() ) { active_worn_items.push_back( &w ); } if( w.active ) { - if( cloak == nullptr && w.has_flag( flag_ACTIVE_CLOAKING ) ) { + if( cloak == nullptr && w.has_flag( "ACTIVE_CLOAKING" ) ) { cloak = &w; } // Only the main power armor item can be active, the other ones (hauling frame, helmet) aren't. @@ -2424,7 +2426,7 @@ void player::process_items() if( update_required ) { reset_encumbrance(); } - if( has_active_bionic( bio_ups ) ) { + if( has_active_bionic( bionic_id( "bio_ups" ) ) ) { ch_UPS += units::to_kilojoule( get_power_level() ); } int ch_UPS_used = 0; @@ -2612,7 +2614,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( flag_NO_INGEST ) ) { + if( target.has_flag( "NO_INGEST" ) ) { const auto &comest = *target.get_comestible(); // Assume that parenteral meds don't spoil, so don't apply rot modify_health( comest ); @@ -2767,7 +2769,7 @@ bool player::add_faction_warning( const faction_id &id ) warning_record[id] = std::make_pair( 1, calendar::turn ); } faction *fac = g->faction_manager_ptr->get( id ); - if( fac != nullptr && is_player() && fac->id != faction_no_faction ) { + if( fac != nullptr && is_player() && fac->id != faction_id( "no_faction" ) ) { fac->likes_u -= 1; fac->respects_u -= 1; } @@ -2810,7 +2812,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( flag_RELOAD_AND_SHOOT ) ? _( "Select ammo for %s" ) : _( "Reload %s" ), + base.has_flag( "RELOAD_AND_SHOOT" ) ? _( "Select ammo for %s" ) : _( "Reload %s" ), base.tname() ); menu.w_width = -1; menu.w_height = -1; @@ -3009,7 +3011,7 @@ item::reload_option player::select_ammo( const item &base, } return false; } - } cb( opts, draw_row, last_key, default_to, !base.has_flag( flag_RELOAD_ONE ) ); + } cb( opts, draw_row, last_key, default_to, !base.has_flag( "RELOAD_ONE" ) ); menu.callback = &cb; menu.query(); @@ -3054,11 +3056,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( flag_SPEEDLOADER ) || e->ammo_remaining() < 1 ) { + if( !ammo->has_flag( "SPEEDLOADER" ) || e->ammo_remaining() < 1 ) { ammo_match_found = true; } } - if( can_reload( *e, id ) || e->has_flag( flag_RELOAD_AND_SHOOT ) ) { + if( can_reload( *e, id ) || e->has_flag( "RELOAD_AND_SHOOT" ) ) { ammo_list.emplace_back( this, e, &base, std::move( ammo ) ); } } @@ -3135,11 +3137,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( flag_RESTRICT_HANDS ) ) ) { - if( worn_with_flag( flag_RESTRICT_HANDS ) ) { + if( it.is_two_handed( *this ) && ( !has_two_arms() || worn_with_flag( "RESTRICT_HANDS" ) ) ) { + if( worn_with_flag( "RESTRICT_HANDS" ) ) { return ret_val::make_failure( _( "Something you are wearing hinders the use of both hands." ) ); - } else if( it.has_flag( flag_ALWAYS_TWOHAND ) ) { + } else if( it.has_flag( "ALWAYS_TWOHAND" ) ) { return ret_val::make_failure( _( "The %s can't be wielded with only one arm." ), it.tname() ); } else { @@ -3174,25 +3176,25 @@ bool player::unwield() // ids of martial art styles that are available with the bio_cqb bionic. static const std::vector bio_cqb_styles{ { - style_aikido, - style_biojutsu, - style_boxing, - style_capoeira, - style_crane, - style_dragon, - style_judo, - style_karate, - style_krav_maga, - style_leopard, - style_muay_thai, - style_ninjutsu, - style_pankration, - style_snake, - style_taekwondo, - style_tai_chi, - style_tiger, - style_wingchun, - style_zui_quan + matype_id{ "style_aikido" }, + matype_id{ "style_biojutsu" }, + matype_id{ "style_boxing" }, + matype_id{ "style_capoeira" }, + matype_id{ "style_crane" }, + matype_id{ "style_dragon" }, + matype_id{ "style_judo" }, + matype_id{ "style_karate" }, + matype_id{ "style_krav_maga" }, + matype_id{ "style_leopard" }, + matype_id{ "style_muay_thai" }, + matype_id{ "style_ninjutsu" }, + matype_id{ "style_pankration" }, + matype_id{ "style_snake" }, + matype_id{ "style_taekwondo" }, + matype_id{ "style_tai_chi" }, + matype_id{ "style_tiger" }, + matype_id{ "style_wingchun" }, + matype_id{ "style_zui_quan" } }}; bool character_martial_arts::pick_style( const avatar &you ) // Style selection menu @@ -3428,7 +3430,7 @@ void player::mend_item( item_location &&obj, bool interactive ) } const mending_method &method = opt.method; - assign_activity( ACT_MEND_ITEM, to_moves( method.time ) ); + assign_activity( activity_id( "ACT_MEND_ITEM" ), to_moves( method.time ) ); activity.name = opt.fault.str(); activity.str_values.emplace_back( method.id ); activity.targets.push_back( std::move( obj ) ); @@ -3458,7 +3460,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( flag_MAG_BULKY ) ) { + if( ammo.has_flag( "MAG_BULKY" ) ) { mv *= 1.5; // bulky magazines take longer to insert } @@ -3478,7 +3480,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( flag_STR_RELOAD ) ) { + if( it.has_flag( "STR_RELOAD" ) ) { /** @EFFECT_STR reduces reload time of some weapons */ mv -= get_str() * 20; } @@ -3566,7 +3568,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( flag_NO_TAKEOFF ) ) { + if( it.has_flag( "NO_TAKEOFF" ) ) { return ret_val::make_failure( !is_npc() ? _( "You can't take that item off." ) : _( " can't take that item off." ) ); @@ -3679,7 +3681,7 @@ bool player::unload( item &it ) std::vector opts( 1, &it ); for( auto e : it.gunmods() ) { - if( e->is_gun() && !e->has_flag( flag_NO_UNLOAD ) && + if( e->is_gun() && !e->has_flag( "NO_UNLOAD" ) && ( e->magazine_current() || e->ammo_remaining() > 0 || e->casings_count() > 0 ) ) { msgs.emplace_back( e->tname() ); opts.emplace_back( e ); @@ -3706,8 +3708,8 @@ bool player::unload( item &it ) return false; } - if( target->has_flag( flag_NO_UNLOAD ) ) { - if( target->has_flag( flag_RECHARGE ) || target->has_flag( flag_USE_UPS ) ) { + if( target->has_flag( "NO_UNLOAD" ) ) { + if( target->has_flag( "RECHARGE" ) || target->has_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() ); @@ -3729,7 +3731,7 @@ bool player::unload( item &it ) } ); if( target->is_magazine() ) { - player_activity unload_mag_act( ACT_UNLOAD_MAG ); + player_activity unload_mag_act( activity_id( "ACT_UNLOAD_MAG" ) ); assign_activity( unload_mag_act ); activity.targets.emplace_back( item_location( *this, target ) ); @@ -3846,7 +3848,7 @@ hint_rating player::rate_action_unload( const item &it ) const return HINT_GOOD; } - if( it.has_flag( flag_NO_UNLOAD ) ) { + if( it.has_flag( "NO_UNLOAD" ) ) { return HINT_CANT; } @@ -3855,7 +3857,7 @@ hint_rating player::rate_action_unload( const item &it ) const } for( auto e : it.gunmods() ) { - if( e->is_gun() && !e->has_flag( flag_NO_UNLOAD ) && + if( e->is_gun() && !e->has_flag( "NO_UNLOAD" ) && ( e->magazine_current() || e->ammo_remaining() > 0 || e->casings_count() > 0 ) ) { return HINT_GOOD; } @@ -4059,7 +4061,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( flag_INSTALL_DIFFICULT ) || has_trait( trait_DEBUG_HS ) ) { + if( !mod.has_flag( "INSTALL_DIFFICULT" ) || has_trait( trait_DEBUG_HS ) ) { return std::make_pair( 100, 0 ); } @@ -4165,7 +4167,7 @@ void player::gunmod_add( item &gun, item &mod ) const int moves = !has_trait( trait_DEBUG_HS ) ? mod.type->gunmod->install_time : 0; - assign_activity( ACT_GUNMOD_ADD, moves, -1, get_item_position( &gun ), tool ); + assign_activity( activity_id( "ACT_GUNMOD_ADD" ), moves, -1, get_item_position( &gun ), tool ); activity.values.push_back( get_item_position( &mod ) ); activity.values.push_back( roll ); // chance of success (%) activity.values.push_back( risk ); // chance of damage (%) @@ -4190,7 +4192,7 @@ void player::toolmod_add( item_location tool, item_location mod ) return; // player canceled installation } - assign_activity( ACT_TOOLMOD_ADD, 1, -1 ); + assign_activity( activity_id( "ACT_TOOLMOD_ADD" ), 1, -1 ); activity.targets.emplace_back( std::move( tool ) ); activity.targets.emplace_back( std::move( mod ) ); } @@ -4202,7 +4204,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( flag_INSPIRATIONAL ) ) { + } else if( has_trait( trait_SPIRITUAL ) && book.has_flag( "INSPIRATIONAL" ) ) { return true; } else { return book_fun_for( book, *this ) > 0; @@ -4222,7 +4224,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( flag_INSPIRATIONAL ) ) { + } else if( p.has_trait( trait_SPIRITUAL ) && book.has_flag( "INSPIRATIONAL" ) ) { fun_bonus = abs( fun_bonus * 3 ); } @@ -4359,7 +4361,7 @@ void player::try_to_sleep( const time_duration &dur ) } } else if( has_trait( trait_M_SKIN3 ) ) { fungaloid_cosplay = true; - if( g->m.has_flag_ter_or_furn( flag_FUNGUS, pos() ) ) { + if( g->m.has_flag_ter_or_furn( "FUNGUS", pos() ) ) { add_msg_if_player( m_good, _( "Our fibers meld with the ground beneath us. The gills on our neck begin to seed the air with spores as our awareness fades." ) ); } @@ -4406,7 +4408,7 @@ void player::try_to_sleep( const time_duration &dur ) add_msg_if_player( m_good, _( "You lay beneath the waves' embrace, gazing up through the water's surface…" ) ); watersleep = true; - } else if( g->m.has_flag_ter( flag_SWIMMABLE, pos() ) ) { + } else if( g->m.has_flag_ter( "SWIMMABLE", pos() ) ) { add_msg_if_player( m_good, _( "You settle into the water and begin to drowse…" ) ); watersleep = true; } @@ -4415,8 +4417,8 @@ void player::try_to_sleep( const time_duration &dur ) ter_at_pos == t_improvised_shelter || trap_at_pos.comfort > static_cast( comfort_level::neutral ) || in_shell || websleeping || watersleep || - vp.part_with_feature( flag_SEAT, true ) || - vp.part_with_feature( flag_BED, true ) ) ) { + vp.part_with_feature( "SEAT", true ) || + vp.part_with_feature( "BED", true ) ) ) { add_msg_if_player( m_good, _( "This is a comfortable place to sleep." ) ); } else if( !plantsleep && !fungaloid_cosplay && !watersleep ) { if( !vp && ter_at_pos != t_floor ) { @@ -4449,7 +4451,7 @@ void player::try_to_sleep( const time_duration &dur ) add_msg_if_player( m_bad, _( "Your soporific inducer doesn't have enough power to operate." ) ); } } - assign_activity( ACT_TRY_SLEEP, to_moves( dur ) ); + assign_activity( activity_id( "ACT_TRY_SLEEP" ), to_moves( dur ) ); } int player::sleep_spot( const tripoint &p ) const @@ -4482,7 +4484,7 @@ int player::sleep_spot( const tripoint &p ) const // Mousefolk can sleep just about anywhere. sleepy += 40; } - if( watersleep && g->m.has_flag_ter( flag_SWIMMABLE, pos() ) ) { + if( watersleep && g->m.has_flag_ter( "SWIMMABLE", pos() ) ) { sleepy += 10; //comfy water! } @@ -4571,9 +4573,8 @@ 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( flag_ALLOWS_NATURAL_ATTACKS ) && - !i.has_flag( flag_SEMITANGIBLE ) && - !i.has_flag( flag_PERSONAL ) && !i.has_flag( flag_AURA ) ) { + if( i.covers( bp ) && !i.has_flag( "ALLOWS_NATURAL_ATTACKS" ) && !i.has_flag( "SEMITANGIBLE" ) && + !i.has_flag( "PERSONAL" ) && !i.has_flag( "AURA" ) ) { return true; } } @@ -4631,16 +4632,16 @@ void player::practice( const skill_id &id, int amount, int cap, bool suppress_wa amount = 0; } } - if( has_trait_flag( flag_PRED2 ) && skill.is_combat_skill() ) { + if( has_trait_flag( "PRED2" ) && skill.is_combat_skill() ) { if( one_in( 3 ) ) { amount *= 2; } } - if( has_trait_flag( flag_PRED3 ) && skill.is_combat_skill() ) { + if( has_trait_flag( "PRED3" ) && skill.is_combat_skill() ) { amount *= 2; } - if( has_trait_flag( flag_PRED4 ) && skill.is_combat_skill() ) { + if( has_trait_flag( "PRED4" ) && skill.is_combat_skill() ) { amount *= 3; } @@ -4671,7 +4672,7 @@ void player::practice( const skill_id &id, int amount, int cap, bool suppress_wa focus_pool -= chance_to_drop / 100; // Apex Predators don't think about much other than killing. // They don't lose Focus when practicing combat skills. - if( ( rng( 1, 100 ) <= ( chance_to_drop % 100 ) ) && ( !( has_trait_flag( flag_PRED4 ) && + if( ( rng( 1, 100 ) <= ( chance_to_drop % 100 ) ) && ( !( has_trait_flag( "PRED4" ) && skill.is_combat_skill() ) ) ) { focus_pool--; } @@ -4750,7 +4751,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( flag_NO_RELOAD ) && + return !it.has_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 && @@ -4765,11 +4766,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( flag_RELOAD_AND_SHOOT ); + bool base = weapon.ammo_capacity() > 0 && !weapon.has_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( flag_RELOAD_AND_SHOOT ); + return e->is_gun() && e->ammo_capacity() > 0 && !e->has_flag( "RELOAD_AND_SHOOT" ); } ); if( base || aux ) { @@ -4785,7 +4786,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( flag_RELOAD_AND_SHOOT ) ) { + if( e->is_gun() && e->ammo_capacity() > 0 && !e->has_flag( "RELOAD_AND_SHOOT" ) ) { str += " (" + std::to_string( e->ammo_remaining() ); if( e->magazine_integral() ) { str += "/" + std::to_string( e->ammo_capacity() ); @@ -5442,10 +5443,10 @@ void player::place_corpse() for( const bionic &bio : *my_bionics ) { if( item::type_is_defined( bio.id.str() ) ) { item cbm( bio.id.str(), calendar::turn ); - cbm.set_flag( flag_FILTHY ); - cbm.set_flag( flag_NO_STERILE ); - cbm.set_flag( flag_NO_PACKED ); - cbm.faults.emplace( fault_bionic_salvaged ); + cbm.set_flag( "FILTHY" ); + cbm.set_flag( "NO_STERILE" ); + cbm.set_flag( "NO_PACKED" ); + cbm.faults.emplace( fault_id( "fault_bionic_salvaged" ) ); body.put_in( cbm ); } } diff --git a/src/player.h b/src/player.h index 99be20fa30579..05164077e6ec4 100644 --- a/src/player.h +++ b/src/player.h @@ -65,6 +65,7 @@ class JsonOut; struct dealt_projectile_attack; class dispersion_sources; +using itype_id = std::string; using faction_id = string_id; struct trap; class profession; diff --git a/src/player_activity.cpp b/src/player_activity.cpp index 5c7b46bc5c969..6571685f02a3e 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -4,7 +4,6 @@ #include "activity_handlers.h" #include "activity_type.h" -#include "cata_string_consts.h" #include "construction.h" #include "map.h" #include "game.h" @@ -13,6 +12,7 @@ #include "avatar.h" #include "itype.h" #include "skill.h" +#include "cata_string_consts.h" player_activity::player_activity() : type( activity_id::NULL_ID() ) { } diff --git a/src/player_activity.h b/src/player_activity.h index 9efb7b0d47da7..9c6ad33aaefe1 100644 --- a/src/player_activity.h +++ b/src/player_activity.h @@ -25,6 +25,8 @@ class activity_type; class monster; class translation; +using activity_id = string_id; + class player_activity { private: diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 48b6f9769bac5..0946237d1520c 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -1011,7 +1011,7 @@ void player::hardcoded_effects( effect &it ) } if( has_trait( trait_M_SKIN3 ) ) { // Spores happen! - if( g->m.has_flag_ter_or_furn( flag_FUNGUS, pos() ) ) { + if( g->m.has_flag_ter_or_furn( "FUNGUS", pos() ) ) { if( get_fatigue() >= 0 ) { mod_fatigue( -5 ); // Local guides need less sleep on fungal soil } @@ -1145,7 +1145,7 @@ void player::hardcoded_effects( effect &it ) if( mp == pos() ) { continue; } - if( g->m.has_flag( flag_FLAT, mp ) && + if( g->m.has_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 acf39956d6361..20765f0229e7b 100644 --- a/src/profession.cpp +++ b/src/profession.cpp @@ -23,7 +23,6 @@ #include "item.h" #include "flat_set.h" #include "type_id.h" -#include "cata_string_consts.h" namespace { @@ -404,7 +403,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( flag_VARSIZE ) ) { + if( it.has_flag( "VARSIZE" ) ) { it.item_tags.insert( "FIT" ); } } diff --git a/src/profession.h b/src/profession.h index baa2f410f1141..8c3c5fb96340e 100644 --- a/src/profession.h +++ b/src/profession.h @@ -20,6 +20,7 @@ class generic_factory; using Group_tag = std::string; class item; +using itype_id = std::string; class avatar; class player; class JsonObject; diff --git a/src/ranged.cpp b/src/ranged.cpp index 45b634fbd1499..39b1cb0f459cb 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( flag_WATERPROOF_GUN ) && one_in( effective_durability ) ) { + if( is_underwater() && !it.has_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() ); @@ -353,7 +353,7 @@ int player::fire_gun( const tripoint &target, int shots, item &gun ) } // usage of any attached bipod is dependent upon terrain - bool bipod = g->m.has_flag_ter_or_furn( flag_MOUNTABLE, pos() ); + bool bipod = g->m.has_flag_ter_or_furn( "MOUNTABLE", pos() ); if( !bipod ) { if( const optional_vpart_position vp = g->m.veh_at( pos() ) ) { bipod = vp->vehicle().has_part( pos(), "MOUNTABLE" ); @@ -593,7 +593,7 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & auto &impact = proj.impact; auto &proj_effects = proj.proj_effects; - static const std::set ferric = { material_iron, material_steel }; + static const std::set ferric = { material_id( "iron" ), material_id( "steel" ) }; bool do_railgun = has_active_bionic( bio_railgun ) && thrown.made_of_any( ferric ) && !throw_assist; @@ -611,14 +611,14 @@ 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( flag_ACT_ON_RANGED_HIT ) ) { + if( thrown.has_flag( "ACT_ON_RANGED_HIT" ) ) { proj_effects.insert( "ACT_ON_RANGED_HIT" ); thrown.active = true; } // Item will shatter upon landing, destroying the item, dealing damage, and making noise /** @EFFECT_STR increases chance of shattering thrown glass items (NEGATIVE) */ - const bool shatter = !thrown.active && thrown.made_of( material_glass ) && + const bool shatter = !thrown.active && thrown.made_of( material_id( "glass" ) ) && rng( 0, units::to_milliliter( 2_liter - volume ) ) < get_str() * 100; // Item will burst upon landing, destroying the item, and spilling its contents @@ -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( flag_TANGLE ) ) { + if( thrown.has_flag( "TANGLE" ) ) { proj_effects.insert( "TANGLE" ); } @@ -2189,14 +2189,14 @@ 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( flag_VEHICLE ) ) { - cargo = vp->vehicle().get_parts_at( pos, flag_CARGO, part_status_flag::any ); + if( vp && weap.has_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( flag_RELOAD_EJECT ) || weap.gunmod_find( "brass_catcher" ) ) { - weap.contents.push_back( item( casing ).set_flag( flag_CASING ) ); + if( weap.has_flag( "RELOAD_EJECT" ) || weap.gunmod_find( "brass_catcher" ) ) { + weap.contents.push_back( item( casing ).set_flag( "CASING" ) ); } else { if( cargo.empty() ) { g->m.add_item_or_charges( eject, item( casing ) ); @@ -2214,7 +2214,7 @@ static void cycle_action( item &weap, const tripoint &pos ) if( mag && mag->type->magazine->linkage ) { item linkage( *mag->type->magazine->linkage, calendar::turn, 1 ); if( weap.gunmod_find( "brass_catcher" ) ) { - linkage.set_flag( flag_CASING ); + linkage.set_flag( "CASING" ); weap.contents.push_back( linkage ); } else if( cargo.empty() ) { g->m.add_item_or_charges( eject, linkage ); diff --git a/src/recipe.cpp b/src/recipe.cpp index 21b250c75b8bd..2766064917da8 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -26,7 +26,6 @@ #include "string_id.h" #include "flat_set.h" #include "units.h" -#include "cata_string_consts.h" extern bool test_mode; @@ -445,7 +444,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( flag_VARSIZE ) ) { + if( obj.has_flag( "VARSIZE" ) ) { obj.item_tags.insert( "FIT" ); } @@ -560,7 +559,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( flag_ALLOW_ROTTEN ); + result.is_food() && !result.goes_bad() && !has_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; @@ -576,14 +575,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( flag_FROZEN ) || component.has_flag( flag_EDIBLE_FROZEN ); + return !component.has_flag( "FROZEN" ) || component.has_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( flag_FULL_MAGAZINE ) ) { + if( has_flag( "FULL_MAGAZINE" ) ) { magazine_filter = []( const item & component ) { return !component.is_magazine() || ( component.ammo_remaining() >= component.ammo_capacity() ); }; diff --git a/src/recipe.h b/src/recipe.h index 385acd21d9c1b..cce16c8b2a82e 100644 --- a/src/recipe.h +++ b/src/recipe.h @@ -18,6 +18,7 @@ class item; class JsonObject; class time_duration; +using itype_id = std::string; // From itype.h class Character; enum class recipe_filter_flags : int { diff --git a/src/recipe_dictionary.h b/src/recipe_dictionary.h index d93a54e33124b..9e9ab4ee6d8f6 100644 --- a/src/recipe_dictionary.h +++ b/src/recipe_dictionary.h @@ -18,6 +18,8 @@ class JsonIn; class JsonOut; class JsonObject; +using itype_id = std::string; + class recipe_dictionary { friend class Item_factory; // allow removal of blacklisted recipes diff --git a/src/requirements.cpp b/src/requirements.cpp index a0a5754b7b567..30af435881715 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( flag_UNRECOVERABLE ); + return !comp.recoverable || item( comp.type ).has_flag( "UNRECOVERABLE" ); } ), cov.end() ); return cov.empty(); } ), ret.components.end() ); diff --git a/src/requirements.h b/src/requirements.h index bc5ed5f052978..a9fccc5554c9e 100644 --- a/src/requirements.h +++ b/src/requirements.h @@ -23,6 +23,9 @@ class JsonOut; class inventory; class item; +// Denotes the id of an item type +using itype_id = std::string; + enum available_status { a_true = +1, // yes, it's available a_false = -1, // no, it's not available diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index ddf5ea8e94a11..2090ff00b88fe 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -450,7 +450,7 @@ void Character::load( const JsonObject &data ) matype_id temp_selected_style; data.read( "style_selected", temp_selected_style ); if( !temp_selected_style.is_valid() ) { - temp_selected_style = style_none; + temp_selected_style = matype_id( "style_none" ); } martial_arts_data = character_martial_arts( temp_styles, temp_selected_style, temp_keep_hands_free ); @@ -479,8 +479,8 @@ void Character::load( const JsonObject &data ) backlog.push_front( temp ); } if( !backlog.empty() && !backlog.front().str_values.empty() && ( ( activity && - activity.id() == ACT_FETCH_REQUIRED ) || ( destination_activity && - destination_activity.id() == ACT_FETCH_REQUIRED ) ) ) { + activity.id() == activity_id( "ACT_FETCH_REQUIRED" ) ) || ( destination_activity && + destination_activity.id() == activity_id( "ACT_FETCH_REQUIRED" ) ) ) ) { requirement_data fetch_reqs; data.read( "fetch_data", fetch_reqs ); const requirement_id req_id( backlog.front().str_values.back() ); @@ -716,8 +716,8 @@ void Character::store( JsonOut &json ) const // handling for storing activity requirements if( !backlog.empty() && !backlog.front().str_values.empty() && ( ( activity && - activity.id() == ACT_FETCH_REQUIRED ) || ( destination_activity && - destination_activity.id() == ACT_FETCH_REQUIRED ) ) ) { + activity.id() == activity_id( "ACT_FETCH_REQUIRED" ) ) || ( destination_activity && + destination_activity.id() == activity_id( "ACT_FETCH_REQUIRED" ) ) ) ) { requirement_data things_to_fetch = requirement_id( backlog.front().str_values.back() ).obj(); json.member( "fetch_data", things_to_fetch ); } @@ -909,13 +909,13 @@ void player::load( const JsonObject &data ) data.read( "automoveroute", auto_move_route ); // Add the earplugs. - if( has_bionic( bio_ears ) && !has_bionic( bio_earplugs ) ) { - add_bionic( bio_earplugs ); + if( has_bionic( bionic_id( "bio_ears" ) ) && !has_bionic( bionic_id( "bio_earplugs" ) ) ) { + add_bionic( bionic_id( "bio_earplugs" ) ); } // Add the blindfold. - if( has_bionic( bio_sunglasses ) && !has_bionic( bio_blindfold ) ) { - add_bionic( bio_blindfold ); + if( has_bionic( bionic_id( "bio_sunglasses" ) ) && !has_bionic( bionic_id( "bio_blindfold" ) ) ) { + add_bionic( bionic_id( "bio_blindfold" ) ); } // Fixes bugged characters for CBM's preventing mutations. @@ -2475,7 +2475,7 @@ void vehicle_part::deserialize( JsonIn &jsin ) // if we don't know what type of part it is, it'll cause problems later. if( !pid.is_valid() ) { if( pid.str() == "wheel_underbody" ) { - pid = vpart_wheel_wide; + pid = vpart_id( "wheel_wide" ); } else { data.throw_error( "bad vehicle part", "id" ); } @@ -2517,8 +2517,8 @@ void vehicle_part::deserialize( JsonIn &jsin ) } // with VEHICLE tag migrate fuel tanks only if amount field exists - if( base.has_flag( flag_VEHICLE ) ) { - if( data.has_int( "amount" ) && ammo_capacity() > 0 && legacy_fuel != fuel_type_battery ) { + if( base.has_flag( "VEHICLE" ) ) { + if( data.has_int( "amount" ) && ammo_capacity() > 0 && legacy_fuel != "battery" ) { ammo_set( legacy_fuel, data.get_int( "amount" ) ); } @@ -2683,39 +2683,39 @@ void vehicle::deserialize( JsonIn &jsin ) } } - for( const vpart_reference &vp : get_any_parts( flag_TURRET ) ) { - install_part( vp.mount(), vpart_turret_mount, false ); + for( const vpart_reference &vp : get_any_parts( "TURRET" ) ) { + install_part( vp.mount(), vpart_id( "turret_mount" ), false ); //Forcibly set turrets' targeting mode to manual if no turret control unit is present on turret's tile on loading save - if( !has_part( global_part_pos3( vp.part() ), flag_TURRET_CONTROLS ) ) { + if( !has_part( global_part_pos3( vp.part() ), "TURRET_CONTROLS" ) ) { vp.part().enabled = false; } //Set turret control unit's state equal to turret's targeting mode on loading save - for( const vpart_reference &turret_part : get_any_parts( flag_TURRET_CONTROLS ) ) { + for( const vpart_reference &turret_part : get_any_parts( "TURRET_CONTROLS" ) ) { turret_part.part().enabled = vp.part().enabled; } } // Add vehicle mounts to cars that are missing them. - for( const vpart_reference &vp : get_any_parts( flag_NEEDS_WHEEL_MOUNT_LIGHT ) ) { - if( vp.info().has_flag( flag_STEERABLE ) ) { - install_part( vp.mount(), vpart_wheel_mount_light_steerable, false ); + for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_LIGHT" ) ) { + if( vp.info().has_flag( "STEERABLE" ) ) { + install_part( vp.mount(), vpart_id( "wheel_mount_light_steerable" ), false ); } else { - install_part( vp.mount(), vpart_wheel_mount_light, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_light" ), false ); } } - for( const vpart_reference &vp : get_any_parts( flag_NEEDS_WHEEL_MOUNT_MEDIUM ) ) { - if( vp.info().has_flag( flag_STEERABLE ) ) { - install_part( vp.mount(), vpart_wheel_mount_medium_steerable, false ); + for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_MEDIUM" ) ) { + if( vp.info().has_flag( "STEERABLE" ) ) { + install_part( vp.mount(), vpart_id( "wheel_mount_medium_steerable" ), false ); } else { - install_part( vp.mount(), vpart_wheel_mount_medium, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_medium" ), false ); } } - for( const vpart_reference &vp : get_any_parts( flag_NEEDS_WHEEL_MOUNT_HEAVY ) ) { - if( vp.info().has_flag( flag_STEERABLE ) ) { - install_part( vp.mount(), vpart_wheel_mount_heavy_steerable, false ); + for( const vpart_reference &vp : get_any_parts( "NEEDS_WHEEL_MOUNT_HEAVY" ) ) { + if( vp.info().has_flag( "STEERABLE" ) ) { + install_part( vp.mount(), vpart_id( "wheel_mount_heavy_steerable" ), false ); } else { - install_part( vp.mount(), vpart_wheel_mount_heavy, false ); + install_part( vp.mount(), vpart_id( "wheel_mount_heavy" ), false ); } } diff --git a/src/savegame_legacy.cpp b/src/savegame_legacy.cpp index 7ed52c4f3c9ab..3ce600378503b 100644 --- a/src/savegame_legacy.cpp +++ b/src/savegame_legacy.cpp @@ -29,7 +29,6 @@ #include "type_id.h" #include "flat_set.h" #include "point.h" -#include "cata_string_consts.h" namespace std { @@ -198,49 +197,49 @@ void player_activity::deserialize_legacy_type( int legacy_type, activity_id &des { static const std::vector< activity_id > legacy_map = { activity_id::NULL_ID(), - ACT_RELOAD, - ACT_READ, - ACT_GAME, - ACT_WAIT, - ACT_CRAFT, + activity_id( "ACT_RELOAD" ), + activity_id( "ACT_READ" ), + activity_id( "ACT_GAME" ), + activity_id( "ACT_WAIT" ), + activity_id( "ACT_CRAFT" ), activity_id::NULL_ID(), // ACT_LONGCRAFT is deprecated - ACT_DISASSEMBLE, - ACT_BUTCHER, - ACT_LONGSALVAGE, - ACT_FORAGE, - ACT_BUILD, - ACT_VEHICLE, + activity_id( "ACT_DISASSEMBLE" ), + activity_id( "ACT_BUTCHER" ), + activity_id( "ACT_LONGSALVAGE" ), + activity_id( "ACT_FORAGE" ), + activity_id( "ACT_BUILD" ), + activity_id( "ACT_VEHICLE" ), activity_id::NULL_ID(), // ACT_REFILL_VEHICLE is deprecated - ACT_TRAIN, - ACT_WAIT_WEATHER, - ACT_FIRSTAID, - ACT_FISH, - ACT_PICKAXE, - ACT_BURROW, - ACT_PULP, - ACT_VIBE, - ACT_MAKE_ZLAVE, - ACT_DROP, - ACT_STASH, - ACT_PICKUP, - ACT_MOVE_ITEMS, - ACT_ADV_INVENTORY, - ACT_ARMOR_LAYERS, - ACT_START_FIRE, - ACT_OPEN_GATE, - ACT_FILL_LIQUID, - ACT_HOTWIRE_CAR, - ACT_AIM, - ACT_ATM, - ACT_START_ENGINES, - ACT_OXYTORCH, - ACT_CRACKING, - ACT_REPAIR_ITEM, - ACT_MEND_ITEM, - ACT_GUNMOD_ADD, - ACT_WAIT_NPC, - ACT_CLEAR_RUBBLE, - ACT_MEDITATE, + activity_id( "ACT_TRAIN" ), + activity_id( "ACT_WAIT_WEATHER" ), + activity_id( "ACT_FIRSTAID" ), + activity_id( "ACT_FISH" ), + activity_id( "ACT_PICKAXE" ), + activity_id( "ACT_BURROW" ), + activity_id( "ACT_PULP" ), + activity_id( "ACT_VIBE" ), + activity_id( "ACT_MAKE_ZLAVE" ), + activity_id( "ACT_DROP" ), + activity_id( "ACT_STASH" ), + activity_id( "ACT_PICKUP" ), + activity_id( "ACT_MOVE_ITEMS" ), + activity_id( "ACT_ADV_INVENTORY" ), + activity_id( "ACT_ARMOR_LAYERS" ), + activity_id( "ACT_START_FIRE" ), + activity_id( "ACT_OPEN_GATE" ), + activity_id( "ACT_FILL_LIQUID" ), + activity_id( "ACT_HOTWIRE_CAR" ), + activity_id( "ACT_AIM" ), + activity_id( "ACT_ATM" ), + activity_id( "ACT_START_ENGINES" ), + activity_id( "ACT_OXYTORCH" ), + activity_id( "ACT_CRACKING" ), + activity_id( "ACT_REPAIR_ITEM" ), + activity_id( "ACT_MEND_ITEM" ), + activity_id( "ACT_GUNMOD_ADD" ), + activity_id( "ACT_WAIT_NPC" ), + activity_id( "ACT_CLEAR_RUBBLE" ), + activity_id( "ACT_MEDITATE" ), activity_id::NULL_ID() // NUM_ACTIVITIES }; diff --git a/src/scenario.cpp b/src/scenario.cpp index 066f162625b38..4f095057a826f 100644 --- a/src/scenario.cpp +++ b/src/scenario.cpp @@ -12,7 +12,6 @@ #include "profession.h" #include "translations.h" #include "rng.h" -#include "cata_string_consts.h" namespace { @@ -301,11 +300,11 @@ std::vector> scenario::permitted_professions() const const bool present = std::find( professions.begin(), professions.end(), p.ident() ) != professions.end(); if( blacklist || professions.empty() ) { - if( !present && !p.has_flag( flag_SCEN_ONLY ) ) { + if( !present && !p.has_flag( "SCEN_ONLY" ) ) { res.push_back( p.ident() ); } } else if( extra_professions ) { - if( present || !p.has_flag( flag_SCEN_ONLY ) ) { + if( present || !p.has_flag( "SCEN_ONLY" ) ) { res.push_back( p.ident() ); } } else if( present ) { diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 01f7add3679fd..53c7ae7aadddc 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -57,7 +57,6 @@ #include "json.h" #include "optional.h" #include "point.h" -#include "cata_string_consts.h" #if defined(__linux__) # include // getenv()/setenv() @@ -1836,7 +1835,7 @@ input_context touch_input_context; std::string get_quick_shortcut_name( const std::string &category ) { - if( category == "DEFAULTMODE" && g->check_zone( zone_type_NO_AUTO_PICKUP, g->u.pos() ) && + if( category == "DEFAULTMODE" && g->check_zone( zone_type_id( "NO_AUTO_PICKUP" ), g->u.pos() ) && get_option( "ANDROID_SHORTCUT_ZONE" ) ) { return "DEFAULTMODE____SHORTCUTS"; } @@ -2616,7 +2615,7 @@ static void CheckMessages() actions.insert( ACTION_CYCLE_MOVE ); } // Only prioritize fire weapon options if we're wielding a ranged weapon. - if( g->u.weapon.is_gun() || g->u.weapon.has_flag( flag_REACH_ATTACK ) ) { + if( g->u.weapon.is_gun() || g->u.weapon.has_flag( "REACH_ATTACK" ) ) { actions.insert( ACTION_FIRE ); } } @@ -2650,19 +2649,19 @@ static void CheckMessages() vehicle *const veh = veh_pointer_or_null( vp ); if( veh ) { const int veh_part = vp ? vp->part_index() : -1; - if( veh->part_with_feature( veh_part, flag_CONTROLS, true ) >= 0 ) { + if( veh->part_with_feature( veh_part, "CONTROLS", true ) >= 0 ) { actions.insert( ACTION_CONTROL_VEHICLE ); } - const int openablepart = veh->part_with_feature( veh_part, flag_OPENABLE, true ); + const int openablepart = veh->part_with_feature( veh_part, "OPENABLE", true ); if( openablepart >= 0 && veh->is_open( openablepart ) && ( dx != 0 || dy != 0 ) ) { // an open door adjacent to us actions.insert( ACTION_CLOSE ); } - const int curtainpart = veh->part_with_feature( veh_part, flag_CURTAIN, true ); + const int curtainpart = veh->part_with_feature( veh_part, "CURTAIN", true ); if( curtainpart >= 0 && veh->is_open( curtainpart ) && ( dx != 0 || dy != 0 ) ) { actions.insert( ACTION_CLOSE ); } - const int cargopart = veh->part_with_feature( veh_part, flag_CARGO, true ); + const int cargopart = veh->part_with_feature( veh_part, "CARGO", true ); if( cargopart >= 0 && ( !veh->get_items( cargopart ).empty() ) ) { actions.insert( ACTION_PICKUP ); } diff --git a/src/sounds.cpp b/src/sounds.cpp index d7e79149576d4..09d2e71ca89ba 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1075,11 +1075,11 @@ void sfx::do_projectile_hit( const Creature &target ) if( target.is_monster() ) { const monster &mon = dynamic_cast( target ); static const std::set fleshy = { - material_flesh, - material_hflesh, - material_iflesh, - material_veggy, - material_bone, + material_id( "flesh" ), + material_id( "hflesh" ), + material_id( "iflesh" ), + material_id( "veggy" ), + material_id( "bone" ), }; const bool is_fleshy = std::any_of( fleshy.begin(), fleshy.end(), [&mon]( const material_id & m ) { return mon.made_of( m ); @@ -1088,10 +1088,10 @@ void sfx::do_projectile_hit( const Creature &target ) if( is_fleshy ) { play_variant_sound( "bullet_hit", "hit_flesh", heard_volume, angle, 0.8, 1.2 ); return; - } else if( mon.made_of( material_stone ) ) { + } else if( mon.made_of( material_id( "stone" ) ) ) { play_variant_sound( "bullet_hit", "hit_wall", heard_volume, angle, 0.8, 1.2 ); return; - } else if( mon.made_of( material_steel ) ) { + } else if( mon.made_of( material_id( "steel" ) ) ) { play_variant_sound( "bullet_hit", "hit_metal", heard_volume, angle, 0.8, 1.2 ); return; } else { @@ -1249,104 +1249,104 @@ void sfx::do_footstep() int heard_volume = sfx::get_heard_volume( g->u.pos() ); const auto terrain = g->m.ter( g->u.pos() ).id(); static const std::set grass = { - ter_grass, - ter_shrub, - ter_shrub_peanut, - ter_shrub_peanut_harvested, - ter_shrub_blueberry, - ter_shrub_blueberry_harvested, - ter_shrub_strawberry, - ter_shrub_strawberry_harvested, - ter_shrub_blackberry, - ter_shrub_blackberry_harvested, - ter_shrub_huckleberry, - ter_shrub_huckleberry_harvested, - ter_shrub_raspberry, - ter_shrub_raspberry_harvested, - ter_shrub_grape, - ter_shrub_grape_harvested, - ter_shrub_rose, - ter_shrub_rose_harvested, - ter_shrub_hydrangea, - ter_shrub_hydrangea_harvested, - ter_shrub_lilac, - ter_shrub_lilac_harvested, - ter_underbrush, - ter_underbrush_harvested_spring, - ter_underbrush_harvested_summer, - ter_underbrush_harvested_autumn, - ter_underbrush_harvested_winter, - ter_moss, - ter_grass_white, - ter_grass_long, - ter_grass_tall, - ter_grass_dead, - ter_grass_golf, - ter_golf_hole, - ter_trunk, - ter_stump, + ter_str_id( "t_grass" ), + ter_str_id( "t_shrub" ), + ter_str_id( "t_shrub_peanut" ), + ter_str_id( "t_shrub_peanut_harvested" ), + ter_str_id( "t_shrub_blueberry" ), + ter_str_id( "t_shrub_blueberry_harvested" ), + ter_str_id( "t_shrub_strawberry" ), + ter_str_id( "t_shrub_strawberry_harvested" ), + ter_str_id( "t_shrub_blackberry" ), + ter_str_id( "t_shrub_blackberry_harvested" ), + ter_str_id( "t_shrub_huckleberry" ), + ter_str_id( "t_shrub_huckleberry_harvested" ), + ter_str_id( "t_shrub_raspberry" ), + ter_str_id( "t_shrub_raspberry_harvested" ), + ter_str_id( "t_shrub_grape" ), + ter_str_id( "t_shrub_grape_harvested" ), + ter_str_id( "t_shrub_rose" ), + ter_str_id( "t_shrub_rose_harvested" ), + ter_str_id( "t_shrub_hydrangea" ), + ter_str_id( "t_shrub_hydrangea_harvested" ), + ter_str_id( "t_shrub_lilac" ), + ter_str_id( "t_shrub_lilac_harvested" ), + ter_str_id( "t_underbrush" ), + ter_str_id( "t_underbrush_harvested_spring" ), + ter_str_id( "t_underbrush_harvested_summer" ), + ter_str_id( "t_underbrush_harvested_autumn" ), + ter_str_id( "t_underbrush_harvested_winter" ), + ter_str_id( "t_moss" ), + ter_str_id( "t_grass_white" ), + ter_str_id( "t_grass_long" ), + ter_str_id( "t_grass_tall" ), + ter_str_id( "t_grass_dead" ), + ter_str_id( "t_grass_golf" ), + ter_str_id( "t_golf_hole" ), + ter_str_id( "t_trunk" ), + ter_str_id( "t_stump" ), }; static const std::set dirt = { - ter_dirt, - ter_dirtmound, - ter_dirtmoundfloor, - ter_sand, - ter_clay, - ter_dirtfloor, - ter_palisade_gate_o, - ter_sandbox, - ter_claymound, - ter_sandmound, - ter_rootcellar, - ter_railroad_rubble, - ter_railroad_track, - ter_railroad_track_h, - ter_railroad_track_v, - ter_railroad_track_d, - ter_railroad_track_d1, - ter_railroad_track_d2, - ter_railroad_tie, - ter_railroad_tie_d, - ter_railroad_tie_d, - ter_railroad_tie_h, - ter_railroad_tie_v, - ter_railroad_tie_d, - ter_railroad_track_on_tie, - ter_railroad_track_h_on_tie, - ter_railroad_track_v_on_tie, - ter_railroad_track_d_on_tie, - ter_railroad_tie, - ter_railroad_tie_h, - ter_railroad_tie_v, - ter_railroad_tie_d1, - ter_railroad_tie_d2, + ter_str_id( "t_dirt" ), + ter_str_id( "t_dirtmound" ), + ter_str_id( "t_dirtmoundfloor" ), + ter_str_id( "t_sand" ), + ter_str_id( "t_clay" ), + ter_str_id( "t_dirtfloor" ), + ter_str_id( "t_palisade_gate_o" ), + ter_str_id( "t_sandbox" ), + ter_str_id( "t_claymound" ), + ter_str_id( "t_sandmound" ), + ter_str_id( "t_rootcellar" ), + ter_str_id( "t_railroad_rubble" ), + ter_str_id( "t_railroad_track" ), + ter_str_id( "t_railroad_track_h" ), + ter_str_id( "t_railroad_track_v" ), + ter_str_id( "t_railroad_track_d" ), + ter_str_id( "t_railroad_track_d1" ), + ter_str_id( "t_railroad_track_d2" ), + ter_str_id( "t_railroad_tie" ), + ter_str_id( "t_railroad_tie_d" ), + ter_str_id( "t_railroad_tie_d" ), + ter_str_id( "t_railroad_tie_h" ), + ter_str_id( "t_railroad_tie_v" ), + ter_str_id( "t_railroad_tie_d" ), + ter_str_id( "t_railroad_track_on_tie" ), + ter_str_id( "t_railroad_track_h_on_tie" ), + ter_str_id( "t_railroad_track_v_on_tie" ), + ter_str_id( "t_railroad_track_d_on_tie" ), + ter_str_id( "t_railroad_tie" ), + ter_str_id( "t_railroad_tie_h" ), + ter_str_id( "t_railroad_tie_v" ), + ter_str_id( "t_railroad_tie_d1" ), + ter_str_id( "t_railroad_tie_d2" ), }; static const std::set metal = { - ter_ov_smreb_cage, - ter_metal_floor, - ter_grate, - ter_bridge, - ter_elevator, - ter_guardrail_bg_dp, - ter_slide, - ter_conveyor, - ter_machinery_light, - ter_machinery_heavy, - ter_machinery_old, - ter_machinery_electronic, + ter_str_id( "t_ov_smreb_cage" ), + ter_str_id( "t_metal_floor" ), + ter_str_id( "t_grate" ), + ter_str_id( "t_bridge" ), + ter_str_id( "t_elevator" ), + ter_str_id( "t_guardrail_bg_dp" ), + ter_str_id( "t_slide" ), + ter_str_id( "t_conveyor" ), + ter_str_id( "t_machinery_light" ), + ter_str_id( "t_machinery_heavy" ), + ter_str_id( "t_machinery_old" ), + ter_str_id( "t_machinery_electronic" ), }; static const std::set water = { - ter_water_moving_sh, - ter_water_moving_dp, - ter_water_sh, - ter_water_dp, - ter_swater_sh, - ter_swater_dp, - ter_water_pool, - ter_sewage, + ter_str_id( "t_water_moving_sh" ), + ter_str_id( "t_water_moving_dp" ), + ter_str_id( "t_water_sh" ), + ter_str_id( "t_water_dp" ), + ter_str_id( "t_swater_sh" ), + ter_str_id( "t_swater_dp" ), + ter_str_id( "t_water_pool" ), + ter_str_id( "t_sewage" ), }; static const std::set chain_fence = { - ter_chainfence, + ter_str_id( "t_chainfence" ), }; if( !g->u.wearing_something_on( bp_foot_l ) ) { play_variant_sound( "plmove", "walk_barefoot", heard_volume, 0, 0.8, 1.2 ); diff --git a/src/start_location.cpp b/src/start_location.cpp index cda55d9f8d0f2..b5a156b4d3c6f 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -25,7 +25,6 @@ #include "rng.h" #include "translations.h" #include "point.h" -#include "cata_string_consts.h" class item; @@ -186,7 +185,7 @@ static void board_up( map &m, const tripoint_range &range ) void start_location::prepare_map( tinymap &m ) const { const int z = m.get_abs_sub().z; - if( flags().count( flag_BOARDED ) > 0 ) { + if( flags().count( "BOARDED" ) > 0 ) { m.build_outside_cache( z ); board_up( m, m.points_on_zlevel( z ) ); } else { @@ -269,7 +268,7 @@ static int rate_location( map &m, const tripoint &p, const bool must_be_inside, checked[cur.x][cur.y] = attempt; if( cur.x == 0 || cur.x == MAPSIZE_X - 1 || cur.y == 0 || cur.y == MAPSIZE_Y - 1 || - m.has_flag( flag_GOES_UP, cur ) ) { + m.has_flag( "GOES_UP", cur ) ) { return INT_MAX; } @@ -296,7 +295,7 @@ void start_location::place_player( player &u ) const u.setz( g->get_levz() ); m.invalidate_map_cache( m.get_abs_sub().z ); m.build_map_cache( m.get_abs_sub().z ); - const bool must_be_inside = flags().count( flag_ALLOW_OUTSIDE ) == 0; + const bool must_be_inside = flags().count( "ALLOW_OUTSIDE" ) == 0; ///\EFFECT_STR allows player to start behind less-bashable furniture and terrain // TODO: Allow using items here const int bash = u.get_str(); @@ -361,11 +360,11 @@ void start_location::burn( const tripoint &omtstart, const int uy = g->u.posy() % HALF_MAPSIZE_Y; std::vector valid; for( const tripoint &p : m.points_on_zlevel() ) { - if( !( m.has_flag_ter( flag_DOOR, p ) || - m.has_flag_ter( flag_OPENCLOSE_INSIDE, p ) || + if( !( m.has_flag_ter( "DOOR", p ) || + m.has_flag_ter( "OPENCLOSE_INSIDE", p ) || m.is_outside( p ) || ( p.x >= ux - rad && p.x <= ux + rad && p.y >= uy - rad && p.y <= uy + rad ) ) ) { - if( m.has_flag( flag_FLAMMABLE, p ) || m.has_flag( flag_FLAMMABLE_ASH, p ) ) { + if( m.has_flag( "FLAMMABLE", p ) || m.has_flag( "FLAMMABLE_ASH", p ) ) { valid.push_back( p ); } } diff --git a/src/string_id.h b/src/string_id.h index b1a9ace6f67e3..5b2a396f89ca9 100644 --- a/src/string_id.h +++ b/src/string_id.h @@ -25,6 +25,8 @@ class int_id; * * Example: * \code + * struct itype; + * using itype_id = string_id; * struct mtype; * using mtype_id = string_id; * \endcode diff --git a/src/submap.cpp b/src/submap.cpp index a0db8694fb22f..55c6c0b7c0954 100644 --- a/src/submap.cpp +++ b/src/submap.cpp @@ -8,7 +8,6 @@ #include "mapdata.h" #include "trap.h" #include "tileray.h" -#include "cata_string_consts.h" template void maptile_soa::swap_soa_tile( const point &p1, const point &p2 ) @@ -109,7 +108,7 @@ void submap::delete_graffiti( const point &p ) } bool submap::has_signage( const point &p ) const { - if( frn[p.x][p.y].obj().has_flag( flag_SIGN ) ) { + if( frn[p.x][p.y].obj().has_flag( "SIGN" ) ) { return find_cosmetic( cosmetics, p, COSMETICS_SIGNAGE ).result; } @@ -117,7 +116,7 @@ bool submap::has_signage( const point &p ) const } std::string submap::get_signage( const point &p ) const { - if( frn[p.x][p.y].obj().has_flag( flag_SIGN ) ) { + if( frn[p.x][p.y].obj().has_flag( "SIGN" ) ) { const auto fresult = find_cosmetic( cosmetics, p, COSMETICS_SIGNAGE ); if( fresult.result ) { return cosmetics[ fresult.ndx ].str; diff --git a/src/suffer.cpp b/src/suffer.cpp index e8690c3381c47..5cc31878cb9d4 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -144,7 +144,7 @@ void Character::suffer_while_underwater() if( !has_trait( trait_GILLS ) && !has_trait( trait_GILLS_CEPH ) ) { oxygen--; } - if( oxygen < 12 && worn_with_flag( flag_REBREATHER ) ) { + if( oxygen < 12 && worn_with_flag( "REBREATHER" ) ) { oxygen += 12; } if( oxygen <= 5 ) { @@ -156,7 +156,7 @@ void Character::suffer_while_underwater() apply_damage( nullptr, bp_torso, rng( 1, 4 ) ); } } - if( has_trait( trait_FRESHWATEROSMOSIS ) && !g->m.has_flag_ter( flag_SALT_WATER, pos() ) && + if( has_trait( trait_FRESHWATEROSMOSIS ) && !g->m.has_flag_ter( "SALT_WATER", pos() ) && get_thirst() > -60 ) { mod_thirst( -1 ); } @@ -625,8 +625,8 @@ void Character::suffer_in_sunlight() } if( x_in_y( sunlight_nutrition, 18000 ) ) { - vitamin_mod( vitamin_vitA, 1, true ); - vitamin_mod( vitamin_vitC, 1, true ); + vitamin_mod( vitamin_id( "vitA" ), 1, true ); + vitamin_mod( vitamin_id( "vitC" ), 1, true ); } if( x_in_y( sunlight_nutrition, 12000 ) ) { @@ -645,7 +645,7 @@ void Character::suffer_in_sunlight() } if( has_trait( trait_SUNBURN ) && one_in( 10 ) ) { - if( !( weapon.has_flag( flag_RAIN_PROTECT ) ) ) { + if( !( weapon.has_flag( "RAIN_PROTECT" ) ) ) { add_msg_if_player( m_bad, _( "The sunlight burns your skin!" ) ); if( has_effect( effect_sleep ) && !has_effect( effect_narcosis ) ) { wake_up(); @@ -696,7 +696,7 @@ void Character::suffer_from_albinism() } } // Umbrellas can keep the sun off the skin - if( weapon.has_flag( flag_RAIN_PROTECT ) ) { + if( weapon.has_flag( "RAIN_PROTECT" ) ) { return; } //calculate total coverage of skin @@ -796,8 +796,8 @@ void Character::suffer_from_other_mutations() } if( x_in_y( root_vitamins, 576 ) ) { - vitamin_mod( vitamin_iron, 1, true ); - vitamin_mod( vitamin_calcium, 1, true ); + vitamin_mod( vitamin_id( "iron" ), 1, true ); + vitamin_mod( vitamin_id( "calcium" ), 1, true ); mod_healthy_mod( 5, 50 ); } @@ -1391,7 +1391,7 @@ bool Character::irradiate( float rads, bool bypass ) if( rads > 0 ) { bool has_helmet = false; const bool power_armored = is_wearing_power_armor( &has_helmet ); - const bool rad_resist = power_armored || worn_with_flag( flag_RAD_RESIST ); + const bool rad_resist = power_armored || worn_with_flag( "RAD_RESIST" ); if( is_rad_immune() && !bypass ) { // Power armor and some high-tech gear protects completely from radiation @@ -1527,7 +1527,7 @@ void Character::mend( int rate_multiplier ) } body_part part = hp_to_bp( static_cast( i ) ); - if( needs_splint && !worn_with_flag( flag_SPLINT, part ) ) { + if( needs_splint && !worn_with_flag( "SPLINT", part ) ) { continue; } diff --git a/src/teleport.cpp b/src/teleport.cpp index 9ed95831ecdd6..b903bfe30ad2a 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -23,8 +23,8 @@ bool teleport::teleport( Creature &critter, int min_distance, int max_distance, tripoint origin = critter.pos(); tripoint new_pos = origin; //The teleportee is dimensionally anchored so nothing happens - if( p && ( p->worn_with_flag( flag_DIMENSIONAL_ANCHOR ) || - p->has_effect_with_flag( flag_DIMENSIONAL_ANCHOR ) ) ) { + if( p && ( p->worn_with_flag( "DIMENSIONAL_ANCHOR" ) || + p->has_effect_with_flag( "DIMENSIONAL_ANCHOR" ) ) ) { p->add_msg_if_player( m_warning, _( "You feel a strange, inwards force." ) ); return false; } @@ -59,8 +59,8 @@ bool teleport::teleport( Creature &critter, int min_distance, int max_distance, add_msg( m_bad, _( "You cannot teleport safely." ) ); } return false; - } else if( poor_player && ( poor_player->worn_with_flag( flag_DIMENSIONAL_ANCHOR ) || - poor_player->has_effect_with_flag( flag_DIMENSIONAL_ANCHOR ) ) ) { + } else if( poor_player && ( poor_player->worn_with_flag( "DIMENSIONAL_ANCHOR" ) || + poor_player->has_effect_with_flag( "DIMENSIONAL_ANCHOR" ) ) ) { poor_player->add_msg_if_player( m_warning, _( "You feel disjointed." ) ); return false; } else { diff --git a/src/trap.h b/src/trap.h index 990fb4e300a73..c8e61e96bf25e 100644 --- a/src/trap.h +++ b/src/trap.h @@ -65,6 +65,8 @@ bool snake( const tripoint &p, Creature *c, item *i ); } // namespace trapfunc struct vehicle_handle_trap_data { + using itype_id = std::string; + bool remove_trap = false; bool do_explosion = false; bool is_falling = false; @@ -83,6 +85,7 @@ struct vehicle_handle_trap_data { using trap_function = std::function; struct trap { + using itype_id = std::string; trap_str_id id; trap_id loadid; diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index ccb9c38e6448e..d9b564996d7f5 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -654,7 +654,7 @@ bool trapfunc::goo( const tripoint &p, Creature *c, item * ) if( z->type->id != mon_blob ) { z->set_speed_base( z->get_speed_base() - 15 ); //All monsters that aren't blobs or robots transform into a blob - if( !z->type->in_species( species_ROBOT ) ) { + if( !z->type->in_species( ROBOT ) ) { z->poly( mon_blob ); z->set_hp( z->get_speed() ); } @@ -675,7 +675,7 @@ bool trapfunc::dissector( const tripoint &p, Creature *c, item * ) } monster *z = dynamic_cast( c ); if( z != nullptr ) { - if( z->type->in_species( species_ROBOT ) ) { + if( z->type->in_species( ROBOT ) ) { //The monster is a robot. So the dissector should not try to dissect the monsters flesh. //Dissector error sound. sounds::sound( p, 4, sounds::sound_t::electronic_speech, @@ -966,16 +966,16 @@ bool trapfunc::lava( const tripoint &p, Creature *c, item * ) if( z->made_of_any( Creature::cmat_flesh ) ) { dam = 50; } - if( z->made_of( material_veggy ) ) { + if( z->made_of( material_id( "veggy" ) ) ) { dam = 80; } if( z->made_of( LIQUID ) || z->made_of_any( Creature::cmat_flammable ) ) { dam = 200; } - if( z->made_of( material_stone ) ) { + if( z->made_of( material_id( "stone" ) ) ) { dam = 15; } - if( z->made_of( material_kevlar ) || z->made_of( material_steel ) ) { + if( z->made_of( material_id( "kevlar" ) ) || z->made_of( material_id( "steel" ) ) ) { dam = 5; } z->deal_damage( nullptr, bp_torso, damage_instance( DT_HEAT, dam ) ); diff --git a/src/turret.cpp b/src/turret.cpp index 89b3ca8ca6656..1d39b853e45e7 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -64,7 +64,7 @@ turret_data vehicle::turret_query( const vehicle_part &pt ) const turret_data vehicle::turret_query( const tripoint &pos ) { - auto res = get_parts_at( pos, flag_TURRET, part_status_flag::any ); + auto res = get_parts_at( pos, "TURRET", part_status_flag::any ); return !res.empty() ? turret_query( *res.front() ) : turret_data(); } @@ -93,7 +93,7 @@ int turret_data::ammo_remaining() const if( !veh || !part ) { return 0; } - if( part->info().has_flag( flag_USE_TANKS ) ) { + if( part->info().has_flag( "USE_TANKS" ) ) { return veh->fuel_left( ammo_current() ); } return part->base.ammo_remaining(); @@ -101,7 +101,7 @@ int turret_data::ammo_remaining() const int turret_data::ammo_capacity() const { - if( !veh || !part || part->info().has_flag( flag_USE_TANKS ) ) { + if( !veh || !part || part->info().has_flag( "USE_TANKS" ) ) { return 0; } return part->base.ammo_capacity(); @@ -112,7 +112,7 @@ const itype *turret_data::ammo_data() const if( !veh || !part ) { return nullptr; } - if( part->info().has_flag( flag_USE_TANKS ) ) { + if( part->info().has_flag( "USE_TANKS" ) ) { return ammo_current() != "null" ? item::find_type( ammo_current() ) : nullptr; } return part->base.ammo_data(); @@ -141,7 +141,7 @@ std::set turret_data::ammo_options() const return opts; } - if( !part->info().has_flag( flag_USE_TANKS ) ) { + if( !part->info().has_flag( "USE_TANKS" ) ) { if( part->base.ammo_current() != "null" ) { opts.insert( part->base.ammo_current() ); } @@ -176,7 +176,7 @@ std::set turret_data::ammo_effects() const return std::set(); } auto res = part->base.ammo_effects(); - if( part->info().has_flag( flag_USE_TANKS ) && ammo_data() ) { + if( part->info().has_flag( "USE_TANKS" ) && ammo_data() ) { res.insert( ammo_data()->ammo->ammo_effects.begin(), ammo_data()->ammo->ammo_effects.end() ); } return res; @@ -188,7 +188,7 @@ int turret_data::range() const return 0; } int res = part->base.gun_range(); - if( part->info().has_flag( flag_USE_TANKS ) && ammo_data() ) { + if( part->info().has_flag( "USE_TANKS" ) && ammo_data() ) { res += ammo_data()->ammo->range; } return res; @@ -196,7 +196,7 @@ int turret_data::range() const bool turret_data::can_reload() const { - if( !veh || !part || part->info().has_flag( flag_USE_TANKS ) ) { + if( !veh || !part || part->info().has_flag( "USE_TANKS" ) ) { return false; } if( !part->base.magazine_integral() ) { @@ -208,7 +208,7 @@ bool turret_data::can_reload() const bool turret_data::can_unload() const { - if( !veh || !part || part->info().has_flag( flag_USE_TANKS ) ) { + if( !veh || !part || part->info().has_flag( "USE_TANKS" ) ) { return false; } return part->base.ammo_remaining() || part->base.magazine_current(); @@ -220,7 +220,7 @@ turret_data::status turret_data::query() const return status::invalid; } - if( part->info().has_flag( flag_USE_TANKS ) ) { + if( part->info().has_flag( "USE_TANKS" ) ) { if( veh->fuel_left( ammo_current() ) < part->base.ammo_required() ) { return status::no_ammo; } @@ -249,7 +249,7 @@ void turret_data::prepare_fire( player &p ) p.recoil = 0; // set fuel tank fluid as ammo, if appropriate - if( part->info().has_flag( flag_USE_TANKS ) ) { + if( part->info().has_flag( "USE_TANKS" ) ) { auto mode = base()->gun_current_mode(); int qty = mode->ammo_required(); int fuel_left = veh->fuel_left( ammo_current() ); @@ -266,7 +266,7 @@ void turret_data::post_fire( player &p, int shots ) auto mode = base()->gun_current_mode(); // handle draining of vehicle tanks and UPS charges, if applicable - if( part->info().has_flag( flag_USE_TANKS ) ) { + if( part->info().has_flag( "USE_TANKS" ) ) { veh->drain( ammo_current(), mode->ammo_required() * shots ); mode->ammo_unset(); } @@ -331,7 +331,7 @@ void vehicle::turrets_set_targeting() turrets[sel]->enabled = false; } - for( const vpart_reference &vp : get_avail_parts( flag_TURRET_CONTROLS ) ) { + for( const vpart_reference &vp : get_avail_parts( "TURRET_CONTROLS" ) ) { vehicle_part &e = vp.part(); if( e.mount == turrets[sel]->mount ) { e.enabled = turrets[sel]->enabled; diff --git a/src/type_id.h b/src/type_id.h index 69ae264e82f03..d3246ae43dc3c 100644 --- a/src/type_id.h +++ b/src/type_id.h @@ -5,11 +5,6 @@ #include "int_id.h" #include "string_id.h" -using itype_id = std::string; - -class activity_type; -using activity_id = string_id; - class ammunition_type; using ammotype = string_id; diff --git a/src/uistate.h b/src/uistate.h index 6d68705be4c0b..1f172311d3f8c 100644 --- a/src/uistate.h +++ b/src/uistate.h @@ -25,6 +25,8 @@ class uistatedata { /**** this will set a default value on startup, however to save, see below ****/ private: + // not needed for compilation, but keeps syntax plugins happy + using itype_id = std::string; enum side { left = 0, right = 1, NUM_PANES = 2 }; public: int ags_pay_gas_selected_pump = 0; diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index b5fe18527e42f..7b6d6a9b4acab 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -180,7 +180,7 @@ veh_interact::veh_interact( vehicle &veh, const point &p ) for( const auto &e : vpart_info::all() ) { const vpart_info &vp = e.second; vpart_shapes[ vp.name() + vp.item ].push_back( &vp ); - if( vp.has_flag( flag_WHEEL ) ) { + if( vp.has_flag( "WHEEL" ) ) { wheel_types.push_back( &vp ); } } @@ -316,7 +316,7 @@ void veh_interact::do_main_loop() if( veh->has_owner() ) { owner_fac = g->faction_manager_ptr->get( veh->get_owner() ); } else { - owner_fac = g->faction_manager_ptr->get( faction_no_faction ); + owner_fac = g->faction_manager_ptr->get( faction_id( "no_faction" ) ); } while( !finish ) { overview(); @@ -454,9 +454,9 @@ void veh_interact::cache_tool_availability() if( g->u.is_mounted() ) { mech_jack = g->u.mounted_creature->mech_str_addition() + 10; } - max_jack = std::max( { g->u.max_quality( quality_JACK ), mech_jack, - map_selector( g->u.pos(), PICKUP_RANGE ).max_quality( quality_JACK ), - vehicle_selector( g->u.pos(), 2, true, *veh ).max_quality( quality_JACK ) + max_jack = std::max( { g->u.max_quality( qual_JACK ), mech_jack, + map_selector( g->u.pos(), PICKUP_RANGE ).max_quality( qual_JACK ), + vehicle_selector( g->u.pos(), 2, true, *veh ).max_quality( qual_JACK ) } ); } @@ -629,8 +629,8 @@ bool veh_interact::can_self_jack() { int lvl = jack_quality( *veh ); - for( const vpart_reference &vp : veh->get_avail_parts( flag_SELF_JACK ) ) { - if( vp.part().base.has_quality( quality_SELF_JACK, lvl ) ) { + for( const vpart_reference &vp : veh->get_avail_parts( "SELF_JACK" ) ) { + if( vp.part().base.has_quality( qual_SELF_JACK, lvl ) ) { return true; } } @@ -648,7 +648,7 @@ bool veh_interact::can_install_part() if( is_drive_conflict() ) { return false; } - if( sel_vpart_info->has_flag( flag_FUNNEL ) ) { + if( sel_vpart_info->has_flag( "FUNNEL" ) ) { if( std::none_of( parts_here.begin(), parts_here.end(), [&]( const int e ) { return veh->parts[e].is_tank(); } ) ) { @@ -661,7 +661,7 @@ bool veh_interact::can_install_part() } } - if( sel_vpart_info->has_flag( flag_TURRET ) ) { + if( sel_vpart_info->has_flag( "TURRET" ) ) { if( std::any_of( parts_here.begin(), parts_here.end(), [&]( const int e ) { return veh->parts[e].is_turret(); } ) ) { @@ -674,13 +674,13 @@ bool veh_interact::can_install_part() } } - bool is_engine = sel_vpart_info->has_flag( flag_ENGINE ); + bool is_engine = sel_vpart_info->has_flag( "ENGINE" ); //count current engines, some engines don't require higher skill int engines = 0; int dif_eng = 0; - if( is_engine && sel_vpart_info->has_flag( flag_E_HIGHER_SKILL ) ) { - for( const vpart_reference &vp : veh->get_avail_parts( flag_ENGINE ) ) { - if( vp.has_feature( flag_E_HIGHER_SKILL ) ) { + if( is_engine && sel_vpart_info->has_flag( "E_HIGHER_SKILL" ) ) { + for( const vpart_reference &vp : veh->get_avail_parts( "ENGINE" ) ) { + if( vp.has_feature( "E_HIGHER_SKILL" ) ) { engines++; dif_eng = dif_eng / 2 + 8; } @@ -688,10 +688,10 @@ bool veh_interact::can_install_part() } int dif_steering = 0; - if( sel_vpart_info->has_flag( flag_STEERABLE ) ) { + if( sel_vpart_info->has_flag( "STEERABLE" ) ) { std::set axles; for( auto &p : veh->steering ) { - if( !veh->part_flag( p, flag_TRACKED ) ) { + if( !veh->part_flag( p, "TRACKED" ) ) { // tracked parts don't contribute to axle complexity axles.insert( veh->parts[p].mount.x ); } @@ -738,14 +738,14 @@ bool veh_interact::can_install_part() bool use_aid = false; bool use_str = false; item base( sel_vpart_info->item ); - if( sel_vpart_info->has_flag( flag_NEEDS_JACKING ) ) { - qual = quality_JACK; + if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) { + qual = qual_JACK; lvl = jack_quality( *veh ); str = veh->lift_strength(); use_aid = ( max_jack >= lvl ) || can_self_jack(); use_str = g->u.can_lift( *veh ); } else { - qual = quality_LIFT; + qual = qual_LIFT; lvl = std::ceil( units::quantity( base.weight() ) / TOOL_LIFT_FACTOR ); str = base.lift_strength(); @@ -846,7 +846,7 @@ bool veh_interact::do_install( std::string &msg ) tab_filters[1] = [&]( const vpart_info * p ) { auto &part = *p; return part.has_flag( VPFLAG_CARGO ) && // Cargo - !part.has_flag( flag_TURRET ); + !part.has_flag( "TURRET" ); }; tab_filters[2] = [&]( const vpart_info * p ) { auto &part = *p; @@ -860,44 +860,44 @@ bool veh_interact::do_install( std::string &msg ) }; tab_filters[3] = [&]( const vpart_info * p ) { auto &part = *p; - return part.has_flag( flag_TRACK ) || //Util + return part.has_flag( "TRACK" ) || //Util part.has_flag( VPFLAG_FRIDGE ) || part.has_flag( VPFLAG_FREEZER ) || - part.has_flag( flag_KITCHEN ) || - part.has_flag( flag_WELDRIG ) || - part.has_flag( flag_CRAFTRIG ) || - part.has_flag( flag_CHEMLAB ) || - part.has_flag( flag_FORGE ) || - part.has_flag( flag_HORN ) || - part.has_flag( flag_BEEPER ) || - part.has_flag( flag_AUTOPILOT ) || - part.has_flag( flag_WATCH ) || - part.has_flag( flag_ALARMCLOCK ) || + part.has_flag( "KITCHEN" ) || + part.has_flag( "WELDRIG" ) || + part.has_flag( "CRAFTRIG" ) || + part.has_flag( "CHEMLAB" ) || + part.has_flag( "FORGE" ) || + part.has_flag( "HORN" ) || + part.has_flag( "BEEPER" ) || + part.has_flag( "AUTOPILOT" ) || + part.has_flag( "WATCH" ) || + part.has_flag( "ALARMCLOCK" ) || part.has_flag( VPFLAG_RECHARGE ) || - part.has_flag( flag_VISION ) || - part.has_flag( flag_POWER_TRANSFER ) || - part.has_flag( flag_FAUCET ) || - part.has_flag( flag_STEREO ) || - part.has_flag( flag_CHIMES ) || - part.has_flag( flag_MUFFLER ) || - part.has_flag( flag_REMOTE_CONTROLS ) || - part.has_flag( flag_CURTAIN ) || - part.has_flag( flag_SEATBELT ) || - part.has_flag( flag_SECURITY ) || - part.has_flag( flag_SEAT ) || - part.has_flag( flag_BED ) || - part.has_flag( flag_SPACE_HEATER ) || - part.has_flag( flag_COOLER ) || - part.has_flag( flag_DOOR_MOTOR ) || - part.has_flag( flag_WATER_PURIFIER ) || - part.has_flag( flag_WORKBENCH ); + part.has_flag( "VISION" ) || + part.has_flag( "POWER_TRANSFER" ) || + part.has_flag( "FAUCET" ) || + part.has_flag( "STEREO" ) || + part.has_flag( "CHIMES" ) || + part.has_flag( "MUFFLER" ) || + part.has_flag( "REMOTE_CONTROLS" ) || + part.has_flag( "CURTAIN" ) || + part.has_flag( "SEATBELT" ) || + part.has_flag( "SECURITY" ) || + part.has_flag( "SEAT" ) || + part.has_flag( "BED" ) || + part.has_flag( "SPACE_HEATER" ) || + part.has_flag( "COOLER" ) || + part.has_flag( "DOOR_MOTOR" ) || + part.has_flag( "WATER_PURIFIER" ) || + part.has_flag( "WORKBENCH" ); }; tab_filters[4] = [&]( const vpart_info * p ) { auto &part = *p; return( part.has_flag( VPFLAG_OBSTACLE ) || // Hull - part.has_flag( flag_ROOF ) || + part.has_flag( "ROOF" ) || part.has_flag( VPFLAG_ARMOR ) ) && - !part.has_flag( flag_WHEEL ) && + !part.has_flag( "WHEEL" ) && !tab_filters[3]( p ); }; tab_filters[5] = [&]( const vpart_info * p ) { @@ -907,7 +907,7 @@ bool veh_interact::do_install( std::string &msg ) part.has_flag( VPFLAG_CONTROLS ) || part.location == "fuel_source" || part.location == "on_battery_mount" || - ( part.location.empty() && part.has_flag( flag_FUEL_TANK ) ); + ( part.location.empty() && part.has_flag( "FUEL_TANK" ) ); }; // Other: everything that's not in the other filters @@ -983,7 +983,7 @@ bool veh_interact::do_install( std::string &msg ) default: break; } - if( veh->is_foldable() && !sel_vpart_info->has_flag( flag_FOLDABLE ) && + if( veh->is_foldable() && !sel_vpart_info->has_flag( "FOLDABLE" ) && !query_yn( _( "Installing this part will make the vehicle unfoldable. Continue?" ) ) ) { return true; } @@ -1660,14 +1660,14 @@ bool veh_interact::can_remove_part( int idx, const player &p ) bool use_aid = false; bool use_str = false; item base( sel_vpart_info->item ); - if( sel_vpart_info->has_flag( flag_NEEDS_JACKING ) ) { - qual = quality_JACK; + if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) { + qual = qual_JACK; lvl = jack_quality( *veh ); str = veh->lift_strength(); use_aid = ( max_jack >= lvl ) || can_self_jack(); use_str = g->u.can_lift( *veh ); } else { - qual = quality_LIFT; + qual = qual_LIFT; lvl = ceil( units::quantity( base.weight() ) / TOOL_LIFT_FACTOR ); str = base.lift_strength(); use_aid = max_lift >= lvl; @@ -2014,7 +2014,7 @@ void veh_interact::move_cursor( const point &d, int dstart_at ) if( pt.base.damage() > 0 && pt.info().is_repairable() ) { need_repair.push_back( i ); } - if( pt.info().has_flag( flag_WHEEL ) ) { + if( pt.info().has_flag( "WHEEL" ) ) { wheel = &pt; } } @@ -2207,7 +2207,7 @@ void veh_interact::display_stats() const units::volume total_cargo = 0_ml; units::volume free_cargo = 0_ml; - for( const vpart_reference &vp : veh->get_any_parts( flag_CARGO ) ) { + for( const vpart_reference &vp : veh->get_any_parts( "CARGO" ) ) { const size_t p = vp.part_index(); total_cargo += veh->max_volume( p ); free_cargo += veh->free_volume( p ); @@ -2558,9 +2558,9 @@ void veh_interact::display_details( const vpart_info *part ) std::string label; if( part->has_flag( VPFLAG_SEATBELT ) ) { label = small_mode ? _( "Str" ) : _( "Strength" ); - } else if( part->has_flag( flag_HORN ) ) { + } else if( part->has_flag( "HORN" ) ) { label = _( "Noise" ); - } else if( part->has_flag( flag_MUFFLER ) ) { + } else if( part->has_flag( "MUFFLER" ) ) { label = small_mode ? _( "NoisRed" ) : _( "Noise Reduction" ); } else if( part->has_flag( VPFLAG_EXTENDS_VISION ) ) { label = _( "Range" ); @@ -2735,7 +2735,7 @@ void act_vehicle_unload_fuel( vehicle *veh ) uilist smenu; smenu.text = _( "Remove what?" ); for( auto &fuel : fuels ) { - if( fuel == fuel_type_plut_cell && veh->fuel_left( fuel ) < PLUTONIUM_CHARGES ) { + if( fuel == "plut_cell" && veh->fuel_left( fuel ) < PLUTONIUM_CHARGES ) { continue; } smenu.addentry( item::nname( fuel ) ); @@ -2751,7 +2751,7 @@ void act_vehicle_unload_fuel( vehicle *veh ) } int qty = veh->fuel_left( fuel ); - if( fuel == fuel_type_plut_cell ) { + if( fuel == "plut_cell" ) { if( qty / PLUTONIUM_CHARGES == 0 ) { add_msg( m_info, _( "The vehicle has no charged plutonium cells." ) ); return; @@ -2987,7 +2987,7 @@ void veh_interact::complete_vehicle( player &p ) contents.clear(); // Power cables must remove parts from the target vehicle, too. - if( veh->part_flag( vehicle_part, flag_POWER_TRANSFER ) ) { + if( veh->part_flag( vehicle_part, "POWER_TRANSFER" ) ) { veh->remove_remote_part( vehicle_part ); } diff --git a/src/veh_type.cpp b/src/veh_type.cpp index a3d7418f8a196..e0486058a8f52 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -31,7 +31,6 @@ #include "game_constants.h" #include "item.h" #include "mapdata.h" -#include "cata_string_consts.h" class npc; @@ -403,15 +402,15 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) def.damage_reduction = load_damage_array( dred ); } - if( def.has_flag( flag_ENGINE ) ) { + if( def.has_flag( "ENGINE" ) ) { load_engine( def.engine_info, jo, def.fuel_type ); } - if( def.has_flag( flag_WHEEL ) ) { + if( def.has_flag( "WHEEL" ) ) { load_wheel( def.wheel_info, jo ); } - if( def.has_flag( flag_WORKBENCH ) ) { + if( def.has_flag( "WORKBENCH" ) ) { load_workbench( def.workbench_info, jo ); } @@ -437,7 +436,7 @@ void vpart_info::finalize() for( auto &e : vpart_info_all ) { if( e.second.folded_volume > 0_ml ) { - e.second.set_flag( flag_FOLDABLE ); + e.second.set_flag( "FOLDABLE" ); } for( const auto &f : e.second.flags ) { @@ -449,7 +448,7 @@ void vpart_info::finalize() // Calculate and cache z-ordering based off of location // list_order is used when inspecting the vehicle - if( e.second.location == part_location_onroof ) { + if( e.second.location == "on_roof" ) { e.second.z_order = 9; e.second.list_order = 3; } else if( e.second.location == "on_cargo" ) { @@ -577,7 +576,7 @@ void vpart_info::check() if( part.folded_volume < 0_ml ) { debugmsg( "vehicle part %s has negative folded volume", part.id.c_str() ); } - if( part.has_flag( flag_FOLDABLE ) && part.folded_volume == 0_ml ) { + if( part.has_flag( "FOLDABLE" ) && part.folded_volume == 0_ml ) { debugmsg( "vehicle part %s has folding part with zero folded volume", part.name() ); } if( !item::type_is_defined( part.default_ammo ) ) { @@ -602,13 +601,13 @@ void vpart_info::check() part.id.c_str(), part.fuel_type.c_str() ); part.fuel_type = "null"; } - if( part.has_flag( flag_TURRET ) && !base_item_type.gun ) { + if( part.has_flag( "TURRET" ) && !base_item_type.gun ) { debugmsg( "vehicle part %s has the TURRET flag, but is not made from a gun item", part.id.c_str() ); } - if( !part.emissions.empty() && !part.has_flag( flag_EMITTER ) ) { + if( !part.emissions.empty() && !part.has_flag( "EMITTER" ) ) { debugmsg( "vehicle part %s has emissions set, but the EMITTER flag is not set", part.id.c_str() ); } - if( part.has_flag( flag_EMITTER ) ) { + if( part.has_flag( "EMITTER" ) ) { if( part.emissions.empty() ) { debugmsg( "vehicle part %s has the EMITTER flag, but no emissions were set", part.id.c_str() ); } else { @@ -620,7 +619,7 @@ void vpart_info::check() } } } - if( part.has_flag( flag_WHEEL ) && !base_item_type.wheel ) { + if( part.has_flag( "WHEEL" ) && !base_item_type.wheel ) { debugmsg( "vehicle part %s has the WHEEL flag, but base item %s is not a wheel. THIS WILL CRASH!", part.id.c_str(), part.item ); } @@ -682,7 +681,7 @@ int vpart_info::format_description( std::string &msg, const nc_color &format_col long_descrip += description.translated(); } for( const auto &flagid : flags ) { - if( flagid == flag_ALARMCLOCK || flagid == flag_WATCH ) { + if( flagid == "ALARMCLOCK" || flagid == "WATCH" ) { continue; } json_flag flag = json_flag::get( flagid ); @@ -693,15 +692,15 @@ int vpart_info::format_description( std::string &msg, const nc_color &format_col long_descrip += _( flag.info() ); } } - if( ( has_flag( flag_SEAT ) || has_flag( flag_BED ) ) && !has_flag( flag_BELTABLE ) ) { - json_flag nobelt = json_flag::get( flag_NONBELTABLE ); + if( ( has_flag( "SEAT" ) || has_flag( "BED" ) ) && !has_flag( "BELTABLE" ) ) { + json_flag nobelt = json_flag::get( "NONBELTABLE" ); long_descrip += " " + _( nobelt.info() ); } - if( has_flag( flag_BOARDABLE ) && has_flag( flag_OPENABLE ) ) { - json_flag nobelt = json_flag::get( flag_DOOR ); + if( has_flag( "BOARDABLE" ) && has_flag( "OPENABLE" ) ) { + json_flag nobelt = json_flag::get( "DOOR" ); long_descrip += " " + _( nobelt.info() ); } - if( has_flag( flag_TURRET ) ) { + if( has_flag( "TURRET" ) ) { class::item base( item ); long_descrip += string_format( _( "\nRange: %1$5d Damage: %2$5.0f" ), base.gun_range( true ), @@ -1068,7 +1067,7 @@ void vehicle_prototype::finalize() } } - if( pt.part.obj().has_flag( flag_CARGO ) ) { + if( pt.part.obj().has_flag( "CARGO" ) ) { cargo_spots.insert( pt.pos ); } } diff --git a/src/veh_type.h b/src/veh_type.h index 258fbdfb06c99..55cf3811e97ba 100644 --- a/src/veh_type.h +++ b/src/veh_type.h @@ -23,6 +23,8 @@ #include "point.h" #include "translations.h" +using itype_id = std::string; + class JsonObject; class Character; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e3637c4c5a5f1..3042bd524756d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -183,7 +183,7 @@ void vehicle_stack::insert( const item &newitem ) units::volume vehicle_stack::max_volume() const { - if( myorigin->part_flag( part_num, flag_CARGO ) && myorigin->parts[part_num].is_available() ) { + if( myorigin->part_flag( part_num, "CARGO" ) && myorigin->parts[part_num].is_available() ) { // Set max volume for vehicle cargo to prevent integer overflow return std::min( myorigin->parts[part_num].info().size, 10000_liter ); } @@ -228,7 +228,7 @@ bool vehicle::player_in_control( const player &p ) const const optional_vpart_position vp = g->m.veh_at( p.pos() ); if( vp && &vp->vehicle() == this && - ( ( part_with_feature( vp->part_index(), flag_CONTROL_ANIMAL, true ) >= 0 && + ( ( part_with_feature( vp->part_index(), "CONTROL_ANIMAL", true ) >= 0 && has_engine_type( fuel_type_animal, false ) && has_harnessed_animal() ) || ( part_with_feature( vp->part_index(), VPFLAG_CONTROLS, false ) >= 0 ) ) && p.controlling_vehicle ) { @@ -245,7 +245,7 @@ bool vehicle::remote_controlled( const player &p ) const return false; } - for( const vpart_reference &vp : get_avail_parts( flag_REMOTE_CONTROLS ) ) { + for( const vpart_reference &vp : get_avail_parts( "REMOTE_CONTROLS" ) ) { if( rl_dist( p.pos(), vp.pos() ) <= 40 ) { return true; } @@ -260,6 +260,7 @@ bool vehicle::remote_controlled( const player &p ) const * loading from a game saved before the vehicle construction rules overhaul). */ void vehicle::add_missing_frames() { + static const vpart_id frame_id( "frame_vertical" ); //No need to check the same spot more than once std::set locations_checked; for( auto &i : parts ) { @@ -277,7 +278,7 @@ void vehicle::add_missing_frames() } if( !found ) { // Install missing frame - parts.emplace_back( vpart_frame_vertical, i.mount, item( vpart_frame_vertical->item ) ); + parts.emplace_back( frame_id, i.mount, item( frame_id->item ) ); } } } @@ -292,7 +293,7 @@ void vehicle::add_steerable_wheels() // Find wheels that have steerable versions. // Convert the wheel(s) with the largest x value. for( const vpart_reference &vp : get_all_parts() ) { - if( vp.has_feature( flag_STEERABLE ) || vp.has_feature( flag_TRACKED ) ) { + if( vp.has_feature( "STEERABLE" ) || vp.has_feature( "TRACKED" ) ) { // Has a wheel that is inherently steerable // (e.g. unicycle, casters), this vehicle doesn't // need conversion. @@ -402,7 +403,7 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) //Provide some variety to non-mint vehicles if( veh_status != 0 ) { //Leave engine running in some vehicles, if the engine has not been destroyed - if( veh_fuel_mult > 0 && !empty( get_avail_parts( flag_ENGINE ) ) && + if( veh_fuel_mult > 0 && !empty( get_avail_parts( "ENGINE" ) ) && one_in( 8 ) && !destroyEngine && !has_no_key && has_engine_type_not( fuel_type_muscle, true ) ) { engine_on = true; } @@ -440,15 +441,15 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) blood_inside = true; } - for( const vpart_reference &vp : get_parts_including_carried( flag_FRIDGE ) ) { + for( const vpart_reference &vp : get_parts_including_carried( "FRIDGE" ) ) { vp.part().enabled = true; } - for( const vpart_reference &vp : get_parts_including_carried( flag_FREEZER ) ) { + for( const vpart_reference &vp : get_parts_including_carried( "FREEZER" ) ) { vp.part().enabled = true; } - for( const vpart_reference &vp : get_parts_including_carried( flag_WATER_PURIFIER ) ) { + for( const vpart_reference &vp : get_parts_including_carried( "WATER_PURIFIER" ) ) { vp.part().enabled = true; } } @@ -465,44 +466,44 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) if( pt.is_reactor() ) { if( veh_fuel_mult == 100 ) { // Mint condition vehicle - pt.ammo_set( fuel_type_plut_cell, pt.ammo_capacity() ); + pt.ammo_set( "plut_cell", pt.ammo_capacity() ); } else if( one_in( 2 ) && veh_fuel_mult > 0 ) { // Randomize charge a bit - pt.ammo_set( fuel_type_plut_cell, pt.ammo_capacity() * ( veh_fuel_mult + rng( 0, 10 ) ) / 100 ); + pt.ammo_set( "plut_cell", pt.ammo_capacity() * ( veh_fuel_mult + rng( 0, 10 ) ) / 100 ); } else if( one_in( 2 ) && veh_fuel_mult > 0 ) { - pt.ammo_set( fuel_type_plut_cell, pt.ammo_capacity() * ( veh_fuel_mult - rng( 0, 10 ) ) / 100 ); + pt.ammo_set( "plut_cell", pt.ammo_capacity() * ( veh_fuel_mult - rng( 0, 10 ) ) / 100 ); } else { - pt.ammo_set( fuel_type_plut_cell, pt.ammo_capacity() * veh_fuel_mult / 100 ); + pt.ammo_set( "plut_cell", pt.ammo_capacity() * veh_fuel_mult / 100 ); } } if( pt.is_battery() ) { if( veh_fuel_mult == 100 ) { // Mint condition vehicle - pt.ammo_set( fuel_type_battery, pt.ammo_capacity() ); + pt.ammo_set( "battery", pt.ammo_capacity() ); } else if( one_in( 2 ) && veh_fuel_mult > 0 ) { // Randomize battery ammo a bit - pt.ammo_set( fuel_type_battery, pt.ammo_capacity() * ( veh_fuel_mult + rng( 0, 10 ) ) / 100 ); + pt.ammo_set( "battery", pt.ammo_capacity() * ( veh_fuel_mult + rng( 0, 10 ) ) / 100 ); } else if( one_in( 2 ) && veh_fuel_mult > 0 ) { - pt.ammo_set( fuel_type_battery, pt.ammo_capacity() * ( veh_fuel_mult - rng( 0, 10 ) ) / 100 ); + pt.ammo_set( "battery", pt.ammo_capacity() * ( veh_fuel_mult - rng( 0, 10 ) ) / 100 ); } else { - pt.ammo_set( fuel_type_battery, pt.ammo_capacity() * veh_fuel_mult / 100 ); + pt.ammo_set( "battery", pt.ammo_capacity() * veh_fuel_mult / 100 ); } } - if( pt.is_tank() && type->parts[p].fuel != fuel_type_none ) { + if( pt.is_tank() && type->parts[p].fuel != "null" ) { int qty = pt.ammo_capacity() * veh_fuel_mult / 100; qty *= std::max( item::find_type( type->parts[p].fuel )->stack_size, 1 ); qty /= to_milliliter( units::legacy_volume_factor ); pt.ammo_set( type->parts[ p ].fuel, qty ); - } else if( pt.is_fuel_store() && type->parts[p].fuel != fuel_type_none ) { + } else if( pt.is_fuel_store() && type->parts[p].fuel != "null" ) { int qty = pt.ammo_capacity() * veh_fuel_mult / 100; pt.ammo_set( type->parts[ p ].fuel, qty ); } - if( vp.has_feature( flag_OPENABLE ) ) { // doors are closed + if( vp.has_feature( "OPENABLE" ) ) { // doors are closed if( !pt.open && one_in( 4 ) ) { open( p ); } } - if( vp.has_feature( flag_BOARDABLE ) ) { // no passengers + if( vp.has_feature( "BOARDABLE" ) ) { // no passengers pt.remove_flag( vehicle_part::passenger_flag ); } @@ -537,9 +538,9 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) } while( one_in( 3 ) ); } - } else if( ( destroySeats && ( vp.has_feature( flag_SEAT ) || vp.has_feature( flag_SEATBELT ) ) ) || - ( destroyControls && ( vp.has_feature( flag_CONTROLS ) || vp.has_feature( flag_SECURITY ) ) ) || - ( destroyAlarm && vp.has_feature( flag_SECURITY ) ) ) { + } else if( ( destroySeats && ( vp.has_feature( "SEAT" ) || vp.has_feature( "SEATBELT" ) ) ) || + ( destroyControls && ( vp.has_feature( "CONTROLS" ) || vp.has_feature( "SECURITY" ) ) ) || + ( destroyAlarm && vp.has_feature( "SECURITY" ) ) ) { set_hp( pt, 0 ); } @@ -550,7 +551,7 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) } //Solar panels have 25% of being destroyed - if( vp.has_feature( flag_SOLAR_PANEL ) && one_in( 4 ) ) { + if( vp.has_feature( "SOLAR_PANEL" ) && one_in( 4 ) ) { set_hp( pt, 0 ); } @@ -577,14 +578,14 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) if( distSq <= 1 ) { pt.blood = rng( 200, 400 ) - distSq * 100; } - } else if( vp.has_feature( flag_SEAT ) ) { + } else if( vp.has_feature( "SEAT" ) ) { // Set the center of the bloody mess inside blood_inside_pos.emplace( vp.mount() ); } } } //sets the vehicle to locked, if there is no key and an alarm part exists - if( vp.has_feature( flag_SECURITY ) && has_no_key && pt.is_available() ) { + if( vp.has_feature( "SECURITY" ) && has_no_key && pt.is_available() ) { is_locked = true; if( one_in( 2 ) ) { @@ -653,7 +654,7 @@ void vehicle::autopilot_patrol() return; } zone_manager &mgr = zone_manager::get_manager(); - const auto &zone_src_set = mgr.get_near( zone_type_VEHICLE_PATROL, + const auto &zone_src_set = mgr.get_near( zone_type_id( "VEHICLE_PATROL" ), g->m.getabs( global_pos3() ), 60 ); if( zone_src_set.empty() ) { is_patrolling = false; @@ -1074,7 +1075,7 @@ bool vehicle::is_engine_type( const int e, const itype_id &ft ) const bool vehicle::is_perpetual_type( const int e ) const { const itype_id &ft = part_info( engines[e] ).fuel_type; - return item( ft ).has_flag( flag_PERPETUAL ); + return item( ft ).has_flag( "PERPETUAL" ); } bool vehicle::is_engine_on( const int e ) const @@ -1107,7 +1108,7 @@ bool vehicle::has_security_working() const bool found_security = false; if( fuel_left( fuel_type_battery ) > 0 ) { for( int s : speciality ) { - if( part_flag( s, flag_SECURITY ) && parts[ s ].is_available() ) { + if( part_flag( s, "SECURITY" ) && parts[ s ].is_available() ) { found_security = true; break; } @@ -1232,7 +1233,7 @@ bool vehicle::has_structural_part( const point &dp ) const { for( const int elem : parts_at_relative( dp, false ) ) { if( part_info( elem ).location == part_location_structure && - !part_info( elem ).has_flag( flag_PROTRUSION ) ) { + !part_info( elem ).has_flag( "PROTRUSION" ) ) { return true; } } @@ -1269,7 +1270,7 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const //It also has to be a real part, not the null part const vpart_info &part = id.obj(); - if( part.has_flag( flag_NOINSTALL ) ) { + if( part.has_flag( "NOINSTALL" ) ) { return false; } @@ -1280,11 +1281,11 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const return false; } // If its a part that harnesses animals that dont allow placing on it. - if( !parts_in_square.empty() && part_info( parts_in_square[0] ).has_flag( flag_ANIMAL_CTRL ) ) { + if( !parts_in_square.empty() && part_info( parts_in_square[0] ).has_flag( "ANIMAL_CTRL" ) ) { return false; } //No other part can be placed on a protrusion - if( !parts_in_square.empty() && part_info( parts_in_square[0] ).has_flag( flag_PROTRUSION ) ) { + if( !parts_in_square.empty() && part_info( parts_in_square[0] ).has_flag( "PROTRUSION" ) ) { return false; } @@ -1299,7 +1300,7 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } // Until we have an interface for handling multiple components with CARGO space, // exclude them from being mounted in the same tile. - if( part.has_flag( flag_CARGO ) && other_part.has_flag( flag_CARGO ) ) { + if( part.has_flag( "CARGO" ) && other_part.has_flag( "CARGO" ) ) { return false; } @@ -1328,7 +1329,7 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const if( part.has_flag( VPFLAG_ALTERNATOR ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_E_ALTERNATOR ) ) { + if( part_info( elem ).has_flag( "E_ALTERNATOR" ) ) { anchor_found = true; } } @@ -1338,10 +1339,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Seatbelts must be installed on a seat - if( part.has_flag( flag_SEATBELT ) ) { + if( part.has_flag( "SEATBELT" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_BELTABLE ) ) { + if( part_info( elem ).has_flag( "BELTABLE" ) ) { anchor_found = true; } } @@ -1351,10 +1352,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Internal must be installed into a cargo area. - if( part.has_flag( flag_INTERNAL ) ) { + if( part.has_flag( "INTERNAL" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_CARGO ) ) { + if( part_info( elem ).has_flag( "CARGO" ) ) { anchor_found = true; } } @@ -1365,10 +1366,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const // curtains must be installed on (reinforced)windshields // TODO: do this automatically using "location":"on_mountpoint" - if( part.has_flag( flag_WINDOW_CURTAIN ) ) { + if( part.has_flag( "WINDOW_CURTAIN" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_WINDOW ) ) { + if( part_info( elem ).has_flag( "WINDOW" ) ) { anchor_found = true; } } @@ -1378,10 +1379,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } // Security system must be installed on controls - if( part.has_flag( flag_ON_CONTROLS ) ) { + if( part.has_flag( "ON_CONTROLS" ) ) { bool anchor_found = false; for( auto it : parts_in_square ) { - if( part_info( it ).has_flag( flag_CONTROLS ) ) { + if( part_info( it ).has_flag( "CONTROLS" ) ) { anchor_found = true; } } @@ -1392,10 +1393,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const // Cargo locks must go on lockable cargo containers // TODO: do this automatically using "location":"on_mountpoint" - if( part.has_flag( flag_CARGO_LOCKING ) ) { + if( part.has_flag( "CARGO_LOCKING" ) ) { bool anchor_found = false; for( auto it : parts_in_square ) { - if( part_info( it ).has_flag( flag_LOCKABLE_CARGO ) ) { + if( part_info( it ).has_flag( "LOCKABLE_CARGO" ) ) { anchor_found = true; } } @@ -1405,10 +1406,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Swappable storage battery must be installed on a BATTERY_MOUNT - if( part.has_flag( flag_NEEDS_BATTERY_MOUNT ) ) { + if( part.has_flag( "NEEDS_BATTERY_MOUNT" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_BATTERY_MOUNT ) ) { + if( part_info( elem ).has_flag( "BATTERY_MOUNT" ) ) { anchor_found = true; } } @@ -1418,10 +1419,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Door motors need OPENABLE - if( part.has_flag( flag_DOOR_MOTOR ) ) { + if( part.has_flag( "DOOR_MOTOR" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_OPENABLE ) ) { + if( part_info( elem ).has_flag( "OPENABLE" ) ) { anchor_found = true; } } @@ -1431,28 +1432,28 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Mirrors cannot be mounted on OPAQUE parts - if( part.has_flag( flag_VISION ) && !part.has_flag( flag_CAMERA ) ) { + if( part.has_flag( "VISION" ) && !part.has_flag( "CAMERA" ) ) { for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_OPAQUE ) ) { + if( part_info( elem ).has_flag( "OPAQUE" ) ) { return false; } } } //and vice versa - if( part.has_flag( flag_OPAQUE ) ) { + if( part.has_flag( "OPAQUE" ) ) { for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_VISION ) && - !part_info( elem ).has_flag( flag_CAMERA ) ) { + if( part_info( elem ).has_flag( "VISION" ) && + !part_info( elem ).has_flag( "CAMERA" ) ) { return false; } } } //Turrets must be installed on a turret mount - if( part.has_flag( flag_TURRET ) ) { + if( part.has_flag( "TURRET" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_TURRET_MOUNT ) ) { + if( part_info( elem ).has_flag( "TURRET_MOUNT" ) ) { anchor_found = true; break; } @@ -1463,19 +1464,19 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Turret mounts must NOT be installed on other (modded) turret mounts - if( part.has_flag( flag_TURRET_MOUNT ) ) { + if( part.has_flag( "TURRET_MOUNT" ) ) { for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_TURRET_MOUNT ) ) { + if( part_info( elem ).has_flag( "TURRET_MOUNT" ) ) { return false; } } } //Roof-mounted parts must be installed on a roofs - if( part.has_flag( flag_ON_ROOF ) ) { + if( part.has_flag( "ON_ROOF" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_ROOF ) ) { + if( part_info( elem ).has_flag( "ROOF" ) ) { anchor_found = true; break; } @@ -1486,10 +1487,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } // Wheels that need axles must be installed on a wheel mount - if( part.has_flag( flag_NEEDS_WHEEL_MOUNT_LIGHT ) ) { + if( part.has_flag( "NEEDS_WHEEL_MOUNT_LIGHT" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_WHEEL_MOUNT_LIGHT ) ) { + if( part_info( elem ).has_flag( "WHEEL_MOUNT_LIGHT" ) ) { anchor_found = true; break; } @@ -1498,10 +1499,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const return false; } } - if( part.has_flag( flag_NEEDS_WHEEL_MOUNT_MEDIUM ) ) { + if( part.has_flag( "NEEDS_WHEEL_MOUNT_MEDIUM" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_WHEEL_MOUNT_MEDIUM ) ) { + if( part_info( elem ).has_flag( "WHEEL_MOUNT_MEDIUM" ) ) { anchor_found = true; break; } @@ -1510,10 +1511,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const return false; } } - if( part.has_flag( flag_NEEDS_WHEEL_MOUNT_HEAVY ) ) { + if( part.has_flag( "NEEDS_WHEEL_MOUNT_HEAVY" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_WHEEL_MOUNT_HEAVY ) ) { + if( part_info( elem ).has_flag( "WHEEL_MOUNT_HEAVY" ) ) { anchor_found = true; break; } @@ -1524,10 +1525,10 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } //Turret controls must be installed on a turret - if( part.has_flag( flag_TURRET_CONTROLS ) ) { + if( part.has_flag( "TURRET_CONTROLS" ) ) { bool anchor_found = false; for( const auto &elem : parts_in_square ) { - if( part_info( elem ).has_flag( flag_TURRET ) ) { + if( part_info( elem ).has_flag( "TURRET" ) ) { anchor_found = true; break; } @@ -1556,15 +1557,15 @@ bool vehicle::can_unmount( const int p, std::string &reason ) const // Check if the part is required by another part. Do not allow removing those. // { "FLAG THAT IS REQUIRED", "FLAG THAT REQUIRES", "Reason why can't remove." } static const std::array, 9> blocking_flags = {{ - std::make_tuple( flag_ENGINE, flag_ALTERNATOR, translate_marker( "Remove attached alternator first." ) ), - std::make_tuple( flag_BELTABLE, flag_SEATBELT, translate_marker( "Remove attached seatbelt first." ) ), - std::make_tuple( flag_WINDOW, flag_CURTAIN, translate_marker( "Remove attached curtains first." ) ), - std::make_tuple( flag_CONTROLS, flag_ON_CONTROLS, translate_marker( "Remove the attached %s first." ) ), - std::make_tuple( flag_BATTERY_MOUNT, flag_NEEDS_BATTERY_MOUNT, translate_marker( "Remove battery from mount first." ) ), - std::make_tuple( flag_TURRET_MOUNT, flag_TURRET, translate_marker( "Remove attached mounted weapon first." ) ), - std::make_tuple( flag_WHEEL_MOUNT_LIGHT, flag_NEEDS_WHEEL_MOUNT_LIGHT, translate_marker( "Remove attached wheel first." ) ), - std::make_tuple( flag_WHEEL_MOUNT_MEDIUM, flag_NEEDS_WHEEL_MOUNT_MEDIUM, translate_marker( "Remove attached wheel first." ) ), - std::make_tuple( flag_WHEEL_MOUNT_HEAVY, flag_NEEDS_WHEEL_MOUNT_HEAVY, translate_marker( "Remove attached wheel first." ) ) + std::make_tuple( "ENGINE", "ALTERNATOR", translate_marker( "Remove attached alternator first." ) ), + std::make_tuple( "BELTABLE", "SEATBELT", translate_marker( "Remove attached seatbelt first." ) ), + std::make_tuple( "WINDOW", "CURTAIN", translate_marker( "Remove attached curtains first." ) ), + std::make_tuple( "CONTROLS", "ON_CONTROLS", translate_marker( "Remove the attached %s first." ) ), + std::make_tuple( "BATTERY_MOUNT", "NEEDS_BATTERY_MOUNT", translate_marker( "Remove battery from mount first." ) ), + std::make_tuple( "TURRET_MOUNT", "TURRET", translate_marker( "Remove attached mounted weapon first." ) ), + std::make_tuple( "WHEEL_MOUNT_LIGHT", "NEEDS_WHEEL_MOUNT_LIGHT", translate_marker( "Remove attached wheel first." ) ), + std::make_tuple( "WHEEL_MOUNT_MEDIUM", "NEEDS_WHEEL_MOUNT_MEDIUM", translate_marker( "Remove attached wheel first." ) ), + std::make_tuple( "WHEEL_MOUNT_HEAVY", "NEEDS_WHEEL_MOUNT_HEAVY", translate_marker( "Remove attached wheel first." ) ) } }; for( auto &flag_check : blocking_flags ) { @@ -1685,7 +1686,7 @@ bool vehicle::is_connected( const vehicle_part &to, const vehicle_part &from, if( !parts_there.empty() && !parts[ parts_there[ 0 ] ].removed && part_info( parts_there[ 0 ] ).location == "structure" && - !part_info( parts_there[ 0 ] ).has_flag( flag_PROTRUSION ) ) { + !part_info( parts_there[ 0 ] ).has_flag( "PROTRUSION" ) ) { //Only add the part if we haven't been here before bool found = false; for( auto &elem : discovered ) { @@ -1747,26 +1748,26 @@ int vehicle::install_part( const point &dp, const vehicle_part &new_part ) } else { // TODO: read toggle groups from JSON static const std::vector enable_like = {{ - flag_CONE_LIGHT, - flag_CIRCLE_LIGHT, - flag_AISLE_LIGHT, - flag_AUTOPILOT, - flag_DOME_LIGHT, - flag_ATOMIC_LIGHT, - flag_STEREO, - flag_CHIMES, - flag_FRIDGE, - flag_FREEZER, - flag_RECHARGE, - flag_PLOW, - flag_REAPER, - flag_PLANTER, - flag_SCOOP, - flag_SPACE_HEATER, - flag_COOLER, - flag_WATER_PURIFIER, - flag_ROCKWHEEL, - flag_ROADHEAD + "CONE_LIGHT", + "CIRCLE_LIGHT", + "AISLE_LIGHT", + "AUTOPILOT", + "DOME_LIGHT", + "ATOMIC_LIGHT", + "STEREO", + "CHIMES", + "FRIDGE", + "FREEZER", + "RECHARGE", + "PLOW", + "REAPER", + "PLANTER", + "SCOOP", + "SPACE_HEATER", + "COOLER", + "WATER_PURIFIER", + "ROCKWHEEL", + "ROADHEAD" } }; @@ -2006,7 +2007,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) const tripoint part_loc = global_part_pos3( p ); // Unboard any entities standing on removed boardable parts - if( part_flag( p, flag_BOARDABLE ) && parts[p].has_flag( vehicle_part::passenger_flag ) ) { + if( part_flag( p, "BOARDABLE" ) && parts[p].has_flag( vehicle_part::passenger_flag ) ) { handler.unboard( part_loc ); } @@ -2027,12 +2028,12 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) // if a windshield is removed (usually destroyed) also remove curtains // attached to it. - if( remove_dependent_part( flag_WINDOW, flag_CURTAIN ) || part_flag( p, VPFLAG_OPAQUE ) ) { + if( remove_dependent_part( "WINDOW", "CURTAIN" ) || part_flag( p, VPFLAG_OPAQUE ) ) { handler.set_transparency_cache_dirty( sm_pos.z ); } - remove_dependent_part( flag_SEAT, flag_SEATBELT ); - remove_dependent_part( flag_BATTERY_MOUNT, flag_NEEDS_BATTERY_MOUNT ); + remove_dependent_part( "SEAT", "SEATBELT" ); + remove_dependent_part( "BATTERY_MOUNT", "NEEDS_BATTERY_MOUNT" ); // Release any animal held by the part if( parts[p].has_flag( vehicle_part::animal_flag ) ) { @@ -2043,7 +2044,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) } // Update current engine configuration if needed - if( part_flag( p, flag_ENGINE ) && engines.size() > 1 ) { + if( part_flag( p, "ENGINE" ) && engines.size() > 1 ) { bool any_engine_on = false; for( auto &e : engines ) { @@ -2065,7 +2066,7 @@ bool vehicle::remove_part( const int p, RemovePartHandler &handler ) const auto lz_iter = loot_zones.find( parts[p].mount ); const bool no_zone = lz_iter != loot_zones.end(); - if( no_zone && part_flag( p, flag_CARGO ) ) { + if( no_zone && part_flag( p, "CARGO" ) ) { // Using the key here (instead of the iterator) will remove all zones on // this mount points regardless of how many there are loot_zones.erase( parts[p].mount ); @@ -2347,7 +2348,7 @@ bool vehicle::find_and_split_vehicles( int exclude ) void vehicle::relocate_passengers( const std::vector &passengers ) { - const auto boardables = get_avail_parts( flag_BOARDABLE ); + const auto boardables = get_avail_parts( "BOARDABLE" ); for( player *passenger : passengers ) { for( const vpart_reference &vp : boardables ) { if( vp.part().passenger_id == passenger->getID() ) { @@ -2398,7 +2399,7 @@ bool vehicle::split_vehicles( const std::vector> &new_vehs, for( size_t sp = 0; sp < split_parts.size(); sp++ ) { int p = split_parts[ sp ]; if( part_info( p ).location == part_location_structure && - !part_info( p ).has_flag( flag_PROTRUSION ) ) { + !part_info( p ).has_flag( "PROTRUSION" ) ) { split_part0 = sp; break; } @@ -2437,7 +2438,7 @@ bool vehicle::split_vehicles( const std::vector> &new_vehs, player *passenger = nullptr; // Unboard any entities standing on any transferred part - if( part_flag( mov_part, flag_BOARDABLE ) ) { + if( part_flag( mov_part, "BOARDABLE" ) ) { passenger = get_passenger( mov_part ); if( passenger ) { passengers.push_back( passenger ); @@ -2791,7 +2792,7 @@ int vehicle::next_part_to_close( int p, bool outside ) const if( part_flag( *part_it, VPFLAG_OPENABLE ) && parts[ *part_it ].is_available() && parts[*part_it].open == 1 - && ( !outside || !part_flag( *part_it, flag_OPENCLOSE_INSIDE ) ) ) { + && ( !outside || !part_flag( *part_it, "OPENCLOSE_INSIDE" ) ) ) { return *part_it; } } @@ -2805,7 +2806,7 @@ int vehicle::next_part_to_open( int p, bool outside ) const // We want forwards, since we open the innermost thing first (curtains), and then the innermost thing (door) for( auto &elem : parts_here ) { if( part_flag( elem, VPFLAG_OPENABLE ) && parts[ elem ].is_available() && parts[elem].open == 0 && - ( !outside || !part_flag( elem, flag_OPENCLOSE_INSIDE ) ) ) { + ( !outside || !part_flag( elem, "OPENCLOSE_INSIDE" ) ) ) { return elem; } } @@ -2938,7 +2939,7 @@ std::vector> vehicle::find_lines_of_parts( int part, const std: point target = parts[ part ].mount; for( const vpart_reference &vp : possible_parts ) { if( vp.part().is_unavailable() || - !vp.has_feature( flag_MULTISQUARE ) || + !vp.has_feature( "MULTISQUARE" ) || vp.info().get_id() != part_id ) { continue; } @@ -3114,7 +3115,7 @@ int vehicle::roof_at_part( const int part ) const { std::vector parts_in_square = parts_at_relative( parts[part].mount, true ); for( const int p : parts_in_square ) { - if( part_info( p ).location == part_location_onroof || part_flag( p, flag_ROOF ) ) { + if( part_info( p ).location == "on_roof" || part_flag( p, "ROOF" ) ) { return p; } } @@ -3343,15 +3344,15 @@ int vehicle::fuel_left( const itype_id &ftype, bool recurse ) const const int p = avail_part_with_feature( vp->part_index(), VPFLAG_ENGINE, true ); if( p >= 0 && is_part_on( p ) && part_info( p ).fuel_type == fuel_type_muscle ) { //Broken limbs prevent muscle engines from working - if( ( part_info( p ).has_flag( flag_MUSCLE_LEGS ) && ( g->u.get_working_leg_count() >= 2 ) ) || - ( part_info( p ).has_flag( flag_MUSCLE_ARMS ) && + if( ( part_info( p ).has_flag( "MUSCLE_LEGS" ) && ( g->u.get_working_leg_count() >= 2 ) ) || + ( part_info( p ).has_flag( "MUSCLE_ARMS" ) && ( g->u.get_working_arm_count() >= 2 ) ) ) { fl += 10; } } } // As do any other engine flagged as perpetual - } else if( item( ftype ).has_flag( flag_PERPETUAL ) ) { + } else if( item( ftype ).has_flag( "PERPETUAL" ) ) { fl += 10; } @@ -3469,7 +3470,7 @@ int vehicle::basic_consumption( const itype_id &ftype ) const int vehicle::consumption_per_hour( const itype_id &ftype, int fuel_rate_w ) const { item fuel = item( ftype ); - if( fuel_rate_w == 0 || fuel.has_flag( flag_PERPETUAL ) || !engine_on ) { + if( fuel_rate_w == 0 || fuel.has_flag( "PERPETUAL" ) || !engine_on ) { return 0; } // consume this fuel type's share of alternator load for 3600 seconds @@ -3768,7 +3769,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) double muffle = 1.0; double m = 0.0; int exhaust_part = -1; - for( const vpart_reference &vp : get_avail_parts( flag_MUFFLER ) ) { + for( const vpart_reference &vp : get_avail_parts( "MUFFLER" ) ) { m = 1.0 - ( 1.0 - vp.info().bonus / 100.0 ) * vp.part().health_percent(); if( m < muffle ) { muffle = m; @@ -3792,7 +3793,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) cur_stress = std::max( cur_stress, 1.0 ); double part_noise = cur_stress * part_info( p ).engine_noise_factor(); - if( part_info( p ).has_flag( flag_E_COMBUSTION ) ) { + if( part_info( p ).has_flag( "E_COMBUSTION" ) ) { combustion = true; double health = parts[p].health_percent(); if( parts[ p ].base.faults.count( fault_filter_fuel ) ) { @@ -3916,16 +3917,16 @@ double vehicle::coeff_air_drag() const if( p.info().location != part_location_center ) { return false; } - return !( p.inside || p.info().has_flag( flag_NO_ROOF_NEEDED ) || - p.info().has_flag( flag_WINDSHIELD ) || - p.info().has_flag( flag_OPENABLE ) ); + return !( p.inside || p.info().has_flag( "NO_ROOF_NEEDED" ) || + p.info().has_flag( "WINDSHIELD" ) || + p.info().has_flag( "OPENABLE" ) ); }; const auto d_protrusion = [&]( std::vector parts_at ) { if( parts_at.size() > 1 ) { return false; } else { - return parts[ parts_at.front() ].info().has_flag( flag_PROTRUSION ); + return parts[ parts_at.front() ].info().has_flag( "PROTRUSION" ); } }; const auto d_check_min = [&]( int &value, const vehicle_part & p, bool test ) { @@ -3948,22 +3949,22 @@ double vehicle::coeff_air_drag() const d_check_min( drag[ col ].pro, parts[ p ], d_protrusion( parts_at ) ); for( int pa_index : parts_at ) { const vehicle_part &pa = parts[ pa_index ]; - d_check_max( drag[ col ].hboard, pa, pa.info().has_flag( flag_HALF_BOARD ) ); - d_check_max( drag[ col ].fboard, pa, pa.info().has_flag( flag_FULL_BOARD ) ); - d_check_max( drag[ col ].aisle, pa, pa.info().has_flag( flag_AISLE ) ); - d_check_max( drag[ col ].shield, pa, pa.info().has_flag( flag_WINDSHIELD ) && + d_check_max( drag[ col ].hboard, pa, pa.info().has_flag( "HALF_BOARD" ) ); + d_check_max( drag[ col ].fboard, pa, pa.info().has_flag( "FULL_BOARD" ) ); + d_check_max( drag[ col ].aisle, pa, pa.info().has_flag( "AISLE" ) ); + d_check_max( drag[ col ].shield, pa, pa.info().has_flag( "WINDSHIELD" ) && pa.is_available() ); - d_check_max( drag[ col ].seat, pa, pa.info().has_flag( flag_SEAT ) || - pa.info().has_flag( flag_BED ) ); + d_check_max( drag[ col ].seat, pa, pa.info().has_flag( "SEAT" ) || + pa.info().has_flag( "BED" ) ); d_check_max( drag[ col ].turret, pa, pa.info().location == part_location_onroof && - !pa.info().has_flag( flag_SOLAR_PANEL ) ); - d_check_max( drag[ col ].roof, pa, pa.info().has_flag( flag_ROOF ) ); - d_check_max( drag[ col ].panel, pa, pa.info().has_flag( flag_SOLAR_PANEL ) ); - d_check_max( drag[ col ].windmill, pa, pa.info().has_flag( flag_WIND_TURBINE ) ); - d_check_max( drag[ col ].sail, pa, pa.info().has_flag( flag_WIND_POWERED ) ); + !pa.info().has_flag( "SOLAR_PANEL" ) ); + d_check_max( drag[ col ].roof, pa, pa.info().has_flag( "ROOF" ) ); + d_check_max( drag[ col ].panel, pa, pa.info().has_flag( "SOLAR_PANEL" ) ); + d_check_max( drag[ col ].windmill, pa, pa.info().has_flag( "WIND_TURBINE" ) ); + d_check_max( drag[ col ].sail, pa, pa.info().has_flag( "WIND_POWERED" ) ); d_check_max( drag[ col ].exposed, pa, d_exposed( pa ) ); - d_check_min( drag[ col ].last, pa, pa.info().has_flag( flag_LOW_FINAL_AIR_DRAG ) || - pa.info().has_flag( flag_HALF_BOARD ) ); + d_check_min( drag[ col ].last, pa, pa.info().has_flag( "LOW_FINAL_AIR_DRAG" ) || + pa.info().has_flag( "HALF_BOARD" ) ); } } double height = 0; @@ -4181,7 +4182,7 @@ bool vehicle::sufficient_wheel_config() const return false; } else if( wheelcache.size() == 1 ) { //Has to be a stable wheel, and one wheel can only support a 1-3 tile vehicle - if( !part_info( wheelcache.front() ).has_flag( flag_STABLE ) || + if( !part_info( wheelcache.front() ).has_flag( "STABLE" ) || all_parts_at_location( part_location_structure ).size() > 3 ) { return false; } @@ -4382,8 +4383,9 @@ std::map vehicle::fuel_usage() const const size_t e = engines[ i ]; const auto &info = part_info( e ); + static const itype_id null_fuel_type( "null" ); const itype_id &cur_fuel = parts[ e ].fuel_current(); - if( cur_fuel == fuel_type_none ) { + if( cur_fuel == null_fuel_type ) { continue; } @@ -4622,7 +4624,7 @@ void vehicle::update_alternator_load() if( engine_on ) { int engine_vpower = 0; for( size_t e = 0; e < engines.size(); ++e ) { - if( is_engine_on( e ) && parts[engines[e]].info().has_flag( flag_E_ALTERNATOR ) ) { + if( is_engine_on( e ) && parts[engines[e]].info().has_flag( "E_ALTERNATOR" ) ) { engine_vpower += part_vpower_w( engines[e] ); } } @@ -4712,11 +4714,11 @@ void vehicle::power_parts() if( battery_deficit != 0 ) { // Scoops need a special case since they consume power during actual use - for( const vpart_reference &vp : get_enabled_parts( flag_SCOOP ) ) { + for( const vpart_reference &vp : get_enabled_parts( "SCOOP" ) ) { vp.part().enabled = false; } // Rechargers need special case since they consume power on demand - for( const vpart_reference &vp : get_enabled_parts( flag_RECHARGE ) ) { + for( const vpart_reference &vp : get_enabled_parts( "RECHARGE" ) ) { vp.part().enabled = false; } @@ -4803,7 +4805,7 @@ int vehicle::traverse_vehicle_graph( Vehicle *start_veh, int amount, Func action g->u.add_msg_if_player( m_debug, "Traversing graph with %d power", amount ); for( auto &p : current_veh->loose_parts ) { - if( !current_veh->part_info( p ).has_flag( flag_POWER_TRANSFER ) ) { + if( !current_veh->part_info( p ).has_flag( "POWER_TRANSFER" ) ) { continue; // ignore loose parts that aren't power transfer cables } @@ -4952,7 +4954,7 @@ void vehicle::idle( bool on_map ) } if( !warm_enough_to_plant( g->u.pos() ) ) { - for( const vpart_reference &vp : get_enabled_parts( flag_PLANTER ) ) { + for( const vpart_reference &vp : get_enabled_parts( "PLANTER" ) ) { if( g->u.sees( global_pos3() ) ) { add_msg( _( "The %s's planter turns off due to low temperature." ), name ); } @@ -4966,15 +4968,15 @@ void vehicle::idle( bool on_map ) update_time( calendar::turn ); } - if( has_part( flag_STEREO, true ) ) { + if( has_part( "STEREO", true ) ) { play_music(); } - if( has_part( flag_CHIMES, true ) ) { + if( has_part( "CHIMES", true ) ) { play_chimes(); } - if( has_part( flag_CRASH_TERRAIN_AROUND, true ) ) { + if( has_part( "CRASH_TERRAIN_AROUND", true ) ) { crash_terrain_around(); } @@ -4985,16 +4987,16 @@ void vehicle::idle( bool on_map ) void vehicle::on_move() { - if( has_part( flag_TRANSFORM_TERRAIN, true ) ) { + if( has_part( "TRANSFORM_TERRAIN", true ) ) { transform_terrain(); } - if( has_part( flag_SCOOP, true ) ) { + if( has_part( "SCOOP", true ) ) { operate_scoop(); } - if( has_part( flag_PLANTER, true ) ) { + if( has_part( "PLANTER", true ) ) { operate_planter(); } - if( has_part( flag_REAPER, true ) ) { + if( has_part( "REAPER", true ) ) { operate_reaper(); } @@ -5016,11 +5018,11 @@ void vehicle::slow_leak() const tripoint dest = global_pos3() + tripoint( q, 0 ); // damaged batteries self-discharge without leaking, plutonium leaks slurry - if( fuel != fuel_type_battery && fuel != fuel_type_plut_cell ) { + if( fuel != fuel_type_battery && fuel != fuel_type_plutonium_cell ) { item leak( fuel, calendar::turn, qty ); g->m.add_item_or_charges( dest, leak ); p.ammo_consume( qty, global_part_pos3( p ) ); - } else if( fuel == fuel_type_plut_cell ) { + } else if( fuel == fuel_type_plutonium_cell ) { if( p.ammo_remaining() >= PLUTONIUM_CHARGES / 10 ) { item leak( "plut_slurry_dense", calendar::turn, qty ); g->m.add_item_or_charges( dest, leak ); @@ -5056,7 +5058,7 @@ void vehicle::make_active( item_location &loc ) if( !target.needs_processing() ) { return; } - auto cargo_parts = get_parts_at( loc.position(), flag_CARGO, part_status_flag::any ); + auto cargo_parts = get_parts_at( loc.position(), "CARGO", part_status_flag::any ); if( cargo_parts.empty() ) { return; } @@ -5189,7 +5191,7 @@ void vehicle::place_spawn_items() for( const auto &pt : type->parts ) { if( pt.with_ammo ) { - int turret = part_with_feature( pt.pos, flag_TURRET, true ); + int turret = part_with_feature( pt.pos, "TURRET", true ); if( turret >= 0 && x_in_y( pt.with_ammo, 100 ) ) { parts[ turret ].ammo_set( random_entry( pt.ammo_types ), rng( pt.ammo_qty.first, pt.ammo_qty.second ) ); @@ -5199,7 +5201,7 @@ void vehicle::place_spawn_items() for( const auto &spawn : type.obj().item_spawns ) { if( rng( 1, 100 ) <= spawn.chance ) { - int part = part_with_feature( spawn.pos, flag_CARGO, false ); + int part = part_with_feature( spawn.pos, "CARGO", false ); if( part < 0 ) { debugmsg( "No CARGO parts at (%d, %d) of %s!", spawn.pos.x, spawn.pos.y, name ); @@ -5423,22 +5425,22 @@ void vehicle::refresh() if( vpi.has_flag( VPFLAG_SOLAR_PANEL ) ) { solar_panels.push_back( p ); } - if( vpi.has_flag( flag_WIND_TURBINE ) ) { + if( vpi.has_flag( "WIND_TURBINE" ) ) { wind_turbines.push_back( p ); } - if( vpi.has_flag( flag_WIND_POWERED ) ) { + if( vpi.has_flag( "WIND_POWERED" ) ) { sails.push_back( p ); } - if( vpi.has_flag( flag_WATER_WHEEL ) ) { + if( vpi.has_flag( "WATER_WHEEL" ) ) { water_wheels.push_back( p ); } - if( vpi.has_flag( flag_FUNNEL ) ) { + if( vpi.has_flag( "FUNNEL" ) ) { funnels.push_back( p ); } - if( vpi.has_flag( flag_UNMOUNT_ON_MOVE ) ) { + if( vpi.has_flag( "UNMOUNT_ON_MOVE" ) ) { loose_parts.push_back( p ); } - if( vpi.has_flag( flag_EMITTER ) ) { + if( vpi.has_flag( "EMITTER" ) ) { emitters.push_back( p ); } if( vpi.has_flag( VPFLAG_WHEEL ) ) { @@ -5459,30 +5461,29 @@ void vehicle::refresh() railwheel_xmax = std::max( railwheel_xmax, pt.x ); railwheel_ymax = std::max( railwheel_ymax, pt.y ); } - if( ( vpi.has_flag( flag_STEERABLE ) && part_with_feature( pt, flag_STEERABLE, true ) != -1 ) || - vpi.has_flag( flag_TRACKED ) ) { + if( ( vpi.has_flag( "STEERABLE" ) && part_with_feature( pt, "STEERABLE", true ) != -1 ) || + vpi.has_flag( "TRACKED" ) ) { // TRACKED contributes to steering effectiveness but // (a) doesn't count as a steering axle for install difficulty // (b) still contributes to drag for the center of steering calculation steering.push_back( p ); } - if( vpi.has_flag( flag_SECURITY ) ) { + if( vpi.has_flag( "SECURITY" ) ) { speciality.push_back( p ); } - if( vp.part().enabled && vpi.has_flag( flag_EXTRA_DRAG ) ) { + if( vp.part().enabled && vpi.has_flag( "EXTRA_DRAG" ) ) { extra_drag += vpi.power; } - if( vpi.has_flag( flag_EXTRA_DRAG ) && ( vpi.has_flag( flag_WIND_TURBINE ) || - vpi.has_flag( flag_WATER_WHEEL ) ) ) { + if( vpi.has_flag( "EXTRA_DRAG" ) && ( vpi.has_flag( "WIND_TURBINE" ) || + vpi.has_flag( "WATER_WHEEL" ) ) ) { extra_drag += vpi.power; } - if( camera_on && vpi.has_flag( flag_CAMERA ) ) { + if( camera_on && vpi.has_flag( "CAMERA" ) ) { vp.part().enabled = true; - } else if( !camera_on && vpi.has_flag( flag_CAMERA ) ) { + } else if( !camera_on && vpi.has_flag( "CAMERA" ) ) { vp.part().enabled = false; } - if( vpi.has_flag( flag_TURRET ) && - !has_part( global_part_pos3( vp.part() ), flag_TURRET_CONTROLS ) ) { + if( vpi.has_flag( "TURRET" ) && !has_part( global_part_pos3( vp.part() ), "TURRET_CONTROLS" ) ) { vp.part().enabled = false; } } @@ -5589,7 +5590,7 @@ void vehicle::refresh_pivot() const // broken wheels don't roll on either axis weight_i = contact_area * 2.0; weight_p = contact_area * 2.0; - } else if( part_with_feature( wheel.mount, flag_STEERABLE, true ) != -1 ) { + } else if( part_with_feature( wheel.mount, "STEERABLE", true ) != -1 ) { // Unbroken steerable wheels can handle motion on both axes // (but roll a little more easily inline) weight_i = contact_area * 0.1; @@ -5628,8 +5629,7 @@ void vehicle::remove_remote_part( int part_num ) int remote_partnum = veh->loose_parts[j]; auto remote_part = &veh->parts[remote_partnum]; - if( veh->part_flag( remote_partnum, flag_POWER_TRANSFER ) && - remote_part->target.first == local_abs ) { + if( veh->part_flag( remote_partnum, "POWER_TRANSFER" ) && remote_part->target.first == local_abs ) { veh->remove_part( remote_partnum ); return; } @@ -5643,7 +5643,7 @@ void vehicle::shed_loose_parts() // it will stay empty. while( !loose_parts.empty() ) { const int elem = loose_parts.front(); - if( part_flag( elem, flag_POWER_TRANSFER ) ) { + if( part_flag( elem, "POWER_TRANSFER" ) ) { remove_remote_part( elem ); } @@ -5658,7 +5658,7 @@ void vehicle::shed_loose_parts() bool vehicle::enclosed_at( const tripoint &pos ) { refresh_insides(); - std::vector parts_here = get_parts_at( pos, flag_BOARDABLE, + std::vector parts_here = get_parts_at( pos, "BOARDABLE", part_status_flag::working ); if( !parts_here.empty() ) { return parts_here.front()->inside; @@ -5679,7 +5679,7 @@ void vehicle::refresh_insides() } /* If there's no roof, or there is a roof but it's broken, it's outside. * (Use short-circuiting && so broken frames don't screw this up) */ - if( !( part_with_feature( p, flag_ROOF, true ) >= 0 && vp.part().is_available() ) ) { + if( !( part_with_feature( p, "ROOF", true ) >= 0 && vp.part().is_available() ) ) { vp.part().inside = false; continue; } @@ -5694,12 +5694,12 @@ void vehicle::refresh_insides() bool cover = false; for( auto &j : parts_n3ar ) { // another roof -- cover - if( part_flag( j, flag_ROOF ) && parts[ j ].is_available() ) { + if( part_flag( j, "ROOF" ) && parts[ j ].is_available() ) { cover = true; break; - } else if( part_flag( j, flag_OBSTACLE ) && parts[ j ].is_available() ) { + } else if( part_flag( j, "OBSTACLE" ) && parts[ j ].is_available() ) { // found an obstacle, like board or windshield or door - if( parts[j].inside || ( part_flag( j, flag_OPENABLE ) && parts[j].open ) ) { + if( parts[j].inside || ( part_flag( j, "OPENABLE" ) && parts[j].open ) ) { // door and it's open -- can't cover continue; } @@ -5748,8 +5748,8 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) if( !aimed ) { bool found_obs = false; for( auto &i : pl ) { - if( part_flag( i, flag_OBSTACLE ) && - ( !part_flag( i, flag_OPENABLE ) || !parts[i].open ) ) { + if( part_flag( i, "OBSTACLE" ) && + ( !part_flag( i, "OPENABLE" ) || !parts[i].open ) ) { found_obs = true; break; } @@ -5763,12 +5763,12 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) int target_part = random_entry( pl ); // door motor mechanism is protected by closed doors - if( part_flag( target_part, flag_DOOR_MOTOR ) ) { + if( part_flag( target_part, "DOOR_MOTOR" ) ) { // find the most strong openable that is not open int strongest_door_part = -1; int strongest_door_durability = INT_MIN; for( int part : pl ) { - if( part_flag( part, flag_OPENABLE ) && !parts[part].open ) { + if( part_flag( part, "OPENABLE" ) && !parts[part].open ) { int door_durability = part_info( part ).durability; if( door_durability > strongest_door_durability ) { strongest_door_part = part; @@ -5785,7 +5785,7 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) int damage_dealt; - int armor_part = part_with_feature( p, flag_ARMOR, true ); + int armor_part = part_with_feature( p, "ARMOR", true ); if( armor_part < 0 ) { // Not covered by armor -- damage part damage_dealt = damage_direct( target_part, dmg, type ); @@ -5793,8 +5793,7 @@ int vehicle::damage( int p, int dmg, damage_type type, bool aimed ) // Covered by armor -- hit both armor and part, but reduce damage by armor's reduction int protection = part_info( armor_part ).damage_reduction[ type ]; // Parts on roof aren't protected - bool overhead = part_flag( target_part, flag_ROOF ) || - part_info( target_part ).location == part_location_onroof; + bool overhead = part_flag( target_part, "ROOF" ) || part_info( target_part ).location == "on_roof"; // Calling damage_direct may remove the damaged part // completely, therefore the other index (target_part) becomes // wrong if target_part > armor_part. @@ -5827,7 +5826,7 @@ void vehicle::damage_all( int dmg1, int dmg2, damage_type type, const point &imp const size_t p = vp.part_index(); int distance = 1 + square_dist( vp.mount(), impact ); if( distance > 1 && part_info( p ).location == part_location_structure && - !part_info( p ).has_flag( flag_PROTRUSION ) ) { + !part_info( p ).has_flag( "PROTRUSION" ) ) { damage_direct( p, rng( dmg1, dmg2 ) / ( distance * distance ), type ); } } @@ -5880,8 +5879,8 @@ bool vehicle::shift_if_needed() } //Find a frame, any frame, to shift to for( const vpart_reference &vp : get_all_parts() ) { - if( vp.info().location == part_location_structure - && !vp.has_feature( flag_PROTRUSION ) + if( vp.info().location == "structure" + && !vp.has_feature( "PROTRUSION" ) && !vp.part().removed ) { shift_parts( vp.mount() ); refresh(); @@ -6038,7 +6037,7 @@ int vehicle::damage_direct( int p, int dmg, damage_type type ) if( parts[p].is_fuel_store() ) { explode_fuel( p, type ); - } else if( parts[ p ].is_broken() && part_flag( p, flag_UNMOUNT_ON_DAMAGE ) ) { + } else if( parts[ p ].is_broken() && part_flag( p, "UNMOUNT_ON_DAMAGE" ) ) { g->m.spawn_item( global_part_pos3( p ), part_info( p ).item, 1, 0, calendar::turn ); monster *mon = get_pet( p ); if( mon != nullptr && mon->has_effect( effect_harnessed ) ) { @@ -6090,7 +6089,7 @@ std::map vehicle::fuels_left() const bool vehicle::is_foldable() const { for( const vpart_reference &vp : get_all_parts() ) { - if( !vp.has_feature( flag_FOLDABLE ) ) { + if( !vp.has_feature( "FOLDABLE" ) ) { return false; } } @@ -6276,12 +6275,12 @@ void vehicle::update_time( const time_point &update_to ) int cost_to_purify = c_qty * item::find_type( "water_purifier" )->charges_to_use(); if( qty > 0 ) { - if( has_part( global_part_pos3( pt ), flag_WATER_PURIFIER, true ) && - ( fuel_left( fuel_type_battery, true ) > cost_to_purify ) ) { - tank->ammo_set( fuel_type_water_clean, c_qty ); + if( has_part( global_part_pos3( pt ), "WATER_PURIFIER", true ) && + ( fuel_left( "battery", true ) > cost_to_purify ) ) { + tank->ammo_set( "water_clean", c_qty ); discharge_battery( cost_to_purify ); } else { - tank->ammo_set( fuel_type_water, tank->ammo_remaining() + qty ); + tank->ammo_set( "water", tank->ammo_remaining() + qty ); } invalidate_mass(); } @@ -6444,7 +6443,7 @@ bool vehicle::refresh_zones() zone_data zone = z.second; //Get the global position of the first cargo part at the relative coordinate - const int part_idx = part_with_feature( z.first, flag_CARGO, false ); + const int part_idx = part_with_feature( z.first, "CARGO", false ); if( part_idx == -1 ) { debugmsg( "Could not find cargo part at %d,%d on vehicle %s for loot zone. Removing loot zone.", z.first.x, z.first.y, this->name ); diff --git a/src/vehicle_display.cpp b/src/vehicle_display.cpp index 0a619ecf315fc..87d03854a956a 100644 --- a/src/vehicle_display.cpp +++ b/src/vehicle_display.cpp @@ -20,8 +20,9 @@ #include "units.h" #include "color.h" #include "optional.h" -#include "cata_string_consts.h" +static const std::string part_location_structure( "structure" ); +static const itype_id fuel_type_muscle( "muscle" ); std::string vehicle::disp_name() const { @@ -170,7 +171,7 @@ int vehicle::print_part_list( const catacurses::window &win, int y1, const int m } } - if( part_flag( pl[i], flag_CARGO ) ) { + if( part_flag( pl[i], "CARGO" ) ) { //~ used/total volume of a cargo vehicle part partname += string_format( _( " (vol: %s/%s %s)" ), format_volume( stored_volume( pl[i] ) ), @@ -178,7 +179,7 @@ int vehicle::print_part_list( const catacurses::window &win, int y1, const int m volume_units_abbr() ); } - bool armor = part_flag( pl[i], flag_ARMOR ); + bool armor = part_flag( pl[i], "ARMOR" ); std::string left_sym; std::string right_sym; if( armor ) { diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 12b33b78c7baf..ef111cb60b704 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -463,7 +463,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, return ret; } // we just ran into a fish, so move it out of the way - if( g->m.has_flag( flag_SWIMMABLE, critter->pos() ) ) { + if( g->m.has_flag( "SWIMMABLE", critter->pos() ) ) { tripoint end_pos = critter->pos(); tripoint start_pos; const int angle = move.dir() + 45 * ( parts[part].mount.x > pivot_point().x ? -1 : 1 ); @@ -509,13 +509,13 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, ( g->m.is_bashable_ter_furn( p, false ) && g->m.move_cost_ter_furn( p ) != 2 && // Don't collide with tiny things, like flowers, unless we have a wheel in our space. ( part_with_feature( ret.part, VPFLAG_WHEEL, true ) >= 0 || - !g->m.has_flag_ter_or_furn( flag_TINY, p ) ) && + !g->m.has_flag_ter_or_furn( "TINY", p ) ) && // Protrusions don't collide with short terrain. // Tiny also doesn't, but it's already excluded unless there's a wheel present. - !( part_with_feature( ret.part, flag_PROTRUSION, true ) >= 0 && - g->m.has_flag_ter_or_furn( flag_SHORT, p ) ) && + !( part_with_feature( ret.part, "PROTRUSION", true ) >= 0 && + g->m.has_flag_ter_or_furn( "SHORT", p ) ) && // These are bashable, but don't interact with vehicles. - !g->m.has_flag_ter_or_furn( flag_NOCOLLIDE, p ) && + !g->m.has_flag_ter_or_furn( "NOCOLLIDE", p ) && // Do not collide with track tiles if we can use rails !( g->m.has_flag_ter_or_furn( TFLAG_RAIL, p ) && this->can_use_rails() ) ) ) { // Movecost 2 indicates flat terrain like a floor, no collision there. @@ -652,7 +652,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, // No blood from hallucinations if( critter != nullptr && !critter->is_hallucination() ) { - if( part_flag( ret.part, flag_SHARP ) ) { + if( part_flag( ret.part, "SHARP" ) ) { parts[ret.part].blood += ( 20 + dam ) * 5; } else if( dam > rng( 10, 30 ) ) { parts[ret.part].blood += ( 10 + dam / 2 ) * 5; @@ -669,7 +669,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, if( ph != nullptr ) { ph->hitall( dam, 40, driver ); } else { - const int armor = part_flag( ret.part, flag_SHARP ) ? + const int armor = part_flag( ret.part, "SHARP" ) ? critter->get_armor_cut( bp_torso ) : critter->get_armor_bash( bp_torso ); dam = std::max( 0, dam - armor ); @@ -727,7 +727,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, } } - if( part_flag( ret.part, flag_SHARP ) ) { + if( part_flag( ret.part, "SHARP" ) ) { critter->bleed(); } else { sounds::sound( p, 20, sounds::sound_t::combat, snd, false, "smash_success", "hit_vehicle" ); diff --git a/src/vehicle_part.cpp b/src/vehicle_part.cpp index f900af04cc04d..25388c7552b0a 100644 --- a/src/vehicle_part.cpp +++ b/src/vehicle_part.cpp @@ -66,7 +66,7 @@ item vehicle_part::properties_to_item() const // Cables get special handling: their target coordinates need to remain // stored, and if a cable actually drops, it should be half-connected. - if( tmp.has_flag( flag_CABLE_SPOOL ) ) { + if( tmp.has_flag( "CABLE_SPOOL" ) ) { const tripoint local_pos = g->m.getlocal( target.first ); if( !g->m.veh_at( local_pos ) ) { // That vehicle ain't there no more. @@ -488,7 +488,7 @@ bool vehicle_part::is_turret() const bool vehicle_part::is_seat() const { - return info().has_flag( flag_SEAT ); + return info().has_flag( "SEAT" ); } const vpart_info &vehicle_part::info() const @@ -533,7 +533,7 @@ bool vehicle::can_enable( const vehicle_part &pt, bool alert ) const return false; } - if( pt.info().has_flag( flag_PLANTER ) && !warm_enough_to_plant( g->u.pos() ) ) { + if( pt.info().has_flag( "PLANTER" ) && !warm_enough_to_plant( g->u.pos() ) ) { if( alert ) { add_msg( m_bad, _( "It is too cold to plant anything now." ) ); } diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index b0679c78ead31..ed0724df5c03d 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -114,7 +114,7 @@ void vehicle::add_toggle_to_opts( std::vector &options, void vehicle::control_doors() { - const auto door_motors = get_avail_parts( flag_DOOR_MOTOR ); + const auto door_motors = get_avail_parts( "DOOR_MOTOR" ); // Indices of doors std::vector< int > doors_with_motors; // Locations used to display the doors @@ -174,7 +174,7 @@ void vehicle::control_doors() if( open ) { int part = next_part_to_open( motor ); if( part != -1 ) { - if( !part_flag( part, flag_CURTAIN ) && option == OPENCURTAINS ) { + if( !part_flag( part, "CURTAIN" ) && option == OPENCURTAINS ) { continue; } open_or_close( part, open ); @@ -188,7 +188,7 @@ void vehicle::control_doors() } else { int part = next_part_to_close( motor ); if( part != -1 ) { - if( part_flag( part, flag_CURTAIN ) && option == CLOSEDOORS ) { + if( part_flag( part, "CURTAIN" ) && option == CLOSEDOORS ) { continue; } open_or_close( part, open ); @@ -256,11 +256,11 @@ void vehicle::set_electronics_menu_options( std::vector &options, add_toggle( pgettext( "electronics menu option", "water purifier" ), keybind( "TOGGLE_WATER_PURIFIER" ), "WATER_PURIFIER" ); - if( has_part( flag_DOOR_MOTOR ) ) { + if( has_part( "DOOR_MOTOR" ) ) { options.emplace_back( _( "Toggle doors" ), keybind( "TOGGLE_DOORS" ) ); actions.push_back( [&] { control_doors(); refresh(); } ); } - if( camera_on || ( has_part( flag_CAMERA ) && has_part( flag_CAMERA_CONTROL ) ) ) { + if( camera_on || ( has_part( "CAMERA" ) && has_part( "CAMERA_CONTROL" ) ) ) { options.emplace_back( camera_on ? colorize( _( "Turn off camera system" ), c_pink ) : _( "Turn on camera system" ), @@ -447,9 +447,9 @@ void vehicle::smash_security_system() int s = -1; int c = -1; for( int p : speciality ) { - if( part_flag( p, flag_SECURITY ) && !parts[ p ].is_broken() ) { + if( part_flag( p, "SECURITY" ) && !parts[ p ].is_broken() ) { s = p; - c = part_with_feature( s, flag_CONTROLS, true ); + c = part_with_feature( s, "CONTROLS", true ); break; } } @@ -493,7 +493,7 @@ std::string vehicle::tracking_toggle_string() void vehicle::autopilot_patrol_check() { zone_manager &mgr = zone_manager::get_manager(); - if( mgr.has_near( zone_type_VEHICLE_PATROL, g->m.getabs( global_pos3() ), 60 ) ) { + if( mgr.has_near( zone_type_id( "VEHICLE_PATROL" ), g->m.getabs( global_pos3() ), 60 ) ) { enable_patrol(); } else { g->zones_manager(); @@ -562,7 +562,7 @@ void vehicle::use_controls( const tripoint &pos ) refresh(); } ); - has_electronic_controls = has_part( flag_CTRL_ELECTRONIC ) || has_part( flag_REMOTE_CONTROLS ); + has_electronic_controls = has_part( "CTRL_ELECTRONIC" ) || has_part( "REMOTE_CONTROLS" ); } else if( veh_pointer_or_null( g->m.veh_at( pos ) ) == this ) { if( g->u.controlling_vehicle ) { @@ -573,12 +573,11 @@ void vehicle::use_controls( const tripoint &pos ) refresh(); } ); } - has_electronic_controls = !get_parts_at( pos, flag_CTRL_ELECTRONIC, + has_electronic_controls = !get_parts_at( pos, "CTRL_ELECTRONIC", part_status_flag::any ).empty(); } - if( get_parts_at( pos, flag_CONTROLS, part_status_flag::any ).empty() && - !has_electronic_controls ) { + if( get_parts_at( pos, "CONTROLS", part_status_flag::any ).empty() && !has_electronic_controls ) { add_msg( m_info, _( "No controls there" ) ); return; } @@ -588,7 +587,7 @@ void vehicle::use_controls( const tripoint &pos ) return; } - if( has_part( flag_ENGINE ) ) { + if( has_part( "ENGINE" ) ) { if( g->u.controlling_vehicle || ( remote && engine_on ) ) { options.emplace_back( _( "Stop driving" ), keybind( "TOGGLE_ENGINE" ) ); actions.push_back( [&] { @@ -650,12 +649,12 @@ void vehicle::use_controls( const tripoint &pos ) } } - if( has_part( flag_HORN ) ) { + if( has_part( "HORN" ) ) { options.emplace_back( _( "Honk horn" ), keybind( "SOUND_HORN" ) ); actions.push_back( [&] { honk_horn(); refresh(); } ); } - if( has_part( flag_AUTOPILOT ) && ( has_part( flag_CTRL_ELECTRONIC ) || - has_part( flag_REMOTE_CONTROLS ) ) ) { + if( has_part( "AUTOPILOT" ) && ( has_part( "CTRL_ELECTRONIC" ) || + has_part( "REMOTE_CONTROLS" ) ) ) { options.emplace_back( _( "Control autopilot" ), keybind( "CONTROL_AUTOPILOT" ) ); actions.push_back( [&] { toggle_autopilot(); refresh(); } ); @@ -685,7 +684,7 @@ void vehicle::use_controls( const tripoint &pos ) actions.push_back( [&] { fold_up(); } ); } - if( has_part( flag_ENGINE ) ) { + if( has_part( "ENGINE" ) ) { options.emplace_back( _( "Control individual engines" ), keybind( "CONTROL_ENGINES" ) ); actions.push_back( [&] { control_engines(); refresh(); } ); } @@ -695,7 +694,7 @@ void vehicle::use_controls( const tripoint &pos ) options.emplace_back( _( "Try to disarm alarm." ), keybind( "TOGGLE_ALARM" ) ); actions.push_back( [&] { smash_security_system(); refresh(); } ); - } else if( has_electronic_controls && has_part( flag_SECURITY ) ) { + } else if( has_electronic_controls && has_part( "SECURITY" ) ) { options.emplace_back( _( "Trigger alarm" ), keybind( "TOGGLE_ALARM" ) ); actions.push_back( [&] { is_alarm_on = true; @@ -705,7 +704,7 @@ void vehicle::use_controls( const tripoint &pos ) } } - if( has_part( flag_TURRET ) ) { + if( has_part( "TURRET" ) ) { options.emplace_back( _( "Set turret targeting modes" ), keybind( "TURRET_TARGET_MODE" ) ); actions.push_back( [&] { turrets_set_targeting(); refresh(); } ); @@ -781,7 +780,7 @@ bool vehicle::fold_up() item bicycle( can_be_folded ? "generic_folded_vehicle" : "folding_bicycle", calendar::turn ); // Drop stuff in containers on ground - for( const vpart_reference &vp : get_any_parts( flag_CARGO ) ) { + for( const vpart_reference &vp : get_any_parts( "CARGO" ) ) { const size_t p = vp.part_index(); for( auto &elem : get_items( p ) ) { g->m.add_item_or_charges( g->u.pos(), elem ); @@ -827,7 +826,7 @@ bool vehicle::fold_up() double vehicle::engine_cold_factor( const int e ) const { - if( !part_info( engines[e] ).has_flag( flag_E_COLD_START ) ) { + if( !part_info( engines[e] ).has_flag( "E_COLD_START" ) ) { return 0.0; } @@ -841,7 +840,7 @@ double vehicle::engine_cold_factor( const int e ) const int vehicle::engine_start_time( const int e ) const { - if( !is_engine_on( e ) || part_info( engines[e] ).has_flag( flag_E_STARTS_INSTANTLY ) || + if( !is_engine_on( e ) || part_info( engines[e] ).has_flag( "E_STARTS_INSTANTLY" ) || !engine_fuel_left( e ) ) { return 0; } @@ -881,10 +880,10 @@ bool vehicle::start_engine( const int e ) if( out_of_fuel ) { if( einfo.fuel_type == fuel_type_muscle ) { // Muscle engines cannot start with broken limbs - if( einfo.has_flag( flag_MUSCLE_ARMS ) && ( g->u.get_working_arm_count() < 2 ) ) { + if( einfo.has_flag( "MUSCLE_ARMS" ) && ( g->u.get_working_arm_count() < 2 ) ) { add_msg( _( "You cannot use %s with a broken arm." ), eng.name() ); return false; - } else if( einfo.has_flag( flag_MUSCLE_LEGS ) && ( g->u.get_working_leg_count() < 2 ) ) { + } else if( einfo.has_flag( "MUSCLE_LEGS" ) && ( g->u.get_working_leg_count() < 2 ) ) { add_msg( _( "You cannot use %s with a broken leg." ), eng.name() ); return false; } @@ -1058,10 +1057,10 @@ void vehicle::honk_horn() const bool no_power = !fuel_left( fuel_type_battery, true ); bool honked = false; - for( const vpart_reference &vp : get_avail_parts( flag_HORN ) ) { + for( const vpart_reference &vp : get_avail_parts( "HORN" ) ) { //Only bicycle horn doesn't need electricity to work const vpart_info &horn_type = vp.info(); - if( ( horn_type.get_id() != vpart_horn_bicycle ) && no_power ) { + if( ( horn_type.get_id() != vpart_id( "horn_bicycle" ) ) && no_power ) { continue; } if( !honked ) { @@ -1139,7 +1138,7 @@ void vehicle::beeper_sound() } const bool odd_turn = calendar::once_every( 2_turns ); - for( const vpart_reference &vp : get_avail_parts( flag_BEEPER ) ) { + for( const vpart_reference &vp : get_avail_parts( "BEEPER" ) ) { if( ( odd_turn && vp.has_feature( VPFLAG_EVENTURN ) ) || ( !odd_turn && vp.has_feature( VPFLAG_ODDTURN ) ) ) { continue; @@ -1153,7 +1152,7 @@ void vehicle::beeper_sound() void vehicle::play_music() { - for( const vpart_reference &vp : get_enabled_parts( flag_STEREO ) ) { + for( const vpart_reference &vp : get_enabled_parts( "STEREO" ) ) { iuse::play_music( g->u, vp.pos(), 15, 30 ); } } @@ -1164,7 +1163,7 @@ void vehicle::play_chimes() return; } - for( const vpart_reference &vp : get_enabled_parts( flag_CHIMES ) ) { + for( const vpart_reference &vp : get_enabled_parts( "CHIMES" ) ) { sounds::sound( vp.pos(), 40, sounds::sound_t::music, _( "a simple melody blaring from the loudspeakers." ), false, "vehicle", "chimes" ); } @@ -1175,7 +1174,7 @@ void vehicle::crash_terrain_around() if( total_power_w() <= 0 ) { return; } - for( const vpart_reference &vp : get_enabled_parts( flag_CRASH_TERRAIN_AROUND ) ) { + for( const vpart_reference &vp : get_enabled_parts( "CRASH_TERRAIN_AROUND" ) ) { tripoint crush_target( 0, 0, -OVERMAP_LAYERS ); const tripoint start_pos = vp.pos(); const transform_terrain_data &ttd = vp.info().transform_terrain; @@ -1206,7 +1205,7 @@ void vehicle::crash_terrain_around() void vehicle::transform_terrain() { - for( const vpart_reference &vp : get_enabled_parts( flag_TRANSFORM_TERRAIN ) ) { + for( const vpart_reference &vp : get_enabled_parts( "TRANSFORM_TERRAIN" ) ) { const tripoint start_pos = vp.pos(); const transform_terrain_data &ttd = vp.info().transform_terrain; bool prereq_fulfilled = false; @@ -1241,7 +1240,7 @@ void vehicle::transform_terrain() void vehicle::operate_reaper() { - for( const vpart_reference &vp : get_enabled_parts( flag_REAPER ) ) { + for( const vpart_reference &vp : get_enabled_parts( "REAPER" ) ) { const size_t reaper_id = vp.part_index(); const tripoint reaper_pos = vp.pos(); const int plant_produced = rng( 1, vp.info().bonus ); @@ -1268,7 +1267,7 @@ void vehicle::operate_reaper() } sounds::sound( reaper_pos, rng( 10, 25 ), sounds::sound_t::combat, _( "Swish" ), false, "vehicle", "reaper" ); - if( vp.has_feature( flag_CARGO ) ) { + if( vp.has_feature( "CARGO" ) ) { for( map_stack::iterator iter = items.begin(); iter != items.end(); ) { if( ( iter->volume() <= max_pickup_volume ) && add_item( reaper_id, *iter ) ) { @@ -1283,19 +1282,19 @@ void vehicle::operate_reaper() void vehicle::operate_planter() { - for( const vpart_reference &vp : get_enabled_parts( flag_PLANTER ) ) { + for( const vpart_reference &vp : get_enabled_parts( "PLANTER" ) ) { const size_t planter_id = vp.part_index(); const tripoint loc = vp.pos(); vehicle_stack v = get_items( planter_id ); for( auto i = v.begin(); i != v.end(); i++ ) { if( i->is_seed() ) { // If it is an "advanced model" then it will avoid damaging itself or becoming damaged. It's a real feature. - if( g->m.ter( loc ) != t_dirtmound && vp.has_feature( flag_ADVANCED_PLANTER ) ) { + if( g->m.ter( loc ) != t_dirtmound && vp.has_feature( "ADVANCED_PLANTER" ) ) { //then don't put the item there. break; } else if( g->m.ter( loc ) == t_dirtmound ) { g->m.set( loc, t_dirt, f_plant_seed ); - } else if( !g->m.has_flag( flag_PLOWABLE, loc ) ) { + } else if( !g->m.has_flag( "PLOWABLE", loc ) ) { //If it isn't plowable terrain, then it will most likely be damaged. damage( planter_id, rng( 1, 10 ), DT_BASH, false ); sounds::sound( loc, rng( 10, 20 ), sounds::sound_t::combat, _( "Clink" ), false, "smash_success", @@ -1320,7 +1319,7 @@ void vehicle::operate_planter() void vehicle::operate_scoop() { - for( const vpart_reference &vp : get_enabled_parts( flag_SCOOP ) ) { + for( const vpart_reference &vp : get_enabled_parts( "SCOOP" ) ) { const size_t scoop = vp.part_index(); const int chance_to_damage_item = 9; const units::volume max_pickup_volume = vp.info().size / 10; @@ -1342,7 +1341,7 @@ void vehicle::operate_scoop() } item *that_item_there = nullptr; map_stack items = g->m.i_at( position ); - if( g->m.has_flag( flag_SEALED, position ) ) { + if( g->m.has_flag( "SEALED", position ) ) { // Ignore it. Street sweepers are not known for their ability to harvest crops. continue; } @@ -1403,7 +1402,7 @@ void vehicle::alarm() */ void vehicle::open( int part_index ) { - if( !part_info( part_index ).has_flag( flag_OPENABLE ) ) { + if( !part_info( part_index ).has_flag( "OPENABLE" ) ) { debugmsg( "Attempted to open non-openable part %d (%s) on a %s!", part_index, parts[ part_index ].name(), name ); } else { @@ -1418,7 +1417,7 @@ void vehicle::open( int part_index ) */ void vehicle::close( int part_index ) { - if( !part_info( part_index ).has_flag( flag_OPENABLE ) ) { + if( !part_info( part_index ).has_flag( "OPENABLE" ) ) { debugmsg( "Attempted to close non-closeable part %d (%s) on a %s!", part_index, parts[ part_index ].name(), name ); } else { @@ -1492,7 +1491,7 @@ void vehicle::use_autoclave( int p ) _( "You turn the autoclave off before it's finished the program, and open its door." ) ); } else if( items.empty() ) { add_msg( m_bad, _( "The autoclave is empty, there's no point in starting it." ) ); - } else if( fuel_left( fuel_type_water ) < 8 && fuel_left( fuel_type_water_clean ) < 8 ) { + } else if( fuel_left( "water" ) < 8 && fuel_left( "water_clean" ) < 8 ) { add_msg( m_bad, _( "You need 8 charges of water in tanks of the %s for the autoclave to run." ), name ); } else if( filthy_items ) { @@ -1508,10 +1507,10 @@ void vehicle::use_autoclave( int p ) n.set_age( 0_turns ); } - if( fuel_left( fuel_type_water ) >= 8 ) { - drain( fuel_type_water, 8 ); + if( fuel_left( "water" ) >= 8 ) { + drain( "water", 8 ); } else { - drain( fuel_type_water_clean, 8 ); + drain( "water_clean", 8 ); } add_msg( m_good, @@ -1524,7 +1523,7 @@ void vehicle::use_washing_machine( int p ) // Get all the items that can be used as detergent const inventory &inv = g->u.crafting_inventory(); std::vector detergents = inv.items_with( [inv]( const item & it ) { - return it.has_flag( flag_DETERGENT ) && inv.has_charges( it.typeId(), 5 ); + return it.has_flag( "DETERGENT" ) && inv.has_charges( it.typeId(), 5 ); } ); auto items = get_items( p ); @@ -1544,7 +1543,7 @@ void vehicle::use_washing_machine( int p ) } else if( items.empty() ) { add_msg( m_bad, _( "The washing machine is empty, there's no point in starting it." ) ); - } else if( fuel_left( fuel_type_water ) < 24 && fuel_left( fuel_type_water_clean ) < 24 ) { + } else if( fuel_left( "water" ) < 24 && fuel_left( "water_clean" ) < 24 ) { add_msg( m_bad, _( "You need 24 charges of water in tanks of the %s to fill the washing machine." ), name ); } else if( detergents.empty() ) { @@ -1589,10 +1588,10 @@ void vehicle::use_washing_machine( int p ) n.set_age( 0_turns ); } - if( fuel_left( fuel_type_water ) >= 24 ) { - drain( fuel_type_water, 24 ); + if( fuel_left( "water" ) >= 24 ) { + drain( "water", 24 ); } else { - drain( fuel_type_water_clean, 24 ); + drain( "water_clean", 24 ); } std::vector detergent; @@ -1630,7 +1629,7 @@ void vehicle::use_dishwasher( int p ) } else if( items.empty() ) { add_msg( m_bad, _( "The dishwasher is empty, there's no point in starting it." ) ); - } else if( fuel_left( fuel_type_water ) < 24 && fuel_left( fuel_type_water_clean ) < 24 ) { + } else if( fuel_left( "water" ) < 24 && fuel_left( "water_clean" ) < 24 ) { add_msg( m_bad, _( "You need 24 charges of water in tanks of the %s to fill the dishwasher." ), name ); } else if( !detergent_is_enough ) { @@ -1646,10 +1645,10 @@ void vehicle::use_dishwasher( int p ) n.set_age( 0_turns ); } - if( fuel_left( fuel_type_water ) >= 24 ) { - drain( fuel_type_water, 24 ); + if( fuel_left( "water" ) >= 24 ) { + drain( "water", 24 ); } else { - drain( fuel_type_water_clean, 24 ); + drain( "water_clean", 24 ); } std::vector detergent; @@ -1717,7 +1716,7 @@ void vehicle::use_harness( int part, const tripoint &pos ) } else if( !m.has_flag( MF_PET_MOUNTABLE ) && !m.has_flag( MF_PET_HARNESSABLE ) ) { add_msg( m_info, _( "This creature cannot be harnessed." ) ); return; - } else if( !part_flag( part, Harness_Bodytype ) && !part_flag( part, flag_HARNESS_any ) ) { + } else if( !part_flag( part, Harness_Bodytype ) && !part_flag( part, "HARNESS_any" ) ) { add_msg( m_info, _( "The harness is not adapted for this creature morphology." ) ); return; } @@ -1839,49 +1838,47 @@ void vehicle::interact_with( const tripoint &pos, int interact_part ) std::vector menu_items; std::vector options_message; const bool has_items_on_ground = g->m.sees_some_items( pos, g->u ); - const bool items_are_sealed = g->m.has_flag( flag_SEALED, pos ); + const bool items_are_sealed = g->m.has_flag( "SEALED", pos ); auto turret = turret_query( pos ); - const int curtain_part = avail_part_with_feature( interact_part, flag_CURTAIN, true ); + const int curtain_part = avail_part_with_feature( interact_part, "CURTAIN", true ); const bool curtain_closed = ( curtain_part == -1 ) ? false : !parts[curtain_part].open; - const bool has_kitchen = avail_part_with_feature( interact_part, flag_KITCHEN, true ) >= 0; - const bool has_faucet = avail_part_with_feature( interact_part, flag_FAUCET, true ) >= 0; - const bool has_towel = avail_part_with_feature( interact_part, flag_TOWEL, true ) >= 0; - const bool has_weldrig = avail_part_with_feature( interact_part, flag_WELDRIG, true ) >= 0; - const bool has_chemlab = avail_part_with_feature( interact_part, flag_CHEMLAB, true ) >= 0; - const bool has_purify = avail_part_with_feature( interact_part, flag_WATER_PURIFIER, true ) >= 0; - const bool has_controls = avail_part_with_feature( interact_part, flag_CONTROLS, true ) >= 0; - const bool has_electronics = avail_part_with_feature( interact_part, flag_CTRL_ELECTRONIC, - true ) >= 0; - const int cargo_part = part_with_feature( interact_part, flag_CARGO, false ); + const bool has_kitchen = avail_part_with_feature( interact_part, "KITCHEN", true ) >= 0; + const bool has_faucet = avail_part_with_feature( interact_part, "FAUCET", true ) >= 0; + const bool has_towel = avail_part_with_feature( interact_part, "TOWEL", true ) >= 0; + const bool has_weldrig = avail_part_with_feature( interact_part, "WELDRIG", true ) >= 0; + const bool has_chemlab = avail_part_with_feature( interact_part, "CHEMLAB", true ) >= 0; + const bool has_purify = avail_part_with_feature( interact_part, "WATER_PURIFIER", true ) >= 0; + const bool has_controls = avail_part_with_feature( interact_part, "CONTROLS", true ) >= 0; + const bool has_electronics = avail_part_with_feature( interact_part, "CTRL_ELECTRONIC", true ) >= 0; + const int cargo_part = part_with_feature( interact_part, "CARGO", false ); const bool from_vehicle = cargo_part >= 0 && !get_items( cargo_part ).empty(); const bool can_be_folded = is_foldable(); const bool is_convertible = tags.count( "convertible" ) > 0; const bool remotely_controlled = g->remoteveh() == this; - const int autoclave_part = avail_part_with_feature( interact_part, flag_AUTOCLAVE, true ); + const int autoclave_part = avail_part_with_feature( interact_part, "AUTOCLAVE", true ); const bool has_autoclave = autoclave_part >= 0; bool autoclave_on = ( autoclave_part == -1 ) ? false : parts[autoclave_part].enabled; - const int washing_machine_part = avail_part_with_feature( interact_part, flag_WASHING_MACHINE, - true ); + const int washing_machine_part = avail_part_with_feature( interact_part, "WASHING_MACHINE", true ); const bool has_washmachine = washing_machine_part >= 0; bool washing_machine_on = ( washing_machine_part == -1 ) ? false : parts[washing_machine_part].enabled; - const int dishwasher_part = avail_part_with_feature( interact_part, flag_DISHWASHER, true ); + const int dishwasher_part = avail_part_with_feature( interact_part, "DISHWASHER", true ); const bool has_dishwasher = dishwasher_part >= 0; bool dishwasher_on = ( dishwasher_part == -1 ) ? false : parts[dishwasher_part].enabled; - const int monster_capture_part = avail_part_with_feature( interact_part, flag_CAPTURE_MONSTER_VEH, + const int monster_capture_part = avail_part_with_feature( interact_part, "CAPTURE_MONSTER_VEH", true ); const bool has_monster_capture = monster_capture_part >= 0; - const int bike_rack_part = avail_part_with_feature( interact_part, flag_BIKE_RACK_VEH, true ); - const int harness_part = avail_part_with_feature( interact_part, flag_ANIMAL_CTRL, true ); + const int bike_rack_part = avail_part_with_feature( interact_part, "BIKE_RACK_VEH", true ); + const int harness_part = avail_part_with_feature( interact_part, "ANIMAL_CTRL", true ); const bool has_harness = harness_part >= 0; const bool has_bike_rack = bike_rack_part >= 0; - const bool has_planter = avail_part_with_feature( interact_part, flag_PLANTER, true ) >= 0 || - avail_part_with_feature( interact_part, flag_ADVANCED_PLANTER, true ) >= 0; - const int workbench_part = avail_part_with_feature( interact_part, flag_WORKBENCH, true ); + const bool has_planter = avail_part_with_feature( interact_part, "PLANTER", true ) >= 0 || + avail_part_with_feature( interact_part, "ADVANCED_PLANTER", true ) >= 0; + const int workbench_part = avail_part_with_feature( interact_part, "WORKBENCH", true ); const bool has_workbench = workbench_part >= 0; enum { @@ -1933,25 +1930,25 @@ void vehicle::interact_with( const tripoint &pos, int interact_part ) if( curtain_part >= 0 && curtain_closed ) { selectmenu.addentry( PEEK_CURTAIN, true, 'p', _( "Peek through the closed curtains" ) ); } - if( ( has_kitchen || has_chemlab ) && fuel_left( fuel_type_battery, true ) > 0 ) { + if( ( has_kitchen || has_chemlab ) && fuel_left( "battery", true ) > 0 ) { selectmenu.addentry( USE_HOTPLATE, true, 'h', _( "Use the hotplate" ) ); } - if( has_faucet && fuel_left( fuel_type_water_clean ) > 0 ) { + if( has_faucet && fuel_left( "water_clean" ) > 0 ) { selectmenu.addentry( FILL_CONTAINER, true, 'c', _( "Fill a container with water" ) ); selectmenu.addentry( DRINK, true, 'd', _( "Have a drink" ) ); } if( has_towel ) { selectmenu.addentry( USE_TOWEL, true, 't', _( "Use a towel" ) ); } - if( has_weldrig && fuel_left( fuel_type_battery, true ) > 0 ) { + if( has_weldrig && fuel_left( "battery", true ) > 0 ) { selectmenu.addentry( USE_WELDER, true, 'w', _( "Use the welding rig" ) ); } if( has_purify ) { - bool can_purify = fuel_left( fuel_type_battery, true ) >= + bool can_purify = fuel_left( "battery", true ) >= item::find_type( "water_purifier" )->charges_to_use(); selectmenu.addentry( USE_PURIFIER, can_purify, 'p', _( "Purify water in carried container" ) ); - selectmenu.addentry( PURIFY_TANK, can_purify && fuel_left( fuel_type_water ), + selectmenu.addentry( PURIFY_TANK, can_purify && fuel_left( "water" ), 'P', _( "Purify water in vehicle tank" ) ); } if( has_monster_capture ) { @@ -2058,7 +2055,7 @@ void vehicle::interact_with( const tripoint &pos, int interact_part ) act.coords.push_back( pos ); // Finally tell if it is the vehicle part with welding rig act.values.resize( 2 ); - act.values[1] = part_with_feature( interact_part, flag_WELDRIG, true ); + act.values[1] = part_with_feature( interact_part, "WELDRIG", true ); } } return; diff --git a/src/visitable.cpp b/src/visitable.cpp index 859c67936830a..279effe7e4b4b 100644 --- a/src/visitable.cpp +++ b/src/visitable.cpp @@ -260,7 +260,7 @@ int visitable::max_quality( const quality_id &qual ) const res = std::max( res, bio.get_quality( qual ) ); } - if( qual == quality_BUTCHER ) { + if( qual == qual_BUTCHER ) { if( self->has_trait( trait_CLAWS_ST ) ) { res = std::max( res, 8 ); } else if( self->has_trait( trait_TALONS ) || self->has_trait( trait_MANDIBLES ) || @@ -433,7 +433,7 @@ VisitResponse visitable::visit_items( auto cur = static_cast( this ); // skip inaccessible items - if( g->m.has_flag( flag_SEALED, *cur ) && !g->m.has_flag( flag_LIQUIDCONT, *cur ) ) { + if( g->m.has_flag( "SEALED", *cur ) && !g->m.has_flag( "LIQUIDCONT", *cur ) ) { return VisitResponse::NEXT; } @@ -465,7 +465,7 @@ VisitResponse visitable::visit_items( { auto self = static_cast( this ); - int idx = self->veh.part_with_feature( self->part, flag_CARGO, true ); + int idx = self->veh.part_with_feature( self->part, "CARGO", true ); if( idx >= 0 ) { for( auto &e : self->veh.get_items( idx ) ) { if( visit_internal( func, &e ) == VisitResponse::ABORT ) { @@ -715,7 +715,7 @@ std::list visitable::remove_items_with( const return res; } - int idx = cur->veh.part_with_feature( cur->part, flag_CARGO, false ); + int idx = cur->veh.part_with_feature( cur->part, "CARGO", false ); if( idx < 0 ) { return res; } @@ -779,7 +779,7 @@ static int charges_of_internal( const T &self, const M &main, const itype_id &id if( e->typeId() == id ) { // includes charges from any included magazine. qty = sum_no_wrap( qty, e->ammo_remaining() ); - if( e->has_flag( flag_USE_UPS ) ) { + if( e->has_flag( "USE_UPS" ) ) { found_tool_with_UPS = true; } } @@ -887,7 +887,7 @@ static int amount_of_internal( const T &self, const itype_id &id, bool pseudo, i int qty = 0; self.visit_items( [&qty, &id, &pseudo, &limit, &filter]( const item * e ) { if( ( id == "any" || e->typeId() == id ) && filter( *e ) && ( pseudo || - !e->has_flag( flag_PSEUDO ) ) ) { + !e->has_flag( "PSEUDO" ) ) ) { qty = sum_no_wrap( qty, 1 ); } return qty != limit ? VisitResponse::NEXT : VisitResponse::ABORT; diff --git a/src/weather.cpp b/src/weather.cpp index d718115382810..261391bb14468 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -354,8 +354,8 @@ static void wet_player( int amount ) { if( !is_player_outside() || g->u.has_trait( trait_FEATHERS ) || - g->u.weapon.has_flag( flag_RAIN_PROTECT ) || - ( !one_in( 50 ) && g->u.worn_with_flag( flag_RAINPROOF ) ) ) { + g->u.weapon.has_flag( "RAIN_PROTECT" ) || + ( !one_in( 50 ) && g->u.worn_with_flag( "RAINPROOF" ) ) ) { return; } // Coarse correction to get us back to previously intended soaking rate. @@ -480,10 +480,10 @@ void weather_effect::lightning() void weather_effect::light_acid() { if( calendar::once_every( 1_minutes ) && is_player_outside() ) { - if( g->u.weapon.has_flag( flag_RAIN_PROTECT ) && !one_in( 3 ) ) { + if( g->u.weapon.has_flag( "RAIN_PROTECT" ) && !one_in( 3 ) ) { add_msg( _( "Your %s protects you from the acidic drizzle." ), g->u.weapon.tname() ); } else { - if( g->u.worn_with_flag( flag_RAINPROOF ) && !one_in( 4 ) ) { + if( g->u.worn_with_flag( "RAINPROOF" ) && !one_in( 4 ) ) { add_msg( _( "Your clothing protects you from the acidic drizzle." ) ); } else { bool has_helmet = false; @@ -507,10 +507,10 @@ void weather_effect::light_acid() void weather_effect::acid() { if( calendar::once_every( 2_turns ) && is_player_outside() ) { - if( g->u.weapon.has_flag( flag_RAIN_PROTECT ) && one_in( 4 ) ) { + if( g->u.weapon.has_flag( "RAIN_PROTECT" ) && one_in( 4 ) ) { add_msg( _( "Your umbrella protects you from the acid rain." ) ); } else { - if( g->u.worn_with_flag( flag_RAINPROOF ) && one_in( 2 ) ) { + if( g->u.worn_with_flag( "RAINPROOF" ) && one_in( 2 ) ) { add_msg( _( "Your clothing protects you from the acid rain." ) ); } else { bool has_helmet = false; @@ -875,7 +875,7 @@ double get_local_windpower( double windpower, const oter_id &omter, const tripoi bool is_wind_blocker( const tripoint &location ) { - return g->m.has_flag( flag_BLOCK_WIND, location ); + return g->m.has_flag( "BLOCK_WIND", location ); } // Description of Wind Speed - https://en.wikipedia.org/wiki/Beaufort_scale diff --git a/tests/bionics_test.cpp b/tests/bionics_test.cpp index 65f5b12d27609..044717f5bc3f2 100644 --- a/tests/bionics_test.cpp +++ b/tests/bionics_test.cpp @@ -15,7 +15,6 @@ #include "pimpl.h" #include "string_id.h" #include "type_id.h" -#include "cata_string_consts.h" static void clear_bionics( player &p ) { @@ -103,14 +102,14 @@ TEST_CASE( "bionics", "[bionics] [item]" ) INFO( "no power capacity at first" ); CHECK( !dummy.has_max_power() ); - dummy.add_bionic( bio_power_storage ); + dummy.add_bionic( bionic_id( "bio_power_storage" ) ); INFO( "adding Power Storage CBM only increases capacity" ); CHECK( !dummy.has_power() ); REQUIRE( dummy.has_max_power() ); SECTION( "bio_advreactor" ) { - give_and_activate( dummy, bio_advreactor ); + give_and_activate( dummy, bionic_id( "bio_advreactor" ) ); static const std::list always = { "plut_cell", // solid @@ -130,7 +129,7 @@ TEST_CASE( "bionics", "[bionics] [item]" ) } SECTION( "bio_batteries" ) { - give_and_activate( dummy, bio_batteries ); + give_and_activate( dummy, bionic_id( "bio_batteries" ) ); static const std::list always = { "battery" // old-school diff --git a/tests/comestible_test.cpp b/tests/comestible_test.cpp index d3d2a06781ab6..4d51d5285829c 100644 --- a/tests/comestible_test.cpp +++ b/tests/comestible_test.cpp @@ -17,7 +17,6 @@ #include "optional.h" #include "string_id.h" #include "value_ptr.h" -#include "cata_string_consts.h" struct all_stats { statistics calories; @@ -125,7 +124,7 @@ TEST_CASE( "recipe_permutations", "[recipe]" ) const recipe &recipe_obj = recipe_pair.first.obj(); item res_it = food_or_food_container( recipe_obj.create_result() ); const bool is_food = res_it.is_food(); - const bool has_override = res_it.has_flag( flag_NUTRIENT_OVERRIDE ); + const bool has_override = res_it.has_flag( "NUTRIENT_OVERRIDE" ); if( is_food && !has_override ) { // Collection of kcal values of all ingredient permutations all_stats mystats = run_stats( diff --git a/tests/encumbrance_test.cpp b/tests/encumbrance_test.cpp index 2407272c61585..ae5bb48cb717b 100644 --- a/tests/encumbrance_test.cpp +++ b/tests/encumbrance_test.cpp @@ -16,7 +16,6 @@ #include "material.h" #include "type_id.h" #include "debug.h" -#include "cata_string_consts.h" static void test_encumbrance_on( player &p, @@ -118,7 +117,7 @@ TEST_CASE( "same_layer_encumbrance", "[encumbrance]" ) TEST_CASE( "tiny_clothing", "[encumbrance]" ) { item i( "longshirt" ); - i.set_flag( flag_UNDERSIZE ); + i.set_flag( "UNDERSIZE" ); test_encumbrance_items( { i }, "TORSO", longshirt_e * 3 ); } @@ -129,7 +128,7 @@ TEST_CASE( "tiny_character", "[encumbrance]" ) test_encumbrance_items( { i }, "TORSO", longshirt_e * 2, add_trait( "SMALL2" ) ); } SECTION( "undersize shrt" ) { - i.set_flag( flag_UNDERSIZE ); + i.set_flag( "UNDERSIZE" ); test_encumbrance_items( { i }, "TORSO", longshirt_e, add_trait( "SMALL2" ) ); } } diff --git a/tests/memorial_test.cpp b/tests/memorial_test.cpp index df761c762d5f7..c28f144f4410e 100644 --- a/tests/memorial_test.cpp +++ b/tests/memorial_test.cpp @@ -7,7 +7,6 @@ #include "mutation.h" #include "output.h" #include "player_helpers.h" -#include "cata_string_consts.h" template void check_memorial( memorial_logger &m, event_bus &b, const std::string &ref, Args... args ) @@ -51,12 +50,12 @@ TEST_CASE( "memorials" ) std::string u_name = g->u.name; character_id ch2 = character_id( ch.get_value() + 1 ); mutagen_technique mutagen = mutagen_technique::injected_purifier; - mtype_id mon = mon_zombie_kevlar_2; - efftype_id eff = effect_onfire; + mtype_id mon( "mon_zombie_kevlar_2" ); + efftype_id eff( "onfire" ); itype_id it( "marloss_seed" ); - trait_id mut = trait_CARNIVORE; - trait_id mut2 = trait_SAPROPHAGE; - bionic_id cbm = bio_alarm; + trait_id mut( "CARNIVORE" ); + trait_id mut2( "SAPROPHAGE" ); + bionic_id cbm( "bio_alarm" ); check_memorial( m, b, "Activated the art_name.", ch, "art_name" ); @@ -171,7 +170,7 @@ TEST_CASE( "memorials" ) m, b, "Gained the mutation 'Carnivore'.", ch, mut ); check_memorial( - m, b, "Reached skill level 8 in driving.", ch, skill_driving, 8 ); + m, b, "Reached skill level 8 in driving.", ch, skill_id( "driving" ), 8 ); check_memorial( m, b, u_name + " was killed.\nLast words: last_words", false, "last_words" ); @@ -186,7 +185,7 @@ TEST_CASE( "memorials" ) m, b, "Installed bad bionic: Alarm System.", ch, cbm ); check_memorial( - m, b, "Learned Aikido.", ch, style_aikido ); + m, b, "Learned Aikido.", ch, matype_id( "style_aikido" ) ); check_memorial( m, b, "Overcame addiction to alcohol.", ch, ADD_ALCOHOL ); diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 7e611734e6993..b50fa708317a9 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -31,7 +31,6 @@ #include "memory_fast.h" #include "player_helpers.h" -#include "cata_string_consts.h" class Creature; @@ -309,6 +308,8 @@ TEST_CASE( "npc-movement" ) const ter_id t_floor( "t_floor" ); const furn_id f_rubble( "f_rubble" ); const furn_id f_null( "f_null" ); + const vpart_id vpart_frame_vertical( "frame_vertical" ); + const vpart_id vpart_seat( "seat" ); g->place_player( tripoint( 60, 60, 0 ) ); @@ -382,9 +383,9 @@ TEST_CASE( "npc-movement" ) REQUIRE( g->m.passable( p ) ); } if( type == 'R' ) { - REQUIRE( g->m.has_flag( flag_UNSTABLE, p ) ); + REQUIRE( g->m.has_flag( "UNSTABLE", p ) ); } else { - REQUIRE( !g->m.has_flag( flag_UNSTABLE, p ) ); + REQUIRE( !g->m.has_flag( "UNSTABLE", p ) ); } if( type == 'V' || type == 'W' || type == 'M' ) { REQUIRE( g->m.veh_at( p ).part_with_feature( VPFLAG_BOARDABLE, true ).has_value() ); diff --git a/tests/reload_option_test.cpp b/tests/reload_option_test.cpp index 3110a4dc78e4d..4064ee57b4b2c 100644 --- a/tests/reload_option_test.cpp +++ b/tests/reload_option_test.cpp @@ -5,7 +5,6 @@ #include "item.h" #include "item_location.h" #include "avatar.h" -#include "cata_string_consts.h" TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) { @@ -14,7 +13,7 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) item &gun = dummy.i_add( item( "sw_619", 0, 0 ) ); item &ammo = dummy.i_add( item( "38_special", 0, gun.ammo_capacity() ) ); item_location ammo_location( dummy, &ammo ); - REQUIRE( gun.has_flag( flag_RELOAD_ONE ) ); + REQUIRE( gun.has_flag( "RELOAD_ONE" ) ); REQUIRE( gun.ammo_remaining() == 0 ); const item::reload_option gun_option( &dummy, &gun, &gun, ammo_location ); diff --git a/tests/reloading_test.cpp b/tests/reloading_test.cpp index 110dad8759f3b..09d8aa5da8d79 100644 --- a/tests/reloading_test.cpp +++ b/tests/reloading_test.cpp @@ -18,7 +18,6 @@ #include "player_activity.h" #include "type_id.h" #include "value_ptr.h" -#include "cata_string_consts.h" TEST_CASE( "reload_gun_with_integral_magazine", "[reload],[gun]" ) { @@ -61,7 +60,7 @@ TEST_CASE( "reload_gun_with_integral_magazine_using_speedloader", "[reload],[gun REQUIRE( gun.magazine_integral() ); REQUIRE( loader_pos != INT_MIN ); REQUIRE( speedloader.ammo_remaining() == 0 ); - REQUIRE( speedloader.has_flag( flag_SPEEDLOADER ) ); + REQUIRE( speedloader.has_flag( "SPEEDLOADER" ) ); bool speedloader_success = speedloader.reload( dummy, item_location( dummy, &ammo ), ammo.charges ); diff --git a/tests/stomach_contents_test.cpp b/tests/stomach_contents_test.cpp index 416394bf20676..271149acb0872 100644 --- a/tests/stomach_contents_test.cpp +++ b/tests/stomach_contents_test.cpp @@ -11,7 +11,6 @@ #include "stomach.h" #include "units.h" #include "type_id.h" -#include "cata_string_consts.h" static void reset_time() { @@ -38,11 +37,11 @@ static void clear_stomach( player &p ) static void set_all_vitamins( int target, player &p ) { - p.vitamin_set( vitamin_vitA, target ); - p.vitamin_set( vitamin_vitB, target ); - p.vitamin_set( vitamin_vitC, target ); - p.vitamin_set( vitamin_iron, target ); - p.vitamin_set( vitamin_calcium, target ); + p.vitamin_set( vitamin_id( "vitA" ), target ); + p.vitamin_set( vitamin_id( "vitB" ), target ); + p.vitamin_set( vitamin_id( "vitC" ), target ); + p.vitamin_set( vitamin_id( "iron" ), target ); + p.vitamin_set( vitamin_id( "calcium" ), target ); } // time (in minutes) it takes for the player to feel hungry @@ -173,9 +172,9 @@ TEST_CASE( "all_nutrition_starve_test", "[starve]" ) } if( print_tests ) { printf( "vitamins: vitA %d vitB %d vitC %d calcium %d iron %d\n", - dummy.vitamin_get( vitamin_vitA ), dummy.vitamin_get( vitamin_vitB ), - dummy.vitamin_get( vitamin_vitC ), dummy.vitamin_get( vitamin_calcium ), - dummy.vitamin_get( vitamin_iron ) ); + dummy.vitamin_get( vitamin_id( "vitA" ) ), dummy.vitamin_get( vitamin_id( "vitB" ) ), + dummy.vitamin_get( vitamin_id( "vitC" ) ), dummy.vitamin_get( vitamin_id( "calcium" ) ), + dummy.vitamin_get( vitamin_id( "iron" ) ) ); printf( "\n" ); print_stomach_contents( dummy, print_tests ); printf( "\n" ); @@ -183,11 +182,11 @@ TEST_CASE( "all_nutrition_starve_test", "[starve]" ) CHECK( dummy.get_stored_kcal() >= dummy.get_healthy_kcal() ); // We need to account for a day's worth of error since we're passing a day at a time and we are // close to 0 which is the max value for some vitamins - CHECK( dummy.vitamin_get( vitamin_vitA ) >= -100 ); - CHECK( dummy.vitamin_get( vitamin_vitB ) >= -100 ); - CHECK( dummy.vitamin_get( vitamin_vitC ) >= -100 ); - CHECK( dummy.vitamin_get( vitamin_iron ) >= -100 ); - CHECK( dummy.vitamin_get( vitamin_calcium ) >= -100 ); + CHECK( dummy.vitamin_get( vitamin_id( "vitA" ) ) >= -100 ); + CHECK( dummy.vitamin_get( vitamin_id( "vitB" ) ) >= -100 ); + CHECK( dummy.vitamin_get( vitamin_id( "vitC" ) ) >= -100 ); + CHECK( dummy.vitamin_get( vitamin_id( "iron" ) ) >= -100 ); + CHECK( dummy.vitamin_get( vitamin_id( "calcium" ) ) >= -100 ); } TEST_CASE( "tape_worm_halves_nutrients" ) diff --git a/tests/vehicle_drag_test.cpp b/tests/vehicle_drag_test.cpp index 8a67870ca7316..0968ca6b5ed21 100644 --- a/tests/vehicle_drag_test.cpp +++ b/tests/vehicle_drag_test.cpp @@ -18,10 +18,11 @@ #include "type_id.h" #include "point.h" #include "vpart_position.h" -#include "cata_string_consts.h" using efficiency_stat = statistics; +const efftype_id effect_blind( "blind" ); + static void clear_game_drag( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power @@ -59,7 +60,7 @@ static void clear_game_drag( const ter_id &terrain ) static vehicle *setup_drag_test( const vproto_id &veh_id ) { - clear_game_drag( ter_pavement ); + clear_game_drag( ter_id( "t_pavement" ) ); const tripoint map_starting_point( 60, 60, 0 ); vehicle *veh_ptr = g->m.add_vehicle( veh_id, map_starting_point, -90, 0, 0 ); @@ -76,7 +77,7 @@ static vehicle *setup_drag_test( const vproto_id &veh_id ) veh_ptr->toggle_specific_part( vp.part_index(), true ); } // close the doors - const auto doors = veh_ptr->get_avail_parts( flag_OPENABLE ); + const auto doors = veh_ptr->get_avail_parts( "OPENABLE" ); for( const vpart_reference vp : doors ) { const size_t door = vp.part_index(); veh_ptr->close( door ); diff --git a/tests/vehicle_efficiency_test.cpp b/tests/vehicle_efficiency_test.cpp index 4b3eabf3f3053..ef9b7b2a86e53 100644 --- a/tests/vehicle_efficiency_test.cpp +++ b/tests/vehicle_efficiency_test.cpp @@ -32,10 +32,11 @@ #include "type_id.h" #include "point.h" #include "vpart_position.h" -#include "cata_string_consts.h" using efficiency_stat = statistics; +const efftype_id effect_blind( "blind" ); + static void clear_game( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power @@ -85,7 +86,7 @@ static std::map set_vehicle_fuel( vehicle &v, const float veh_fue } // We ignore battery when setting fuel because it uses designated "tanks" - actually_used.erase( fuel_type_battery ); + actually_used.erase( "battery" ); // Currently only one liquid fuel supported REQUIRE( actually_used.size() <= 1 ); @@ -104,8 +105,8 @@ static std::map set_vehicle_fuel( vehicle &v, const float veh_fue vehicle_part &pt = vp.part(); if( pt.is_battery() ) { - pt.ammo_set( fuel_type_battery, pt.ammo_capacity() * veh_fuel_mult ); - ret[ fuel_type_battery ] += pt.ammo_capacity() * veh_fuel_mult; + pt.ammo_set( "battery", pt.ammo_capacity() * veh_fuel_mult ); + ret[ "battery" ] += pt.ammo_capacity() * veh_fuel_mult; } else if( pt.is_tank() && liquid_fuel != "null" ) { float qty = pt.ammo_capacity() * veh_fuel_mult; qty *= std::max( item::find_type( liquid_fuel )->stack_size, 1 ); @@ -118,7 +119,7 @@ static std::map set_vehicle_fuel( vehicle &v, const float veh_fue } // We re-add battery because we want it accounted for, just not in the section above - actually_used.insert( fuel_type_battery ); + actually_used.insert( "battery" ); for( auto iter = ret.begin(); iter != ret.end(); ) { if( iter->second <= 0 || actually_used.count( iter->first ) == 0 ) { iter = ret.erase( iter ); @@ -198,7 +199,7 @@ static int test_efficiency( const vproto_id &veh_id, int &expected_mass, veh_ptr->get_items( vp.part_index() ).clear(); vp.part().ammo_consume( vp.part().ammo_remaining(), vp.pos() ); } - for( const vpart_reference vp : veh.get_avail_parts( flag_OPENABLE ) ) { + for( const vpart_reference vp : veh.get_avail_parts( "OPENABLE" ) ) { veh.close( vp.part_index() ); } @@ -354,29 +355,29 @@ static void test_vehicle( const int pavement_target_smooth_stops = 0, const int dirt_target_smooth_stops = 0 ) { SECTION( type + " on pavement" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_pavement, -1, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_pavement" ), -1, pavement_target ); } SECTION( type + " on dirt" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_dirt, -1, dirt_target ); + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_dirt" ), -1, dirt_target ); } SECTION( type + " on pavement, full stop every 5 turns" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_pavement, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_pavement" ), 5, pavement_target_w_stops ); } SECTION( type + " on dirt, full stop every 5 turns" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_dirt, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_dirt" ), 5, dirt_target_w_stops ); } if( pavement_target_smooth_stops > 0 ) { SECTION( type + " on pavement, alternating 5 turns of acceleration and 5 turns of decceleration" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_pavement, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_pavement" ), 5, pavement_target_smooth_stops, true ); } } if( dirt_target_smooth_stops > 0 ) { SECTION( type + " on dirt, alternating 5 turns of acceleration and 5 turns of decceleration" ) { - test_efficiency( vproto_id( type ), expected_mass, ter_dirt, 5, + test_efficiency( vproto_id( type ), expected_mass, ter_id( "t_dirt" ), 5, dirt_target_smooth_stops, true ); } } diff --git a/tests/vehicle_part_test.cpp b/tests/vehicle_part_test.cpp index 380a211cc17aa..c8fedbc139e1c 100644 --- a/tests/vehicle_part_test.cpp +++ b/tests/vehicle_part_test.cpp @@ -1,12 +1,11 @@ #include "catch/catch.hpp" #include "veh_type.h" -#include "cata_string_consts.h" TEST_CASE( "verify_copy_from_gets_damage_reduction", "[vehicle]" ) { // Picking halfboard_horizontal as a vpart which is likely to remain // defined via copy-from, and which should have non-zero damage reduction. - const vpart_info &vp = vpart_halfboard_horizontal.obj(); + const vpart_info &vp = vpart_id( "halfboard_horizontal" ).obj(); CHECK( vp.damage_reduction[DT_BASH] != 0 ); } diff --git a/tests/vehicle_test.cpp b/tests/vehicle_test.cpp index 46b35022da6b2..ee7e528450364 100644 --- a/tests/vehicle_test.cpp +++ b/tests/vehicle_test.cpp @@ -10,7 +10,6 @@ #include "enums.h" #include "type_id.h" #include "point.h" -#include "cata_string_consts.h" TEST_CASE( "detaching_vehicle_unboards_passengers" ) { @@ -56,7 +55,7 @@ TEST_CASE( "add_item_to_broken_vehicle_part" ) REQUIRE( veh_ptr != nullptr ); const tripoint pos = vehicle_origin + tripoint_west; - auto cargo_parts = veh_ptr->get_parts_at( pos, flag_CARGO, part_status_flag::any ); + auto cargo_parts = veh_ptr->get_parts_at( pos, "CARGO", part_status_flag::any ); REQUIRE( !cargo_parts.empty( ) ); vehicle_part *cargo_part = cargo_parts.front(); REQUIRE( cargo_part != nullptr ); diff --git a/tests/vehicle_turrets_test.cpp b/tests/vehicle_turrets_test.cpp index 7bbc608b983cc..397a209d31dff 100644 --- a/tests/vehicle_turrets_test.cpp +++ b/tests/vehicle_turrets_test.cpp @@ -19,14 +19,13 @@ #include "units.h" #include "type_id.h" #include "point.h" -#include "cata_string_consts.h" static std::vector turret_types() { std::vector res; for( const auto &e : vpart_info::all() ) { - if( e.second.has_flag( flag_TURRET ) ) { + if( e.second.has_flag( "TURRET" ) ) { res.push_back( &e.second ); } } @@ -70,12 +69,12 @@ TEST_CASE( "vehicle_turret", "[vehicle] [gun] [magazine] [.]" ) const int idx = veh->install_part( point_zero, e->get_id(), true ); REQUIRE( idx >= 0 ); - REQUIRE( veh->install_part( point_zero, vpart_storage_battery, true ) >= 0 ); + REQUIRE( veh->install_part( point_zero, vpart_id( "storage_battery" ), true ) >= 0 ); veh->charge_battery( 10000 ); auto ammo = ammotype( veh->turret_query( veh->parts[idx] ).base()->ammo_default() ); - if( veh->part_flag( idx, flag_USE_TANKS ) ) { + if( veh->part_flag( idx, "USE_TANKS" ) ) { auto *tank = biggest_tank( ammo ); REQUIRE( tank ); INFO( tank->get_id().str() ); diff --git a/tests/visitable_remove_test.cpp b/tests/visitable_remove_test.cpp index abd7bc2624602..2b8fce5a50d07 100644 --- a/tests/visitable_remove_test.cpp +++ b/tests/visitable_remove_test.cpp @@ -22,7 +22,6 @@ #include "optional.h" #include "type_id.h" #include "point.h" -#include "cata_string_consts.h" template static int count_items( const T &src, const itype_id &id ) @@ -417,7 +416,7 @@ TEST_CASE( "visitable_remove", "[visitable]" ) return static_cast( g->m.veh_at( e ) ); } ) == 1 ); - const cata::optional vp = g->m.veh_at( veh ).part_with_feature( flag_CARGO, true ); + const cata::optional vp = g->m.veh_at( veh ).part_with_feature( "CARGO", true ); REQUIRE( vp ); vehicle *const v = &vp->vehicle(); const int part = vp->part_index();