Skip to content

Commit

Permalink
Merge pull request CleverRaven#70163 from GoLoT/molle_pocket_cleanup
Browse files Browse the repository at this point in the history
Prevent cleanup of MOLLE pockets on contents update
  • Loading branch information
akrieger authored Dec 12, 2023
2 parents 178d8d2 + bdcb39c commit 5fef522
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ void item::update_modified_pockets()
std::optional<const pocket_data *> mag_or_mag_well;
std::vector<const pocket_data *> container_pockets;

// Prevent cleanup of pockets belonging to the item base type
for( const pocket_data &pocket : type->pockets ) {
if( pocket.type == pocket_type::CONTAINER ) {
container_pockets.push_back( &pocket );
Expand All @@ -1287,6 +1288,13 @@ void item::update_modified_pockets()
}
}

// Prevent cleanup of added modular pockets
for( const item *it : contents.get_added_pockets() ) {
for( const pocket_data &pocket : it->type->pockets ) {
container_pockets.push_back( &pocket );
}
}

for( const item *mod : mods() ) {
if( mod->type->mod ) {
for( const pocket_data &pocket : mod->type->mod->add_pockets ) {
Expand Down

0 comments on commit 5fef522

Please sign in to comment.