Skip to content

Commit

Permalink
Merge pull request #39100 from AMurkin/remove-redundant-g-param
Browse files Browse the repository at this point in the history
Remove redundant `game g` parameter in two functions
  • Loading branch information
ZhilkinSerg authored Mar 29, 2020
2 parents 5a52d64 + 14724a4 commit f654d5e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4569,27 +4569,27 @@ template player *game::critter_by_id<player>( const character_id & );
template npc *game::critter_by_id<npc>( const character_id & );
template Creature *game::critter_by_id<Creature>( const character_id & );

static bool can_place_monster( game &g, const monster &mon, const tripoint &p )
static bool can_place_monster( const monster &mon, const tripoint &p )
{
if( const monster *const critter = g.critter_at<monster>( p ) ) {
if( const monster *const critter = g->critter_at<monster>( p ) ) {
// Creature_tracker handles this. The hallucination monster will simply vanish
if( !critter->is_hallucination() ) {
return false;
}
}
// Although monsters can sometimes exist on the same place as a Character (e.g. ridden horse),
// it is usually wrong. So don't allow it.
if( g.critter_at<Character>( p ) ) {
if( g->critter_at<Character>( p ) ) {
return false;
}
return mon.will_move_to( p );
}

static cata::optional<tripoint> choose_where_to_place_monster( game &g, const monster &mon,
static cata::optional<tripoint> choose_where_to_place_monster( const monster &mon,
const tripoint_range &range )
{
return random_point( range, [&]( const tripoint & p ) {
return can_place_monster( g, mon, p );
return can_place_monster( mon, p );
} );
}

Expand Down Expand Up @@ -4617,14 +4617,14 @@ monster *game::place_critter_around( const shared_ptr_fast<monster> &mon,
const int radius )
{
cata::optional<tripoint> where;
if( can_place_monster( *this, *mon, center ) ) {
if( can_place_monster( *mon, center ) ) {
where = center;
}

// This loop ensures the monster is placed as close to the center as possible,
// but all places that equally far from the center have the same probability.
for( int r = 1; r <= radius && !where; ++r ) {
where = choose_where_to_place_monster( *this, *mon, m.points_in_radius( center, r ) );
where = choose_where_to_place_monster( *mon, m.points_in_radius( center, r ) );
}

if( !where ) {
Expand All @@ -4646,7 +4646,7 @@ monster *game::place_critter_within( const mtype_id &id, const tripoint_range &r
monster *game::place_critter_within( const shared_ptr_fast<monster> &mon,
const tripoint_range &range )
{
const cata::optional<tripoint> where = choose_where_to_place_monster( *this, *mon, range );
const cata::optional<tripoint> where = choose_where_to_place_monster( *mon, range );
if( !where ) {
return nullptr;
}
Expand Down

0 comments on commit f654d5e

Please sign in to comment.