Skip to content

Commit

Permalink
use pockets instead
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Mar 15, 2024
1 parent 3a27036 commit 5a82093
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
18 changes: 13 additions & 5 deletions data/json/items/containers/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,28 @@
"id": "outfit_storage",
"type": "TOOL",
"category": "container",
"name": { "str": "Set of clothes" },
"name": { "str": "set of clothes", "str_pl": "sets of clothes" },
"description": "A bundle of presses, coat hangars, and other miscellaneous items needed to store and keep a good change of clothes. You can interact with it to swap to the clothes it's currently containing, or disassemble it to get the clothes back.",
"//": "The below weight and volume values are necessary to make sure you can't make quantum storage.",
"weight": "100 kg",
"volume": "100 L",
"weight": "1 kg",
"volume": "1 L",
"longest_side": "150 cm",
"price": 0,
"price_postapoc": 0,
"to_hit": -3,
"use_action": [ "CHANGE_OUTFIT" ],
"material": [ "plastic" ],
"pocket_data": [
{
"pocket_type": "CONTAINER",
"max_contains_volume": "100 L",
"max_contains_weight": "100 kg",
"rigid": false,
"moves": 1000
}
],
"symbol": "#",
"color": "black",
"flags": [ "SINGLE_USE", "NO_SALVAGE" ]
"flags": [ "SINGLE_USE", "NO_SALVAGE", "NO_RELOAD" ]
},
{
"id": "box_paper_small",
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ class Character : public Creature, public visitable
* @param interactive Alert player and drain moves if true.
*/
std::optional<std::list<item>::iterator>
wear( item_location item_wear, bool interactive = true, bool no_remove = false );
wear( item_location item_wear, bool interactive = true );

/** Used for eating object at a location. Removes item if all of it was consumed.
* @returns trinary enum NONE, SOME or ALL amount consumed.
Expand Down
4 changes: 1 addition & 3 deletions src/character_attire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Character::wear( int pos, bool interactive )
}

std::optional<std::list<item>::iterator>
Character::wear( item_location item_wear, bool interactive, bool no_remove )
Character::wear( item_location item_wear, bool interactive )
{
item to_wear = *item_wear;
if( is_worn( to_wear ) ) {
Expand All @@ -254,8 +254,6 @@ Character::wear( item_location item_wear, bool interactive, bool no_remove )
if( &to_wear == &weapon ) {
weapon = item();
was_weapon = true;
} else if( no_remove ) {
was_weapon = false;
} else if( has_item( to_wear ) ) {
remove_item( to_wear );
was_weapon = false;
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ ret_val<void> item::put_in( const item &payload, pocket_type pk_type,
void item::force_insert_item( const item &it, pocket_type pk_type )
{
contents.force_insert_item( it, pk_type );
update_inherited_flags();
on_contents_changed();
}

void item::set_var( const std::string &name, const int value )
Expand Down
27 changes: 12 additions & 15 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8607,30 +8607,27 @@ std::optional<int> iuse::change_outfit( Character *p, item *it, const tripoint &
map &here = get_map();

// First, make a new outfit and shove all our existing clothes into it.
item new_outfit( "outfit_storage" );
item new_outfit( it->typeId() );
item_location ground = here.add_item_ret_loc( there, new_outfit );
// Taken-off items are put in this temporary list, then naturally deleted from the world when the function returns.
std::list<item> it_list;
for( item_location &worn_item : p->get_visible_worn_items() ) {
item outfit_component( *worn_item );
if( p->takeoff( worn_item, &it_list ) ) {
// Exact copies of our removed clothes are safely stored in the components.
ground->components.add( outfit_component );
ground->force_insert_item( outfit_component, pocket_type::CONTAINER );
}
}

// Now we have to take components out of the one we activated
for( auto &component_list : it->components ) {
for( item component : component_list.second ) {
auto ret = p->can_wear( component );
if( ret.success() ) {
item_location new_clothes( *p, &component );
p->wear( new_clothes, true, true );
} else {
// For some reason we couldn't wear this item. Maybe the player mutated in the meanwhile, but
// drop the item instead of deleting it.
here.add_item( there, component );
}
// Now we have to take clothes out of the one we activated
for( item *component : it->all_items_top() ) {
auto ret = p->can_wear( *component );
if( ret.success() ) {
item_location new_clothes( *p, component );
p->wear( new_clothes );
} else {
// For some reason we couldn't wear this item. Maybe the player mutated in the meanwhile, but
// drop the item instead of deleting it.
here.add_item( there, *component );
}
}

Expand Down

0 comments on commit 5a82093

Please sign in to comment.