Skip to content

Commit

Permalink
Simply construction logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Sep 9, 2021
1 parent aa511c4 commit 9043453
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 38 deletions.
12 changes: 0 additions & 12 deletions data/json/construction.json
Original file line number Diff line number Diff line change
Expand Up @@ -2791,18 +2791,6 @@
"post_special": "done_vehicle",
"vehicle_start": true
},
{
"type": "construction",
"id": "constr_power_grid",
"group": "start_power_grid",
"//": "no components required, they are filled in at runtime based on the vehicle parts that can be used to start a power grid",
"category": "OTHER",
"required_skills": [ [ "electronics", 0 ] ],
"time": "10 m",
"//2": "no components required, they are filled in at runtime based on the vehicle parts that can be used to start a power grid",
"pre_special": "check_empty",
"post_special": "done_vehicle"
},
{
"type": "construction",
"id": "constr_barricade_road",
Expand Down
5 changes: 0 additions & 5 deletions data/json/construction_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,6 @@
"id": "start_vehicle_construction",
"name": "Start Vehicle Construction"
},
{
"type": "construction_group",
"id": "start_power_grid",
"name": "Start Power Grid"
},
{
"type": "construction_group",
"id": "take_paint_off_pavement",
Expand Down
11 changes: 1 addition & 10 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1805,17 +1805,12 @@ std::vector<std::string> construction::get_folded_time_string( int width ) const
void finalize_constructions()
{
std::vector<item_comp> frame_items;
std::vector<item_comp> power_grid_items;
for( const auto &e : vpart_info::all() ) {
const vpart_info &vp = e.second;
if( !vp.has_flag( flag_INITIAL_PART ) ) {
continue;
}
if( vp.has_flag( VPFLAG_APPLIANCE ) ) {
power_grid_items.emplace_back( vp.base_item, 1 );
} else {
frame_items.emplace_back( vp.base_item, 1 );
}
frame_items.emplace_back( vp.base_item, 1 );
}

if( frame_items.empty() ) {
Expand All @@ -1830,10 +1825,6 @@ void finalize_constructions()
if( con.vehicle_start ) {
const_cast<requirement_data &>( con.requirements.obj() ).get_components().push_back( frame_items );
}
if( con.str_id == construction_str_id( "constr_power_grid" ) ) {
const_cast<requirement_data &>( con.requirements.obj() ).get_components().push_back(
power_grid_items );
}
bool is_valid_construction_category = false;
for( const construction_category &cc : construction_categories::get_all() ) {
if( con.category == cc.id ) {
Expand Down
11 changes: 2 additions & 9 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,6 @@ bool veh_interact::can_self_jack()
return false;
}

bool veh_interact::appliance_reqs_met( const vpart_info &info )
{
bool is_appliance = veh->has_part( flag_APPLIANCE, false );
bool installing_appliance = info.has_flag( VPFLAG_APPLIANCE );
return ( is_appliance && installing_appliance ) || ( !is_appliance && !installing_appliance );
}

bool veh_interact::update_part_requirements()
{
if( sel_vpart_info == nullptr ) {
Expand Down Expand Up @@ -2264,7 +2257,7 @@ bool veh_interact::can_potentially_install( const vpart_info &vpart )
engine_reqs_met = engines < 2;
}

return hammerspace || ( can_make && engine_reqs_met && appliance_reqs_met( vpart ) );
return hammerspace || ( can_make && engine_reqs_met && !vpart.has_flag( VPFLAG_APPLIANCE ) );
}

/**
Expand Down Expand Up @@ -2855,7 +2848,7 @@ void veh_interact::display_list( size_t pos, const std::vector<const vpart_info
size_t page = pos / lines_per_page;
for( size_t i = page * lines_per_page; i < ( page + 1 ) * lines_per_page && i < list.size(); i++ ) {
const vpart_info &info = *list[i];
if( !appliance_reqs_met( info ) ) {
if( !info.has_flag( VPFLAG_APPLIANCE ) ) {
continue;
}

Expand Down
2 changes: 0 additions & 2 deletions src/veh_interact.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ class veh_interact

/** Returns true if the vehicle has a jack powerful enough to lift itself installed */
bool can_self_jack();

bool appliance_reqs_met( const vpart_info &info );
};

void act_vehicle_siphon( vehicle *veh );
Expand Down

0 comments on commit 9043453

Please sign in to comment.