mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Revert mapgen to best working version (2)
This commit is contained in:
parent
685a635aea
commit
ee89e29ae1
34
src/main.cpp
34
src/main.cpp
@ -259,11 +259,11 @@ FEATURE: Erosion simulation at map generation time
|
||||
- Simulate rock falling from cliffs when water has removed
|
||||
enough solid rock from the bottom
|
||||
|
||||
Mapgen v2 (not doing):
|
||||
Mapgen v2:
|
||||
* only_from_disk might not work anymore - check and fix it.
|
||||
* Make the generator to run in background and not blocking block
|
||||
placement and transfer
|
||||
* Add some kind of erosion and other stuff that now is possible
|
||||
* Possibly add some kind of erosion and other stuff
|
||||
* Make client to fetch stuff asynchronously
|
||||
- Needs method SyncProcessData
|
||||
* Better water generation (spread it to underwater caverns but don't
|
||||
@ -273,28 +273,6 @@ Mapgen v2 (not doing):
|
||||
the other chunk making nasty straight walls when the other chunk
|
||||
is generated. Fix it.
|
||||
|
||||
Mapgen v4 (not doing):
|
||||
* only_from_disk might not work anymore - check and fix it.
|
||||
* Make the generator to run in background and not blocking block
|
||||
placement and transfer
|
||||
* Make chunks to be tiled vertically too
|
||||
* MAKE IT FASTER
|
||||
|
||||
Mapgen v3 (not doing):
|
||||
* Generate trees better
|
||||
- Add a "trees_added" flag to sector, or something
|
||||
* How 'bout making turbulence controlled so that for a given 2d position
|
||||
it can be completely turned off, and is usually so. This way generation
|
||||
can be sped up a lot.
|
||||
* Add a way to generate a block partly, so that trees are not added, like
|
||||
the chunks in v2
|
||||
* Add mud "discretely", not by guessing from the noise
|
||||
|
||||
Mapgen v4:
|
||||
* This will be the final way.
|
||||
* Generate blocks in the same way as chunks, by copying a VoxelManipulator
|
||||
from the map that is one block larger in all directions.
|
||||
|
||||
Misc. stuff:
|
||||
------------
|
||||
* Make an "environment metafile" to store at least time of day
|
||||
@ -1275,6 +1253,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
video::ITexture *g_map_plot_texture = NULL;
|
||||
float g_map_plot_texture_scale = 4;
|
||||
|
||||
@ -1416,6 +1395,7 @@ void updateMapPlotTexture(v2f centerpos, video::IVideoDriver* driver,
|
||||
img->drop();
|
||||
assert(g_map_plot_texture);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Chat data
|
||||
struct ChatLine
|
||||
@ -3219,7 +3199,7 @@ int main(int argc, char *argv[])
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
Draw map plot
|
||||
*/
|
||||
@ -3234,7 +3214,7 @@ int main(int argc, char *argv[])
|
||||
core::rect<s32> source(v2s32(0,0), g_map_plot_texture->getSize());
|
||||
driver->draw2DImage(g_map_plot_texture, dest, source);
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
Draw crosshair
|
||||
*/
|
||||
@ -3277,6 +3257,7 @@ int main(int argc, char *argv[])
|
||||
End of drawing
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/*
|
||||
Refresh map plot if player has moved considerably
|
||||
*/
|
||||
@ -3291,6 +3272,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
g_refresh_map_plot = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static s16 lastFPS = 0;
|
||||
//u16 fps = driver->getFPS();
|
||||
|
2784
src/map.cpp
2784
src/map.cpp
File diff suppressed because it is too large
Load Diff
122
src/map.h
122
src/map.h
@ -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
|
||||
*/
|
||||
|
||||
// Returns the position of the chunk where the sector is in
|
||||
v2s16 sector_to_chunk(v2s16 sectorpos)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
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.
|
||||
Get a chunk.
|
||||
*/
|
||||
bool blockNonVolatile(v3s16 blockpos)
|
||||
MapChunk *getChunk(v2s16 chunkpos)
|
||||
{
|
||||
for(s16 x=-1; x<=1; x++)
|
||||
for(s16 y=-1; y<=1; y++)
|
||||
for(s16 z=-1; z<=1; z++)
|
||||
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)
|
||||
{
|
||||
v3s16 blockpos0 = blockpos + v3s16(x,y,z);
|
||||
MapBlock *block = getBlockNoCreateNoEx(blockpos);
|
||||
if(block == NULL)
|
||||
/*for(s16 x=-1; x<=1; x++)
|
||||
for(s16 y=-1; y<=1; y++)*/
|
||||
s16 x=0;
|
||||
s16 y=0;
|
||||
{
|
||||
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);
|
||||
|
@ -36,7 +36,7 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
|
||||
is_underground(false),
|
||||
m_lighting_expired(true),
|
||||
m_day_night_differs(false),
|
||||
m_not_fully_generated(false),
|
||||
//m_not_fully_generated(false),
|
||||
m_objects(this)
|
||||
{
|
||||
data = NULL;
|
||||
@ -1763,8 +1763,8 @@ void MapBlock::serialize(std::ostream &os, u8 version)
|
||||
flags |= 0x02;
|
||||
if(m_lighting_expired)
|
||||
flags |= 0x04;
|
||||
if(m_not_fully_generated)
|
||||
flags |= 0x08;
|
||||
/*if(m_not_fully_generated)
|
||||
flags |= 0x08;*/
|
||||
os.write((char*)&flags, 1);
|
||||
|
||||
u32 nodecount = MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE;
|
||||
@ -1887,7 +1887,7 @@ void MapBlock::deSerialize(std::istream &is, u8 version)
|
||||
is_underground = (flags & 0x01) ? true : false;
|
||||
m_day_night_differs = (flags & 0x02) ? true : false;
|
||||
m_lighting_expired = (flags & 0x04) ? true : false;
|
||||
m_not_fully_generated = (flags & 0x08) ? true : false;
|
||||
//m_not_fully_generated = (flags & 0x08) ? true : false;
|
||||
|
||||
// Uncompress data
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
|
@ -244,16 +244,15 @@ public:
|
||||
return m_lighting_expired;
|
||||
}
|
||||
|
||||
bool isFullyGenerated()
|
||||
/*bool isFullyGenerated()
|
||||
{
|
||||
return !m_not_fully_generated;
|
||||
}
|
||||
|
||||
void setFullyGenerated(bool b)
|
||||
{
|
||||
setChangedFlag();
|
||||
m_not_fully_generated = !b;
|
||||
}
|
||||
}*/
|
||||
|
||||
bool isValid()
|
||||
{
|
||||
@ -680,7 +679,7 @@ private:
|
||||
|
||||
TODO: Save in file
|
||||
*/
|
||||
bool m_not_fully_generated;
|
||||
//bool m_not_fully_generated;
|
||||
|
||||
MapBlockObjectList m_objects;
|
||||
|
||||
|
@ -544,10 +544,16 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
||||
block_is_invalid = true;
|
||||
}
|
||||
|
||||
if(block->isFullyGenerated() == false)
|
||||
/*if(block->isFullyGenerated() == false)
|
||||
{
|
||||
block_is_invalid = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
v2s16 p2d(p.X, p.Z);
|
||||
ServerMap *map = (ServerMap*)(&server->m_env.getMap());
|
||||
v2s16 chunkpos = map->sector_to_chunk(p2d);
|
||||
if(map->chunkNonVolatile(chunkpos) == false)
|
||||
block_is_invalid = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1711,7 +1717,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
writeU16(&reply[0], TOCLIENT_INIT);
|
||||
writeU8(&reply[2], deployed);
|
||||
writeV3S16(&reply[2+1], floatToInt(player->getPosition()+v3f(0,BS/2,0), BS));
|
||||
writeU64(&reply[2+1+6], m_env.getServerMap().getSeed());
|
||||
//writeU64(&reply[2+1+6], m_env.getServerMap().getSeed());
|
||||
|
||||
// Send as reliable
|
||||
m_con.Send(peer_id, 0, reply, true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user