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 limit of item count per tile #35411

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 4 additions & 33 deletions src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,9 @@ void advanced_inventory::redraw_pane( side p )
// draw a darker border around the inactive pane
draw_border( w, active ? BORDER_COLOR : c_dark_gray );
mvwprintw( w, point( 3, 0 ), _( "< [s]ort: %s >" ), get_sortname( pane.sortby ) );
int max = square.max_size;
if( max > 0 ) {
int itemcount = square.get_item_count();
int fmtw = 7 + ( itemcount > 99 ? 3 : itemcount > 9 ? 2 : 1 ) +
( max > 99 ? 3 : max > 9 ? 2 : 1 );
mvwprintw( w, point( w_width / 2 - fmtw, 0 ), "< %d/%d >", itemcount, max );
}
int itemcount = square.get_item_count();
int fmtw = 7 + ( itemcount > 99 ? 3 : itemcount > 9 ? 2 : 1 );
mvwprintw( w, point( w_width / 2 - fmtw, 0 ), "< %d >", itemcount );

const char *fprefix = _( "[F]ilter" );
const char *fsuffix = _( "[R]eset" );
Expand Down Expand Up @@ -1509,11 +1505,7 @@ bool advanced_inventory::query_destination( aim_location &def )
}
for( auto &ordered_loc : ordered_locs ) {
auto &s = squares[ordered_loc];
const int size = s.get_item_count();
std::string prefix = string_format( "%2d/%d", size, MAX_ITEM_IN_SQUARE );
if( size >= MAX_ITEM_IN_SQUARE ) {
prefix += _( " (FULL)" );
}
std::string prefix = string_format( "%d", s.get_item_count() );
menu.addentry( ordered_loc,
s.canputitems() && s.id != panes[src].get_area(),
get_location_key( ordered_loc )[0],
Expand Down Expand Up @@ -1612,27 +1604,6 @@ bool advanced_inventory::query_charges( aim_location destarea, const advanced_in
}
amount = std::min( room_for, amount );
}
// Map and vehicles have a maximal item count, check that. Inventory does not have this.
if( destarea != AIM_INVENTORY &&
destarea != AIM_WORN &&
destarea != AIM_CONTAINER ) {
const int cntmax = p.max_size - p.get_item_count();
// For items counted by charges, adding it adds 0 items if something there stacks with it.
const bool adds0 = by_charges && std::any_of( panes[dest].items.begin(), panes[dest].items.end(),
[&it]( const advanced_inv_listitem & li ) {
return li.is_item_entry() && li.items.front()->stacks_with( it );
} );
if( cntmax <= 0 && !adds0 ) {
popup( _( "Destination area has too many items. Remove some first." ) );
redraw = true;
return false;
}
// Items by charge count as a single item, regardless of the charges. As long as the
// destination can hold another item, one can move all charges.
if( !by_charges ) {
amount = std::min( cntmax, amount );
}
}
// Inventory has a weight capacity, map and vehicle don't have that
if( destarea == AIM_INVENTORY || destarea == AIM_WORN ) {
const units::mass unitweight = it.weight() / ( by_charges ? it.charges : 1 );
Expand Down
2 changes: 0 additions & 2 deletions src/advanced_inv_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ void advanced_inv_area::init()
if( vstor >= 0 ) {
desc[0] = veh->name;
canputitemsloc = true;
max_size = MAX_ITEM_IN_VEHICLE_STORAGE;
} else {
veh = nullptr;
canputitemsloc = false;
Expand Down Expand Up @@ -128,7 +127,6 @@ void advanced_inv_area::init()
vstor = -1;
}
canputitemsloc = can_store_in_vehicle() || g->m.can_put_items_ter_furn( pos );
max_size = MAX_ITEM_IN_SQUARE;
if( can_store_in_vehicle() ) {
desc[1] = vpart_position( *veh, vstor ).get_label().value_or( "" );
}
Expand Down
4 changes: 1 addition & 3 deletions src/advanced_inv_area.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class advanced_inv_area
// total volume and weight of items currently there
units::volume volume;
units::mass weight;
// maximal count / volume of items there.
int max_size;
// appears as part of the legend at the top right
const std::string minimapname;
// user commant that corresponds to this location
Expand All @@ -87,7 +85,7 @@ class advanced_inv_area
std::string actionname, aim_location relative_location ) : id( id ),
hscreen( hscreenx, hscreeny ), off( off ), name( name ), shortname( shortname ),
canputitemsloc( false ), veh( nullptr ), vstor( -1 ), volume( 0_ml ),
weight( 0_gram ), max_size( 0 ), minimapname( minimapname ), actionname( actionname ),
weight( 0_gram ), minimapname( minimapname ), actionname( actionname ),
relative_location( relative_location ) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8253,7 +8253,7 @@ void game::butcher()

// Magic indices for special butcher options
enum : int {
MULTISALVAGE = MAX_ITEM_IN_SQUARE + 1,
MULTISALVAGE = std::numeric_limits<int>::max() - 16,
MULTIBUTCHER,
MULTIDISASSEMBLE_ONE,
MULTIDISASSEMBLE_ALL,
Expand Down
4 changes: 0 additions & 4 deletions src/game_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#define BLINK_SPEED 300
#define EXPLOSION_MULTIPLIER 7

// Really just a sanity check for functions not tested beyond this. in theory 4096 works (`InvletInvlet)
#define MAX_ITEM_IN_SQUARE 4096
// no reason to differ
#define MAX_ITEM_IN_VEHICLE_STORAGE MAX_ITEM_IN_SQUARE
// only can wear a maximum of two of any type of clothing
#define MAX_WORN_PER_TYPE 2

Expand Down
7 changes: 0 additions & 7 deletions src/item_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ units::volume item_stack::stored_volume() const

int item_stack::amount_can_fit( const item &it ) const
{
// Without stacking charges, would we violate the count limit?
const bool violates_count = size() >= static_cast<size_t>( count_limit() );
const item *here = it.count_by_charges() ? stacks_with( it ) : nullptr;

if( violates_count && !here ) {
return 0;
}
// Call max because a tile may have been overfilled to begin with (e.g. #14115)
const int ret = std::max( 0, it.charges_per_volume( free_volume() ) );
return it.count_by_charges() ? std::min( ret, it.charges ) : ret;
Expand Down
2 changes: 0 additions & 2 deletions src/item_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class item_stack
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;

/** Maximum number of items allowed here */
virtual int count_limit() const = 0;
/** Maximum volume allowed here */
virtual units::volume max_volume() const = 0;
/** Total volume of the items here */
Expand Down
2 changes: 1 addition & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4377,7 +4377,7 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow )

// Checks if sufficient space at tile to add item
auto valid_limits = [&]( const tripoint & e ) {
return obj.volume() <= free_volume( e ) && i_at( e ).size() < MAX_ITEM_IN_SQUARE;
return obj.volume() <= free_volume( e );
};

// Performs the actual insertion of the object onto the map
Expand Down
3 changes: 0 additions & 3 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ class map_stack : public item_stack
item_stack( newstack ), location( newloc ), myorigin( neworigin ) {}
void insert( const item &newitem ) override;
iterator erase( const_iterator it ) override;
int count_limit() const override {
return MAX_ITEM_IN_SQUARE;
}
units::volume max_volume() const override;
};

Expand Down
3 changes: 0 additions & 3 deletions src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ class vehicle_stack : public item_stack
item_stack( newstack ), location( newloc ), myorigin( neworigin ), part_num( part ) {}
iterator erase( const_iterator it ) override;
void insert( const item &newitem ) override;
int count_limit() const override {
return MAX_ITEM_IN_VEHICLE_STORAGE;
}
units::volume max_volume() const override;
};

Expand Down