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

Fixed "Zone construction build wooden wall builds window instead. #32965" (rebased) #33673

Merged
Merged
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
8 changes: 2 additions & 6 deletions data/json/player_activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@
"type": "activity_type",
"activity_level": "ACTIVE_EXERCISE",
"verb": "constructing",
"suspendable": false,
"based_on": "neither",
"no_resume": true
"based_on": "neither"
},
{
"id": "ACT_TIDY_UP",
"type": "activity_type",
"activity_level": "MODERATE_EXERCISE",
"verb": "tidying up",
"suspendable": false,
"based_on": "neither",
"no_resume": true
"based_on": "neither"
},
{
"id": "ACT_GAME",
Expand Down
10 changes: 1 addition & 9 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3087,14 +3087,6 @@ void activity_handlers::operation_finish( player_activity *act, player *p )
act->set_to_null();
}

static bool character_has_skill_for( const player *p, const construction &con )
{
return std::all_of( con.required_skills.begin(), con.required_skills.end(),
[&]( const std::pair<skill_id, int> &pr ) {
return p->get_skill_level( pr.first ) >= pr.second;
} );
}

void activity_handlers::churn_do_turn( player_activity *act, player *p )
{
( void )act;
Expand Down Expand Up @@ -3134,7 +3126,7 @@ void activity_handlers::build_do_turn( player_activity *act, player *p )
}
// if you ( or NPC ) are finishing someone elses started construction...
const construction &built = list_constructions[pc->id];
if( !character_has_skill_for( p, built ) ) {
if( !p->meets_skill_requirements( built ) ) {
add_msg( m_info, _( "%s can't work on this construction anymore." ), p->disp_name() );
p->cancel_activity();
if( p->is_npc() ) {
Expand Down
28 changes: 26 additions & 2 deletions src/activity_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ enum do_activity_reason : int {
CAN_DO_CONSTRUCTION, // Can do construction.
CAN_DO_FETCH, // Can do fetch - this is usually the default result for fetch task
CAN_DO_PREREQ, // for constructions - cant build the main construction, but can build the pre-req
CAN_DO_PREREQ_2, // Can do the second pre-req deep below the desired one.
NO_COMPONENTS, // can't do the activity there due to lack of components /tools
NO_COMPONENTS_PREREQ, // need components to build the pre-requisite for the actual desired construction
NO_COMPONENTS_PREREQ_2, // need components to the second pre-req deep.
DONT_HAVE_SKILL, // don't have the required skill
NO_ZONE, // There is no required zone anymore
ALREADY_DONE, // the activity is done already ( maybe by someone else )
Expand All @@ -47,6 +45,32 @@ enum do_activity_reason : int {
BLOCKING_TILE // Something has made it's way onto the tile, so the activity cannot proceed
};

struct activity_reason_info {
do_activity_reason reason; //reason for success or fail
bool can_do; //is it possible to do this
cata::optional<size_t> con_idx; //construction index

activity_reason_info( do_activity_reason reason_, bool can_do_,
cata::optional<size_t> con_idx_ = cata::optional<size_t>() ) :
reason( reason_ ),
can_do( can_do_ ),
con_idx( con_idx_ )
{ }

static activity_reason_info ok( const do_activity_reason &reason_ ) {
return activity_reason_info( reason_, true );
}

static activity_reason_info build( const do_activity_reason &reason_, bool can_do_,
size_t con_idx_ ) {
return activity_reason_info( reason_, can_do_, con_idx_ );
}

static activity_reason_info fail( const do_activity_reason &reason_ ) {
return activity_reason_info( reason_, false );
}
};

int butcher_time_to_cut( const player &u, const item &corpse_item, butcher_type action );

// activity_item_handling.cpp
Expand Down
Loading