Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove string spawn item overloads #79173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ static const itype_id itype_smartphone_music( "smartphone_music" );
static const itype_id itype_soap( "soap" );
static const itype_id itype_soldering_iron( "soldering_iron" );
static const itype_id itype_spiral_stone( "spiral_stone" );
static const itype_id itype_splinter( "splinter" );
static const itype_id itype_stick( "stick" );
static const itype_id itype_syringe( "syringe" );
static const itype_id itype_tazer( "tazer" );
static const itype_id itype_tongs( "tongs" );
Expand Down Expand Up @@ -8717,16 +8719,16 @@ std::optional<int> iuse::break_stick( Character *p, item *it, const tripoint_bub
map &here = get_map();
if( chance <= 20 ) {
p->add_msg_if_player( _( "You try to break the stick in two, but it shatters into splinters." ) );
here.spawn_item( p->pos_bub(), "splinter", 2 );
here.spawn_item( p->pos_bub(), itype_splinter, 2 );
return 1;
} else if( chance <= 40 ) {
p->add_msg_if_player( _( "The stick breaks clean into two parts." ) );
here.spawn_item( p->pos_bub(), "stick", 2 );
here.spawn_item( p->pos_bub(), itype_stick, 2 );
return 1;
} else if( chance <= 100 ) {
p->add_msg_if_player( _( "You break the stick, but one half shatters into splinters." ) );
here.spawn_item( p->pos_bub(), "stick", 1 );
here.spawn_item( p->pos_bub(), "splinter", 1 );
here.spawn_item( p->pos_bub(), itype_stick, 1 );
here.spawn_item( p->pos_bub(), itype_splinter, 1 );
return 1;
}
return 0;
Expand Down
27 changes: 0 additions & 27 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1242,25 +1242,6 @@ class map
variant, faction );
}

// FIXME: remove these overloads and require spawn_item to take an
// itype_id
void spawn_item( const tripoint_bub_ms &p, const std::string &type_id,
unsigned quantity = 1, int charges = 0,
const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0,
const std::set<flag_id> &flags = {}, const std::string &variant = "",
const std::string &faction = "" ) {
spawn_item( p, itype_id( type_id ), quantity, charges, birthday, damlevel, flags, variant,
faction );
}
void spawn_item( const point_bub_ms &p, const std::string &type_id,
unsigned quantity = 1, int charges = 0,
const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0,
const std::set<flag_id> &flags = {}, const std::string &variant = "",
const std::string &faction = "" ) {
spawn_item( tripoint_bub_ms( p, abs_sub.z() ), type_id, quantity, charges, birthday, damlevel,
flags,
variant, faction );
}
units::volume max_volume( const tripoint_bub_ms &p );
units::volume free_volume( const tripoint_bub_ms &p );
units::volume stored_volume( const tripoint_bub_ms &p );
Expand Down Expand Up @@ -2383,14 +2364,6 @@ class tinymap : private map
map::spawn_item( rebase_bub( p ), type_id, quantity, charges, birthday, damlevel, flags, variant,
faction );
}
void spawn_item( const tripoint_omt_ms &p, const std::string &type_id, // TODO: Make it typed
unsigned quantity = 1, int charges = 0,
const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0,
const std::set<flag_id> &flags = {}, const std::string &variant = "",
const std::string &faction = "" ) {
map::spawn_item( rebase_bub( p ), type_id, quantity, charges, birthday, damlevel, flags, variant,
faction );
}
std::vector<item *> spawn_items( const tripoint_omt_ms &p, const std::vector<item> &new_items ) {
return map::spawn_items( rebase_bub( p ), new_items );
}
Expand Down
2 changes: 1 addition & 1 deletion src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ void field_processor_fd_fire( const tripoint_bub_ms &p, field_entry &cur, field_
if( cur.get_field_intensity() > 1 &&
one_in( 200 - cur.get_field_intensity() * 50 ) ) {
here.bash( p, 999, false, true, true );
here.spawn_item( p, "ash", 1, rng( 10, 1000 ) );
here.spawn_item( p, itype_ash, 1, rng( 10, 1000 ) );
}

} else if( frn.has_flag( ter_furn_flag::TFLAG_FLAMMABLE_ASH ) ) {
Expand Down
55 changes: 34 additions & 21 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,24 @@ static const item_group_id Item_spawn_data_lab_dorm( "lab_dorm" );
static const item_group_id Item_spawn_data_mut_lab( "mut_lab" );
static const item_group_id Item_spawn_data_teleport( "teleport" );

static const itype_id itype_UPS_off( "UPS_off" );
static const itype_id itype_ash( "ash" );
static const itype_id itype_avgas( "avgas" );
static const itype_id itype_diesel( "diesel" );
static const itype_id itype_gasoline( "gasoline" );
static const itype_id itype_glass_shard( "glass_shard" );
static const itype_id itype_heavy_battery_cell( "heavy_battery_cell" );
static const itype_id itype_id_science( "id_science" );
static const itype_id itype_jp8( "jp8" );
static const itype_id itype_laser_rifle( "laser_rifle" );
static const itype_id itype_plasma( "plasma" );
static const itype_id itype_plasma_gun( "plasma_gun" );
static const itype_id itype_plut_cell( "plut_cell" );
static const itype_id itype_recipe_atomic_battery( "recipe_atomic_battery" );
static const itype_id itype_recipe_caseless( "recipe_caseless" );
static const itype_id itype_rm13_armor( "rm13_armor" );
static const itype_id itype_rock( "rock" );
static const itype_id itype_v29( "v29" );
static const itype_id itype_water( "water" );

static const mongroup_id GROUP_BREATHER( "GROUP_BREATHER" );
Expand Down Expand Up @@ -6353,7 +6366,7 @@ void map::draw_lab( mapgendata &dat )
point_bub_ms( 6, SEEY * 2 - 7 ), abs_sub.z(), 1, true );
place_spawns( GROUP_ROBOT_SECUBOT, 1, point_bub_ms( SEEX * 2 - 7, SEEY * 2 - 7 ),
point_bub_ms( SEEX * 2 - 7, SEEY * 2 - 7 ), abs_sub.z(), 1, true );
spawn_item( point_bub_ms( SEEX - 4, SEEY - 2 ), "id_science" );
spawn_item( point_bub_ms( SEEX - 4, SEEY - 2 ), itype_id_science );
if( loot_variant <= 96 ) {
mtrap_set( this, tripoint_bub_ms( SEEX - 3, SEEY - 3, dat.zlevel() ), tr_dissector );
mtrap_set( this, tripoint_bub_ms( SEEX + 2, SEEY - 3, dat.zlevel() ), tr_dissector );
Expand All @@ -6375,22 +6388,22 @@ void map::draw_lab( mapgendata &dat )
furn_set( point_bub_ms( SEEX - 1, SEEY ), furn_f_table );
furn_set( point_bub_ms( SEEX, SEEY ), furn_f_table );
if( loot_variant <= 67 ) {
spawn_item( point_bub_ms( SEEX, SEEY - 1 ), "UPS_off" );
spawn_item( point_bub_ms( SEEX, SEEY - 1 ), "heavy_battery_cell" );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), "v29" );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), "laser_rifle", dice( 1, 0 ) );
spawn_item( point_bub_ms( SEEX, SEEY ), "plasma_gun" );
spawn_item( point_bub_ms( SEEX, SEEY ), "plasma" );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), "recipe_atomic_battery" );
spawn_item( point_bub_ms( SEEX + 1, SEEY ), "plut_cell", rng( 8, 20 ) );
spawn_item( point_bub_ms( SEEX, SEEY - 1 ), itype_UPS_off );
spawn_item( point_bub_ms( SEEX, SEEY - 1 ), itype_heavy_battery_cell );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), itype_v29 );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), itype_laser_rifle, dice( 1, 0 ) );
spawn_item( point_bub_ms( SEEX, SEEY ), itype_plasma_gun );
spawn_item( point_bub_ms( SEEX, SEEY ), itype_plasma );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), itype_recipe_atomic_battery );
spawn_item( point_bub_ms( SEEX + 1, SEEY ), itype_plut_cell, rng( 8, 20 ) );
} else if( loot_variant < 89 ) {
spawn_item( point_bub_ms( SEEX, SEEY ), "recipe_atomic_battery" );
spawn_item( point_bub_ms( SEEX + 1, SEEY ), "plut_cell", rng( 8, 20 ) );
spawn_item( point_bub_ms( SEEX, SEEY ), itype_recipe_atomic_battery );
spawn_item( point_bub_ms( SEEX + 1, SEEY ), itype_plut_cell, rng( 8, 20 ) );
} else { // loot_variant between 90 and 96.
spawn_item( point_bub_ms( SEEX - 1, SEEY - 1 ), "rm13_armor" );
spawn_item( point_bub_ms( SEEX, SEEY - 1 ), "plut_cell" );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), "plut_cell" );
spawn_item( point_bub_ms( SEEX, SEEY ), "recipe_caseless" );
spawn_item( point_bub_ms( SEEX - 1, SEEY - 1 ), itype_rm13_armor );
spawn_item( point_bub_ms( SEEX, SEEY - 1 ), itype_plut_cell );
spawn_item( point_bub_ms( SEEX - 1, SEEY ), itype_plut_cell );
spawn_item( point_bub_ms( SEEX, SEEY ), itype_recipe_caseless );
}
} else { // 4% of the lab ends will be this weapons testing end.
mtrap_set( this, tripoint_bub_ms( SEEX - 4, SEEY - 3, dat.zlevel() ), tr_dissector );
Expand Down Expand Up @@ -6423,7 +6436,7 @@ void map::draw_lab( mapgendata &dat )
place_items( Item_spawn_data_guns_rare, 96, point_bub_ms( SEEX - 2, SEEY ),
point_bub_ms( SEEX + 1, SEEY ), abs_sub.z(), false,
calendar::start_of_cataclysm );
spawn_item( point_bub_ms( SEEX + 1, SEEY ), "plut_cell", rng( 1, 10 ) );
spawn_item( point_bub_ms( SEEX + 1, SEEY ), itype_plut_cell, rng( 1, 10 ) );
}
break;
// Netherworld access
Expand Down Expand Up @@ -6452,7 +6465,7 @@ void map::draw_lab( mapgendata &dat )
}
}

spawn_item( point_bub_ms( SEEX - 1, 8 ), "id_science" );
spawn_item( point_bub_ms( SEEX - 1, 8 ), itype_id_science );
tmpcomp = add_computer( { SEEX, 8, abs_sub.z() },
_( "Sub-prime contact console" ), 7 );
if( monsters_end ) { //only add these options when there are monsters.
Expand Down Expand Up @@ -6506,7 +6519,7 @@ void map::draw_lab( mapgendata &dat )
line( this, ter_t_reinforced_glass, point_bub_ms( SEEX + 1, SEEY - 1 ), point_bub_ms( SEEX + 1,
SEEY ),
dat.zlevel() );
spawn_item( point_bub_ms( SEEX - 4, SEEY - 3 ), "id_science" );
spawn_item( point_bub_ms( SEEX - 4, SEEY - 3 ), itype_id_science );
furn_set( point_bub_ms( SEEX - 3, SEEY - 3 ), furn_f_console );
tmpcomp = add_computer( { SEEX - 3, SEEY - 3, abs_sub.z() },
_( "Bionic access" ), 3 );
Expand Down Expand Up @@ -6538,7 +6551,7 @@ void map::draw_lab( mapgendata &dat )
line( this, ter_t_cvdbody, point_bub_ms( SEEX + 1, SEEY - 2 ), point_bub_ms( SEEX + 1, SEEY + 1 ),
dat.zlevel() );
ter_set( point_bub_ms( SEEX, SEEY - 2 ), ter_t_cvdmachine );
spawn_item( point_bub_ms( SEEX, SEEY - 3 ), "id_science" );
spawn_item( point_bub_ms( SEEX, SEEY - 3 ), itype_id_science );
break;
}
} // end use_hardcoded_lab_finale
Expand Down Expand Up @@ -6680,7 +6693,7 @@ void map::place_vending( const tripoint_bub_ms &p, const item_group_id &type, bo
bash( p, 9999 );
for( const tripoint_bub_ms &loc : points_in_radius( p, 1 ) ) {
if( one_in( 4 ) ) {
spawn_item( loc, "glass_shard", rng( 1, 25 ) );
spawn_item( loc, itype_glass_shard, rng( 1, 25 ) );
}
}
} else {
Expand Down Expand Up @@ -7733,7 +7746,7 @@ void map::create_anomaly( const tripoint_bub_ms &cp, artifact_natural_property p
if( furn( point_bub_ms( i, j ) ) == furn_f_rubble ) {
add_field( tripoint_bub_ms{ i, j, z }, fd_push_items, 1 );
if( one_in( 3 ) ) {
spawn_item( point_bub_ms( i, j ), "rock" );
spawn_item( point_bub_ms( i, j ), itype_rock );
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/mission_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static const furn_str_id furn_f_console( "f_console" );
static const furn_str_id furn_f_console_broken( "f_console_broken" );
static const furn_str_id furn_f_dresser( "f_dresser" );

static const itype_id itype_safe_box( "safe_box" );
static const itype_id itype_software_medical( "software_medical" );
static const itype_id itype_software_useless( "software_useless" );
static const itype_id itype_usb_drive( "usb_drive" );
Expand Down Expand Up @@ -229,7 +230,7 @@ void mission_start::place_deposit_box( mission *miss )
}
const tripoint_omt_ms fallback( rng( 6, SEEX * 2 - 7 ), rng( 6, SEEY * 2 - 7 ), site.z() );
const tripoint_omt_ms comppoint = random_entry( valid, fallback );
compmap.spawn_item( comppoint, "safe_box" );
compmap.spawn_item( comppoint, itype_safe_box );
compmap.save();
}

Expand Down
6 changes: 3 additions & 3 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2447,8 +2447,8 @@ bool monster::move_effects( bool )
if( type->melee_dice * type->melee_sides >= 7 ) {
if( x_in_y( type->melee_dice * type->melee_sides, 32 ) ) {
remove_effect( effect_heavysnare );
here.spawn_item( pos_bub(), "rope_6" );
here.spawn_item( pos_bub(), "snare_trigger" );
here.spawn_item( pos_bub(), itype_rope_6 );
here.spawn_item( pos_bub(), itype_snare_trigger );
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s escapes the heavy snare!" ), name() );
}
Expand All @@ -2460,7 +2460,7 @@ bool monster::move_effects( bool )
if( type->melee_dice * type->melee_sides >= 18 ) {
if( x_in_y( type->melee_dice * type->melee_sides, 200 ) ) {
remove_effect( effect_beartrap );
here.spawn_item( pos_bub(), "beartrap" );
here.spawn_item( pos_bub(), itype_beartrap );
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s escapes the bear trap!" ), name() );
}
Expand Down
3 changes: 2 additions & 1 deletion src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static const efftype_id effect_weary_7( "weary_7" );
static const efftype_id effect_weary_8( "weary_8" );
static const efftype_id effect_winded( "winded" );

static const itype_id itype_bone( "bone" );
static const itype_id itype_e_handcuffs( "e_handcuffs" );
static const itype_id itype_inhaler( "inhaler" );
static const itype_id itype_oxygen_tank( "oxygen_tank" );
Expand Down Expand Up @@ -1032,7 +1033,7 @@ void suffer::from_other_mutations( Character &you )
const tripoint_bub_ms position = you.pos_bub();
if( you.has_trait( trait_SHARKTEETH ) && one_turn_in( 24_hours ) ) {
you.add_msg_if_player( m_neutral, _( "You shed a tooth!" ) );
here.spawn_item( position, "bone", 1 );
here.spawn_item( position, itype_bone, 1 );
}

if( you.has_trait( trait_WINGS_INSECT_active ) ) {
Expand Down
27 changes: 18 additions & 9 deletions src/trapfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,19 @@ static const efftype_id effect_tetanus( "tetanus" );
static const flag_id json_flag_PROXIMITY( "PROXIMITY" );
static const flag_id json_flag_UNCONSUMED( "UNCONSUMED" );

static const itype_id itype_beartrap( "beartrap" );
static const itype_id itype_bolt_steel( "bolt_steel" );
static const itype_id itype_bullwhip( "bullwhip" );
static const itype_id itype_crossbow( "crossbow" );
static const itype_id itype_glass_shard( "glass_shard" );
static const itype_id itype_grapnel( "grapnel" );
static const itype_id itype_grenade_act( "grenade_act" );
static const itype_id itype_light_snare_kit( "light_snare_kit" );
static const itype_id itype_pointy_stick( "pointy_stick" );
static const itype_id itype_rope_30( "rope_30" );
static const itype_id itype_shotgun_d( "shotgun_d" );
static const itype_id itype_shotgun_s( "shotgun_s" );
static const itype_id itype_string_36( "string_36" );

static const json_character_flag json_flag_INFECTION_IMMUNE( "INFECTION_IMMUNE" );

Expand Down Expand Up @@ -210,7 +219,7 @@ bool trapfunc::beartrap( const tripoint_bub_ms &p, Creature *c, item * )
}
c->check_dead_state();
} else {
here.spawn_item( p, "beartrap" );
here.spawn_item( p, itype_beartrap );
}

return true;
Expand Down Expand Up @@ -541,10 +550,10 @@ bool trapfunc::crossbow( const tripoint_bub_ms &p, Creature *c, item * )
}
map &here = get_map();
here.remove_trap( p );
here.spawn_item( p, "crossbow" );
here.spawn_item( p, "string_36" );
here.spawn_item( p, itype_crossbow );
here.spawn_item( p, itype_string_36 );
if( add_bolt ) {
here.spawn_item( p, "bolt_steel", 1, 1 );
here.spawn_item( p, itype_bolt_steel, 1, 1 );
}
return true;
}
Expand Down Expand Up @@ -645,8 +654,8 @@ bool trapfunc::shotgun( const tripoint_bub_ms &p, Creature *c, item * )
c->check_dead_state();
}

here.spawn_item( p, here.tr_at( p ) == tr_shotgun_1 ? "shotgun_s" : "shotgun_d" );
here.spawn_item( p, "string_36" );
here.spawn_item( p, here.tr_at( p ) == tr_shotgun_1 ? itype_shotgun_s : itype_shotgun_d );
here.spawn_item( p, itype_string_36 );
here.remove_trap( p );
return true;
}
Expand Down Expand Up @@ -691,7 +700,7 @@ bool trapfunc::snare_light( const tripoint_bub_ms &p, Creature *c, item * )
}

// Always get trap components back on triggering tile
here.spawn_item( p, "light_snare_kit" );
here.spawn_item( p, itype_light_snare_kit );
return true;
}

Expand Down Expand Up @@ -1063,7 +1072,7 @@ bool trapfunc::pit_spikes( const tripoint_bub_ms &p, Creature *c, item * )
// 4 spears to a pit
for( int i = 0; i < 4; i++ ) {
if( one_in( 3 ) ) {
here.spawn_item( p, "pointy_stick" );
here.spawn_item( p, itype_pointy_stick );
}
}
}
Expand Down Expand Up @@ -1153,7 +1162,7 @@ bool trapfunc::pit_glass( const tripoint_bub_ms &p, Creature *c, item * )
// 20 shards in a pit.
for( int i = 0; i < 20; i++ ) {
if( one_in( 3 ) ) {
here.spawn_item( p, "glass_shard" );
here.spawn_item( p, itype_glass_shard );
}
}
}
Expand Down
Loading