Skip to content

Commit

Permalink
within_visual_range changed to reflect usage (CleverRaven#27691)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenAudeles authored and kevingranade committed Jan 18, 2019
1 parent ed196fe commit 8c5fe5d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ static const trait_id trait_THRESH_MARLOSS( "THRESH_MARLOSS" );
static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" );

// shared utility functions
int within_visual_range( monster *z, int max_range )
bool within_visual_range( monster *z, int max_range )
{
int dist = rl_dist( z->pos(), g->u.pos() );
if( dist > max_range || !z->sees( g->u ) ) {
return -1; // Out of range
}
return dist;
return !( rl_dist( z->pos(), g->u.pos() ) > max_range || !z->sees( g->u ) );
}

bool within_target_range( const monster *const z, const Creature *const target, int range )
Expand Down Expand Up @@ -2690,7 +2686,7 @@ bool mattack::fear_paralyze( monster *z )

bool mattack::photograph( monster *z )
{
if( within_visual_range( z, 6 ) < 0 ) {
if( !within_visual_range( z, 6 ) ) {
return false;
}

Expand Down Expand Up @@ -3199,8 +3195,7 @@ bool mattack::flamethrower( monster *z )
return true;
}

int dist = within_visual_range( z, 5 );
if( dist < 0 ) {
if( !within_visual_range( z, 5 ) ) {
return false;
}

Expand Down

0 comments on commit 8c5fe5d

Please sign in to comment.