Skip to content

Commit

Permalink
Use the z-level from the tinymap instead of passing it as parameter e…
Browse files Browse the repository at this point in the history
…xplicitly.
  • Loading branch information
BevapDin committed Sep 23, 2019
1 parent e77c467 commit ec771e2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/mission_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void mission_start::kill_horde_master( mission *miss )
* 3) A spot near the center of the tile that is not a console
* 4) A random spot near the center of the tile.
*/
static tripoint find_potential_computer_point( const tinymap &compmap, int z )
static tripoint find_potential_computer_point( const tinymap &compmap )
{
constexpr int rng_x_min = 10;
constexpr int rng_x_max = SEEX * 2 - 11;
Expand All @@ -145,7 +145,7 @@ static tripoint find_potential_computer_point( const tinymap &compmap, int z )
for( int x = 0; x < SEEX * 2; x++ ) {
for( int y = 0; y < SEEY * 2; y++ ) {
if( compmap.ter( point( x, y ) ) == t_console_broken ) {
broken.emplace_back( x, y, z );
broken.emplace_back( x, y, compmap.get_abs_sub().z );
} else if( broken.empty() && compmap.ter( point( x, y ) ) == t_floor &&
compmap.furn( point( x, y ) ) == f_null ) {
bool okay = false;
Expand All @@ -154,7 +154,7 @@ static tripoint find_potential_computer_point( const tinymap &compmap, int z )
for( int y2 = y - 1; y2 <= y + 1 && !okay; y2++ ) {
if( compmap.furn( point( x2, y2 ) ) == f_bed || compmap.furn( point( x2, y2 ) ) == f_dresser ) {
okay = true;
potential.emplace_back( x, y, z );
potential.emplace_back( x, y, compmap.get_abs_sub().z );
}
if( compmap.has_flag_ter( "WALL", point( x2, y2 ) ) ) {
wall++;
Expand All @@ -166,12 +166,12 @@ static tripoint find_potential_computer_point( const tinymap &compmap, int z )
compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), SOUTH ) &&
compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), WEST ) &&
compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), EAST ) ) {
potential.emplace_back( x, y, z );
potential.emplace_back( x, y, compmap.get_abs_sub().z );
}
}
} else if( broken.empty() && potential.empty() && x >= rng_x_min && x <= rng_x_max
&& y >= rng_y_min && y <= rng_y_max && compmap.ter( point( x, y ) ) != t_console ) {
last_resort.emplace_back( x, y, z );
last_resort.emplace_back( x, y, compmap.get_abs_sub().z );
}
}
}
Expand All @@ -183,7 +183,8 @@ static tripoint find_potential_computer_point( const tinymap &compmap, int z )
used = &last_resort;
}
// if there's no possible location, then we have to overwrite an existing console...
const tripoint fallback( rng( rng_x_min, rng_x_max ), rng( rng_y_min, rng_y_max ), z );
const tripoint fallback( rng( rng_x_min, rng_x_max ), rng( rng_y_min, rng_y_max ),
compmap.get_abs_sub().z );
return random_entry( *used, fallback );
}

Expand Down Expand Up @@ -227,7 +228,7 @@ void mission_start::place_npc_software( mission *miss )
oter_id oter = overmap_buffer.ter( place );
if( is_ot_match( "house", oter, ot_match_type::prefix ) ||
is_ot_match( "s_pharm", oter, ot_match_type::type ) || oter == "" ) {
comppoint = find_potential_computer_point( compmap, place.z );
comppoint = find_potential_computer_point( compmap );
}

compmap.ter_set( comppoint, t_console );
Expand Down Expand Up @@ -643,7 +644,7 @@ void static create_lab_consoles( mission *miss, const tripoint &place, const std
tinymap compmap;
compmap.load( tripoint( om_place.x * 2, om_place.y * 2, om_place.z ), false );

tripoint comppoint = find_potential_computer_point( compmap, om_place.z );
tripoint comppoint = find_potential_computer_point( compmap );

computer *tmpcomp = compmap.add_computer( comppoint, _( comp_name ), security );
tmpcomp->mission_id = miss->get_id();
Expand Down

0 comments on commit ec771e2

Please sign in to comment.