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

Prevent segfault when deconstructing improvised shelter #75703

Merged
merged 1 commit into from
Aug 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"light_emitted": 120,
"looks_like": "t_carpet_green",
"connect_groups": "INDOORFLOOR",
"flags": [ "TRANSPARENT", "FLAMMABLE_HARD", "SUPPORTS_ROOF", "COLLAPSES", "INDOORS", "FLAT", "RUG", "EASY_DECONSTRUCT" ],
"flags": [ "TRANSPARENT", "FLAMMABLE_HARD", "SUPPORTS_ROOF", "COLLAPSES", "INDOORS", "FLAT", "RUG" ],
"bash": {
"str_min": 4,
"str_max": 12,
Expand Down
6 changes: 6 additions & 0 deletions data/json/furniture_and_terrain/terrain-manufactured.json
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@
"sound_fail": "whump!",
"items": [ { "item": "rock_large", "count": [ 0, 20 ] }, { "item": "sharp_rock", "count": [ 0, 16 ] } ]
},
"deconstruct": { "ter_set": "t_dirt", "items": [ { "item": "rock_large", "count": 22 } ] },
"flags": [ "TRANSPARENT", "THIN_OBSTACLE", "SHORT", "ROUGH", "UNSTABLE", "PERMEABLE", "EASY_DECONSTRUCT" ]
},
{
Expand Down Expand Up @@ -1494,6 +1495,7 @@
"HIDE_PLACE",
"EASY_DECONSTRUCT"
],
"deconstruct": { "ter_set": "t_pit_shallow", "items": [ { "item": "stick", "count": 12 }, { "item": "pine_bough", "count": 24 } ] },
"bash": {
"str_min": 4,
"str_max": 60,
Expand Down Expand Up @@ -1526,6 +1528,10 @@
"HIDE_PLACE",
"EASY_DECONSTRUCT"
],
"deconstruct": {
"ter_set": "t_pit_shallow",
"items": [ { "item": "stick", "count": 12 }, { "item": "pine_bough", "count": 24 }, { "item": "withered", "count": 80 } ]
},
"bash": {
"str_min": 4,
"str_max": 60,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"floor_bedding_warmth": 800,
"comfort": 1,
"connect_groups": "INDOORFLOOR",
"flags": [ "CONTAINER", "FLAMMABLE_ASH", "REDUCE_SCENT", "INDOORS", "MOUNTABLE", "HIDE_PLACE", "EASY_DECONSTRUCT", "NO_SIGHT" ],
"flags": [ "CONTAINER", "FLAMMABLE_ASH", "REDUCE_SCENT", "INDOORS", "MOUNTABLE", "HIDE_PLACE", "NO_SIGHT" ],
"bash": {
"str_min": 4,
"str_max": 60,
Expand Down
12 changes: 1 addition & 11 deletions data/mods/Xedra_Evolved/furniture_and_terrain/terrain-flora.json
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,7 @@
"coverage": 80,
"floor_bedding_warmth": 2000,
"comfort": 3,
"flags": [
"TRANSPARENT",
"CONTAINER",
"FLAMMABLE_ASH",
"THIN_OBSTACLE",
"REDUCE_SCENT",
"INDOORS",
"MOUNTABLE",
"HIDE_PLACE",
"EASY_DECONSTRUCT"
],
"flags": [ "TRANSPARENT", "CONTAINER", "FLAMMABLE_ASH", "THIN_OBSTACLE", "REDUCE_SCENT", "INDOORS", "MOUNTABLE", "HIDE_PLACE" ],
"bash": {
"str_min": 12,
"str_max": 60,
Expand Down
6 changes: 5 additions & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2045,8 +2045,12 @@ void construct::do_turn_deconstruct( const tripoint_bub_ms &p, Character &who )

auto deconstruct_items = []( const item_group_id & drop_group ) {
std::string ret;
const Item_spawn_data *spawn_data = item_group::spawn_data_from_group( drop_group );
if( spawn_data == nullptr ) {
return ret;
}
const std::map<const itype *, std::pair<int, int>> deconstruct_items =
item_group::spawn_data_from_group( drop_group )->every_item_min_max();
spawn_data->every_item_min_max();
for( const auto &deconstruct_item : deconstruct_items ) {
const int &min = deconstruct_item.second.first;
const int &max = deconstruct_item.second.second;
Expand Down
4 changes: 4 additions & 0 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,10 @@ void ter_t::check() const
debugmsg( "ter %s has invalid emission %s set", id.c_str(), e.str().c_str() );
}
}
if( has_flag( ter_furn_flag::TFLAG_EASY_DECONSTRUCT ) && !deconstruct.can_do ) {
debugmsg( "ter %s has EASY_DECONSTRUCT flag but cannot be deconstructed",
id.c_str(), deconstruct.drop_group.c_str() );
}
}

furn_t::furn_t() : open( furn_str_id::NULL_ID() ), close( furn_str_id::NULL_ID() ) {}
Expand Down
Loading