1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Revert mapgen to best working version (2)

This commit is contained in:
Perttu Ahola 2011-04-03 12:14:23 +03:00
parent 685a635aea
commit ee89e29ae1
6 changed files with 344 additions and 2830 deletions

126
src/map.h
View file

@ -38,18 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapsector.h"
#include "constants.h"
#include "voxel.h"
/*
Some exposed functions
*/
double base_rock_level_2d(u64 seed, v2f p);
bool get_have_sand_coast(u64 seed, v2f p);
bool get_have_sand_ground(u64 seed, v2f p);
double get_turbulence_factor_2d(u64 seed, v2f p);
/*
*/
#include "mapchunk.h"
#define MAPTYPE_BASE 0
#define MAPTYPE_SERVER 1
@ -335,29 +324,81 @@ public:
Map generation
*/
/*
True if the block and its neighbors are fully generated.
It means the block will not be touched in the future by the
generator. If false, generateBlock will make it true.
*/
bool blockNonVolatile(v3s16 blockpos)
// Returns the position of the chunk where the sector is in
v2s16 sector_to_chunk(v2s16 sectorpos)
{
for(s16 x=-1; x<=1; x++)
for(s16 y=-1; y<=1; y++)
for(s16 z=-1; z<=1; z++)
sectorpos.X += m_chunksize / 2;
sectorpos.Y += m_chunksize / 2;
v2s16 chunkpos = getContainerPos(sectorpos, m_chunksize);
return chunkpos;
}
// Returns the position of the (0,0) sector of the chunk
v2s16 chunk_to_sector(v2s16 chunkpos)
{
v2s16 sectorpos(
chunkpos.X * m_chunksize,
chunkpos.Y * m_chunksize
);
sectorpos.X -= m_chunksize / 2;
sectorpos.Y -= m_chunksize / 2;
return sectorpos;
}
/*
Get a chunk.
*/
MapChunk *getChunk(v2s16 chunkpos)
{
core::map<v2s16, MapChunk*>::Node *n;
n = m_chunks.find(chunkpos);
if(n == NULL)
return NULL;
return n->getValue();
}
/*
True if the chunk and its neighbors are fully generated.
It means the chunk will not be touched in the future by the
generator. If false, generateChunk will make it true.
*/
bool chunkNonVolatile(v2s16 chunkpos)
{
/*for(s16 x=-1; x<=1; x++)
for(s16 y=-1; y<=1; y++)*/
s16 x=0;
s16 y=0;
{
v3s16 blockpos0 = blockpos + v3s16(x,y,z);
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL)
v2s16 chunkpos0 = chunkpos + v2s16(x,y);
MapChunk *chunk = getChunk(chunkpos);
if(chunk == NULL)
return false;
if(block->isFullyGenerated() == false)
if(chunk->getGenLevel() != GENERATED_FULLY)
return false;
}
return true;
}
/*
Generate a chunk.
All chunks touching this one can be altered also.
*/
MapChunk* generateChunkRaw(v2s16 chunkpos,
core::map<v3s16, MapBlock*> &changed_blocks,
bool force=false);
/*
Generate a chunk and its neighbors so that it won't be touched
anymore.
*/
MapChunk* generateChunk(v2s16 chunkpos,
core::map<v3s16, MapBlock*> &changed_blocks);
/*
Generate a sector.
This is mainly called by generateChunkRaw.
*/
//ServerMapSector * generateSector(v2s16 p);
@ -384,27 +425,6 @@ public:
return emergeSector(p, changed_blocks);
}
/*MapBlock * generateBlock(
v3s16 p,
MapBlock *original_dummy,
ServerMapSector *sector,
core::map<v3s16, MapBlock*> &changed_blocks,
core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
);*/
/*
Generate a block.
All blocks touching this one can be altered also.
*/
MapBlock* generateBlockRaw(v3s16 blockpos,
core::map<v3s16, MapBlock*> &changed_blocks,
bool force=false);
/*
Generate a block and its neighbors so that it won't be touched
anymore.
*/
MapBlock * generateBlock(
v3s16 p,
MapBlock *original_dummy,
@ -412,8 +432,6 @@ public:
core::map<v3s16, MapBlock*> &changed_blocks,
core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
);
/*MapBlock* generateBlock(v3s16 blockpos,
core::map<v3s16, MapBlock*> &changed_blocks);*/
/*
Get a block from somewhere.
@ -486,6 +504,9 @@ public:
void saveMapMeta();
void loadMapMeta();
void saveChunkMeta();
void loadChunkMeta();
// The sector mutex should be locked when calling most of these
// This only saves sector-specific data such as the heightmap
@ -510,14 +531,17 @@ public:
bool isSavingEnabled(){ return m_map_saving_enabled; }
u64 getSeed(){ return m_seed; }
private:
// Seed used for all kinds of randomness
u64 m_seed;
std::string m_savedir;
bool m_map_saving_enabled;
// Chunk size in MapSectors
s16 m_chunksize;
// Chunks
core::map<v2s16, MapChunk*> m_chunks;
};
/*
@ -641,7 +665,7 @@ public:
void updateMeshes(v3s16 blockpos, u32 daynight_ratio);
// Update meshes that touch the node
void updateNodeMeshes(v3s16 nodepos, u32 daynight_ratio);
//void updateNodeMeshes(v3s16 nodepos, u32 daynight_ratio);
// For debug printing
virtual void PrintInfo(std::ostream &out);