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

better support for old maps

This commit is contained in:
Perttu Ahola 2011-04-10 22:50:31 +03:00
parent 3d25fe42f3
commit b0b5c43254
6 changed files with 145 additions and 50 deletions

View file

@ -341,6 +341,8 @@ public:
// Returns the position of the chunk where the sector is in
v2s16 sector_to_chunk(v2s16 sectorpos)
{
if(m_chunksize == 0)
return v2s16(0,0);
sectorpos.X += m_chunksize / 2;
sectorpos.Y += m_chunksize / 2;
v2s16 chunkpos = getContainerPos(sectorpos, m_chunksize);
@ -350,6 +352,8 @@ public:
// Returns the position of the (0,0) sector of the chunk
v2s16 chunk_to_sector(v2s16 chunkpos)
{
if(m_chunksize == 0)
return v2s16(0,0);
v2s16 sectorpos(
chunkpos.X * m_chunksize,
chunkpos.Y * m_chunksize
@ -378,6 +382,9 @@ public:
*/
bool chunkNonVolatile(v2s16 chunkpos)
{
if(m_chunksize == 0)
return true;
/*for(s16 x=-1; x<=1; x++)
for(s16 y=-1; y<=1; y++)*/
s16 x=0;
@ -393,6 +400,9 @@ public:
return true;
}
/*
Chunks are generated by using these and makeChunk().
*/
void initChunkMake(ChunkMakeData &data, v2s16 chunkpos);
MapChunk* finishChunkMake(ChunkMakeData &data,
core::map<v3s16, MapBlock*> &changed_blocks);
@ -402,16 +412,16 @@ public:
All chunks touching this one can be altered also.
*/
MapChunk* generateChunkRaw(v2s16 chunkpos,
/*MapChunk* generateChunkRaw(v2s16 chunkpos,
core::map<v3s16, MapBlock*> &changed_blocks,
bool force=false);
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);
/*MapChunk* generateChunk(v2s16 chunkpos,
core::map<v3s16, MapBlock*> &changed_blocks);*/
/*
Generate a sector.
@ -434,14 +444,14 @@ public:
- Check disk (loads blocks also)
- Generate chunk
*/
MapSector * emergeSector(v2s16 p,
core::map<v3s16, MapBlock*> &changed_blocks);
/*MapSector * emergeSector(v2s16 p,
core::map<v3s16, MapBlock*> &changed_blocks);*/
MapSector * emergeSector(v2s16 p)
/*MapSector * emergeSector(v2s16 p)
{
core::map<v3s16, MapBlock*> changed_blocks;
return emergeSector(p, changed_blocks);
}
}*/
MapBlock * generateBlock(
v3s16 p,
@ -516,7 +526,7 @@ public:
v3s16 getBlockPos(std::string sectordir, std::string blockfile);
void save(bool only_changed);
void loadAll();
//void loadAll();
// Saves map seed and possibly other stuff
void saveMapMeta();
@ -557,6 +567,7 @@ private:
bool m_map_saving_enabled;
// Chunk size in MapSectors
// If 0, chunks are disabled.
s16 m_chunksize;
// Chunks
core::map<v2s16, MapChunk*> m_chunks;
@ -754,6 +765,7 @@ protected:
struct ChunkMakeData
{
bool no_op;
ManualMapVoxelManipulator vmanip;
u64 seed;
v2s16 chunkpos;
@ -764,8 +776,10 @@ struct ChunkMakeData
v2s16 sectorpos_bigbase;
s16 sectorpos_bigbase_size;
s16 max_spread_amount;
UniqueQueue<v3s16> transforming_liquid;
ChunkMakeData():
no_op(false),
vmanip(NULL)
{}
};