diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 7d9099479d5f6..99df69b62b372 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2462,7 +2462,7 @@ void activity_handlers::oxytorch_finish( player_activity *act, player *p ) here.furn_set( pos, f_safe_o ); // 50% of starting a fire. if( here.flammable_items_at( pos ) && rng( 1, 100 ) < 50 ) { - here.add_field( pos, field_type_id( "fd_fire" ), 1, 10_minutes ); + here.add_field( pos, fd_fire, 1, 10_minutes ); } } } diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 3c90dabcf0bcc..bc4e134657a0b 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1914,7 +1914,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) // (to prevent taking out wood off the lit brazier) // and inaccessible furniture, like filled charcoal kiln if( mgr.has( zone_type_LOOT_IGNORE, src ) || - here.get_field( src_loc, field_type_id( "fd_fire" ) ) != nullptr || + here.get_field( src_loc, fd_fire ) != nullptr || !here.can_put_items_ter_furn( src_loc ) ) { continue; } @@ -2777,7 +2777,7 @@ static cata::optional find_best_fire( const std::vector &fro time_duration best_fire_age = 1_days; map &here = get_map(); for( const tripoint &pt : from ) { - field_entry *fire = here.get_field( pt, field_type_id( "fd_fire" ) ); + field_entry *fire = here.get_field( pt, fd_fire ); if( fire == nullptr || fire->get_field_intensity() > 1 || !here.clear_path( center, pt, PICKUP_RANGE, 1, 100 ) ) { continue; @@ -2939,7 +2939,7 @@ void try_fuel_fire( player_activity &act, player &p, const bool starting_fire ) // Special case: fire containers allow burning logs, so use them as fuel if fire is contained bool contained = here.has_flag_furn( TFLAG_FIRE_CONTAINER, *best_fire ); fire_data fd( 1, contained ); - time_duration fire_age = here.get_field_age( *best_fire, field_type_id( "fd_fire" ) ); + time_duration fire_age = here.get_field_age( *best_fire, fd_fire ); // Maybe TODO: - refueling in the rain could use more fuel // First, simulate expected burn per turn, to see if we need more fuel diff --git a/src/ammo_effect.h b/src/ammo_effect.h index 561b0cf2e3d4a..75e29b8496ca0 100644 --- a/src/ammo_effect.h +++ b/src/ammo_effect.h @@ -20,7 +20,7 @@ struct ammo_effect { void check() const; public: - field_type_id aoe_field_type = fd_null; + field_type_id aoe_field_type = fd_null.id_or( INVALID_FIELD_TYPE_ID ); /** used during JSON loading only */ std::string aoe_field_type_name = "fd_null"; int aoe_intensity_min = 0; @@ -38,7 +38,7 @@ struct ammo_effect { bool do_emp_blast = false; bool foamcrete_build = false; - field_type_id trail_field_type = fd_null; + field_type_id trail_field_type = fd_null.id_or( INVALID_FIELD_TYPE_ID ); /** used during JSON loading only */ std::string trail_field_type_name = "fd_null"; int trail_intensity_min = 0; diff --git a/src/bionics.cpp b/src/bionics.cpp index 8bd43bbb62d15..95fee84fc8dd4 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -770,7 +770,7 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) const cata::optional pnt = choose_adjacent( _( "Start a fire where?" ) ); if( pnt && here.is_flammable( *pnt ) ) { add_msg_activate(); - here.add_field( *pnt, field_type_id( "fd_fire" ), 1 ); + here.add_field( *pnt, fd_fire, 1 ); mod_moves( -100 ); } else { refund_power(); diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index fb0800bdad3e3..9b5a746d9950a 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -2601,7 +2601,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int auto field_at = [&]( const tripoint & q, const bool invis ) -> field_type_id { const auto it = field_override.find( q ); return it != field_override.end() ? it->second : - ( !fld_overridden || !invis ) ? here.field_at( q ).displayed_field_type() : field_type_id( "fd_null" ); + ( !fld_overridden || !invis ) ? here.field_at( q ).displayed_field_type() : fd_null; }; // for rotation information const int neighborhood[4] = { diff --git a/src/character.cpp b/src/character.cpp index 89f3bcffa11eb..acf384fd57617 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -508,22 +508,22 @@ void Character::randomize_blood() field_type_id Character::bloodType() const { if( has_trait( trait_ACIDBLOOD ) ) { - return field_type_id( "fd_acid" ); + return fd_acid; } if( has_trait( trait_THRESH_PLANT ) ) { - return field_type_id( "fd_blood_veggy" ); + return fd_blood_veggy; } if( has_trait( trait_THRESH_INSECT ) || has_trait( trait_THRESH_SPIDER ) ) { - return field_type_id( "fd_blood_insect" ); + return fd_blood_insect; } if( has_trait( trait_THRESH_CEPHALOPOD ) ) { - return field_type_id( "fd_blood_invertebrate" ); + return fd_blood_invertebrate; } - return field_type_id( "fd_blood" ); + return fd_blood; } field_type_id Character::gibType() const { - return field_type_id( "fd_gibs_flesh" ); + return fd_gibs_flesh; } bool Character::in_species( const species_id &spec ) const @@ -6637,7 +6637,7 @@ Character::comfort_response_t Character::base_comfort_value( const tripoint &p ) const ter_id ter_at_pos = tile.get_ter(); const furn_id furn_at_pos = tile.get_furn(); - int web = here.get_field_intensity( p, field_type_id( "fd_web" ) ); + int web = here.get_field_intensity( p, fd_web ); // Some mutants have different comfort needs if( !plantsleep && !webforce ) { @@ -8846,7 +8846,7 @@ void Character::vomit() if( stomach.contains() != 0_ml ) { stomach.empty(); - get_map().add_field( adjacent_tile(), field_type_id( "fd_bile" ), 1 ); + get_map().add_field( adjacent_tile(), fd_bile, 1 ); add_msg_player_or_npc( m_bad, _( "You throw up heavily!" ), _( " throws up heavily!" ) ); } @@ -9961,7 +9961,7 @@ void Character::blossoms() sounds::sound( pos(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( pos(), 2 ) ) { - here.add_field( tmp, field_type_id( "fd_fungal_haze" ), rng( 1, 2 ) ); + here.add_field( tmp, fd_fungal_haze, rng( 1, 2 ) ); } } diff --git a/src/computer_session.cpp b/src/computer_session.cpp index f41156e0bb1d7..45de56afbf86e 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -1072,7 +1072,7 @@ void computer_session::action_irradiator() "alarm" ); here.i_rem( dest, it ); here.make_rubble( dest ); - here.propagate_field( dest, field_type_id( "fd_nuke_gas" ), 100, 3 ); + here.propagate_field( dest, fd_nuke_gas, 100, 3 ); here.translate_radius( t_water_pool, t_sewage, 8.0, dest, true ); here.adjust_radiation( dest, rng( 50, 500 ) ); for( const tripoint &radorigin : here.points_in_radius( dest, 5 ) ) { @@ -1260,13 +1260,13 @@ void computer_session::action_deactivate_shock_vent() bool has_generator = false; map &here = get_map(); for( const tripoint &dest : here.points_in_radius( player_character.pos(), 10 ) ) { - if( here.get_field( dest, field_type_id( "fd_shock_vent" ) ) != nullptr ) { + if( here.get_field( dest, fd_shock_vent ) != nullptr ) { has_vent = true; } if( here.ter( dest ) == t_plut_generator ) { has_generator = true; } - here.remove_field( dest, field_type_id( "fd_shock_vent" ) ); + here.remove_field( dest, fd_shock_vent ); } print_line( _( "Initiating POWER-DIAG ver.2.34…" ) ); if( has_vent ) { diff --git a/src/emit.h b/src/emit.h index 8fd7dc49a7f62..3e499e514651d 100644 --- a/src/emit.h +++ b/src/emit.h @@ -64,7 +64,7 @@ class emit private: emit_id id_; - field_type_id field_ = fd_null; + field_type_id field_ = fd_null.id_or( INVALID_FIELD_TYPE_ID ); int intensity_ = 1; int qty_ = 1; int chance_ = 100; diff --git a/src/explosion.cpp b/src/explosion.cpp index 12cdb6b0a831d..f069e49644513 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -298,7 +298,7 @@ static void do_blast( const tripoint &p, const float power, intensity++; } - here.add_field( pt, field_type_id( "fd_fire" ), intensity ); + here.add_field( pt, fd_fire, intensity ); } if( const optional_vpart_position vp = here.veh_at( pt ) ) { @@ -804,24 +804,24 @@ void resonance_cascade( const tripoint &p ) case 5: for( int k = i - 1; k <= i + 1; k++ ) { for( int l = j - 1; l <= j + 1; l++ ) { - field_type_id type = field_type_id( "fd_null" ); + field_type_id type = fd_null; switch( rng( 1, 7 ) ) { case 1: - type = field_type_id( "fd_blood" ); + type = fd_blood; break; case 2: - type = field_type_id( "fd_bile" ); + type = fd_bile; break; case 3: case 4: - type = field_type_id( "fd_slime" ); + type = fd_slime; break; case 5: - type = field_type_id( "fd_fire" ); + type = fd_fire; break; case 6: case 7: - type = field_type_id( "fd_nuke_gas" ); + type = fd_nuke_gas; break; } if( !one_in( 3 ) ) { diff --git a/src/field.cpp b/src/field.cpp index a415c182dbad0..8478f1a92c9a7 100644 --- a/src/field.cpp +++ b/src/field.cpp @@ -146,7 +146,7 @@ time_duration field_entry::set_field_age( const time_duration &new_age ) } field::field() - : _displayed_field_type( fd_null ) + : _displayed_field_type( fd_null.id_or( INVALID_FIELD_TYPE_ID ) ) { } diff --git a/src/field.h b/src/field.h index 49237383220bb..7ca6481726e93 100644 --- a/src/field.h +++ b/src/field.h @@ -20,7 +20,8 @@ class field_entry { public: - field_entry() : type( fd_null ), intensity( 1 ), age( 0_turns ), is_alive( false ) { } + field_entry() : type( fd_null.id_or( INVALID_FIELD_TYPE_ID ) ), intensity( 1 ), age( 0_turns ), + is_alive( false ) { } field_entry( const field_type_id &t, const int i, const time_duration &a ) : type( t ), intensity( i ), age( a ), is_alive( true ) { } diff --git a/src/field_type.cpp b/src/field_type.cpp index a4d7e14c753cc..5637288d4ee8a 100644 --- a/src/field_type.cpp +++ b/src/field_type.cpp @@ -11,7 +11,53 @@ #include "json.h" #include "string_id.h" -field_type_id fd_null; +const field_type_str_id fd_null = field_type_str_id::NULL_ID(); +const field_type_str_id fd_fire( "fd_fire" ); +const field_type_str_id fd_blood( "fd_blood" ); +const field_type_str_id fd_bile( "fd_bile" ); +const field_type_str_id fd_extinguisher( "fd_extinguisher" ); +const field_type_str_id fd_gibs_flesh( "fd_gibs_flesh" ); +const field_type_str_id fd_gibs_veggy( "fd_gibs_veggy" ); +const field_type_str_id fd_web( "fd_web" ); +const field_type_str_id fd_slime( "fd_slime" ); +const field_type_str_id fd_acid( "fd_acid" ); +const field_type_str_id fd_sap( "fd_sap" ); +const field_type_str_id fd_sludge( "fd_sludge" ); +const field_type_str_id fd_smoke( "fd_smoke" ); +const field_type_str_id fd_toxic_gas( "fd_toxic_gas" ); +const field_type_str_id fd_tear_gas( "fd_tear_gas" ); +const field_type_str_id fd_nuke_gas( "fd_nuke_gas" ); +const field_type_str_id fd_gas_vent( "fd_gas_vent" ); +const field_type_str_id fd_fire_vent( "fd_fire_vent" ); +const field_type_str_id fd_flame_burst( "fd_flame_burst" ); +const field_type_str_id fd_electricity( "fd_electricity" ); +const field_type_str_id fd_fatigue( "fd_fatigue" ); +const field_type_str_id fd_push_items( "fd_push_items" ); +const field_type_str_id fd_shock_vent( "fd_shock_vent" ); +const field_type_str_id fd_acid_vent( "fd_acid_vent" ); +const field_type_str_id fd_plasma( "fd_plasma" ); +const field_type_str_id fd_laser( "fd_laser" ); +const field_type_str_id fd_dazzling( "fd_dazzling" ); +const field_type_str_id fd_blood_veggy( "fd_blood_veggy" ); +const field_type_str_id fd_blood_insect( "fd_blood_insect" ); +const field_type_str_id fd_blood_invertebrate( "fd_blood_invertebrate" ); +const field_type_str_id fd_gibs_insect( "fd_gibs_insect" ); +const field_type_str_id fd_gibs_invertebrate( "fd_gibs_invertebrate" ); +const field_type_str_id fd_bees( "fd_bees" ); +const field_type_str_id fd_incendiary( "fd_incendiary" ); +const field_type_str_id fd_relax_gas( "fd_relax_gas" ); +const field_type_str_id fd_fungal_haze( "fd_fungal_haze" ); +const field_type_str_id fd_cold_air2( "fd_cold_air2" ); +const field_type_str_id fd_cold_air3( "fd_cold_air3" ); +const field_type_str_id fd_cold_air4( "fd_cold_air4" ); +const field_type_str_id fd_hot_air1( "fd_hot_air1" ); +const field_type_str_id fd_hot_air2( "fd_hot_air2" ); +const field_type_str_id fd_hot_air3( "fd_hot_air3" ); +const field_type_str_id fd_hot_air4( "fd_hot_air4" ); +const field_type_str_id fd_fungicidal_gas( "fd_fungicidal_gas" ); +const field_type_str_id fd_insecticidal_gas( "fd_insecticidal_gas" ); +const field_type_str_id fd_smoke_vent( "fd_smoke_vent" ); +const field_type_str_id fd_tindalos_rift( "fd_tindalos_rift" ); namespace io { @@ -101,11 +147,17 @@ const field_type &string_id::obj() const return all_field_types.obj( *this ); } +template<> +int_id string_id::id_or( const int_id &fallback ) const +{ + return all_field_types.convert( *this, fallback, false ); +} + /** @relates string_id */ template<> int_id string_id::id() const { - return all_field_types.convert( *this, fd_null ); + return all_field_types.convert( *this, fd_null.id_or( int_id() ) ); } /** @relates int_id */ @@ -272,7 +324,6 @@ void field_type::finalize() debugmsg( "Invalid mtype_id %s in immune_mtypes for field %s.", m_id.c_str(), id.c_str() ); } } - fd_null = field_type_id( "fd_null" ); } void field_type::check() const diff --git a/src/field_type.h b/src/field_type.h index 3b1525507e57c..363217be01ba3 100644 --- a/src/field_type.h +++ b/src/field_type.h @@ -115,7 +115,54 @@ struct field_intensity_level { std::vector field_effects; }; -extern field_type_id fd_null; +const field_type_id INVALID_FIELD_TYPE_ID = field_type_id( -1 ); +extern const field_type_str_id fd_null; +extern const field_type_str_id fd_fire; +extern const field_type_str_id fd_blood; +extern const field_type_str_id fd_bile; +extern const field_type_str_id fd_extinguisher; +extern const field_type_str_id fd_gibs_flesh; +extern const field_type_str_id fd_gibs_veggy; +extern const field_type_str_id fd_web; +extern const field_type_str_id fd_slime; +extern const field_type_str_id fd_acid; +extern const field_type_str_id fd_sap; +extern const field_type_str_id fd_sludge; +extern const field_type_str_id fd_smoke; +extern const field_type_str_id fd_toxic_gas; +extern const field_type_str_id fd_tear_gas; +extern const field_type_str_id fd_nuke_gas; +extern const field_type_str_id fd_gas_vent; +extern const field_type_str_id fd_fire_vent; +extern const field_type_str_id fd_flame_burst; +extern const field_type_str_id fd_electricity; +extern const field_type_str_id fd_fatigue; +extern const field_type_str_id fd_push_items; +extern const field_type_str_id fd_shock_vent; +extern const field_type_str_id fd_acid_vent; +extern const field_type_str_id fd_plasma; +extern const field_type_str_id fd_laser; +extern const field_type_str_id fd_dazzling; +extern const field_type_str_id fd_blood_veggy; +extern const field_type_str_id fd_blood_insect; +extern const field_type_str_id fd_blood_invertebrate; +extern const field_type_str_id fd_gibs_insect; +extern const field_type_str_id fd_gibs_invertebrate; +extern const field_type_str_id fd_bees; +extern const field_type_str_id fd_incendiary; +extern const field_type_str_id fd_relax_gas; +extern const field_type_str_id fd_fungal_haze; +extern const field_type_str_id fd_cold_air2; +extern const field_type_str_id fd_cold_air3; +extern const field_type_str_id fd_cold_air4; +extern const field_type_str_id fd_hot_air1; +extern const field_type_str_id fd_hot_air2; +extern const field_type_str_id fd_hot_air3; +extern const field_type_str_id fd_hot_air4; +extern const field_type_str_id fd_fungicidal_gas; +extern const field_type_str_id fd_insecticidal_gas; +extern const field_type_str_id fd_smoke_vent; +extern const field_type_str_id fd_tindalos_rift; struct field_type { public: diff --git a/src/fungal_effects.cpp b/src/fungal_effects.cpp index 903f17611b2af..95111f8239931 100644 --- a/src/fungal_effects.cpp +++ b/src/fungal_effects.cpp @@ -183,7 +183,7 @@ void fungal_effects::spread_fungus_one_tile( const tripoint &p, const int growth } } else if( m.has_flag( flag_YOUNG, p ) ) { if( x_in_y( growth * 10, 500 ) ) { - if( m.get_field_intensity( p, field_type_id( "fd_fungal_haze" ) ) != 0 ) { + if( m.get_field_intensity( p, fd_fungal_haze ) != 0 ) { if( x_in_y( growth * 10, 800 ) ) { // young trees are vulnerable m.ter_set( p, t_fungus ); if( gm.place_critter_at( mon_fungal_blossom, p ) ) { @@ -199,7 +199,7 @@ void fungal_effects::spread_fungus_one_tile( const tripoint &p, const int growth } } else if( m.has_flag( flag_TREE, p ) ) { if( one_in( 10 ) ) { - if( m.get_field_intensity( p, field_type_id( "fd_fungal_haze" ) ) != 0 ) { + if( m.get_field_intensity( p, fd_fungal_haze ) != 0 ) { if( x_in_y( growth * 10, 100 ) ) { m.ter_set( p, t_fungus ); if( gm.place_critter_at( mon_fungal_blossom, p ) ) { diff --git a/src/game.cpp b/src/game.cpp index 093b9d2fb194b..e83a41265a7c2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1829,7 +1829,7 @@ int get_heat_radiation( const tripoint &location, bool direct ) maptile mt = here.maptile_at( dest ); - int ffire = maptile_field_intensity( mt, field_type_id( "fd_fire" ) ); + int ffire = maptile_field_intensity( mt, fd_fire ); if( ffire > 0 ) { heat_intensity = ffire; } else if( here.tr_at( dest ) == tr_lava ) { @@ -1865,8 +1865,7 @@ int get_convection_temperature( const tripoint &location ) int temp_mod = 0; map &here = get_map(); // Directly on lava tiles - int lava_mod = here.tr_at( location ) == tr_lava ? - field_type_id( "fd_fire" )->get_convection_temperature_mod() : 0; + int lava_mod = here.tr_at( location ) == tr_lava ? fd_fire->get_convection_temperature_mod() : 0; // Modifier from fields for( auto fd : here.field_at( location ) ) { // Nullify lava modifier when there is open fire @@ -5799,7 +5798,7 @@ static std::string get_fire_fuel_string( const tripoint &examp ) { map &here = get_map(); if( here.has_flag( TFLAG_FIRE_CONTAINER, examp ) ) { - field_entry *fire = here.get_field( examp, field_type_id( "fd_fire" ) ); + field_entry *fire = here.get_field( examp, fd_fire ); if( fire ) { std::string ss; ss += _( "There is a fire here." ); @@ -9631,11 +9630,11 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp ) if( pulling ) { const tripoint shifted_furn_pos = furn_pos - ms_shift; const tripoint shifted_furn_dest = furn_dest - ms_shift; - const time_duration fire_age = m.get_field_age( shifted_furn_pos, field_type_id( "fd_fire" ) ); - const int fire_intensity = m.get_field_intensity( shifted_furn_pos, field_type_id( "fd_fire" ) ); - m.remove_field( shifted_furn_pos, field_type_id( "fd_fire" ) ); - m.set_field_intensity( shifted_furn_dest, field_type_id( "fd_fire" ), fire_intensity ); - m.set_field_age( shifted_furn_dest, field_type_id( "fd_fire" ), fire_age ); + const time_duration fire_age = m.get_field_age( shifted_furn_pos, fd_fire ); + const int fire_intensity = m.get_field_intensity( shifted_furn_pos, fd_fire ); + m.remove_field( shifted_furn_pos, fd_fire ); + m.set_field_intensity( shifted_furn_dest, fd_fire, fire_intensity ); + m.set_field_age( shifted_furn_dest, fd_fire, fire_age ); } if( u.is_hauling() ) { @@ -10145,8 +10144,8 @@ bool game::grabbed_furn_move( const tripoint &dp ) m.furn( fpos ).obj().has_flag( "FIRE_CONTAINER" ) || m.furn( fpos ).obj().has_flag( "SEALED" ); - const int fire_intensity = m.get_field_intensity( fpos, field_type_id( "fd_fire" ) ); - time_duration fire_age = m.get_field_age( fpos, field_type_id( "fd_fire" ) ); + const int fire_intensity = m.get_field_intensity( fpos, fd_fire ); + time_duration fire_age = m.get_field_age( fpos, fd_fire ); int str_req = furntype.move_str_req; // Factor in weight of items contained in the furniture. @@ -10215,9 +10214,9 @@ bool game::grabbed_furn_move( const tripoint &dp ) m.furn_set( fpos, f_null ); if( fire_intensity == 1 && !pulling_furniture ) { - m.remove_field( fpos, field_type_id( "fd_fire" ) ); - m.set_field_intensity( fdest, field_type_id( "fd_fire" ), fire_intensity ); - m.set_field_age( fdest, field_type_id( "fd_fire" ), fire_age ); + m.remove_field( fpos, fd_fire ); + m.set_field_intensity( fdest, fd_fire, fire_intensity ); + m.set_field_age( fdest, fd_fire, fire_age ); } // Is there is only liquids on the ground, remove them after moving furniture. diff --git a/src/generic_factory.h b/src/generic_factory.h index 53fafaac15210..67c626d5f1d7c 100644 --- a/src/generic_factory.h +++ b/src/generic_factory.h @@ -451,13 +451,17 @@ class generic_factory } /** * Converts string_id to int_id. Returns null_id on failure. + * When optional flag warn is true, issues a warning if `id` is not found and null_id was returned. */ - int_id convert( const string_id &id, const int_id &null_id ) const { + int_id convert( const string_id &id, const int_id &null_id, + const bool warn = true ) const { int_id result; if( find_id( id, result ) ) { return result; } - debugmsg( "invalid %s id \"%s\"", type_name, id.c_str() ); + if( warn ) { + debugmsg( "invalid %s id \"%s\"", type_name, id.c_str() ); + } return null_id; } /** diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 37eee038a6e6a..4786288bc676c 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -2921,8 +2921,7 @@ void iexamine::fireplace( player &p, const tripoint &examp ) return; } case 2: { - if( !here.get_field( examp, field_type_id( "fd_fire" ) ) && - here.add_field( examp, field_type_id( "fd_fire" ), 1 ) ) { + if( !here.get_field( examp, fd_fire ) && here.add_field( examp, fd_fire, 1 ) ) { p.mod_power_level( -bio_lighter->power_activate ); p.mod_moves( -to_moves( 1_seconds ) ); } else { @@ -2944,7 +2943,7 @@ void iexamine::fireplace( player &p, const tripoint &examp ) return; } case 4: { - here.remove_field( examp, field_type_id( "fd_fire" ) ); + here.remove_field( examp, fd_fire ); p.mod_moves( -200 ); p.add_msg_if_player( m_info, _( "With a few determined moves you put out the fire in the %s." ), here.furnname( examp ) ); diff --git a/src/item.cpp b/src/item.cpp index ca33dee353ba3..ff5b706b54413 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -9569,7 +9569,7 @@ bool item::process_litcig( player *carrier, const tripoint &pos ) if( here.flammable_items_at( pos ) || here.has_flag( flag_FLAMMABLE, pos ) || here.has_flag( flag_FLAMMABLE_ASH, pos ) ) { - here.add_field( pos, field_type_id( "fd_fire" ), 1 ); + here.add_field( pos, fd_fire, 1 ); } } } diff --git a/src/iuse.cpp b/src/iuse.cpp index 92e1ea78407bf..59b8669a90227 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2027,7 +2027,7 @@ int iuse::extinguisher( player *p, item *it, bool, const tripoint & ) map &here = get_map(); // Reduce the strength of fire (if any) in the target tile. - here.add_field( dest, field_type_id( "fd_extinguisher" ), 3, 10_turns ); + here.add_field( dest, fd_extinguisher, 3, 10_turns ); // Also spray monsters in that tile. if( monster *const mon_ptr = g->critter_at( dest, true ) ) { @@ -2059,8 +2059,7 @@ int iuse::extinguisher( player *p, item *it, bool, const tripoint & ) dest.x += ( dest.x - p->posx() ); dest.y += ( dest.y - p->posy() ); - here.mod_field_intensity( dest, field_type_id( "fd_fire" ), std::min( 0 - rng( 0, 1 ) + rng( 0, 1 ), - 0 ) ); + here.mod_field_intensity( dest, fd_fire, std::min( 0 - rng( 0, 1 ) + rng( 0, 1 ), 0 ) ); } return it->type->charges_to_use(); @@ -3848,7 +3847,7 @@ int iuse::granade_act( player *p, item *it, bool t, const tripoint &pos ) explosion_handler::draw_explosion( pos, explosion_radius, c_yellow ); for( const tripoint &dest : here.points_in_radius( pos, explosion_radius ) ) { if( one_in( 5 ) && !g->critter_at( dest ) ) { - here.add_field( dest, field_type_id( "fd_bees" ), rng( 1, 3 ) ); + here.add_field( dest, fd_bees, rng( 1, 3 ) ); } } break; @@ -3878,7 +3877,7 @@ int iuse::acidbomb_act( player *p, item *it, bool, const tripoint &pos ) it->charges = -1; map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( pos.x == -999 ? p->pos() : pos, 1 ) ) { - here.add_field( tmp, field_type_id( "fd_acid" ), 3 ); + here.add_field( tmp, fd_acid, 3 ); } return 1; } @@ -3904,12 +3903,12 @@ int iuse::grenade_inc_act( player *p, item *it, bool t, const tripoint &pos ) tripoint dest( pos + point( rng( -5, 5 ), rng( -5, 5 ) ) ); std::vector flames = line_to( pos, dest, 0, 0 ); for( auto &flame : flames ) { - here.add_field( flame, field_type_id( "fd_fire" ), rng( 0, 2 ) ); + here.add_field( flame, fd_fire, rng( 0, 2 ) ); } } explosion_handler::explosion( pos, 8, 0.8, true ); for( const tripoint &dest : here.points_in_radius( pos, 2 ) ) { - here.add_field( dest, field_type_id( "fd_incendiary" ), 3 ); + here.add_field( dest, fd_incendiary, 3 ); } } @@ -3946,7 +3945,7 @@ int iuse::molotov_lit( player *p, item *it, bool t, const tripoint &pos ) map &here = get_map(); for( const tripoint &pt : here.points_in_radius( pos, 1, 0 ) ) { const int intensity = 1 + one_in( 3 ) + one_in( 5 ); - here.add_field( pt, field_type_id( "fd_fire" ), intensity ); + here.add_field( pt, fd_fire, intensity ); } return 1; } else if( it->charges > 0 ) { @@ -4788,7 +4787,7 @@ int iuse::call_of_tindalos( player *p, item *it, bool, const tripoint & ) map &here = get_map(); for( const tripoint &dest : here.points_in_radius( p->pos(), 12 ) ) { if( here.is_cornerfloor( dest ) ) { - here.add_field( dest, field_type_id( "fd_tindalos_rift" ), 3 ); + here.add_field( dest, fd_tindalos_rift, 3 ); add_msg( m_info, _( "You hear a low-pitched echoing howl." ) ); } } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 1e6530484f25d..19cf986c8ac37 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1176,7 +1176,7 @@ bool firestarter_actor::prep_firestarter_use( const player &p, tripoint &pos ) return false; } map &here = get_map(); - if( here.get_field( pos, field_type_id( "fd_fire" ) ) ) { + if( here.get_field( pos, fd_fire ) ) { // check if there's already a fire p.add_msg_if_player( m_info, _( "There is already a fire." ) ); return false; @@ -1211,7 +1211,7 @@ bool firestarter_actor::prep_firestarter_use( const player &p, tripoint &pos ) void firestarter_actor::resolve_firestarter_use( player &p, const tripoint &pos ) { - if( get_map().add_field( pos, field_type_id( "fd_fire" ), 1, 10_minutes ) ) { + if( get_map().add_field( pos, fd_fire, 1, 10_minutes ) ) { if( !p.has_trait( trait_PYROMANIA ) ) { p.add_msg_if_player( _( "You successfully light a fire." ) ); } else { diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 21b255934ac3f..45be9ce446399 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -432,7 +432,7 @@ static void damage_targets( const spell &sp, Creature &caster, sp.make_sound( target ); sp.create_field( target ); if( sp.has_flag( spell_flag::IGNITE_FLAMMABLE ) && here.is_flammable( target ) ) { - here.add_field( target, field_type_id( "fd_fire" ), 1, 10_minutes ); + here.add_field( target, fd_fire, 1, 10_minutes ); } Creature *const cr = g->critter_at( target ); if( !cr ) { @@ -712,9 +712,9 @@ static void spell_move( const spell &sp, const Creature &caster, } }; // Moving fields. - move_field( spell_target::fire, field_type_id( "fd_fire" ) ); - move_field( spell_target::blood, field_type_id( "fd_blood" ) ); - move_field( spell_target::blood, field_type_id( "fd_gibs_flesh" ) ); + move_field( spell_target::fire, fd_fire ); + move_field( spell_target::blood, fd_blood ); + move_field( spell_target::blood, fd_gibs_flesh ); } void spell_effect::area_pull( const spell &sp, Creature &caster, const tripoint ¢er ) diff --git a/src/map.cpp b/src/map.cpp index 4b3f807712b39..3530b7956d285 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2693,7 +2693,7 @@ bool map::is_flammable( const tripoint &p ) return true; } - if( get_field_intensity( p, field_type_id( "fd_web" ) ) > 0 ) { + if( get_field_intensity( p, fd_web ) > 0 ) { return true; } @@ -2797,7 +2797,7 @@ bool map::has_adjacent_furniture_with( const tripoint &p, bool map::has_nearby_fire( const tripoint &p, int radius ) { for( const tripoint &pt : points_in_radius( p, radius ) ) { - if( get_field( pt, field_type_id( "fd_fire" ) ) != nullptr ) { + if( get_field( pt, fd_fire ) != nullptr ) { return true; } if( has_flag_ter_or_furn( "USABLE_FIRE", p ) ) { @@ -3047,8 +3047,7 @@ void map::smash_items( const tripoint &p, const int power, const std::string &ca item_was_damaged = true; } } else { - const field_type_id type_blood = i->is_corpse() ? i->get_mtype()->bloodType() : - field_type_id( "fd_null" ); + const field_type_id type_blood = i->is_corpse() ? i->get_mtype()->bloodType() : fd_null; while( ( damage_chance > material_factor || x_in_y( damage_chance, material_factor ) ) && i->damage() < i->max_damage() ) { @@ -3783,7 +3782,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) ter_set( p, t_dirt ); } if( inc ) { - add_field( p, field_type_id( "fd_fire" ), 1 ); + add_field( p, fd_fire, 1 ); } } else if( terrain == t_gas_pump ) { if( hit_items || one_in( 3 ) ) { @@ -3844,7 +3843,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) for( const std::pair &fd : fields_copy ) { if( fd.first->bash_info.str_min > 0 ) { if( inc ) { - add_field( p, field_type_id( "fd_fire" ), fd.second.get_field_intensity() - 1 ); + add_field( p, fd_fire, fd.second.get_field_intensity() - 1 ); } else if( dam > 5 + fd.second.get_field_intensity() * 5 && one_in( 5 - fd.second.get_field_intensity() ) ) { dam -= rng( 1, 2 + fd.second.get_field_intensity() * 2 ); @@ -3929,7 +3928,7 @@ bool map::hit_with_fire( const tripoint &p ) // non passable but flammable terrain, set it on fire if( has_flag( "FLAMMABLE", p ) || has_flag( "FLAMMABLE_ASH", p ) ) { - add_field( p, field_type_id( "fd_fire" ), 3 ); + add_field( p, fd_fire, 3 ); } return true; } @@ -4466,7 +4465,7 @@ item &map::add_item( const tripoint &p, item new_item ) return null_item_reference(); } - if( new_item.has_flag( "ACT_IN_FIRE" ) && get_field( p, field_type_id( "fd_fire" ) ) != nullptr ) { + 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 diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 57caa51c37a46..4686da1775986 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -314,16 +314,16 @@ static bool mx_house_spider( map &m, const tripoint &loc ) for( int x = i - 1; x <= i + 1; x++ ) { for( int y = j - 1; y <= j + 1; y++ ) { if( m.ter( point( x, y ) ) == t_floor ) { - madd_field( &m, point( x, y ), field_type_id( "fd_web" ), rng( 2, 3 ) ); + madd_field( &m, point( x, y ), fd_web, rng( 2, 3 ) ); if( one_in( 4 ) ) { m.furn_set( point( i, j ), egg_type ); - m.remove_field( {i, j, m.get_abs_sub().z}, field_type_id( "fd_web" ) ); + m.remove_field( {i, j, m.get_abs_sub().z}, fd_web ); } } } } } else if( m.passable( point( i, j ) ) && one_in( 5 ) ) { - madd_field( &m, point( i, j ), field_type_id( "fd_web" ), 1 ); + madd_field( &m, point( i, j ), fd_web, 1 ); } } } @@ -519,7 +519,7 @@ static bool mx_military( map &m, const tripoint & ) int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { - m.add_field( *p + point( -j * 1, j * 1 ), field_type_id( "fd_blood" ), 1, 0_turns ); + m.add_field( *p + point( -j * 1, j * 1 ), fd_blood, 1, 0_turns ); } } else { m.add_spawn( mon_dispatch, 1, *p ); @@ -544,7 +544,7 @@ static bool mx_military( map &m, const tripoint & ) int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { - m.add_field( *p + point( -j * 1, j * 1 ), field_type_id( "fd_blood" ), 1, 0_turns ); + m.add_field( *p + point( -j * 1, j * 1 ), fd_blood, 1, 0_turns ); } } } @@ -743,7 +743,7 @@ static bool mx_roadblock( map &m, const tripoint &abs_sub ) int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { - m.add_field( *p + point( -j * 1, j * 1 ), field_type_id( "fd_blood" ), 1, 0_turns ); + m.add_field( *p + point( -j * 1, j * 1 ), fd_blood, 1, 0_turns ); } } } @@ -787,7 +787,7 @@ static bool mx_roadblock( map &m, const tripoint &abs_sub ) int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { - m.add_field( *p + point( j * 1, -j * 1 ), field_type_id( "fd_blood" ), 1, 0_turns ); + m.add_field( *p + point( j * 1, -j * 1 ), fd_blood, 1, 0_turns ); } } } @@ -942,8 +942,7 @@ static bool mx_drugdeal( map &m, const tripoint &abs_sub ) calendar::start_of_cataclysm ); int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { - m.add_field( p + tripoint( j * offset.x, j * offset.y, abs_sub.z ), field_type_id( "fd_blood" ), 1, - 0_turns ); + m.add_field( p + tripoint( j * offset.x, j * offset.y, abs_sub.z ), fd_blood, 1, 0_turns ); } } } @@ -975,8 +974,7 @@ static bool mx_drugdeal( map &m, const tripoint &abs_sub ) calendar::start_of_cataclysm ); int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { - m.add_field( p2 + tripoint( j * offset2.x, j * offset2.y, abs_sub.z ), field_type_id( "fd_blood" ), - 1, 0_turns ); + m.add_field( p2 + tripoint( j * offset2.x, j * offset2.y, abs_sub.z ), fd_blood, 1, 0_turns ); } if( !a_has_drugs && num_drugs > 0 ) { int drugs_placed = rng( 2, 6 ); @@ -1178,7 +1176,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //50% chance to spawn a dead soldier with a trail of blood if( one_in( 2 ) ) { - m.add_splatter_trail( field_type_id( "fd_blood" ), { 17, 6, abs_sub.z }, { 19, 3, abs_sub.z } ); + m.add_splatter_trail( fd_blood, { 17, 6, abs_sub.z }, { 19, 3, abs_sub.z } ); item body = item::make_corpse(); m.put_items_from_loc( "mon_zombie_soldier_death_drops", { 17, 5, abs_sub.z } ); m.add_item_or_charges( { 17, 5, abs_sub.z }, body ); @@ -1200,7 +1198,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //10% chance to spawn corpses of bloody people/zombies on every tile of barbed wire fence if( one_in( 10 ) ) { m.add_corpse( { i, abs_sub.z } ); - m.add_field( { i, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { i, abs_sub.z }, fd_blood, rng( 1, 3 ) ); } } @@ -1219,14 +1217,14 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) for( int i = 0; i < num_mines; i++ ) { const int x = rng( 3, SEEX * 2 - 4 ), y = rng( SEEY, SEEY * 2 - 2 ); if( m.tr_at( { x, y, abs_sub.z } ).is_null() ) { - m.add_field( { x, y, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { x, y, abs_sub.z }, fd_blood, rng( 1, 3 ) ); //10% chance to spawn a corpse of dead people/zombie on a tile with blood if( one_in( 10 ) ) { m.add_corpse( { x, y, abs_sub.z } ); for( const auto &loc : m.points_in_radius( { x, y, abs_sub.z }, 1 ) ) { //50% chance to spawn gibs in every tile around corpse in 1-tile radius if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); } } } @@ -1258,19 +1256,19 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //10% chance to spawn corpses of bloody people/zombies on every tile of barbed wire fence if( one_in( 10 ) ) { m.add_corpse( { i, abs_sub.z } ); - m.add_field( { i, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { i, abs_sub.z }, fd_blood, rng( 1, 3 ) ); } } //50% chance to spawn a blood trail of wounded soldier trying to escape, //but eventually died out of blood loss and wounds and got devoured by zombies if( one_in( 2 ) ) { - m.add_splatter_trail( field_type_id( "fd_blood" ), { 9, 15, abs_sub.z }, { 11, 18, abs_sub.z } ); - m.add_splatter_trail( field_type_id( "fd_blood" ), { 11, 18, abs_sub.z }, { 11, 21, abs_sub.z } ); + m.add_splatter_trail( fd_blood, { 9, 15, abs_sub.z }, { 11, 18, abs_sub.z } ); + m.add_splatter_trail( fd_blood, { 11, 18, abs_sub.z }, { 11, 21, abs_sub.z } ); for( const auto &loc : m.points_in_radius( { 11, 21, abs_sub.z }, 1 ) ) { //50% chance to spawn gibs in every tile around corpse in 1-tile radius if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); } } item body = item::make_corpse(); @@ -1321,14 +1319,14 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) for( int i = 0; i < num_mines; i++ ) { const int x = rng( 3, SEEX * 2 - 4 ), y = rng( 1, SEEY ); if( m.tr_at( { x, y, abs_sub.z } ).is_null() ) { - m.add_field( { x, y, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { x, y, abs_sub.z }, fd_blood, rng( 1, 3 ) ); //10% chance to spawn a corpse of dead people/zombie on a tile with blood if( one_in( 10 ) ) { m.add_corpse( { x, y, abs_sub.z } ); for( const auto &loc : m.points_in_radius( { x, y, abs_sub.z }, 1 ) ) { //50% chance to spawn gibs in every tile around corpse in 1-tile radius if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); } } } @@ -1373,9 +1371,9 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Blood and gore std::vector blood_track = line_to( point( 1, 6 ), point( 8, 6 ) ); for( auto &i : blood_track ) { - m.add_field( { i, abs_sub.z }, field_type_id( "fd_blood" ), 1 ); + m.add_field( { i, abs_sub.z }, fd_blood, 1 ); } - m.add_field( { 1, 6, abs_sub.z }, field_type_id( "fd_gibs_flesh" ), 1 ); + m.add_field( { 1, 6, abs_sub.z }, fd_gibs_flesh, 1 ); //Add the culprit m.add_vehicle( vproto_id( "car_fbi" ), point( 7, 7 ), 0, 70, 1 ); @@ -1449,7 +1447,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //10% chance to spawn corpses of bloody people/zombies on every tile of barbed wire fence if( one_in( 10 ) ) { m.add_corpse( { i, abs_sub.z } ); - m.add_field( { i, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { i, abs_sub.z }, fd_blood, rng( 1, 3 ) ); } } @@ -1468,14 +1466,14 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) for( int i = 0; i < num_mines; i++ ) { const int x = rng( SEEX + 1, SEEX * 2 - 2 ), y = rng( 3, SEEY * 2 - 4 ); if( m.tr_at( { x, y, abs_sub.z } ).is_null() ) { - m.add_field( { x, y, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { x, y, abs_sub.z }, fd_blood, rng( 1, 3 ) ); //10% chance to spawn a corpse of dead people/zombie on a tile with blood if( one_in( 10 ) ) { m.add_corpse( { x, y, abs_sub.z } ); for( const auto &loc : m.points_in_radius( { x, y, abs_sub.z }, 1 ) ) { //50% chance to spawn gibs in every tile around corpse in 1-tile radius if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); } } } @@ -1504,7 +1502,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //50% chance to spawn a soldier killed by gunfire, and a trail of blood if( one_in( 2 ) ) { - m.add_splatter_trail( field_type_id( "fd_blood" ), { 14, 5, abs_sub.z }, { 17, 5, abs_sub.z } ); + m.add_splatter_trail( fd_blood, { 14, 5, abs_sub.z }, { 17, 5, abs_sub.z } ); item body = item::make_corpse(); m.put_items_from_loc( "mon_zombie_soldier_death_drops", { 15, 5, abs_sub.z } ); m.add_item_or_charges( { 15, 5, abs_sub.z }, body ); @@ -1552,7 +1550,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) item body = item::make_corpse(); m.put_items_from_loc( "mon_zombie_soldier_death_drops", { 23, 12, abs_sub.z } ); m.add_item_or_charges( { 23, 12, abs_sub.z }, body ); - m.add_field( { 23, 12, abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { 23, 12, abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); //Spawn broken bench and splintered wood m.furn_set( { 23, 13, abs_sub.z }, f_null ); @@ -1561,7 +1559,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) //Spawn blood for( const auto &loc : m.points_in_radius( { 23, 12, abs_sub.z }, 1, 0 ) ) { if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_blood, rng( 1, 3 ) ); } } //Spawn trash in a crate and its surroundings @@ -1603,14 +1601,14 @@ static bool mx_minefield( map &, const tripoint &abs_sub ) for( int i = 0; i < num_mines; i++ ) { const int x = rng( 1, SEEX ), y = rng( 3, SEEY * 2 - 4 ); if( m.tr_at( { x, y, abs_sub.z } ).is_null() ) { - m.add_field( { x, y, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { x, y, abs_sub.z }, fd_blood, rng( 1, 3 ) ); //10% chance to spawn a corpse of dead people/zombie on a tile with blood if( one_in( 10 ) ) { m.add_corpse( { x, y, abs_sub.z } ); for( const auto &loc : m.points_in_radius( { x, y, abs_sub.z }, 1 ) ) { //50% chance to spawn gibs in every tile around corpse in 1-tile radius if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); } } } @@ -1685,7 +1683,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) switch( rng( 1, 7 ) ) { //Mycus spreading through the portal case 1: { - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); fungal_effects fe( *g, m ); for( const auto &loc : m.points_in_radius( portal_location, 5 ) ) { if( one_in( 3 ) ) { @@ -1698,7 +1696,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) } //Netherworld monsters spawning around the portal case 2: { - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); for( const auto &loc : m.points_in_radius( portal_location, 5 ) ) { m.place_spawns( GROUP_NETHER_PORTAL, 15, loc.xy() + point( -5, -5 ), loc.xy() + point( 5, 5 ), 1, true ); @@ -1707,7 +1705,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) } //Several cracks in the ground originating from the portal case 3: { - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); for( int i = 0; i < rng( 1, 10 ); i++ ) { tripoint end_location = { rng( 0, SEEX * 2 - 1 ), rng( 0, SEEY * 2 - 1 ), abs_sub.z }; std::vector failure = line_to( portal_location, end_location ); @@ -1719,7 +1717,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) } //Radiation from the portal killed the vegetation case 4: { - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); const int rad = 10; for( int i = p.x - rad; i <= p.x + rad; i++ ) { for( int j = p.y - rad; j <= p.y + rad; j++ ) { @@ -1760,7 +1758,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) } const tripoint portal_location = { p1 + tripoint( extra, abs_sub.z ) }; - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); std::set ignited; place_fumarole( m, p1, p2, ignited ); @@ -1772,7 +1770,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) if( m.ter( i ) != t_lava ) { // Spawn an intense but short-lived fire // Any furniture or buildings will catch fire, otherwise it will burn out quickly - m.add_field( tripoint( i, abs_sub.z ), field_type_id( "fd_fire" ), 15, 1_minutes ); + m.add_field( tripoint( i, abs_sub.z ), fd_fire, 15, 1_minutes ); } } } @@ -1780,7 +1778,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) } case 6: { //Mi-go went through the portal and began constructing their base of operations - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); for( const auto &loc : m.points_in_radius( portal_location, 5 ) ) { m.place_spawns( GROUP_MI_GO_CAMP_OM, 30, loc.xy() + point( -5, -5 ), loc.xy() + point( 5, 5 ), 1, true ); @@ -1792,7 +1790,7 @@ static bool mx_portal_in( map &m, const tripoint &abs_sub ) } //Anomaly caused by the portal and spawned an artifact case 7: { - m.add_field( portal_location, field_type_id( "fd_fatigue" ), 3 ); + m.add_field( portal_location, fd_fatigue, 3 ); artifact_natural_property prop = static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ); m.create_anomaly( portal_location, prop ); @@ -1833,14 +1831,14 @@ static bool mx_spider( map &m, const tripoint &abs_sub ) bool should_web_tree = m.has_flag_ter( flag_TREE, location ) && !one_in( 4 ); if( should_web_flat || should_web_shrub || should_web_tree ) { - m.add_field( location, field_type_id( "fd_web" ), rng( 1, 3 ), 0_turns ); + m.add_field( location, fd_web, rng( 1, 3 ), 0_turns ); } } } m.ter_set( point( 12, 12 ), t_dirt ); m.furn_set( point( 12, 12 ), f_egg_sackws ); - m.remove_field( { 12, 12, m.get_abs_sub().z }, field_type_id( "fd_web" ) ); + m.remove_field( { 12, 12, m.get_abs_sub().z }, fd_web ); m.add_spawn( mon_spider_web, rng( 1, 2 ), { SEEX, SEEY, abs_sub.z } ); return true; @@ -2614,7 +2612,7 @@ static bool mx_mayhem( map &m, const tripoint &abs_sub ) m.spawn_item( { 16, 10, abs_sub.z }, itype_shot_hull ); m.add_corpse( { 16, 9, abs_sub.z } ); - m.add_field( { 16, 9, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { 16, 9, abs_sub.z }, fd_blood, rng( 1, 3 ) ); for( const auto &loc : m.points_in_radius( { 16, 3, abs_sub.z }, 1 ) ) { if( one_in( 2 ) ) { @@ -2622,7 +2620,7 @@ static bool mx_mayhem( map &m, const tripoint &abs_sub ) } } - m.add_splatter_trail( field_type_id( "fd_blood" ), { 16, 3, abs_sub.z }, { 23, 1, abs_sub.z } ); + m.add_splatter_trail( fd_blood, { 16, 3, abs_sub.z }, { 23, 1, abs_sub.z } ); m.add_corpse( { 23, 1, abs_sub.z } ); break; } @@ -2634,7 +2632,7 @@ static bool mx_mayhem( map &m, const tripoint &abs_sub ) m.add_corpse( { 16, 11, abs_sub.z } ); m.add_corpse( { 16, 12, abs_sub.z } ); - m.add_splatter_trail( field_type_id( "fd_blood" ), { 16, 8, abs_sub.z }, { 16, 12, abs_sub.z } ); + m.add_splatter_trail( fd_blood, { 16, 8, abs_sub.z }, { 16, 12, abs_sub.z } ); for( const auto &loc : m.points_in_radius( { 12, 11, abs_sub.z }, 2 ) ) { if( one_in( 3 ) ) { @@ -2647,7 +2645,7 @@ static bool mx_mayhem( map &m, const tripoint &abs_sub ) case 3: { m.add_vehicle( vproto_id( "car" ), point( 18, 12 ), 270 ); - m.add_field( { 16, 15, abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { 16, 15, abs_sub.z }, fd_blood, rng( 1, 3 ) ); m.spawn_item( { 16, 16, abs_sub.z }, itype_wheel, 1, 0, calendar::start_of_cataclysm, 4 ); m.spawn_item( { 16, 16, abs_sub.z }, itype_wrench ); @@ -2657,8 +2655,8 @@ static bool mx_mayhem( map &m, const tripoint &abs_sub ) m.spawn_item( { 21, 15, abs_sub.z }, itype_shot_hull ); } else { //Wolves charged to the poor guy... m.add_corpse( { 16, 15, abs_sub.z } ); - m.add_splatter_trail( field_type_id( "fd_gibs_flesh" ), { 16, 13, abs_sub.z }, { 16, 16, abs_sub.z } ); - m.add_field( { 15, 15, abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_splatter_trail( fd_gibs_flesh, { 16, 13, abs_sub.z }, { 16, 16, abs_sub.z } ); + m.add_field( { 15, 15, abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); for( const auto &loc : m.points_in_radius( { 16, 15, abs_sub.z }, 1 ) ) { if( one_in( 2 ) ) { @@ -2673,14 +2671,14 @@ static bool mx_mayhem( map &m, const tripoint &abs_sub ) const auto &loc = m.points_in_radius( { 12, 12, abs_sub.z }, 3 ); const tripoint where = random_entry( loc ); m.add_item_or_charges( where, body ); - m.add_field( where, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( where, fd_blood, rng( 1, 3 ) ); } } else { //...from the south for( int i = 0; i < max_wolves; i++ ) { const auto &loc = m.points_in_radius( { 12, 18, abs_sub.z }, 3 ); const tripoint where = random_entry( loc ); m.add_item_or_charges( where, body ); - m.add_field( where, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( where, fd_blood, rng( 1, 3 ) ); } } } @@ -2713,13 +2711,13 @@ static bool mx_casings( map &m, const tripoint &abs_sub ) } //Spawn blood and bloody rag and sometimes trail of blood if( one_in( 2 ) ) { - m.add_field( location, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( location, fd_blood, rng( 1, 3 ) ); if( one_in( 2 ) ) { const tripoint bloody_rag_loc = random_entry( m.points_in_radius( location, 3 ) ); m.spawn_item( bloody_rag_loc, itype_rag_bloody ); } if( one_in( 2 ) ) { - m.add_splatter_trail( field_type_id( "fd_blood" ), location, + m.add_splatter_trail( fd_blood, location, random_entry( m.points_in_radius( location, rng( 1, 4 ) ) ) ); } } @@ -2746,7 +2744,7 @@ static bool mx_casings( map &m, const tripoint &abs_sub ) //Spawn blood and bloody rag in random place if( one_in( 2 ) ) { const tripoint random_place = random_entry( m.points_in_radius( location, rng( 1, 10 ) ) ); - m.add_field( random_place, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( random_place, fd_blood, rng( 1, 3 ) ); if( one_in( 2 ) ) { const tripoint bloody_rag_loc = random_entry( m.points_in_radius( random_place, 3 ) ); m.spawn_item( bloody_rag_loc, itype_rag_bloody ); @@ -2764,7 +2762,7 @@ static bool mx_casings( map &m, const tripoint &abs_sub ) if( one_in( 2 ) ) { m.spawn_items( { i.xy(), abs_sub.z }, items ); if( one_in( 2 ) ) { - m.add_field( { i.xy(), abs_sub.z }, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( { i.xy(), abs_sub.z }, fd_blood, rng( 1, 3 ) ); } } } @@ -2776,7 +2774,7 @@ static bool mx_casings( map &m, const tripoint &abs_sub ) } //Spawn blood and bloody rag at the destination if( one_in( 2 ) ) { - m.add_field( from, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( from, fd_blood, rng( 1, 3 ) ); if( one_in( 2 ) ) { const tripoint bloody_rag_loc = random_entry( m.points_in_radius( to, 3 ) ); m.spawn_item( bloody_rag_loc, itype_rag_bloody ); @@ -2809,25 +2807,25 @@ static bool mx_casings( map &m, const tripoint &abs_sub ) } //Spawn blood and bloody rag at the first location, sometimes trail of blood if( one_in( 2 ) ) { - m.add_field( first_loc, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( first_loc, fd_blood, rng( 1, 3 ) ); if( one_in( 2 ) ) { const tripoint bloody_rag_loc = random_entry( m.points_in_radius( first_loc, 3 ) ); m.spawn_item( bloody_rag_loc, itype_rag_bloody ); } if( one_in( 2 ) ) { - m.add_splatter_trail( field_type_id( "fd_blood" ), first_loc, + m.add_splatter_trail( fd_blood, first_loc, random_entry( m.points_in_radius( first_loc, rng( 1, 4 ) ) ) ); } } //Spawn blood and bloody rag at the second location, sometimes trail of blood if( one_in( 2 ) ) { - m.add_field( second_loc, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( second_loc, fd_blood, rng( 1, 3 ) ); if( one_in( 2 ) ) { const tripoint bloody_rag_loc = random_entry( m.points_in_radius( second_loc, 3 ) ); m.spawn_item( bloody_rag_loc, itype_rag_bloody ); } if( one_in( 2 ) ) { - m.add_splatter_trail( field_type_id( "fd_blood" ), second_loc, + m.add_splatter_trail( fd_blood, second_loc, random_entry( m.points_in_radius( second_loc, rng( 1, 4 ) ) ) ); } } @@ -2845,8 +2843,7 @@ static bool mx_looters( map &m, const tripoint &abs_sub ) if( one_in( 4 ) && m.passable( center ) ) { m.add_corpse( center ); for( int i = 0; i < rng( 1, 3 ); i++ ) { - m.add_field( random_entry( m.points_in_radius( center, 1 ) ), field_type_id( "fd_blood" ), rng( 1, - 3 ) ); + m.add_field( random_entry( m.points_in_radius( center, 1 ) ), fd_blood, rng( 1, 3 ) ); } } @@ -2871,12 +2868,12 @@ static bool mx_corpses( map &m, const tripoint &abs_sub ) for( int i = 0; i < num_corpses; i++ ) { const tripoint corpse_location = { rng( 1, SEEX * 2 - 1 ), rng( 1, SEEY * 2 - 1 ), abs_sub.z }; if( m.passable( corpse_location ) ) { - m.add_field( corpse_location, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( corpse_location, fd_blood, rng( 1, 3 ) ); m.put_items_from_loc( "everyday_corpse", corpse_location ); //50% chance to spawn blood in every tile around every corpse in 1-tile radius for( const auto &loc : m.points_in_radius( corpse_location, 1 ) ) { if( one_in( 2 ) ) { - m.add_field( loc, field_type_id( "fd_blood" ), rng( 1, 3 ) ); + m.add_field( loc, fd_blood, rng( 1, 3 ) ); } } } @@ -2887,11 +2884,11 @@ static bool mx_corpses( map &m, const tripoint &abs_sub ) const std::vector gibs = item_group::items_from( "remains_human_generic", calendar::start_of_cataclysm ); m.spawn_items( corpse_location, gibs ); - m.add_field( corpse_location, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( corpse_location, fd_gibs_flesh, rng( 1, 3 ) ); //50% chance to spawn gibs and dogs in every tile around what's left of human corpse in 1-tile radius for( const auto &loc : m.points_in_radius( corpse_location, 1 ) ) { if( one_in( 2 ) ) { - m.add_field( { loc.xy(), abs_sub.z }, field_type_id( "fd_gibs_flesh" ), rng( 1, 3 ) ); + m.add_field( { loc.xy(), abs_sub.z }, fd_gibs_flesh, rng( 1, 3 ) ); m.place_spawns( GROUP_STRAY_DOGS, 1, loc.xy(), loc.xy(), 1, true ); } } diff --git a/src/map_field.cpp b/src/map_field.cpp index 2de23213fb9e9..2ef037ed1a660 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -361,16 +361,16 @@ void map::create_hot_air( const tripoint &p, int intensity ) field_type_id hot_air; switch( intensity ) { case 1: - hot_air = field_type_id( "fd_hot_air1" ); + hot_air = fd_hot_air1; break; case 2: - hot_air = field_type_id( "fd_hot_air2" ); + hot_air = fd_hot_air2; break; case 3: - hot_air = field_type_id( "fd_hot_air3" ); + hot_air = fd_hot_air3; break; case 4: - hot_air = field_type_id( "fd_hot_air4" ); + hot_air = fd_hot_air4; break; default: debugmsg( "Tried to spread hot air with intensity %d", intensity ); @@ -392,20 +392,20 @@ If you need to insert a new field behavior per unit time add a case statement in void map::process_fields_in_submap( submap *const current_submap, const tripoint &submap ) { - // create all ids once before the loop - const field_type_id fd_acid( "fd_acid" ); - const field_type_id fd_extinguisher( "fd_extinguisher" ); - const field_type_id fd_fire( "fd_fire" ); - const field_type_id fd_fungal_haze( "fd_fungal_haze" ); - const field_type_id fd_fire_vent( "fd_fire_vent" ); - const field_type_id fd_flame_burst( "fd_flame_burst" ); - const field_type_id fd_electricity( "fd_electricity" ); - const field_type_id fd_push_items( "fd_push_items" ); - const field_type_id fd_shock_vent( "fd_shock_vent" ); - const field_type_id fd_acid_vent( "fd_acid_vent" ); - const field_type_id fd_bees( "fd_bees" ); - const field_type_id fd_incendiary( "fd_incendiary" ); - const field_type_id fd_fungicidal_gas( "fd_fungicidal_gas" ); + // convert all ids once before the loop + const field_type_id fd_acid = ::fd_acid; + const field_type_id fd_extinguisher = ::fd_extinguisher; + const field_type_id fd_fire = ::fd_fire; + const field_type_id fd_fungal_haze = ::fd_fungal_haze; + const field_type_id fd_fire_vent = ::fd_fire_vent; + const field_type_id fd_flame_burst = ::fd_flame_burst; + const field_type_id fd_electricity = ::fd_electricity; + const field_type_id fd_push_items = ::fd_push_items; + const field_type_id fd_shock_vent = ::fd_shock_vent; + const field_type_id fd_acid_vent = ::fd_acid_vent; + const field_type_id fd_bees = ::fd_bees; + const field_type_id fd_incendiary = ::fd_incendiary; + const field_type_id fd_fungicidal_gas = ::fd_fungicidal_gas; scent_block sblk( submap, get_scent() ); @@ -742,7 +742,7 @@ void map::process_fields_in_submap( submap *const current_submap, for( int n = 0; n < dist; n++ ) { boltx += xdir; bolty += ydir; - add_field( tripoint( boltx, bolty, p.z ), field_type_id( "fd_electricity" ), rng( 2, 3 ) ); + add_field( tripoint( boltx, bolty, p.z ), fd_electricity, rng( 2, 3 ) ); if( one_in( 4 ) ) { if( xdir == 0 ) { xdir = rng( 0, 1 ) * 2 - 1; @@ -787,26 +787,26 @@ void map::process_fields_in_submap( submap *const current_submap, if( cur_fd_type_id == fd_bees ) { // Poor bees are vulnerable to so many other fields. // TODO: maybe adjust effects based on different fields. - if( curfield.find_field( field_type_id( "fd_web" ) ) || - curfield.find_field( field_type_id( "fd_fire" ) ) || - curfield.find_field( field_type_id( "fd_smoke" ) ) || - curfield.find_field( field_type_id( "fd_toxic_gas" ) ) || - curfield.find_field( field_type_id( "fd_tear_gas" ) ) || - curfield.find_field( field_type_id( "fd_relax_gas" ) ) || - curfield.find_field( field_type_id( "fd_nuke_gas" ) ) || - curfield.find_field( field_type_id( "fd_gas_vent" ) ) || - curfield.find_field( field_type_id( "fd_smoke_vent" ) ) || - curfield.find_field( field_type_id( "fd_fungicidal_gas" ) ) || - curfield.find_field( field_type_id( "fd_insecticidal_gas" ) ) || - curfield.find_field( field_type_id( "fd_fire_vent" ) ) || - curfield.find_field( field_type_id( "fd_flame_burst" ) ) || - curfield.find_field( field_type_id( "fd_electricity" ) ) || - curfield.find_field( field_type_id( "fd_fatigue" ) ) || - curfield.find_field( field_type_id( "fd_shock_vent" ) ) || - curfield.find_field( field_type_id( "fd_plasma" ) ) || - curfield.find_field( field_type_id( "fd_laser" ) ) || - curfield.find_field( field_type_id( "fd_dazzling" ) ) || - curfield.find_field( field_type_id( "fd_incendiary" ) ) ) { + if( curfield.find_field( fd_web ) || + curfield.find_field( fd_fire ) || + curfield.find_field( fd_smoke ) || + curfield.find_field( fd_toxic_gas ) || + curfield.find_field( fd_tear_gas ) || + curfield.find_field( fd_relax_gas ) || + curfield.find_field( fd_nuke_gas ) || + curfield.find_field( fd_gas_vent ) || + curfield.find_field( fd_smoke_vent ) || + curfield.find_field( fd_fungicidal_gas ) || + curfield.find_field( fd_insecticidal_gas ) || + curfield.find_field( fd_fire_vent ) || + curfield.find_field( fd_flame_burst ) || + curfield.find_field( fd_electricity ) || + curfield.find_field( fd_fatigue ) || + curfield.find_field( fd_shock_vent ) || + curfield.find_field( fd_plasma ) || + curfield.find_field( fd_laser ) || + curfield.find_field( fd_dazzling ) || + curfield.find_field( fd_incendiary ) ) { // Kill them at the end of processing. cur.set_field_intensity( 0 ); } else { @@ -823,8 +823,8 @@ void map::process_fields_in_submap( submap *const current_submap, // TODO: Figure out a way to merge bee fields without allowing // Them to effectively move several times in a turn depending // on iteration direction. - if( !target_field.find_field( field_type_id( "fd_bees" ) ) ) { - add_field( tripoint( candidate_position, p.z ), field_type_id( "fd_bees" ), + if( !target_field.find_field( fd_bees ) ) { + add_field( tripoint( candidate_position, p.z ), fd_bees, cur.get_field_intensity(), cur.get_field_age() ); cur.set_field_intensity( 0 ); break; @@ -1067,7 +1067,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi tripoint dst{ p.xy(), p.z - 1 }; if( valid_move( p, dst, true, true ) ) { maptile dst_tile = maptile_at_internal( dst ); - field_entry *fire_there = dst_tile.find_field( field_type_id( "fd_fire" ) ); + field_entry *fire_there = dst_tile.find_field( fd_fire ); if( fire_there == nullptr ) { add_field( dst, fd_fire, 1, 0_turns, false ); cur.set_field_intensity( cur.get_field_intensity() - 1 ); @@ -1144,7 +1144,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi count != neighs.size() && cur.get_field_age() < 0_turns; i = ( i + 1 ) % neighs.size(), count++ ) { maptile &dst = neighs[i].second; - field_entry *dstfld = dst.find_field( field_type_id( "fd_fire" ) ); + field_entry *dstfld = dst.find_field( fd_fire ); // If the fire exists and is weaker than ours, boost it if( dstfld != nullptr && ( dstfld->get_field_intensity() <= cur.get_field_intensity() || @@ -1167,7 +1167,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi count != neighbour_vec.size() && cur.get_field_age() < 0_turns; i = ( i + 1 ) % neighbour_vec.size(), count++ ) { maptile &dst = neighs[neighbour_vec[i]].second; - field_entry *dstfld = dst.find_field( field_type_id( "fd_fire" ) ); + field_entry *dstfld = dst.find_field( fd_fire ); // If the fire exists and is weaker than ours, boost it if( dstfld != nullptr && ( dstfld->get_field_intensity() <= cur.get_field_intensity() || @@ -1269,7 +1269,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi continue; } - field_entry *nearwebfld = dst.find_field( field_type_id( "fd_web" ) ); + field_entry *nearwebfld = dst.find_field( fd_web ); int spread_chance = 25 * ( cur.get_field_intensity() - 1 ); if( nearwebfld != nullptr ) { spread_chance = 50 + spread_chance / 2; @@ -1332,7 +1332,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi continue; } - field_entry *nearwebfld = dst.find_field( field_type_id( "fd_web" ) ); + field_entry *nearwebfld = dst.find_field( fd_web ); int spread_chance = 25 * ( cur.get_field_intensity() - 1 ); if( nearwebfld != nullptr ) { spread_chance = 50 + spread_chance / 2; @@ -1377,7 +1377,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi if( smoke_up ) { tripoint up{p.xy(), p.z + 1}; if( has_flag_ter( TFLAG_NO_FLOOR, up ) ) { - add_field( up, field_type_id( "fd_smoke" ), rng( 1, cur.get_field_intensity() ), 0_turns, false ); + add_field( up, fd_smoke, rng( 1, cur.get_field_intensity() ), 0_turns, false ); } else { // Can't create smoke above smoke_up = false; @@ -1386,7 +1386,7 @@ bool map::process_fire_field_in_submap( maptile &map_tile, const tripoint &p, fi if( !smoke_up ) { // Create thicker smoke - add_field( p, field_type_id( "fd_smoke" ), cur.get_field_intensity(), 0_turns, false ); + add_field( p, fd_smoke, cur.get_field_intensity(), 0_turns, false ); } } @@ -1433,7 +1433,7 @@ void map::player_in_field( player &u ) // Do things based on what field effect we are currently in. const field_type_id ft = cur.get_field_type(); - if( ft == field_type_id( "fd_acid" ) ) { + if( ft == fd_acid ) { // Assume vehicles block acid damage entirely, // you're certainly not standing in it. if( !u.in_vehicle && !u.has_trait( trait_ACIDPROOF ) ) { @@ -1471,14 +1471,14 @@ void map::player_in_field( player &u ) u.check_dead_state(); } } - if( ft == field_type_id( "fd_sap" ) ) { + if( ft == fd_sap ) { // Sap does nothing to cars. if( !u.in_vehicle ) { // Use up sap. cur.set_field_intensity( cur.get_field_intensity() - 1 ); } } - if( ft == field_type_id( "fd_sludge" ) ) { + if( ft == fd_sludge ) { // Sludge is on the ground, but you are above the ground when boarded on a vehicle if( !u.in_vehicle ) { u.add_msg_if_player( m_bad, _( "The sludge is thick and sticky. You struggle to pull free." ) ); @@ -1486,7 +1486,7 @@ void map::player_in_field( player &u ) cur.set_field_intensity( 0 ); } } - if( ft == field_type_id( "fd_fire" ) ) { + if( ft == fd_fire ) { // Heatsink or suit prevents ALL fire damage. if( !u.has_active_bionic( bio_heatsink ) && !u.is_wearing( itype_rm13_armor_on ) ) { @@ -1569,7 +1569,7 @@ void map::player_in_field( player &u ) } } - if( ft == field_type_id( "fd_tear_gas" ) ) { + if( ft == fd_tear_gas ) { // Tear gas will both give you teargas disease and/or blind you. if( ( cur.get_field_intensity() > 1 || !one_in( 3 ) ) && ( !inside || one_in( 3 ) ) ) { u.add_env_effect( effect_teargas, bodypart_id( "mouth" ), 5, 20_seconds ); @@ -1578,7 +1578,7 @@ void map::player_in_field( player &u ) u.add_env_effect( effect_blind, bodypart_id( "eyes" ), cur.get_field_intensity() * 2, 10_seconds ); } } - if( ft == field_type_id( "fd_fungal_haze" ) ) { + if( ft == fd_fungal_haze ) { if( !u.has_trait( trait_M_IMMUNE ) && ( !inside || one_in( 4 ) ) ) { u.add_env_effect( effect_fungus, bodypart_id( "mouth" ), 4, 10_minutes, true ); u.add_env_effect( effect_fungus, bodypart_id( "eyes" ), 4, 10_minutes, true ); @@ -1596,7 +1596,7 @@ void map::player_in_field( player &u ) u.hurtall( rng( cur.radiation_hurt_damage_min(), cur.radiation_hurt_damage_max() ), nullptr ); } } - if( ft == field_type_id( "fd_flame_burst" ) ) { + if( ft == fd_flame_burst ) { // A burst of flame? Only hits the legs and torso. if( !inside ) { // Fireballs can't touch you inside a car. @@ -1615,7 +1615,7 @@ void map::player_in_field( player &u ) } } } - if( ft == field_type_id( "fd_electricity" ) ) { + if( ft == fd_electricity ) { // Small universal damage based on intensity, only if not electroproofed. if( !u.is_elec_immune() ) { int total_damage = 0; @@ -1640,7 +1640,7 @@ void map::player_in_field( player &u ) } } } - if( ft == field_type_id( "fd_fatigue" ) ) { + if( ft == fd_fatigue ) { // Assume the rift is on the ground for now to prevent issues with the player being unable access vehicle controls on the same tile due to teleportation. if( !u.in_vehicle ) { // Teleports you... somewhere. @@ -1653,10 +1653,10 @@ void map::player_in_field( player &u ) } // Why do these get removed??? // Stepping on a shock vent shuts it down. - if( ft == field_type_id( "fd_shock_vent" ) || ft == field_type_id( "fd_acid_vent" ) ) { + if( ft == fd_shock_vent || ft == fd_acid_vent ) { cur.set_field_intensity( 0 ); } - if( ft == field_type_id( "fd_bees" ) ) { + if( ft == fd_bees ) { // Player is immune to bees while underwater. if( !u.is_underwater() ) { const int intensity = cur.get_field_intensity(); @@ -1679,7 +1679,7 @@ void map::player_in_field( player &u ) } } } - if( ft == field_type_id( "fd_incendiary" ) ) { + if( ft == fd_incendiary ) { // Mysterious incendiary substance melts you horribly. if( u.has_trait( trait_M_SKIN2 ) || u.has_trait( trait_M_SKIN3 ) || @@ -1695,7 +1695,7 @@ void map::player_in_field( player &u ) } } // Both gases are unhealthy and become deadly if you cross a related threshold. - if( ft == field_type_id( "fd_fungicidal_gas" ) || ft == field_type_id( "fd_insecticidal_gas" ) ) { + if( ft == fd_fungicidal_gas || ft == fd_insecticidal_gas ) { // The gas won't harm you inside a vehicle. if( !inside ) { // Full body suits protect you from the effects of the gas. @@ -1704,7 +1704,7 @@ void map::player_in_field( player &u ) const int intensity = cur.get_field_intensity(); bool inhaled = u.add_env_effect( effect_poison, bodypart_id( "mouth" ), 5, intensity * 1_minutes ); if( u.has_trait( trait_THRESH_MYCUS ) || u.has_trait( trait_THRESH_MARLOSS ) || - ( ft == field_type_id( "fd_insecticidal_gas" ) && + ( ft == fd_insecticidal_gas && ( u.get_highest_category() == mutation_category_id( "INSECT" ) || u.get_highest_category() == mutation_category_id( "SPIDER" ) ) ) ) { inhaled |= u.add_env_effect( effect_badpoison, bodypart_id( "mouth" ), 5, intensity * 1_minutes ); @@ -1815,13 +1815,13 @@ void map::monster_in_field( monster &z ) continue; } const field_type_id cur_field_type = cur.get_field_type(); - if( cur_field_type == field_type_id( "fd_web" ) ) { + if( cur_field_type == fd_web ) { if( !z.has_flag( MF_WEBWALK ) ) { z.add_effect( effect_webbed, 1_turns, true, cur.get_field_intensity() ); cur.set_field_intensity( 0 ); } } - if( cur_field_type == field_type_id( "fd_acid" ) ) { + if( cur_field_type == fd_acid ) { if( !z.flies() ) { const int d = rng( cur.get_field_intensity(), cur.get_field_intensity() * 3 ); z.deal_damage( nullptr, bodypart_id( "torso" ), damage_instance( damage_type::ACID, d ) ); @@ -1829,18 +1829,18 @@ void map::monster_in_field( monster &z ) } } - if( cur_field_type == field_type_id( "fd_sap" ) ) { + if( cur_field_type == fd_sap ) { z.moves -= cur.get_field_intensity() * 5; cur.set_field_intensity( cur.get_field_intensity() - 1 ); } - if( cur_field_type == field_type_id( "fd_sludge" ) ) { + if( cur_field_type == fd_sludge ) { if( !z.digs() && !z.flies() && !z.has_flag( MF_SLUDGEPROOF ) ) { z.moves -= cur.get_field_intensity() * 300; cur.set_field_intensity( 0 ); } } - if( cur_field_type == field_type_id( "fd_fire" ) ) { + if( cur_field_type == fd_fire ) { // TODO: MATERIALS Use fire resistance if( z.has_flag( MF_FIREPROOF ) || z.has_flag( MF_FIREY ) ) { return; @@ -1883,7 +1883,7 @@ void map::monster_in_field( monster &z ) } } } - if( cur_field_type == field_type_id( "fd_smoke" ) ) { + if( cur_field_type == fd_smoke ) { if( !z.has_flag( MF_NO_BREATHE ) ) { if( cur.get_field_intensity() == 3 ) { z.moves -= rng( 10, 20 ); @@ -1895,7 +1895,7 @@ void map::monster_in_field( monster &z ) } } - if( cur_field_type == field_type_id( "fd_tear_gas" ) ) { + if( cur_field_type == fd_tear_gas ) { if( z.made_of_any( Creature::cmat_fleshnveg ) && !z.has_flag( MF_NO_BREATHE ) ) { if( cur.get_field_intensity() == 3 ) { z.add_effect( effect_stunned, rng( 1_minutes, 2_minutes ) ); @@ -1916,27 +1916,27 @@ void map::monster_in_field( monster &z ) } } - if( cur_field_type == field_type_id( "fd_relax_gas" ) ) { + if( cur_field_type == fd_relax_gas ) { if( z.made_of_any( Creature::cmat_fleshnveg ) && !z.has_flag( MF_NO_BREATHE ) ) { z.add_effect( effect_stunned, rng( cur.get_field_intensity() * 4_turns, cur.get_field_intensity() * 8_turns ) ); } } - if( cur_field_type == field_type_id( "fd_dazzling" ) ) { + if( cur_field_type == fd_dazzling ) { if( z.has_flag( MF_SEES ) && !z.has_flag( MF_ELECTRONIC ) ) { z.add_effect( effect_blind, cur.get_field_intensity() * 12_turns ); z.add_effect( effect_stunned, cur.get_field_intensity() * rng( 5_turns, 12_turns ) ); } } - if( cur_field_type == field_type_id( "fd_toxic_gas" ) ) { + if( cur_field_type == fd_toxic_gas ) { if( !z.has_flag( MF_NO_BREATHE ) ) { dam += cur.get_field_intensity(); z.moves -= cur.get_field_intensity(); } } - if( cur_field_type == field_type_id( "fd_nuke_gas" ) ) { + if( cur_field_type == fd_nuke_gas ) { if( !z.has_flag( MF_NO_BREATHE ) ) { if( cur.get_field_intensity() == 3 ) { z.moves -= rng( 60, 120 ); @@ -1955,7 +1955,7 @@ void map::monster_in_field( monster &z ) } } - if( cur_field_type == field_type_id( "fd_flame_burst" ) ) { + if( cur_field_type == fd_flame_burst ) { // TODO: MATERIALS Use fire resistance if( z.has_flag( MF_FIREPROOF ) || z.has_flag( MF_FIREY ) ) { return; @@ -1975,18 +1975,18 @@ void map::monster_in_field( monster &z ) dam += rng( 0, 8 ); z.moves -= 20; } - if( cur_field_type == field_type_id( "fd_electricity" ) ) { + if( cur_field_type == fd_electricity ) { // We don't want to increase dam, but deal a separate hit so that it can apply effects z.deal_damage( nullptr, bodypart_id( "torso" ), damage_instance( damage_type::ELECTRIC, rng( 1, cur.get_field_intensity() * 3 ) ) ); } - if( cur_field_type == field_type_id( "fd_fatigue" ) ) { + if( cur_field_type == fd_fatigue ) { if( rng( 0, 2 ) < cur.get_field_intensity() ) { dam += cur.get_field_intensity(); teleport::teleport( z ); } } - if( cur_field_type == field_type_id( "fd_incendiary" ) ) { + if( cur_field_type == fd_incendiary ) { // TODO: MATERIALS Use fire resistance if( z.has_flag( MF_FIREPROOF ) || z.has_flag( MF_FIREY ) ) { return; @@ -2020,7 +2020,7 @@ void map::monster_in_field( monster &z ) } } } - if( cur_field_type == field_type_id( "fd_fungal_haze" ) ) { + if( cur_field_type == fd_fungal_haze ) { if( !z.type->in_species( species_FUNGUS ) && !z.type->has_flag( MF_NO_BREATHE ) && !z.make_fungus() ) { @@ -2030,14 +2030,14 @@ void map::monster_in_field( monster &z ) dam += rng( 0, 10 * intensity ); } } - if( cur_field_type == field_type_id( "fd_fungicidal_gas" ) ) { + if( cur_field_type == fd_fungicidal_gas ) { if( z.type->in_species( 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 == field_type_id( "fd_insecticidal_gas" ) ) { + if( cur_field_type == fd_insecticidal_gas ) { if( z.type->in_species( species_INSECT ) || z.type->in_species( species_SPIDER ) ) { const int intensity = cur.get_field_intensity(); z.moves -= rng( 10 * intensity, 30 * intensity ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 2da0224f174b5..71887880c35d2 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -4044,9 +4044,9 @@ void map::draw_lab( mapgendata &dat ) if( one_in( 200 ) && ( t_thconc_floor == ter( point( i, j ) ) || t_strconc_floor == ter( point( i, j ) ) ) ) { if( is_toxic ) { - add_field( {i, j, abs_sub.z}, field_type_id( "fd_gas_vent" ), 1 ); + add_field( {i, j, abs_sub.z}, fd_gas_vent, 1 ); } else { - add_field( {i, j, abs_sub.z}, field_type_id( "fd_smoke_vent" ), 2 ); + add_field( {i, j, abs_sub.z}, fd_smoke_vent, 2 ); } } } @@ -4501,8 +4501,8 @@ void map::draw_temple( const mapgendata &dat ) square( this, t_rock, point_zero, point( SEEX - 1, SOUTH_EDGE ) ); square( this, t_rock, point( SEEX + 2, 0 ), point( EAST_EDGE, SOUTH_EDGE ) ); for( int i = 2; i < SEEY * 2 - 4; i++ ) { - add_field( {SEEX, i, abs_sub.z}, field_type_id( "fd_fire_vent" ), rng( 1, 3 ) ); - add_field( {SEEX + 1, i, abs_sub.z}, field_type_id( "fd_fire_vent" ), rng( 1, 3 ) ); + add_field( {SEEX, i, abs_sub.z}, fd_fire_vent, rng( 1, 3 ) ); + add_field( {SEEX + 1, i, abs_sub.z}, fd_fire_vent, rng( 1, 3 ) ); } break; @@ -4832,7 +4832,7 @@ void map::draw_mine( mapgendata &dat ) int cx = rng( 9, 14 ); int cy = rng( 9, 14 ); ter_set( point( cx, cy ), t_rock ); - add_field( {cx, cy, abs_sub.z}, field_type_id( "fd_gas_vent" ), 2 ); + add_field( {cx, cy, abs_sub.z}, fd_gas_vent, 2 ); } break; @@ -5249,7 +5249,7 @@ void map::draw_spider_pit( const mapgendata &dat ) one_in( 4 ) ) { ter_set( point( i, j ), t_rock_floor ); if( !one_in( 3 ) ) { - add_field( {i, j, abs_sub.z}, field_type_id( "fd_web" ), rng( 1, 3 ) ); + add_field( {i, j, abs_sub.z}, fd_web, rng( 1, 3 ) ); } } else { ter_set( point( i, j ), t_rock ); @@ -5352,7 +5352,7 @@ void map::draw_triffid( const mapgendata &dat ) } else { for( int webx = node2.x; webx <= node2.x + 3; webx++ ) { for( int weby = node2.y; weby <= node2.y + 3; weby++ ) { - add_field( {webx, weby, abs_sub.z}, field_type_id( "fd_web" ), rng( 1, 3 ) ); + add_field( {webx, weby, abs_sub.z}, fd_web, rng( 1, 3 ) ); } } place_spawns( GROUP_SPIDER, 1, spawn, spawn, 1, true ); @@ -6790,7 +6790,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo for( int i = c.x - 5; i <= c.x + 5; i++ ) { for( int j = c.y - 5; j <= c.y + 5; j++ ) { if( furn( point( i, j ) ) == f_rubble ) { - add_field( {i, j, abs_sub.z}, field_type_id( "fd_push_items" ), 1 ); + add_field( {i, j, abs_sub.z}, fd_push_items, 1 ); if( one_in( 3 ) ) { spawn_item( point( i, j ), "rock" ); } @@ -6867,19 +6867,18 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_ELECTRIC: case ARTPROP_CRACKLING: - add_field( {c, abs_sub.z}, field_type_id( "fd_shock_vent" ), 3 ); + add_field( {c, abs_sub.z}, fd_shock_vent, 3 ); break; case ARTPROP_SLIMY: - add_field( {c, abs_sub.z}, field_type_id( "fd_acid_vent" ), 3 ); + add_field( {c, abs_sub.z}, fd_acid_vent, 3 ); break; case ARTPROP_WARM: for( int i = c.x - 5; i <= c.x + 5; i++ ) { for( int j = c.y - 5; j <= c.y + 5; j++ ) { if( furn( point( i, j ) ) == f_rubble ) { - add_field( {i, j, abs_sub.z}, field_type_id( "fd_fire_vent" ), 1 + ( rl_dist( c, point( i, - j ) ) % 3 ) ); + add_field( {i, j, abs_sub.z}, fd_fire_vent, 1 + ( rl_dist( c, point( i, j ) ) % 3 ) ); } } } diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 86609abdd25ca..97771f1c39f1b 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -487,7 +487,7 @@ void mapgen_spider_pit( mapgendata &dat ) } for( int x1 = p.x - 3; x1 <= p.x + 3; x1++ ) { for( int y1 = p.y - 3; y1 <= p.y + 3; y1++ ) { - madd_field( m, point( x1, y1 ), field_type_id( "fd_web" ), rng( 2, 3 ) ); + madd_field( m, point( x1, y1 ), fd_web, rng( 2, 3 ) ); if( m->ter( point( x1, y1 ) ) != t_slope_down ) { m->ter_set( point( x1, y1 ), t_dirt ); } diff --git a/src/monattack.cpp b/src/monattack.cpp index 57b8c21f5a7b5..1cebed336d0a8 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -628,7 +628,7 @@ bool mattack::acid( monster *z ) if( here.passable( dest ) && here.clear_path( dest, hitp, 6, 1, 100 ) && ( ( one_in( std::abs( j ) ) && one_in( std::abs( i ) ) ) || ( i == 0 && j == 0 ) ) ) { - here.add_field( dest, field_type_id( "fd_acid" ), 2 ); + here.add_field( dest, fd_acid, 2 ); } } } @@ -650,7 +650,7 @@ bool mattack::acid_barf( monster *z ) z->moves -= 80; // Make sure it happens before uncanny dodge - get_map().add_field( target->pos(), field_type_id( "fd_acid" ), 1 ); + get_map().add_field( target->pos(), fd_acid, 1 ); bool uncanny = target->uncanny_dodge(); // Can we dodge the attack? Uses player dodge function % chance (melee.cpp) if( uncanny || dodge_check( z, target ) ) { @@ -766,13 +766,13 @@ bool mattack::shockstorm( monster *z ) // Fill the LOS with electricity for( auto &i : bolt ) { if( !one_in( 4 ) ) { - here.add_field( i, field_type_id( "fd_electricity" ), rng( 1, 3 ) ); + here.add_field( i, fd_electricity, rng( 1, 3 ) ); } } // 5x5 cloud of electricity at the square hit for( const auto &dest : here.points_in_radius( tarp, 2 ) ) { if( !one_in( 4 ) ) { - here.add_field( dest, field_type_id( "fd_electricity" ), rng( 1, 3 ) ); + here.add_field( dest, fd_electricity, rng( 1, 3 ) ); } } @@ -871,10 +871,10 @@ bool mattack::boomer( monster *z ) add_msg( m_warning, _( "The %s spews bile!" ), z->name() ); } for( auto &i : line ) { - here.add_field( i, field_type_id( "fd_bile" ), 1 ); + here.add_field( i, fd_bile, 1 ); // If bile hit a solid tile, return. if( here.impassable( i ) ) { - here.add_field( i, field_type_id( "fd_bile" ), 3 ); + here.add_field( i, fd_bile, 3 ); add_msg_if_player_sees( i, _( "Bile splatters on the %s!" ), here.tername( i ) ); return true; } @@ -914,9 +914,9 @@ bool mattack::boomer_glow( monster *z ) add_msg( m_warning, _( "The %s spews bile!" ), z->name() ); } for( auto &i : line ) { - here.add_field( i, field_type_id( "fd_bile" ), 1 ); + here.add_field( i, fd_bile, 1 ); if( here.impassable( i ) ) { - here.add_field( i, field_type_id( "fd_bile" ), 3 ); + here.add_field( i, fd_bile, 3 ); add_msg_if_player_sees( i, _( "Bile splatters on the %s!" ), here.tername( i ) ); return true; } @@ -970,7 +970,7 @@ bool mattack::resurrect( monster *z ) int lowest_raise_score = INT_MAX; map &here = get_map(); for( const tripoint &p : here.points_in_radius( z->pos(), range ) ) { - if( !g->is_empty( p ) || here.get_field_intensity( p, field_type_id( "fd_fire" ) ) > 1 || + if( !g->is_empty( p ) || here.get_field_intensity( p, fd_fire ) > 1 || !here.sees( z->pos(), p, -1 ) ) { continue; } @@ -1351,7 +1351,7 @@ bool mattack::science( monster *const z ) // I said SCIENCE again! // fill empty tiles with acid for( size_t i = 0; i < empty_neighbor_count; ++i ) { const tripoint &p = empty_neighbors.first[i]; - here.add_field( p, field_type_id( "fd_acid" ), att_acid_intensity ); + here.add_field( p, fd_acid, att_acid_intensity ); } } break; @@ -1738,7 +1738,7 @@ bool mattack::fungus_haze( monster *z ) z->moves -= 150; map &here = get_map(); for( const tripoint &dest : here.points_in_radius( z->pos(), 3 ) ) { - here.add_field( dest, field_type_id( "fd_fungal_haze" ), rng( 1, 2 ) ); + here.add_field( dest, fd_fungal_haze, rng( 1, 2 ) ); } return true; @@ -1751,13 +1751,13 @@ bool mattack::fungus_big_blossom( monster *z ) map &here = get_map(); // Fungal fire-suppressor! >:D for( const tripoint &dest : here.points_in_radius( z->pos(), 6 ) ) { - if( here.get_field_intensity( dest, field_type_id( "fd_fire" ) ) != 0 ) { + if( here.get_field_intensity( dest, fd_fire ) != 0 ) { firealarm = true; } if( firealarm ) { - here.remove_field( dest, field_type_id( "fd_fire" ) ); - here.remove_field( dest, field_type_id( "fd_smoke" ) ); - here.add_field( dest, field_type_id( "fd_fungal_haze" ), 3 ); + here.remove_field( dest, fd_fire ); + here.remove_field( dest, fd_smoke ); + here.add_field( dest, fd_fungal_haze, 3 ); } } // Special effects handled outside the loop @@ -1784,7 +1784,7 @@ bool mattack::fungus_big_blossom( monster *z ) } z->moves -= 150; for( const tripoint &dest : here.points_in_radius( z->pos(), 12 ) ) { - here.add_field( dest, field_type_id( "fd_fungal_haze" ), rng( 1, 2 ) ); + here.add_field( dest, fd_fungal_haze, rng( 1, 2 ) ); } } @@ -3724,7 +3724,7 @@ void mattack::flame( monster *z, Creature *target ) here.tername( i.xy() ) ); return; } - here.add_field( i, field_type_id( "fd_fire" ), 1 ); + here.add_field( i, fd_fire, 1 ); } target->add_effect( effect_onfire, 8_turns, bodypart_id( "torso" ) ); @@ -3746,7 +3746,7 @@ void mattack::flame( monster *z, Creature *target ) here.tername( i.xy() ) ); return; } - here.add_field( i, field_type_id( "fd_fire" ), 1 ); + here.add_field( i, fd_fire, 1 ); } if( !target->uncanny_dodge() ) { target->add_effect( effect_onfire, 8_turns, bodypart_id( "torso" ) ); @@ -4702,7 +4702,7 @@ bool mattack::riotbot( monster *z ) for( const tripoint &dest : here.points_in_radius( z->pos(), 4 ) ) { if( here.passable( dest ) && here.clear_path( z->pos(), dest, 3, 1, 100 ) ) { - here.add_field( dest, field_type_id( "fd_relax_gas" ), rng( 1, 3 ) ); + here.add_field( dest, fd_relax_gas, rng( 1, 3 ) ); } } } @@ -4839,7 +4839,7 @@ bool mattack::riotbot( monster *z ) for( const tripoint &dest : here.points_in_radius( z->pos(), 2 ) ) { if( here.passable( dest ) && here.clear_path( z->pos(), dest, 3, 1, 100 ) ) { - here.add_field( dest, field_type_id( "fd_tear_gas" ), rng( 1, 3 ) ); + here.add_field( dest, fd_tear_gas, rng( 1, 3 ) ); } } @@ -4877,7 +4877,7 @@ bool mattack::riotbot( monster *z ) if( !here.is_transparent( elem ) ) { break; } - here.add_field( elem, field_type_id( "fd_dazzling" ), 1 ); + here.add_field( elem, fd_dazzling, 1 ); } return true; @@ -5034,8 +5034,8 @@ bool mattack::tindalos_teleport( monster *z ) z->setpos( dest ); // Not teleporting if it means losing sight of our current target if( z->sees( *target ) ) { - here.add_field( oldpos, field_type_id( "fd_tindalos_rift" ), 2 ); - here.add_field( dest, field_type_id( "fd_tindalos_rift" ), 2 ); + here.add_field( oldpos, fd_tindalos_rift, 2 ); + here.add_field( dest, fd_tindalos_rift, 2 ); add_msg_if_player_sees( *z, m_bad, _( "The %s dissipates and reforms close by." ), z->name() ); return true; } @@ -5074,7 +5074,7 @@ bool mattack::flesh_tendril( monster *z ) if( monster *const summoned = g->place_critter_around( spawned, z->pos(), 1 ) ) { z->moves -= 100; summoned->make_ally( *z ); - get_map().propagate_field( z->pos(), field_type_id( "fd_gibs_flesh" ), 75, 1 ); + get_map().propagate_field( z->pos(), fd_gibs_flesh, 75, 1 ); add_msg_if_player_sees( *z, m_warning, _( "A %s struggles to pull itself free from the %s!" ), summoned->name(), z->name() ); } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index e66ae0bc7f662..5cae257959503 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -241,7 +241,7 @@ void mdeath::acid( monster &z ) add_msg( m_warning, _( "The %s's body leaks acid." ), z.name() ); } } - get_map().add_field( z.pos(), field_type_id( "fd_acid" ), 3 ); + get_map().add_field( z.pos(), fd_acid, 3 ); } void mdeath::boomer( monster &z ) @@ -262,7 +262,7 @@ void mdeath::boomer( monster &z ) player_character.add_env_effect( effect_boomered, bodypart_id( "eyes" ), 2, 24_turns ); } - here.propagate_field( z.pos(), field_type_id( "fd_bile" ), 15, 1 ); + here.propagate_field( z.pos(), fd_bile, 15, 1 ); } void mdeath::boomer_glow( monster &z ) @@ -289,7 +289,7 @@ void mdeath::boomer_glow( monster &z ) } } - here.propagate_field( z.pos(), field_type_id( "fd_bile" ), 30, 2 ); + here.propagate_field( z.pos(), fd_bile, 30, 2 ); } void mdeath::kill_vines( monster &z ) @@ -603,7 +603,7 @@ void mdeath::focused_beam( monster &z ) if( !here.is_transparent( elem ) ) { break; } - here.add_field( elem, field_type_id( "fd_dazzling" ), 2 ); + here.add_field( elem, fd_dazzling, 2 ); } } @@ -716,7 +716,7 @@ void mdeath::fungalburst( monster &z ) { map &here = get_map(); // If the fungus died from anti-fungal poison, don't pouf - if( here.get_field_intensity( z.pos(), field_type_id( "fd_fungicidal_gas" ) ) ) { + if( here.get_field_intensity( z.pos(), fd_fungicidal_gas ) ) { add_msg_if_player_sees( z, m_good, _( "The %s inflates and melts away." ), z.name() ); return; } @@ -800,7 +800,7 @@ void mdeath::preg_roach( monster &z ) void mdeath::fireball( monster &z ) { if( one_in( 10 ) ) { - get_map().propagate_field( z.pos(), field_type_id( "fd_fire" ), 15, 3 ); + get_map().propagate_field( z.pos(), fd_fire, 15, 3 ); std::string explode = string_format( _( "an explosion of tank of the %s's flamethrower!" ), z.name() ); sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode, false, "explosion", "default" ); @@ -814,7 +814,7 @@ void mdeath::conflagration( monster &z ) { map &here = get_map(); for( const auto &dest : here.points_in_radius( z.pos(), 1 ) ) { - here.propagate_field( dest, field_type_id( "fd_fire" ), 18, 3 ); + here.propagate_field( dest, fd_fire, 18, 3 ); } const std::string explode = string_format( _( "a %s explode!" ), z.name() ); sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode, false, "explosion", "small" ); diff --git a/src/monmove.cpp b/src/monmove.cpp index becf95e81e4e6..9378ba46d9e20 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -80,13 +80,13 @@ bool monster::wander() bool monster::is_immune_field( const field_type_id &fid ) const { - if( fid == field_type_id( "fd_fungal_haze" ) ) { + if( fid == fd_fungal_haze ) { return has_flag( MF_NO_BREATHE ) || type->in_species( species_FUNGUS ); } - if( fid == field_type_id( "fd_fungicidal_gas" ) ) { + if( fid == fd_fungicidal_gas ) { return !type->in_species( species_FUNGUS ); } - if( fid == field_type_id( "fd_insecticidal_gas" ) ) { + if( fid == fd_insecticidal_gas ) { return !type->in_species( species_INSECT ) && !type->in_species( species_SPIDER ); } const field_type &ft = fid.obj(); @@ -215,10 +215,10 @@ bool monster::will_move_to( const tripoint &p ) const } // Without avoid_complex, only fire and electricity are checked for field avoidance. - if( avoid_fire && target_field.find_field( field_type_id( "fd_fire" ) ) ) { + if( avoid_fire && target_field.find_field( fd_fire ) ) { return false; } - if( avoid_simple && target_field.find_field( field_type_id( "fd_electricity" ) ) ) { + if( avoid_simple && target_field.find_field( fd_electricity ) ) { return false; } } @@ -1688,13 +1688,13 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, } // Acid trail monsters leave... a trail of acid if( has_flag( MF_ACIDTRAIL ) ) { - here.add_field( pos(), field_type_id( "fd_acid" ), 3 ); + here.add_field( pos(), fd_acid, 3 ); } // Not all acid trail monsters leave as much acid. Every time this monster takes a step, there is a 1/5 chance it will drop a puddle. if( has_flag( MF_SHORTACIDTRAIL ) ) { if( one_in( 5 ) ) { - here.add_field( pos(), field_type_id( "fd_acid" ), 3 ); + here.add_field( pos(), fd_acid, 3 ); } } @@ -1702,7 +1702,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, for( const tripoint &sludge_p : here.points_in_radius( pos(), 1 ) ) { const int fstr = 3 - ( std::abs( sludge_p.x - posx() ) + std::abs( sludge_p.y - posy() ) ); if( fstr >= 2 ) { - here.add_field( sludge_p, field_type_id( "fd_sludge" ), fstr ); + here.add_field( sludge_p, fd_sludge, fstr ); } } } diff --git a/src/monster.cpp b/src/monster.cpp index ce49bf7e46cfc..89bf9a4009e7e 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1181,7 +1181,7 @@ void monster::process_triggers() int ret = 0; map &here = get_map(); for( const auto &p : here.points_in_radius( pos(), 3 ) ) { - ret += 5 * here.get_field_intensity( p, field_type_id( "fd_fire" ) ); + ret += 5 * here.get_field_intensity( p, fd_fire ); } return ret; } ); @@ -2134,7 +2134,7 @@ void monster::process_turn() const map_stack items = here.i_at( zap ); for( const auto &item : items ) { if( item.made_of( phase_id::LIQUID ) && item.flammable() ) { // start a fire! - here.add_field( zap, field_type_id( "fd_fire" ), 2, 1_minutes ); + here.add_field( zap, fd_fire, 2, 1_minutes ); sounds::sound( pos(), 30, sounds::sound_t::combat, _( "fwoosh!" ), false, "fire", "ignition" ); break; } @@ -2151,7 +2151,7 @@ void monster::process_turn() } else { add_msg_if_player_sees( zap, m_warning, _( "Lightning from %1$s engulfs the %2$s!" ), name(), here.tername( zap ) ); - here.add_field( zap, field_type_id( "fd_fire" ), 1, 2_turns ); + here.add_field( zap, fd_fire, 1, 2_turns ); } } } @@ -2633,14 +2633,14 @@ bool monster::is_hallucination() const field_type_id monster::bloodType() const { if( is_hallucination() ) { - return field_type_id( "fd_null" ); + return fd_null; } return type->bloodType(); } field_type_id monster::gibType() const { if( is_hallucination() ) { - return field_type_id( "fd_null" ); + return fd_null; } return type->gibType(); } diff --git a/src/mtype.cpp b/src/mtype.cpp index 15ae734ff1ed2..5bfeeca63f764 100644 --- a/src/mtype.cpp +++ b/src/mtype.cpp @@ -156,42 +156,42 @@ field_type_id mtype::bloodType() const if( has_flag( MF_ACID_BLOOD ) ) //A monster that has the death effect "ACID" does not need to have acid blood. { - return field_type_id( "fd_acid" ); + return fd_acid; } if( has_flag( MF_BILE_BLOOD ) ) { - return field_type_id( "fd_bile" ); + return fd_bile; } if( has_flag( MF_LARVA ) || has_flag( MF_ARTHROPOD_BLOOD ) ) { - return field_type_id( "fd_blood_invertebrate" ); + return fd_blood_invertebrate; } if( made_of( material_id( "veggy" ) ) ) { - return field_type_id( "fd_blood_veggy" ); + return fd_blood_veggy; } if( made_of( material_id( "iflesh" ) ) ) { - return field_type_id( "fd_blood_insect" ); + return fd_blood_insect; } if( has_flag( MF_WARM ) && made_of( material_id( "flesh" ) ) ) { - return field_type_id( "fd_blood" ); + return fd_blood; } - return field_type_id( "fd_null" ); + return fd_null; } field_type_id mtype::gibType() const { if( has_flag( MF_LARVA ) || in_species( species_MOLLUSK ) ) { - return field_type_id( "fd_gibs_invertebrate" ); + return fd_gibs_invertebrate; } if( made_of( material_id( "veggy" ) ) ) { - return field_type_id( "fd_gibs_veggy" ); + return fd_gibs_veggy; } if( made_of( material_id( "iflesh" ) ) ) { - return field_type_id( "fd_gibs_insect" ); + return fd_gibs_insect; } if( made_of( material_id( "flesh" ) ) ) { - return field_type_id( "fd_gibs_flesh" ); + return fd_gibs_flesh; } // There are other materials not listed here like steel, protoplasmic, powder, null, stone, bone - return field_type_id( "fd_null" ); + return fd_null; } itype_id mtype::get_meat_itype() const diff --git a/src/mutation.cpp b/src/mutation.cpp index 0320af5dc9256..c953c047efcf0 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -647,7 +647,7 @@ void Character::activate_mutation( const trait_id &mut ) } if( mut == trait_WEB_WEAVER ) { - get_map().add_field( pos(), field_type_id( "fd_web" ), 1 ); + get_map().add_field( pos(), fd_web, 1 ); add_msg_if_player( _( "You start spinning web with your spinnerets!" ) ); } else if( mut == trait_BURROW ) { tdata.powered = false; diff --git a/src/npcmove.cpp b/src/npcmove.cpp index da00168bc5539..6ea61f046f396 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -446,7 +446,7 @@ void npc::assess_danger() if( pt == pos() || here.has_flag( TFLAG_FIRE_CONTAINER, pt ) ) { continue; } - if( here.get_field( pt, field_type_id( "fd_fire" ) ) != nullptr ) { + if( here.get_field( pt, fd_fire ) != nullptr ) { int dist = rl_dist( pos(), pt ); cur_threat_map[direction_from( pos(), pt )] += 2.0f * ( NPC_DANGER_MAX - dist ); if( dist < 3 && !has_effect( effect_npc_fire_bad ) ) { diff --git a/src/player.cpp b/src/player.cpp index 28392a73897b4..36c6046b81bca 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2925,7 +2925,7 @@ void player::try_to_sleep( const time_duration &dur ) webforce = true; } if( websleep || webforce ) { - int web = here.get_field_intensity( pos(), field_type_id( "fd_web" ) ); + int web = here.get_field_intensity( pos(), fd_web ); if( !webforce ) { // At this point, it's kinda weird, but surprisingly comfy... if( web >= 3 ) { @@ -2935,7 +2935,7 @@ void player::try_to_sleep( const time_duration &dur ) } else if( web > 0 ) { add_msg_if_player( m_info, _( "You try to sleep, but the webs get in the way. You brush them aside." ) ); - here.remove_field( pos(), field_type_id( "fd_web" ) ); + here.remove_field( pos(), fd_web ); } } else { // Here, you're just not comfortable outside a nice thick web. diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index f593937dea8e9..dfeed86a4e680 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -649,7 +649,7 @@ void player::hardcoded_effects( effect &it ) add_msg_if_player( m_bad, _( "You are beset with a vision of a prowling beast." ) ); for( const tripoint &dest : here.points_in_radius( pos(), 6 ) ) { if( here.is_cornerfloor( dest ) ) { - here.add_field( dest, field_type_id( "fd_tindalos_rift" ), 3 ); + here.add_field( dest, fd_tindalos_rift, 3 ); add_msg_if_player( m_info, _( "Your surroundings are permeated with a foul scent." ) ); //Remove the effect, since it's done all it needs to do to the target. remove_effect( effect_tindrift ); diff --git a/src/start_location.cpp b/src/start_location.cpp index 6c361ee6802c3..c02e1c8615fa3 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -376,7 +376,7 @@ void start_location::burn( const tripoint_abs_omt &omtstart, const size_t count, } std::shuffle( valid.begin(), valid.end(), rng_get_engine() ); for( size_t i = 0; i < std::min( count, valid.size() ); i++ ) { - m.add_field( valid[i], field_type_id( "fd_fire" ), 3 ); + m.add_field( valid[i], fd_fire, 3 ); } m.save(); } diff --git a/src/string_id.h b/src/string_id.h index 21a7f9927c748..ce948b24fc154 100644 --- a/src/string_id.h +++ b/src/string_id.h @@ -131,6 +131,12 @@ class string_id * This may issue a debug message if the string is not a valid id. */ int_id id() const; + /** + * Translate the string based it to the matching integer based id. + * If this string_id is not valid, returns `fallback`. + * Does not produce debug message. + */ + int_id id_or( const int_id &fallback ) const; /** * Returns the actual object this id refers to. May show a debug message if the id is invalid. */ diff --git a/src/suffer.cpp b/src/suffer.cpp index 2d5a9a5a0a8d7..75121ebefda0b 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -1015,7 +1015,7 @@ void Character::suffer_from_other_mutations() //Web Weavers...weave web if( has_active_mutation( trait_WEB_WEAVER ) && !in_vehicle ) { // this adds intensity to if its not already there. - here.add_field( pos(), field_type_id( "fd_web" ), 1 ); + here.add_field( pos(), fd_web, 1 ); } @@ -1040,7 +1040,7 @@ void Character::suffer_from_other_mutations() if( has_trait( trait_WEB_SPINNER ) && !in_vehicle && one_in( 3 ) ) { // this adds intensity to if its not already there. - here.add_field( pos(), field_type_id( "fd_web" ), 1 ); + here.add_field( pos(), fd_web, 1 ); } bool should_mutate = has_trait( trait_UNSTABLE ) && !has_trait( trait_CHAOTIC_BAD ) && diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 537ca4b42a0d9..4a1c03f9278c9 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3823,8 +3823,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) } if( ( exhaust_part == -1 ) && engine_on ) { - spew_field( j, p, field_type_id( "fd_smoke" ), - bad_filter ? field_type_id( "fd_smoke" )->get_max_intensity() : 1 ); + spew_field( j, p, fd_smoke, bad_filter ? fd_smoke->get_max_intensity() : 1 ); } else { mufflesmoke += j; } @@ -3839,8 +3838,8 @@ void vehicle::noise_and_smoke( int load, time_duration time ) /// TODO: handle other engine types: muscle / animal / wind / coal / ... if( exhaust_part != -1 && engine_on ) { - spew_field( mufflesmoke, exhaust_part, field_type_id( "fd_smoke" ), - bad_filter ? field_type_id( "fd_smoke" )->get_max_intensity() : 1 ); + spew_field( mufflesmoke, exhaust_part, fd_smoke, + bad_filter ? fd_smoke->get_max_intensity() : 1 ); } if( is_rotorcraft() ) { noise *= 2; diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index f1a28d9356608..2fa297c6bac6b 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -335,7 +335,7 @@ TEST_CASE( "npc-movement" ) if( type == 'A' || type == 'R' || type == 'W' || type == 'M' || type == 'B' || type == 'C' ) { - here.add_field( p, field_type_id( "fd_acid" ), 3 ); + here.add_field( p, fd_acid, 3 ); } // spawn rubbles if( type == 'R' ) { @@ -360,7 +360,7 @@ TEST_CASE( "npc-movement" ) guy->normalize(); guy->randomize(); // Repeat until we get an NPC vulnerable to acid - } while( guy->is_immune_field( field_type_id( "fd_acid" ) ) ); + } while( guy->is_immune_field( fd_acid ) ); guy->spawn_at_precise( get_map().get_abs_sub().xy(), p ); // Set the shopkeep mission; this means that // the NPC deems themselves to be guarding and stops them