forked from Mirrorlandia_minetest/minetest
Refactor EmergeParams owner
This commit is contained in:
parent
32ff832108
commit
20b10b5691
@ -131,9 +131,15 @@ Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeParams *emerge) :
|
|||||||
*/
|
*/
|
||||||
seed = (s32)params->seed;
|
seed = (s32)params->seed;
|
||||||
|
|
||||||
|
m_emerge = emerge;
|
||||||
ndef = emerge->ndef;
|
ndef = emerge->ndef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mapgen::~Mapgen()
|
||||||
|
{
|
||||||
|
delete m_emerge; // this is our responsibility
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MapgenType Mapgen::getMapgenType(const std::string &mgname)
|
MapgenType Mapgen::getMapgenType(const std::string &mgname)
|
||||||
{
|
{
|
||||||
@ -566,7 +572,6 @@ void Mapgen::spreadLight(const v3s16 &nmin, const v3s16 &nmax)
|
|||||||
MapgenBasic::MapgenBasic(int mapgenid, MapgenParams *params, EmergeParams *emerge)
|
MapgenBasic::MapgenBasic(int mapgenid, MapgenParams *params, EmergeParams *emerge)
|
||||||
: Mapgen(mapgenid, params, emerge)
|
: Mapgen(mapgenid, params, emerge)
|
||||||
{
|
{
|
||||||
this->m_emerge = emerge;
|
|
||||||
this->m_bmgr = emerge->biomemgr;
|
this->m_bmgr = emerge->biomemgr;
|
||||||
|
|
||||||
//// Here, 'stride' refers to the number of elements needed to skip to index
|
//// Here, 'stride' refers to the number of elements needed to skip to index
|
||||||
@ -620,8 +625,6 @@ MapgenBasic::MapgenBasic(int mapgenid, MapgenParams *params, EmergeParams *emerg
|
|||||||
MapgenBasic::~MapgenBasic()
|
MapgenBasic::~MapgenBasic()
|
||||||
{
|
{
|
||||||
delete []heightmap;
|
delete []heightmap;
|
||||||
|
|
||||||
delete m_emerge; // destroying EmergeParams is our responsibility
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,6 +163,9 @@ public:
|
|||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
MMVManip *vm = nullptr;
|
MMVManip *vm = nullptr;
|
||||||
|
// Note that this contains various things the mapgens *can* use, so biomegen
|
||||||
|
// might be NULL while m_emerge->biomegen is not.
|
||||||
|
EmergeParams *m_emerge = nullptr;
|
||||||
const NodeDefManager *ndef = nullptr;
|
const NodeDefManager *ndef = nullptr;
|
||||||
|
|
||||||
u32 blockseed;
|
u32 blockseed;
|
||||||
@ -175,7 +178,7 @@ public:
|
|||||||
|
|
||||||
Mapgen() = default;
|
Mapgen() = default;
|
||||||
Mapgen(int mapgenid, MapgenParams *params, EmergeParams *emerge);
|
Mapgen(int mapgenid, MapgenParams *params, EmergeParams *emerge);
|
||||||
virtual ~Mapgen() = default;
|
virtual ~Mapgen();
|
||||||
DISABLE_CLASS_COPY(Mapgen);
|
DISABLE_CLASS_COPY(Mapgen);
|
||||||
|
|
||||||
virtual MapgenType getType() const { return MAPGEN_INVALID; }
|
virtual MapgenType getType() const { return MAPGEN_INVALID; }
|
||||||
@ -289,7 +292,6 @@ public:
|
|||||||
virtual void generateDungeons(s16 max_stone_y);
|
virtual void generateDungeons(s16 max_stone_y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EmergeParams *m_emerge;
|
|
||||||
BiomeManager *m_bmgr;
|
BiomeManager *m_bmgr;
|
||||||
|
|
||||||
Noise *noise_filler_depth;
|
Noise *noise_filler_depth;
|
||||||
|
@ -32,8 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
MapgenSinglenode::MapgenSinglenode(MapgenParams *params, EmergeParams *emerge)
|
MapgenSinglenode::MapgenSinglenode(MapgenParams *params, EmergeParams *emerge)
|
||||||
: Mapgen(MAPGEN_SINGLENODE, params, emerge)
|
: Mapgen(MAPGEN_SINGLENODE, params, emerge)
|
||||||
{
|
{
|
||||||
const NodeDefManager *ndef = emerge->ndef;
|
|
||||||
|
|
||||||
c_node = ndef->getId("mapgen_singlenode");
|
c_node = ndef->getId("mapgen_singlenode");
|
||||||
if (c_node == CONTENT_IGNORE)
|
if (c_node == CONTENT_IGNORE)
|
||||||
c_node = CONTENT_AIR;
|
c_node = CONTENT_AIR;
|
||||||
|
@ -57,7 +57,6 @@ FlagDesc flagdesc_mapgen_v6[] = {
|
|||||||
MapgenV6::MapgenV6(MapgenV6Params *params, EmergeParams *emerge)
|
MapgenV6::MapgenV6(MapgenV6Params *params, EmergeParams *emerge)
|
||||||
: Mapgen(MAPGEN_V6, params, emerge)
|
: Mapgen(MAPGEN_V6, params, emerge)
|
||||||
{
|
{
|
||||||
m_emerge = emerge;
|
|
||||||
ystride = csize.X;
|
ystride = csize.X;
|
||||||
|
|
||||||
heightmap = new s16[csize.X * csize.Z];
|
heightmap = new s16[csize.X * csize.Z];
|
||||||
@ -160,8 +159,6 @@ MapgenV6::~MapgenV6()
|
|||||||
delete noise_humidity;
|
delete noise_humidity;
|
||||||
|
|
||||||
delete[] heightmap;
|
delete[] heightmap;
|
||||||
|
|
||||||
delete m_emerge; // our responsibility
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user