Skip to content

Commit 9fb0824

Browse files
authored
Merge pull request CleverRaven#68226 from Kamayana/aim_move_all_fixes
[AIM] Make Move All actually move as much as it can
2 parents 8031965 + af95378 commit 9fb0824

12 files changed

+312
-100
lines changed

src/activity_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4391,7 +4391,7 @@ void insert_item_activity_actor::finish( player_activity &act, Character &who )
43914391

43924392
if( !ret.success() ) {
43934393
success = false;
4394-
std::string error = !ret.str().empty() ?
4394+
std::string error = ret.str().empty() ?
43954395
//~ %1$s: item we failed to put in the container, %2$s: container to put item in
43964396
string_format( _( "Could not put %1$s into %2$s." ),
43974397
it.tname(), holster->tname() ) :

src/advanced_inv.cpp

Lines changed: 233 additions & 74 deletions
Large diffs are not rendered by default.

src/advanced_inv.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,13 @@ class advanced_inventory
149149

150150
bool move_all_items();
151151
/**
152-
* Fills drop_or_stash_item_info lists with the current contents of the active pane, for use with move_all_items.
153-
* @param player_character Reference to the player character.
154-
* @param spane Reference to the active AIM pane.
155-
* @param item_list Reference to the list to fill with items.
156-
* @param fav_list Reference to the list to fill with favorited items.
157-
* @param filter_buckets Whether to skip over containers that would spill in certain locations.
158-
* @return a string description of why some items were skipped, if any.
152+
* Fills drop_or_stash_item_info vectors with the contents of the AIM's panes, for use with move_all_items.
159153
*/
160-
std::string fill_lists_with_pane_items( side &p, Character &player_character,
161-
std::vector<drop_or_stash_item_info> &item_list,
162-
std::vector<drop_or_stash_item_info> &fav_list, bool filter_buckets );
154+
bool fill_lists_with_pane_items( Character &player_character, advanced_inv_sortby sort_priority,
155+
advanced_inventory_pane &spane, advanced_inventory_pane &dpane,
156+
std::vector<drop_or_stash_item_info> &item_list,
157+
std::vector<drop_or_stash_item_info> &fav_list, bool forbid_buckets );
158+
163159
// Returns the x coordinate where the header started. The header is
164160
// displayed right of it, everything left of it is till free.
165161
int print_header( advanced_inventory_pane &pane, aim_location sel );

src/advanced_inv_area.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,6 @@ void advanced_inv_area::init()
179179
}
180180
}
181181

182-
units::volume advanced_inv_area::free_volume( bool in_vehicle ) const
183-
{
184-
// should be a specific location instead
185-
cata_assert( id != AIM_ALL );
186-
if( id == AIM_INVENTORY || id == AIM_WORN ) {
187-
return get_player_character().free_space();
188-
} else if( in_vehicle ) {
189-
return get_vehicle_stack().free_volume();
190-
} else {
191-
return get_map().free_volume( pos );
192-
}
193-
}
194-
195182
bool advanced_inv_area::is_same( const advanced_inv_area &other ) const
196183
{
197184
// All locations (sans the below) are compared by the coordinates,

src/advanced_inv_area.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ class advanced_inv_area
9393

9494
template <typename T>
9595
advanced_inv_area::itemstack i_stacked( T items );
96-
// if you want vehicle cargo, specify so via `in_vehicle'
97-
units::volume free_volume( bool in_vehicle = false ) const;
9896
int get_item_count() const;
9997
// Other area is actually the same item source, e.g. dragged vehicle to the south and AIM_SOUTH
10098
bool is_same( const advanced_inv_area &other ) const;

src/advanced_inv_pane.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,40 @@ advanced_inv_listitem *advanced_inventory_pane::get_cur_item_ptr()
430430
return &items[index];
431431
}
432432

433+
units::volume advanced_inventory_pane::free_volume( const advanced_inv_area &square ) const
434+
{
435+
// should be a specific location instead
436+
cata_assert( area != AIM_ALL );
437+
if( area == AIM_CONTAINER ) {
438+
if( !container ) {
439+
return 0_ml;
440+
}
441+
return container->get_remaining_capacity();
442+
} else if( area == AIM_INVENTORY || area == AIM_WORN ) {
443+
return get_player_character().free_space();
444+
} else if( in_vehicle() ) {
445+
return square.get_vehicle_stack().free_volume();
446+
} else {
447+
return get_map().free_volume( square.pos );
448+
}
449+
}
450+
451+
units::mass advanced_inventory_pane::free_weight_capacity() const
452+
{
453+
// should be a specific location instead
454+
cata_assert( area != AIM_ALL );
455+
if( area == AIM_CONTAINER ) {
456+
if( !container ) {
457+
return 0_gram;
458+
}
459+
return container->get_remaining_weight_capacity();
460+
} else if( area == AIM_INVENTORY || area == AIM_WORN ) {
461+
return get_player_character().free_weight_capacity();
462+
} else {
463+
return units::mass_max;
464+
}
465+
}
466+
433467
void advanced_inventory_pane::set_filter( const std::string &new_filter )
434468
{
435469
if( filter == new_filter ) {

src/advanced_inv_pane.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ class advanced_inventory_pane
127127
* item in @ref items.
128128
*/
129129
advanced_inv_listitem *get_cur_item_ptr();
130+
/**
131+
* @return free volume capacity of the pane's container or area
132+
*/
133+
units::volume free_volume( const advanced_inv_area &square ) const;
134+
/**
135+
* @return free weight capacity of the pane's container or area
136+
*/
137+
units::mass free_weight_capacity() const;
130138
/**
131139
* Set the filter string, disables filtering when the filter string is empty.
132140
*/

src/character.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8560,6 +8560,14 @@ units::volume Character::free_space() const
85608560
return volume_capacity;
85618561
}
85628562

8563+
units::mass Character::free_weight_capacity() const
8564+
{
8565+
units::mass weight_capacity = 0_gram;
8566+
weight_capacity += weapon.get_remaining_weight_capacity();
8567+
weight_capacity += worn.free_weight_capacity();
8568+
return weight_capacity;
8569+
}
8570+
85638571
units::volume Character::holster_volume() const
85648572
{
85658573
units::volume holster_volume = 0_ml;

src/character.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,7 @@ class Character : public Creature, public visitable
22022202
units::volume volume_capacity_with_tweaks( const std::vector<std::pair<item_location, int>>
22032203
&locations ) const;
22042204
units::volume free_space() const;
2205+
units::mass free_weight_capacity() const;
22052206
/**
22062207
* Returns the total volume of all worn holsters.
22072208
*/

src/character_attire.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,15 @@ units::volume outfit::free_space() const
16131613
return volume_capacity;
16141614
}
16151615

1616+
units::mass outfit::free_weight_capacity() const
1617+
{
1618+
units::mass weight_capacity = 0_gram;
1619+
for( const item &w : worn ) {
1620+
weight_capacity += w.get_remaining_weight_capacity();
1621+
}
1622+
return weight_capacity;
1623+
}
1624+
16161625
units::volume outfit::holster_volume() const
16171626
{
16181627
units::volume ret = 0_ml;

0 commit comments

Comments
 (0)