|
|
|
@ -17,16 +17,39 @@ namespace CSP {
|
|
|
|
|
extern std::unordered_set<df::coord> dignow_queue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void get_neighbours(const df::coord &map_pos, df::coord(&neighbours)[8]) {
|
|
|
|
|
neighbours[0] = map_pos;
|
|
|
|
|
neighbours[1] = map_pos;
|
|
|
|
|
neighbours[2] = map_pos;
|
|
|
|
|
neighbours[3] = map_pos;
|
|
|
|
|
neighbours[4] = map_pos;
|
|
|
|
|
neighbours[5] = map_pos;
|
|
|
|
|
neighbours[6] = map_pos;
|
|
|
|
|
neighbours[7] = map_pos;
|
|
|
|
|
neighbours[0].x--; neighbours[0].y--;
|
|
|
|
|
neighbours[1].y--;
|
|
|
|
|
neighbours[2].x++; neighbours[2].y--;
|
|
|
|
|
neighbours[3].x--;
|
|
|
|
|
neighbours[4].x++;
|
|
|
|
|
neighbours[5].x--; neighbours[5].y++;
|
|
|
|
|
neighbours[6].y++;
|
|
|
|
|
neighbours[7].x++; neighbours[7].y++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool is_dig_job(const df::job* job) {
|
|
|
|
|
return job->job_type == df::job_type::Dig || job->job_type == df::job_type::DigChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool is_channel_job(const df::job* job) {
|
|
|
|
|
return job->job_type == df::job_type::DigChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool is_dig_designation(const df::tile_designation &designation) {
|
|
|
|
|
return designation.bits.dig != df::tile_dig_designation::No;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool has_unit(const df::tile_occupancy* occupancy) {
|
|
|
|
|
return occupancy->bits.unit || occupancy->bits.unit_grounded;
|
|
|
|
|
inline bool is_channel_designation(const df::tile_designation &designation) {
|
|
|
|
|
return designation.bits.dig != df::tile_dig_designation::Channel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool is_safe_fall(const df::coord &map_pos) {
|
|
|
|
@ -65,11 +88,22 @@ inline bool is_safe_to_dig_down(const df::coord &map_pos) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool is_group_occupied(const ChannelGroups &groups, const Group &group) {
|
|
|
|
|
// return true if any tile in the group is occupied by a unit
|
|
|
|
|
return std::any_of(group.begin(), group.end(), [](const Group::key_type &pos){
|
|
|
|
|
return has_unit(Maps::getTileOccupancy(pos));
|
|
|
|
|
});
|
|
|
|
|
inline bool can_reach_designation(const df::coord &start, const df::coord &end) {
|
|
|
|
|
if (!Maps::canWalkBetween(start,end)) {
|
|
|
|
|
df::coord neighbours[8];
|
|
|
|
|
get_neighbours(end, neighbours);
|
|
|
|
|
for (auto &pos : neighbours) {
|
|
|
|
|
if (Maps::canWalkBetween(start, pos)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool has_unit(const df::tile_occupancy* occupancy) {
|
|
|
|
|
return occupancy->bits.unit || occupancy->bits.unit_grounded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool has_group_above(const ChannelGroups &groups, const df::coord &map_pos) {
|
|
|
|
@ -128,22 +162,3 @@ inline void cancel_job(df::job* job) {
|
|
|
|
|
Job::removeJob(job);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void get_neighbours(const df::coord &map_pos, df::coord(&neighbours)[8]) {
|
|
|
|
|
neighbours[0] = map_pos;
|
|
|
|
|
neighbours[1] = map_pos;
|
|
|
|
|
neighbours[2] = map_pos;
|
|
|
|
|
neighbours[3] = map_pos;
|
|
|
|
|
neighbours[4] = map_pos;
|
|
|
|
|
neighbours[5] = map_pos;
|
|
|
|
|
neighbours[6] = map_pos;
|
|
|
|
|
neighbours[7] = map_pos;
|
|
|
|
|
neighbours[0].x--; neighbours[0].y--;
|
|
|
|
|
neighbours[1].y--;
|
|
|
|
|
neighbours[2].x++; neighbours[2].y--;
|
|
|
|
|
neighbours[3].x--;
|
|
|
|
|
neighbours[4].x++;
|
|
|
|
|
neighbours[5].x--; neighbours[5].y++;
|
|
|
|
|
neighbours[6].y++;
|
|
|
|
|
neighbours[7].x++; neighbours[7].y++;
|
|
|
|
|
}
|
|
|
|
|