16
16
17
17
#include " activity_actor_definitions.h"
18
18
#include " avatar.h"
19
+ #include " butchery.h"
19
20
#include " calendar.h"
20
21
#include " cata_utility.h"
21
22
#include " character.h"
78
79
#include " weather.h"
79
80
80
81
static const activity_id ACT_BUILD ( " ACT_BUILD" );
81
- static const activity_id ACT_BUTCHER_FULL ( " ACT_BUTCHER_FULL" );
82
82
static const activity_id ACT_FETCH_REQUIRED ( " ACT_FETCH_REQUIRED" );
83
83
static const activity_id ACT_FISH ( " ACT_FISH" );
84
84
static const activity_id ACT_MOVE_LOOT ( " ACT_MOVE_LOOT" );
@@ -1209,7 +1209,8 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara
1209
1209
int small_count = 0 ;
1210
1210
for ( const item &i : here.i_at ( src_loc ) ) {
1211
1211
// make sure nobody else is working on that corpse right now
1212
- if ( i.is_corpse () && !i.has_var ( " activity_var" ) ) {
1212
+ if ( i.is_corpse () &&
1213
+ ( !i.has_var ( " activity_var" ) || i.get_var ( " activity_var" ) == you.name ) ) {
1213
1214
const mtype corpse = *i.get_mtype ();
1214
1215
if ( corpse.size > creature_size::medium ) {
1215
1216
big_count += 1 ;
@@ -1219,6 +1220,9 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara
1219
1220
corpses.push_back ( i );
1220
1221
}
1221
1222
}
1223
+ if ( corpses.empty () ) {
1224
+ return activity_reason_info::fail ( do_activity_reason::NO_COMPONENTS );
1225
+ }
1222
1226
bool b_rack_present = false ;
1223
1227
for ( const tripoint_bub_ms &pt : here.points_in_radius ( src_loc, 2 ) ) {
1224
1228
if ( here.has_flag_furn ( ter_furn_flag::TFLAG_BUTCHER_EQ, pt ) ) {
@@ -1970,21 +1974,23 @@ static bool butcher_corpse_activity( Character &you, const tripoint_bub_ms &src_
1970
1974
{
1971
1975
map &here = get_map ();
1972
1976
map_stack items = here.i_at ( src_loc );
1977
+ std::vector<butchery_data> bd;
1973
1978
for ( item &elem : items ) {
1974
- if ( elem.is_corpse () && !elem.has_var ( " activity_var" ) ) {
1979
+ if ( elem.is_corpse () &&
1980
+ ( !elem.has_var ( " activity_var" ) || elem.get_var ( " activity_var" ) == you.name ) ) {
1975
1981
const mtype corpse = *elem.get_mtype ();
1976
1982
if ( corpse.size > creature_size::medium && reason != do_activity_reason::NEEDS_BIG_BUTCHERING ) {
1977
1983
continue ;
1978
1984
}
1979
1985
elem.set_var ( " activity_var" , you.name );
1980
- you.assign_activity ( ACT_BUTCHER_FULL, 0 , true );
1981
- you.activity .targets .emplace_back ( map_cursor ( src_loc ), &elem );
1982
- you.activity .placement = here.get_abs ( src_loc );
1983
- you.may_activity_occupancy_after_end_items_loc .emplace_back ( map_cursor{here.get_abs ( src_loc )},
1984
- &elem );
1985
- return true ;
1986
+ item_location corpse_loc = item_location ( map_cursor ( src_loc ), &elem );
1987
+ bd.emplace_back ( corpse_loc, butcher_type::FULL );
1986
1988
}
1987
1989
}
1990
+ if ( !bd.empty () ) {
1991
+ you.assign_activity ( butchery_activity_actor ( bd ) );
1992
+ return true ;
1993
+ }
1988
1994
return false ;
1989
1995
}
1990
1996
@@ -3486,6 +3492,11 @@ bool generic_multi_activity_handler( player_activity &act, Character &you, bool
3486
3492
}
3487
3493
// if we got here, we need to revert otherwise NPC will be stuck in AI Limbo and have a head explosion.
3488
3494
if ( you.backlog .empty () || src_set.empty () ) {
3495
+ /* *
3496
+ * This should really be a debug message, but too many places rely on this broken behavior.
3497
+ * debugmsg( "Reverting %s activity for %s, probable infinite loop", activity_to_restore.c_str(),
3498
+ * you.get_name() );
3499
+ */
3489
3500
check_npc_revert ( you );
3490
3501
if ( player_activity ( activity_to_restore ).is_multi_type () ) {
3491
3502
you.assign_activity ( activity_id::NULL_ID () );
0 commit comments