Skip to content

Commit

Permalink
split large butcher result stacks to max 1000 liter items
Browse files Browse the repository at this point in the history
  • Loading branch information
mqrause committed Nov 21, 2022
1 parent f6e4f2f commit 5e17019
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,35 @@ static double butchery_dissect_yield_mult( int skill_level, int dex, int tool_qu
0.2 * clamp( dex_score, 0.0, 1.0 );
}

static std::vector<item> create_charge_items( const itype *drop, int count,
const harvest_entry &entry, const item *corpse_item, const Character &you )
{
std::vector<item> objs;
while( count > 0 ) {
item obj( drop, calendar::turn, 1 );
obj.charges = std::min( count, 1000_liter / obj.volume() );
count -= obj.charges;

if( obj.has_temperature() ) {
obj.set_item_temperature( corpse_item->temperature );
if( obj.goes_bad() ) {
obj.set_rot( corpse_item->get_rot() );
}
}
for( const flag_id &flg : entry.flags ) {
obj.set_flag( flg );
}
for( const fault_id &flt : entry.faults ) {
obj.faults.emplace( flt );
}
if( !you.backlog.empty() && you.backlog.front().id() == ACT_MULTIPLE_BUTCHER ) {
obj.set_var( "activity_var", you.name );
}
objs.push_back( obj );
}
return objs;
}

// Returns false if the calling function should abort
static bool butchery_drops_harvest( item *corpse_item, const mtype &mt, Character &you,
butcher_type action )
Expand Down Expand Up @@ -948,23 +977,10 @@ static bool butchery_drops_harvest( item *corpse_item, const mtype &mt, Characte
liquid_handler::handle_all_liquid( obj, 1 );
}
} else if( drop->count_by_charges() ) {
item obj( drop, calendar::turn, roll );
if( obj.has_temperature() ) {
obj.set_item_temperature( corpse_item->temperature );
if( obj.goes_bad() ) {
obj.set_rot( corpse_item->get_rot() );
}
}
for( const flag_id &flg : entry.flags ) {
obj.set_flag( flg );
}
for( const fault_id &flt : entry.faults ) {
obj.faults.emplace( flt );
}
if( !you.backlog.empty() && you.backlog.front().id() == ACT_MULTIPLE_BUTCHER ) {
obj.set_var( "activity_var", you.name );
std::vector<item> objs = create_charge_items( drop, roll, entry, corpse_item, you );
for( item obj : objs ) {
here.add_item_or_charges( you.pos(), obj );
}
here.add_item_or_charges( you.pos(), obj );
} else {
item obj( drop, calendar::turn );
obj.set_mtype( &mt );
Expand Down

0 comments on commit 5e17019

Please sign in to comment.