mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
This map generator is starting to look pretty good now... also, disabled loading player position from disk because map is regenerated always.
This commit is contained in:
parent
56320f7e8d
commit
e92238edc8
@ -112,6 +112,7 @@ void Environment::step(float dtime)
|
|||||||
{
|
{
|
||||||
// Apply gravity to local player
|
// Apply gravity to local player
|
||||||
v3f speed = player->getSpeed();
|
v3f speed = player->getSpeed();
|
||||||
|
if(player->swimming_up == false)
|
||||||
speed.Y -= 9.81 * BS * dtime_part * 2;
|
speed.Y -= 9.81 * BS * dtime_part * 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@ -333,6 +333,19 @@ Doing now:
|
|||||||
* Make the generator to run in background and not blocking block
|
* Make the generator to run in background and not blocking block
|
||||||
placement and transfer
|
placement and transfer
|
||||||
* Fix the strange mineral occurences
|
* Fix the strange mineral occurences
|
||||||
|
* When the map is generated and a place is found for the player, the
|
||||||
|
first chunk is actually still volatile and will have stuff still
|
||||||
|
changed after spawning, which creates a lot of glitches.
|
||||||
|
- This is partly fixed by now allowing only 2-sector deeep
|
||||||
|
modification of volatile chunks. But it should still be fixed?
|
||||||
|
- How about checking that the neighbors are fully generated too and
|
||||||
|
generate them when the middle piece is needed
|
||||||
|
- This is very slow
|
||||||
|
- How about just enabling changed_blocks properly
|
||||||
|
- This is probably a good idea
|
||||||
|
- The server has to make sure the spawn point is not at the
|
||||||
|
changing borders of a chunk
|
||||||
|
* Add some kind of erosion and other stuff that now is possible
|
||||||
|
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
@ -2690,8 +2703,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
// We want a slight delay to very little
|
// We want a slight delay to very little
|
||||||
// time consuming nodes
|
// time consuming nodes
|
||||||
//float mindelay = 0.15;
|
float mindelay = 0.15;
|
||||||
float mindelay = 0.20;
|
|
||||||
if(nodig_delay_counter < mindelay)
|
if(nodig_delay_counter < mindelay)
|
||||||
{
|
{
|
||||||
nodig_delay_counter = mindelay;
|
nodig_delay_counter = mindelay;
|
||||||
|
726
src/map.cpp
726
src/map.cpp
File diff suppressed because it is too large
Load Diff
49
src/map.h
49
src/map.h
@ -100,7 +100,9 @@ public:
|
|||||||
This is overloaded by ClientMap and ServerMap to allow
|
This is overloaded by ClientMap and ServerMap to allow
|
||||||
their differing fetch methods.
|
their differing fetch methods.
|
||||||
*/
|
*/
|
||||||
virtual MapSector * emergeSector(v2s16 p) = 0;
|
virtual MapSector * emergeSector(v2s16 p){ return NULL; }
|
||||||
|
virtual MapSector * emergeSector(v2s16 p,
|
||||||
|
core::map<v3s16, MapBlock*> &changed_blocks){ return NULL; }
|
||||||
|
|
||||||
// Returns InvalidPositionException if not found
|
// Returns InvalidPositionException if not found
|
||||||
MapBlock * getBlockNoCreate(v3s16 p);
|
MapBlock * getBlockNoCreate(v3s16 p);
|
||||||
@ -364,22 +366,42 @@ public:
|
|||||||
return n->getValue();
|
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;
|
||||||
|
{
|
||||||
|
v2s16 chunkpos0 = chunkpos + v2s16(x,y);
|
||||||
|
MapChunk *chunk = getChunk(chunkpos);
|
||||||
|
if(chunk == NULL)
|
||||||
|
return false;
|
||||||
|
if(chunk->getGenLevel() != GENERATED_FULLY)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate a chunk.
|
Generate a chunk.
|
||||||
|
|
||||||
All chunks touching this one can be altered also.
|
All chunks touching this one can be altered also.
|
||||||
|
|
||||||
Doesn't update lighting.
|
|
||||||
*/
|
*/
|
||||||
MapChunk* generateChunkRaw(v2s16 chunkpos);
|
MapChunk* generateChunkRaw(v2s16 chunkpos,
|
||||||
|
core::map<v3s16, MapBlock*> &changed_blocks);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate a chunk and its neighbors so that it won't be touched
|
Generate a chunk and its neighbors so that it won't be touched
|
||||||
anymore.
|
anymore.
|
||||||
|
|
||||||
Doesn't update lighting.
|
|
||||||
*/
|
*/
|
||||||
MapChunk* generateChunk(v2s16 chunkpos);
|
MapChunk* generateChunk(v2s16 chunkpos,
|
||||||
|
core::map<v3s16, MapBlock*> &changed_blocks);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate a sector.
|
Generate a sector.
|
||||||
@ -402,7 +424,14 @@ public:
|
|||||||
- Check disk (loads blocks also)
|
- Check disk (loads blocks also)
|
||||||
- Generate chunk
|
- Generate chunk
|
||||||
*/
|
*/
|
||||||
MapSector * emergeSector(v2s16 p);
|
MapSector * emergeSector(v2s16 p,
|
||||||
|
core::map<v3s16, MapBlock*> &changed_blocks);
|
||||||
|
|
||||||
|
MapSector * emergeSector(v2s16 p)
|
||||||
|
{
|
||||||
|
core::map<v3s16, MapBlock*> changed_blocks;
|
||||||
|
return emergeSector(p, changed_blocks);
|
||||||
|
}
|
||||||
|
|
||||||
MapBlock * generateBlock(
|
MapBlock * generateBlock(
|
||||||
v3s16 p,
|
v3s16 p,
|
||||||
@ -419,6 +448,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
MapBlock * createBlock(v3s16 p);
|
MapBlock * createBlock(v3s16 p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
only_from_disk, changed_blocks and lighting_invalidated_blocks
|
||||||
|
are not properly used by the new map generator.
|
||||||
|
*/
|
||||||
MapBlock * emergeBlock(
|
MapBlock * emergeBlock(
|
||||||
v3s16 p,
|
v3s16 p,
|
||||||
bool only_from_disk,
|
bool only_from_disk,
|
||||||
|
@ -700,6 +700,9 @@ void MapBlock::updateMesh(u32 daynight_ratio)
|
|||||||
const u16 indices[] = {0,1,2,2,3,0};
|
const u16 indices[] = {0,1,2,2,3,0};
|
||||||
|
|
||||||
video::ITexture *texture = g_irrlicht->getTexture(f.tile.spec);
|
video::ITexture *texture = g_irrlicht->getTexture(f.tile.spec);
|
||||||
|
if(texture == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
material.setTexture(0, texture);
|
material.setTexture(0, texture);
|
||||||
if(f.tile.alpha != 255)
|
if(f.tile.alpha != 255)
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||||
|
@ -22,14 +22,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
MapChunk contains map-generation-time metadata for an area of
|
MapChunk contains map-generation-time metadata for an area of
|
||||||
some MapSectors. (something like 64x64)
|
some MapSectors. (something like 16x16)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum{
|
||||||
|
GENERATED_FULLY = 0,
|
||||||
|
GENERATED_PARTLY = 10,
|
||||||
|
GENERATED_NOT = 20
|
||||||
|
};
|
||||||
|
|
||||||
class MapChunk
|
class MapChunk
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MapChunk():
|
MapChunk():
|
||||||
m_is_volatile(true)
|
//m_is_volatile(true)
|
||||||
|
m_generation_level(GENERATED_NOT)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,11 +47,21 @@ public:
|
|||||||
It is set to false when all the 8 neighboring chunks have
|
It is set to false when all the 8 neighboring chunks have
|
||||||
been generated.
|
been generated.
|
||||||
*/
|
*/
|
||||||
bool getIsVolatile(){ return m_is_volatile; }
|
/*bool getIsVolatile(){ return m_is_volatile; }
|
||||||
void setIsVolatile(bool is){ m_is_volatile = is; }
|
void setIsVolatile(bool is){ m_is_volatile = is; }*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generation level. Possible values:
|
||||||
|
GENERATED_FULLY = 0 = fully generated
|
||||||
|
GENERATED_PARTLY = partly generated
|
||||||
|
GENERATED_NOT = not generated
|
||||||
|
*/
|
||||||
|
u16 getGenLevel(){ return m_generation_level; }
|
||||||
|
void setGenLevel(u16 lev){ m_generation_level = lev; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_is_volatile;
|
//bool m_is_volatile;
|
||||||
|
u16 m_generation_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,6 +82,9 @@ void init_mapnode(IIrrlichtWrapper *irrlicht)
|
|||||||
i = CONTENT_TREE;
|
i = CONTENT_TREE;
|
||||||
f = &g_content_features[i];
|
f = &g_content_features[i];
|
||||||
f->setAllTextures(irrlicht->getTextureId("tree.png"));
|
f->setAllTextures(irrlicht->getTextureId("tree.png"));
|
||||||
|
f->setTexture(0, irrlicht->getTextureId("tree_top.png"));
|
||||||
|
f->setTexture(1, irrlicht->getTextureId("tree_top.png"));
|
||||||
|
f->setInventoryTexture(irrlicht->getTextureId("tree_top.png"));
|
||||||
f->param_type = CPT_MINERAL;
|
f->param_type = CPT_MINERAL;
|
||||||
f->is_ground_content = true;
|
f->is_ground_content = true;
|
||||||
|
|
||||||
|
@ -428,6 +428,9 @@ void LocalPlayer::move(f32 dtime, Map &map)
|
|||||||
|
|
||||||
void LocalPlayer::applyControl(float dtime)
|
void LocalPlayer::applyControl(float dtime)
|
||||||
{
|
{
|
||||||
|
// Clear stuff
|
||||||
|
swimming_up = false;
|
||||||
|
|
||||||
// Random constants
|
// Random constants
|
||||||
#define WALK_ACCELERATION (4.0 * BS)
|
#define WALK_ACCELERATION (4.0 * BS)
|
||||||
#define WALKSPEED_MAX (4.0 * BS)
|
#define WALKSPEED_MAX (4.0 * BS)
|
||||||
@ -510,6 +513,7 @@ void LocalPlayer::applyControl(float dtime)
|
|||||||
v3f speed = getSpeed();
|
v3f speed = getSpeed();
|
||||||
speed.Y = 2.0*BS;
|
speed.Y = 2.0*BS;
|
||||||
setSpeed(speed);
|
setSpeed(speed);
|
||||||
|
swimming_up = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ public:
|
|||||||
|
|
||||||
bool touching_ground;
|
bool touching_ground;
|
||||||
bool in_water;
|
bool in_water;
|
||||||
|
bool swimming_up;
|
||||||
|
|
||||||
Inventory inventory;
|
Inventory inventory;
|
||||||
|
|
||||||
|
@ -515,9 +515,13 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
|||||||
generate = false;
|
generate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
If block is far away, don't generate it unless it is
|
If block is far away, don't generate it unless it is
|
||||||
near ground level
|
near ground level
|
||||||
|
|
||||||
|
NOTE: We can't know the ground level this way with the
|
||||||
|
new generator.
|
||||||
*/
|
*/
|
||||||
if(d > 4)
|
if(d > 4)
|
||||||
{
|
{
|
||||||
@ -543,6 +547,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
|||||||
generate = false;
|
generate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Don't draw if not in sight
|
Don't draw if not in sight
|
||||||
@ -610,11 +615,13 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
|||||||
v2s16 p2d(p.X, p.Z);
|
v2s16 p2d(p.X, p.Z);
|
||||||
ServerMap *map = (ServerMap*)(&server->m_env.getMap());
|
ServerMap *map = (ServerMap*)(&server->m_env.getMap());
|
||||||
v2s16 chunkpos = map->sector_to_chunk(p2d);
|
v2s16 chunkpos = map->sector_to_chunk(p2d);
|
||||||
MapChunk *chunk = map->getChunk(chunkpos);
|
if(map->chunkNonVolatile(chunkpos) == false)
|
||||||
|
block_is_invalid = true;
|
||||||
|
/*MapChunk *chunk = map->getChunk(chunkpos);
|
||||||
if(chunk == NULL)
|
if(chunk == NULL)
|
||||||
block_is_invalid = true;
|
block_is_invalid = true;
|
||||||
else if(chunk->getIsVolatile() == true)
|
else if(chunk->getIsVolatile() == true)
|
||||||
block_is_invalid = true;
|
block_is_invalid = true;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3176,6 +3183,16 @@ Player *Server::emergePlayer(const char *name, const char *password,
|
|||||||
setCreativeInventory(player);
|
setCreativeInventory(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
With new map generator the map is regenerated anyway,
|
||||||
|
so start at somewhere where you probably don't get underground
|
||||||
|
*/
|
||||||
|
player->setPosition(intToFloat(v3s16(
|
||||||
|
0,
|
||||||
|
50,
|
||||||
|
0
|
||||||
|
)));
|
||||||
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3206,9 +3223,17 @@ Player *Server::emergePlayer(const char *name, const char *password,
|
|||||||
dstream<<"Server: Finding spawn place for player \""
|
dstream<<"Server: Finding spawn place for player \""
|
||||||
<<player->getName()<<"\""<<std::endl;
|
<<player->getName()<<"\""<<std::endl;
|
||||||
|
|
||||||
#if 1
|
|
||||||
v2s16 nodepos;
|
v2s16 nodepos;
|
||||||
f32 groundheight = 0;
|
f32 groundheight = 0;
|
||||||
|
#if 1
|
||||||
|
player->setPosition(intToFloat(v3s16(
|
||||||
|
0,
|
||||||
|
50,
|
||||||
|
0
|
||||||
|
)));
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
#if 0
|
||||||
// Try to find a good place a few times
|
// Try to find a good place a few times
|
||||||
for(s32 i=0; i<500; i++)
|
for(s32 i=0; i<500; i++)
|
||||||
{
|
{
|
||||||
@ -3271,6 +3296,7 @@ Player *Server::emergePlayer(const char *name, const char *password,
|
|||||||
groundheight + 15,
|
groundheight + 15,
|
||||||
nodepos.Y
|
nodepos.Y
|
||||||
)));
|
)));
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Add player to environment
|
Add player to environment
|
||||||
|
@ -1474,8 +1474,11 @@ void mysrand(unsigned seed);
|
|||||||
|
|
||||||
inline int myrand_range(int min, int max)
|
inline int myrand_range(int min, int max)
|
||||||
{
|
{
|
||||||
if(min >= max)
|
if(min > max)
|
||||||
|
{
|
||||||
|
assert(0);
|
||||||
return max;
|
return max;
|
||||||
|
}
|
||||||
return (myrand()%(max-min+1))+min;
|
return (myrand()%(max-min+1))+min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user