mapgen: drop mapgen id from child mapgens.

This id must be owned by the child mapgen and never be set to a misc value by a developer

Also use nullptr in some places
This commit is contained in:
Loïc Blot 2019-03-25 16:42:53 +01:00 committed by Loïc Blot
parent b3716a03a6
commit b55fc3d773
18 changed files with 36 additions and 40 deletions

@ -174,8 +174,8 @@ MapgenParams *MapSettingsManager::makeMapgenParams()
// Create our MapgenParams
MapgenParams *params = Mapgen::createMapgenParams(mgtype);
if (params == NULL)
return NULL;
if (!params)
return nullptr;
params->mgtype = mgtype;

@ -153,23 +153,23 @@ Mapgen *Mapgen::createMapgen(MapgenType mgtype, int mgid,
{
switch (mgtype) {
case MAPGEN_CARPATHIAN:
return new MapgenCarpathian(mgid, (MapgenCarpathianParams *)params, emerge);
return new MapgenCarpathian((MapgenCarpathianParams *)params, emerge);
case MAPGEN_FLAT:
return new MapgenFlat(mgid, (MapgenFlatParams *)params, emerge);
return new MapgenFlat((MapgenFlatParams *)params, emerge);
case MAPGEN_FRACTAL:
return new MapgenFractal(mgid, (MapgenFractalParams *)params, emerge);
return new MapgenFractal((MapgenFractalParams *)params, emerge);
case MAPGEN_SINGLENODE:
return new MapgenSinglenode(mgid, (MapgenSinglenodeParams *)params, emerge);
return new MapgenSinglenode((MapgenSinglenodeParams *)params, emerge);
case MAPGEN_V5:
return new MapgenV5(mgid, (MapgenV5Params *)params, emerge);
return new MapgenV5((MapgenV5Params *)params, emerge);
case MAPGEN_V6:
return new MapgenV6(mgid, (MapgenV6Params *)params, emerge);
return new MapgenV6((MapgenV6Params *)params, emerge);
case MAPGEN_V7:
return new MapgenV7(mgid, (MapgenV7Params *)params, emerge);
return new MapgenV7((MapgenV7Params *)params, emerge);
case MAPGEN_VALLEYS:
return new MapgenValleys(mgid, (MapgenValleysParams *)params, emerge);
return new MapgenValleys((MapgenValleysParams *)params, emerge);
default:
return NULL;
return nullptr;
}
}
@ -194,7 +194,7 @@ MapgenParams *Mapgen::createMapgenParams(MapgenType mgtype)
case MAPGEN_VALLEYS:
return new MapgenValleysParams;
default:
return NULL;
return nullptr;
}
}

@ -50,9 +50,8 @@ FlagDesc flagdesc_mapgen_carpathian[] = {
///////////////////////////////////////////////////////////////////////////////
MapgenCarpathian::MapgenCarpathian(
int mapgenid, MapgenCarpathianParams *params, EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
MapgenCarpathian::MapgenCarpathian(MapgenCarpathianParams *params, EmergeManager *emerge)
: MapgenBasic(MAPGEN_CARPATHIAN, params, emerge)
{
base_level = params->base_level;

@ -71,8 +71,7 @@ struct MapgenCarpathianParams : public MapgenParams
class MapgenCarpathian : public MapgenBasic
{
public:
MapgenCarpathian(int mapgenid, MapgenCarpathianParams *params,
EmergeManager *emerge);
MapgenCarpathian(MapgenCarpathianParams *params, EmergeManager *emerge);
~MapgenCarpathian();
virtual MapgenType getType() const { return MAPGEN_CARPATHIAN; }

@ -48,8 +48,8 @@ FlagDesc flagdesc_mapgen_flat[] = {
///////////////////////////////////////////////////////////////////////////////////////
MapgenFlat::MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
MapgenFlat::MapgenFlat(MapgenFlatParams *params, EmergeManager *emerge)
: MapgenBasic(MAPGEN_FLAT, params, emerge)
{
spflags = params->spflags;
ground_level = params->ground_level;

@ -59,7 +59,7 @@ struct MapgenFlatParams : public MapgenParams
class MapgenFlat : public MapgenBasic
{
public:
MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *emerge);
MapgenFlat(MapgenFlatParams *params, EmergeManager *emerge);
~MapgenFlat();
virtual MapgenType getType() const { return MAPGEN_FLAT; }

@ -47,8 +47,8 @@ FlagDesc flagdesc_mapgen_fractal[] = {
///////////////////////////////////////////////////////////////////////////////////////
MapgenFractal::MapgenFractal(int mapgenid, MapgenFractalParams *params, EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
MapgenFractal::MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge)
: MapgenBasic(MAPGEN_FRACTAL, params, emerge)
{
spflags = params->spflags;
cave_width = params->cave_width;

@ -62,7 +62,7 @@ struct MapgenFractalParams : public MapgenParams
class MapgenFractal : public MapgenBasic
{
public:
MapgenFractal(int mapgenid, MapgenFractalParams *params, EmergeManager *emerge);
MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge);
~MapgenFractal();
virtual MapgenType getType() const { return MAPGEN_FRACTAL; }

@ -29,9 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "emerge.h"
MapgenSinglenode::MapgenSinglenode(int mapgenid,
MapgenParams *params, EmergeManager *emerge)
: Mapgen(mapgenid, params, emerge)
MapgenSinglenode::MapgenSinglenode(MapgenParams *params, EmergeManager *emerge)
: Mapgen(MAPGEN_SINGLENODE, params, emerge)
{
const NodeDefManager *ndef = emerge->ndef;

@ -38,7 +38,7 @@ public:
content_t c_node;
u8 set_light;
MapgenSinglenode(int mapgenid, MapgenParams *params, EmergeManager *emerge);
MapgenSinglenode(MapgenParams *params, EmergeManager *emerge);
~MapgenSinglenode() = default;
virtual MapgenType getType() const { return MAPGEN_SINGLENODE; }

@ -45,8 +45,8 @@ FlagDesc flagdesc_mapgen_v5[] = {
};
MapgenV5::MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
MapgenV5::MapgenV5(MapgenV5Params *params, EmergeManager *emerge)
: MapgenBasic(MAPGEN_V5, params, emerge)
{
spflags = params->spflags;
cave_width = params->cave_width;

@ -59,7 +59,7 @@ struct MapgenV5Params : public MapgenParams
class MapgenV5 : public MapgenBasic
{
public:
MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge);
MapgenV5(MapgenV5Params *params, EmergeManager *emerge);
~MapgenV5();
virtual MapgenType getType() const { return MAPGEN_V5; }

@ -55,8 +55,8 @@ FlagDesc flagdesc_mapgen_v6[] = {
/////////////////////////////////////////////////////////////////////////////
MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge)
: Mapgen(mapgenid, params, emerge)
MapgenV6::MapgenV6(MapgenV6Params *params, EmergeManager *emerge)
: Mapgen(MAPGEN_V6, params, emerge)
{
m_emerge = emerge;
ystride = csize.X; //////fix this

@ -132,7 +132,7 @@ public:
content_t c_stair_cobble;
content_t c_stair_desert_stone;
MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge);
MapgenV6(MapgenV6Params *params, EmergeManager *emerge);
~MapgenV6();
virtual MapgenType getType() const { return MAPGEN_V6; }

@ -52,8 +52,8 @@ FlagDesc flagdesc_mapgen_v7[] = {
////////////////////////////////////////////////////////////////////////////////
MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
MapgenV7::MapgenV7(MapgenV7Params *params, EmergeManager *emerge)
: MapgenBasic(MAPGEN_V7, params, emerge)
{
spflags = params->spflags;
mount_zero_level = params->mount_zero_level;

@ -77,7 +77,7 @@ struct MapgenV7Params : public MapgenParams {
class MapgenV7 : public MapgenBasic {
public:
MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge);
MapgenV7(MapgenV7Params *params, EmergeManager *emerge);
~MapgenV7();
virtual MapgenType getType() const { return MAPGEN_V7; }

@ -54,9 +54,8 @@ FlagDesc flagdesc_mapgen_valleys[] = {
};
MapgenValleys::MapgenValleys(int mapgenid, MapgenValleysParams *params,
EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
MapgenValleys::MapgenValleys(MapgenValleysParams *params, EmergeManager *emerge)
: MapgenBasic(MAPGEN_VALLEYS, params, emerge)
{
// NOTE: MapgenValleys has a hard dependency on BiomeGenOriginal
m_bgen = (BiomeGenOriginal *)biomegen;

@ -79,7 +79,7 @@ struct MapgenValleysParams : public MapgenParams {
class MapgenValleys : public MapgenBasic {
public:
MapgenValleys(int mapgenid, MapgenValleysParams *params,
MapgenValleys(MapgenValleysParams *params,
EmergeManager *emerge);
~MapgenValleys();