Skip to content

Commit

Permalink
Merge pull request #40296 from BevapDin/wlf
Browse files Browse the repository at this point in the history
Fix map_cursor containing local coordinates
  • Loading branch information
ZhilkinSerg authored May 8, 2020
2 parents dc9ad87 + b0f6766 commit 5a64d75
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
28 changes: 12 additions & 16 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,22 +984,18 @@ static bool are_requirements_nearby( const std::vector<tripoint> &loot_spots,
inventory temp_inv;
units::volume volume_allowed = p.volume_capacity() - p.volume_carried();
units::mass weight_allowed = p.weight_capacity() - p.weight_carried();
const bool check_weight = p.backlog.front().id() == ACT_MULTIPLE_FARM ||
activity_to_restore == ACT_MULTIPLE_FARM ||
p.backlog.front().id() == ACT_MULTIPLE_CHOP_PLANKS ||
activity_to_restore == ACT_MULTIPLE_CHOP_PLANKS ||
p.backlog.front().id() == ACT_MULTIPLE_BUTCHER ||
activity_to_restore == ACT_MULTIPLE_BUTCHER ||
p.backlog.front().id() == ACT_VEHICLE_DECONSTRUCTION ||
activity_to_restore == ACT_VEHICLE_DECONSTRUCTION ||
p.backlog.front().id() == ACT_VEHICLE_REPAIR ||
activity_to_restore == ACT_VEHICLE_REPAIR ||
p.backlog.front().id() == ACT_MULTIPLE_CHOP_TREES ||
activity_to_restore == ACT_MULTIPLE_CHOP_TREES ||
p.backlog.front().id() == ACT_MULTIPLE_FISH ||
activity_to_restore == ACT_MULTIPLE_FISH ||
p.backlog.front().id() == ACT_MULTIPLE_MINE ||
activity_to_restore == ACT_MULTIPLE_MINE;
static const auto check_weight_if = []( const activity_id & id ) {
return id == ACT_MULTIPLE_FARM ||
id == ACT_MULTIPLE_CHOP_PLANKS ||
id == ACT_MULTIPLE_BUTCHER ||
id == ACT_VEHICLE_DECONSTRUCTION ||
id == ACT_VEHICLE_REPAIR ||
id == ACT_MULTIPLE_CHOP_TREES ||
id == ACT_MULTIPLE_FISH ||
id == ACT_MULTIPLE_MINE;
};
const bool check_weight = check_weight_if( activity_to_restore ) || ( !p.backlog.empty() &&
check_weight_if( p.backlog.front().id() ) );
bool found_welder = false;
for( item *elem : p.inv_dump() ) {
if( elem->has_quality( qual_WELD ) ) {
Expand Down
7 changes: 7 additions & 0 deletions src/map_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ cata::optional<tripoint> random_point( const tripoint_range &range,
}
return random_entry( suitable );
}

map_cursor::map_cursor( const tripoint &pos ) : pos_( g ? g->m.getabs( pos ) : pos ) { }

map_cursor::operator tripoint() const
{
return g ? g->m.getlocal( pos_ ) : pos_;
}
8 changes: 6 additions & 2 deletions src/map_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
#include "point.h"
#include "visitable.h"

class map_cursor : public tripoint, public visitable<map_cursor>
class map_cursor : public visitable<map_cursor>
{
private:
tripoint pos_;

public:
map_cursor( const tripoint &pos ) : tripoint( pos ) {}
map_cursor( const tripoint &pos );
operator tripoint() const;
};

class map_selector : public visitable<map_selector>
Expand Down

0 comments on commit 5a64d75

Please sign in to comment.