Skip to content

Commit

Permalink
Change ter_t_null to ter_str_id::NULL_ID()
Browse files Browse the repository at this point in the history
  • Loading branch information
Procyonae committed Apr 2, 2024
1 parent 9587732 commit 0847ee6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 39 deletions.
6 changes: 2 additions & 4 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ static const efftype_id effect_ridden( "ridden" );

static const itype_id itype_corpse( "corpse" );

static const ter_str_id ter_t_null( "t_null" );

static const trait_id trait_INATTENTIVE( "INATTENTIVE" );

static const trap_str_id tr_unfinished_construction( "tr_unfinished_construction" );
Expand Down Expand Up @@ -4846,12 +4844,12 @@ void cata_tiles::get_terrain_orientation( const tripoint &p, int &rota, int &sub
const auto ter = [&]( const tripoint & q, const bool invis ) -> ter_str_id {
const auto override_it = ter_override.find( q );
return override_it != ter_override.end() ? override_it->second.id() :
( !overridden || !invis ) ? here.ter( q ).id() : ter_t_null;
( !overridden || !invis ) ? here.ter( q ).id() : ter_str_id::NULL_ID();
};

// get terrain at x,y
const ter_id tid = ter( p, invisible[0] );
if( tid == ter_t_null ) {
if( tid == ter_str_id::NULL_ID() ) {
subtile = 0;
rota = 0;
return;
Expand Down
11 changes: 5 additions & 6 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ static const ter_str_id ter_t_floor_wax( "t_floor_wax" );
static const ter_str_id ter_t_gas_pump( "t_gas_pump" );
static const ter_str_id ter_t_gas_pump_smashed( "t_gas_pump_smashed" );
static const ter_str_id ter_t_grass( "t_grass" );
static const ter_str_id ter_t_null( "t_null" );
static const ter_str_id ter_t_open_air( "t_open_air" );
static const ter_str_id ter_t_reb_cage( "t_reb_cage" );
static const ter_str_id ter_t_rock( "t_rock" );
Expand Down Expand Up @@ -1914,14 +1913,14 @@ std::string map::furnname( const tripoint_bub_ms &p )
ter_id map::ter( const tripoint &p ) const
{
if( !inbounds( p ) ) {
return ter_t_null.id();
return ter_str_id::NULL_ID().id();
}

point l;
const submap *const current_submap = unsafe_get_submap_at( p, l );
if( current_submap == nullptr ) {
debugmsg( "Tried to process terrain at (%d,%d) but the submap is not loaded", l.x, l.y );
return ter_t_null.id();
return ter_str_id::NULL_ID().id();
}

return current_submap->get_ter( l );
Expand Down Expand Up @@ -3965,7 +3964,7 @@ ter_str_id map::get_roof( const tripoint &p, const bool allow_air ) const

return ter_t_open_air;
}
if( roof == ter_t_null ) {
if( roof == ter_str_id::NULL_ID() ) {
debugmsg( "map::get_new_floor: %d,%d,%d has invalid roof type %s",
p.x, p.y, p.z, roof.c_str() );
return ter_t_dirt;
Expand Down Expand Up @@ -8134,7 +8133,7 @@ void map::saven( const tripoint &grid )
debugmsg( "Tried to save submap node (%d) but it's not loaded", gridn );
return;
}
if( submap_to_save->get_ter( point_zero ) == ter_t_null ) {
if( submap_to_save->get_ter( point_zero ) == ter_str_id::NULL_ID() ) {
// This is a serious error and should be signaled as soon as possible
debugmsg( "map::saven grid %s uninitialized!", grid.to_string() );
return;
Expand Down Expand Up @@ -9804,7 +9803,7 @@ void map::draw_square_ter( const weighted_int_list<ter_id> &f, const point &p1,
{
draw_square( [this, f, avoid_creatures]( const point & p ) {
const ter_id *tid = f.pick();
this->ter_set( p, tid != nullptr ? *tid : ter_t_null, avoid_creatures );
this->ter_set( p, tid != nullptr ? *tid : ter_str_id::NULL_ID(), avoid_creatures );
}, p1, p2 );
}

Expand Down
25 changes: 12 additions & 13 deletions src/mapgen_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ static const ter_str_id ter_t_clay( "t_clay" );
static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_grass( "t_grass" );
static const ter_str_id ter_t_lava( "t_lava" );
static const ter_str_id ter_t_null( "t_null" );
static const ter_str_id ter_t_open_air( "t_open_air" );
static const ter_str_id ter_t_railroad_rubble( "t_railroad_rubble" );
static const ter_str_id ter_t_railroad_tie( "t_railroad_tie" );
Expand Down Expand Up @@ -176,7 +175,7 @@ void mapgen_null( mapgendata &dat )
debugmsg( "Generating null terrain, please report this as a bug" );
for( int i = 0; i < SEEX * 2; i++ ) {
for( int j = 0; j < SEEY * 2; j++ ) {
dat.m.ter_set( point( i, j ), ter_t_null );
dat.m.ter_set( point( i, j ), ter_str_id::NULL_ID() );
dat.m.set_radiation( point( i, j ), 0 );
}
}
Expand Down Expand Up @@ -1720,7 +1719,7 @@ void mapgen_lake_shore( mapgendata &dat )
}
// Use t_null for now instead of t_water_sh, because sometimes our extended terrain
// has put down a t_water_sh, and we need to be able to flood-fill over that.
m->ter_set( bp, ter_t_null );
m->ter_set( bp, ter_str_id::NULL_ID() );
m->furn_set( bp, f_null );
}
}
Expand Down Expand Up @@ -1758,7 +1757,7 @@ void mapgen_lake_shore( mapgendata &dat )
if( !map_boundaries.contains( p ) ) {
return false;
}
return m->ter( p ) != ter_t_null;
return m->ter( p ) != ter_str_id::NULL_ID();
};

const auto fill_deep_water = [&]( const point & starting_point ) {
Expand Down Expand Up @@ -1790,7 +1789,7 @@ void mapgen_lake_shore( mapgendata &dat )

// We previously placed our shallow water but actually did a t_null instead to make sure that we didn't
// pick up shallow water from our extended terrain. Now turn those nulls into t_water_sh.
m->translate( ter_t_null, ter_t_water_sh );
m->translate( ter_str_id::NULL_ID(), ter_t_water_sh );
}

void mapgen_ocean_shore( mapgendata &dat )
Expand Down Expand Up @@ -2171,7 +2170,7 @@ void mapgen_ocean_shore( mapgendata &dat )
}
// Use t_null for now instead of t_sand, because sometimes our extended terrain
// has put down a t_sand, and we need to be able to flood-fill over that.
m->ter_set( bp, ter_t_null );
m->ter_set( bp, ter_str_id::NULL_ID() );
m->furn_set( bp, f_null );
}
for( const point &bp : closest_points_first( p, sand_margin + 1 ) ) {
Expand Down Expand Up @@ -2223,7 +2222,7 @@ void mapgen_ocean_shore( mapgendata &dat )
if( !map_boundaries.contains( p ) ) {
return false;
}
return m->ter( p ) != ter_t_null && m->ter( p ) != ter_t_swater_sh &&
return m->ter( p ) != ter_str_id::NULL_ID() && m->ter( p ) != ter_t_swater_sh &&
m->ter( p ) != ter_t_swater_surf;
};

Expand Down Expand Up @@ -2256,7 +2255,7 @@ void mapgen_ocean_shore( mapgendata &dat )

// We previously placed our sand but actually did a t_null instead to make sure that we didn't
// pick up sand from our extended terrain. Now turn those nulls into t_sand.
m->translate( ter_t_null, ter_t_sand );
m->translate( ter_str_id::NULL_ID(), ter_t_sand );
}

void mapgen_ravine_edge( mapgendata &dat )
Expand Down Expand Up @@ -2305,7 +2304,7 @@ void mapgen_ravine_edge( mapgendata &dat )
if( straight ) {
for( int x = 0; x < SEEX * 2; x++ ) {
int ground_edge = 12 + rng( 1, 3 );
line( m, ter_t_null, point( x, ++ground_edge ), point( x, SEEY * 2 ) );
line( m, ter_str_id::NULL_ID(), point( x, ++ground_edge ), point( x, SEEY * 2 ) );
}
if( w_ravine ) {
m->rotate( 1 );
Expand All @@ -2319,7 +2318,7 @@ void mapgen_ravine_edge( mapgendata &dat )
} else if( interior_corner ) {
for( int x = 0; x < SEEX * 2; x++ ) {
int ground_edge = 12 + rng( 1, 3 ) + x;
line( m, ter_t_null, point( x, ++ground_edge ), point( x, SEEY * 2 ) );
line( m, ter_str_id::NULL_ID(), point( x, ++ground_edge ), point( x, SEEY * 2 ) );
}
if( nw_ravine ) {
m->rotate( 1 );
Expand All @@ -2333,7 +2332,7 @@ void mapgen_ravine_edge( mapgendata &dat )
} else if( exterior_corner ) {
for( int x = 0; x < SEEX * 2; x++ ) {
int ground_edge = 12 + rng( 1, 3 ) - x;
line( m, ter_t_null, point( x, --ground_edge ), point( x, SEEY * 2 - 1 ) );
line( m, ter_str_id::NULL_ID(), point( x, --ground_edge ), point( x, SEEY * 2 - 1 ) );
}
if( w_ravine && s_ravine ) {
m->rotate( 1 );
Expand All @@ -2348,9 +2347,9 @@ void mapgen_ravine_edge( mapgendata &dat )
// The placed t_null terrains are converted into the regional groundcover in the ravine's bottom level,
// in the other levels they are converted into open air to generate the cliffside.
if( dat.zlevel() == dat.region.overmap_ravine.ravine_depth ) {
m->translate( ter_t_null, dat.groundcover() );
m->translate( ter_str_id::NULL_ID(), dat.groundcover() );
} else {
m->translate( ter_t_null, ter_t_open_air );
m->translate( ter_str_id::NULL_ID(), ter_t_open_air );
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/mapgendata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "point.h"
#include "regional_settings.h"

static const ter_str_id ter_t_null( "t_null" );

void mapgen_arguments::merge( const mapgen_arguments &other )
{
for( const std::pair<const std::string, cata_variant> &p : other.map ) {
Expand Down Expand Up @@ -243,7 +241,7 @@ bool mapgendata::has_flag( jmapgen_flags f ) const
ter_id mapgendata::groundcover() const
{
const ter_id *tid = default_groundcover.pick();
return tid != nullptr ? *tid : ter_t_null.id();
return tid != nullptr ? *tid : ter_str_id::NULL_ID().id();
}

const oter_id &mapgendata::neighbor_at( om_direction::type dir ) const
Expand Down
4 changes: 1 addition & 3 deletions src/mapgenformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "mapdata.h"
#include "point.h"

static const ter_str_id ter_t_null( "t_null" );

namespace mapf
{

Expand All @@ -23,7 +21,7 @@ void formatted_set_simple( map *m, const point &start, const char *cstr,
} else {
const ter_id ter = ter_b.translate( *p );
const furn_id furn = furn_b.translate( *p );
if( ter != ter_t_null ) {
if( ter != ter_str_id::NULL_ID() ) {
m->ter_set( p2, ter );
}
if( furn != f_null ) {
Expand Down
10 changes: 4 additions & 6 deletions src/regional_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#include "string_formatter.h"
#include "translations.h"

static const ter_str_id ter_t_null( "t_null" );

ter_furn_id::ter_furn_id() : ter( ter_t_null.id() ), furn( f_null ) { }
ter_furn_id::ter_furn_id() : ter( ter_str_id::NULL_ID().id() ), furn( f_null ) { }

template<typename T>
void read_and_set_or_throw( const JsonObject &jo, const std::string &member, T &target,
Expand Down Expand Up @@ -763,7 +761,7 @@ void groundcover_extra::finalize() // FIXME: return bool for failure

for( std::map<std::string, double>::const_iterator it = percent_str.begin();
it != percent_str.end(); ++it ) {
tf_id.ter = ter_t_null.id();
tf_id.ter = ter_str_id::NULL_ID().id();
tf_id.furn = f_null;
if( it->second < 0.0001 ) {
continue;
Expand All @@ -784,7 +782,7 @@ void groundcover_extra::finalize() // FIXME: return bool for failure

for( std::map<std::string, double>::const_iterator it = boosted_percent_str.begin();
it != boosted_percent_str.end(); ++it ) {
tf_id.ter = ter_t_null.id();
tf_id.ter = ter_str_id::NULL_ID().id();
tf_id.furn = f_null;
if( it->second < 0.0001 ) {
continue;
Expand Down Expand Up @@ -846,7 +844,7 @@ void forest_biome_component::finalize()
{
for( const std::pair<const std::string, int> &pr : unfinalized_types ) {
ter_furn_id tf_id;
tf_id.ter = ter_t_null.id();
tf_id.ter = ter_str_id::NULL_ID().id();
tf_id.furn = f_null;
const ter_str_id tid( pr.first );
const furn_str_id fid( pr.first );
Expand Down
3 changes: 1 addition & 2 deletions src/vehicle_autodrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
* coordinates.
*/

static const ter_str_id ter_t_null( "t_null" );
static const ter_str_id ter_t_open_air( "t_open_air" );

static constexpr int OMT_SIZE = coords::map_squares_per( coords::omt );
Expand Down Expand Up @@ -753,7 +752,7 @@ bool vehicle::autodrive_controller::check_drivable( const tripoint_bub_ms &pt )
}

const ter_id terrain = here.ter( pt );
if( terrain == ter_t_null ) {
if( terrain == ter_str_id::NULL_ID() ) {
return false;
}
// open air is an obstacle to non-flying vehicles; it is drivable
Expand Down
3 changes: 1 addition & 2 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ static const skill_id skill_mechanics( "mechanics" );

static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_dirtmound( "t_dirtmound" );
static const ter_str_id ter_t_null( "t_null" );

static const vpart_id vpart_horn_bicycle( "horn_bicycle" );

Expand Down Expand Up @@ -1002,7 +1001,7 @@ void vehicle::transform_terrain()
}
if( prereq_fulfilled ) {
const ter_id new_ter = ter_id( ttd.post_terrain );
if( new_ter != ter_t_null ) {
if( new_ter != ter_str_id::NULL_ID() ) {
here.ter_set( start_pos, new_ter );
}
const furn_id new_furn = furn_id( ttd.post_furniture );
Expand Down

0 comments on commit 0847ee6

Please sign in to comment.