forked from Mirrorlandia_minetest/minetest
a commit before starting to reorganize the map loading/generation logic
This commit is contained in:
parent
7aa2d4d109
commit
6fa85c8502
@ -528,8 +528,8 @@ void ServerEnvironment::step(float dtime)
|
|||||||
i = block->m_static_objects.m_stored.begin();
|
i = block->m_static_objects.m_stored.begin();
|
||||||
i != block->m_static_objects.m_stored.end(); i++)
|
i != block->m_static_objects.m_stored.end(); i++)
|
||||||
{
|
{
|
||||||
dstream<<"INFO: Server: Creating an active object from "
|
/*dstream<<"INFO: Server: Creating an active object from "
|
||||||
<<"static data"<<std::endl;
|
<<"static data"<<std::endl;*/
|
||||||
StaticObject &s_obj = *i;
|
StaticObject &s_obj = *i;
|
||||||
// Create an active object from the data
|
// Create an active object from the data
|
||||||
ServerActiveObject *obj = ServerActiveObject::create
|
ServerActiveObject *obj = ServerActiveObject::create
|
||||||
@ -643,9 +643,9 @@ void ServerEnvironment::step(float dtime)
|
|||||||
obj->m_static_exists = false;
|
obj->m_static_exists = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/*dstream<<"INFO: Server: Stored static data. Deleting object."
|
||||||
|
<<std::endl;*/
|
||||||
// Delete active object
|
// Delete active object
|
||||||
dstream<<"INFO: Server: Stored static data. Deleting object."
|
|
||||||
<<std::endl;
|
|
||||||
delete obj;
|
delete obj;
|
||||||
// Id to be removed from m_active_objects
|
// Id to be removed from m_active_objects
|
||||||
objects_to_remove.push_back(id);
|
objects_to_remove.push_back(id);
|
||||||
@ -767,8 +767,8 @@ u16 ServerEnvironment::addActiveObject(ServerActiveObject *object)
|
|||||||
delete object;
|
delete object;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dstream<<"INGO: ServerEnvironment::addActiveObject(): "
|
/*dstream<<"INGO: ServerEnvironment::addActiveObject(): "
|
||||||
<<"added (id="<<object->getId()<<")"<<std::endl;
|
<<"added (id="<<object->getId()<<")"<<std::endl;*/
|
||||||
|
|
||||||
m_active_objects.insert(object->getId(), object);
|
m_active_objects.insert(object->getId(), object);
|
||||||
|
|
||||||
|
810
src/map.cpp
810
src/map.cpp
File diff suppressed because it is too large
Load Diff
@ -731,6 +731,9 @@ class ManualMapVoxelManipulator : public MapVoxelManipulator
|
|||||||
public:
|
public:
|
||||||
ManualMapVoxelManipulator(Map *map);
|
ManualMapVoxelManipulator(Map *map);
|
||||||
virtual ~ManualMapVoxelManipulator();
|
virtual ~ManualMapVoxelManipulator();
|
||||||
|
|
||||||
|
void setMap(Map *map)
|
||||||
|
{m_map = map;}
|
||||||
|
|
||||||
virtual void emerge(VoxelArea a, s32 caller_id=-1);
|
virtual void emerge(VoxelArea a, s32 caller_id=-1);
|
||||||
|
|
||||||
|
@ -139,6 +139,22 @@ void * EmergeThread::Thread()
|
|||||||
bool got_block = true;
|
bool got_block = true;
|
||||||
core::map<v3s16, MapBlock*> modified_blocks;
|
core::map<v3s16, MapBlock*> modified_blocks;
|
||||||
|
|
||||||
|
bool only_from_disk = false;
|
||||||
|
|
||||||
|
if(optional)
|
||||||
|
only_from_disk = true;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: Map loading logic here, so that the chunk can be
|
||||||
|
generated asynchronously:
|
||||||
|
|
||||||
|
- Check limits
|
||||||
|
With the environment locked:
|
||||||
|
- Check if block already is loaded and not dummy
|
||||||
|
- If so, we're ready
|
||||||
|
-
|
||||||
|
*/
|
||||||
|
|
||||||
{//envlock
|
{//envlock
|
||||||
|
|
||||||
//TimeTaker envlockwaittimer("block emerge envlock wait time");
|
//TimeTaker envlockwaittimer("block emerge envlock wait time");
|
||||||
@ -151,10 +167,6 @@ void * EmergeThread::Thread()
|
|||||||
//TimeTaker timer("block emerge (while env locked)");
|
//TimeTaker timer("block emerge (while env locked)");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
bool only_from_disk = false;
|
|
||||||
|
|
||||||
if(optional)
|
|
||||||
only_from_disk = true;
|
|
||||||
|
|
||||||
// First check if the block already exists
|
// First check if the block already exists
|
||||||
//block = map.getBlockNoCreate(p);
|
//block = map.getBlockNoCreate(p);
|
||||||
@ -167,28 +179,6 @@ void * EmergeThread::Thread()
|
|||||||
only_from_disk,
|
only_from_disk,
|
||||||
changed_blocks,
|
changed_blocks,
|
||||||
lighting_invalidated_blocks);
|
lighting_invalidated_blocks);
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
While we're at it, generate some other blocks too
|
|
||||||
*/
|
|
||||||
try
|
|
||||||
{
|
|
||||||
map.emergeBlock(
|
|
||||||
p+v3s16(0,1,0),
|
|
||||||
only_from_disk,
|
|
||||||
changed_blocks,
|
|
||||||
lighting_invalidated_blocks);
|
|
||||||
map.emergeBlock(
|
|
||||||
p+v3s16(0,-1,0),
|
|
||||||
only_from_disk,
|
|
||||||
changed_blocks,
|
|
||||||
lighting_invalidated_blocks);
|
|
||||||
}
|
|
||||||
catch(InvalidPositionException &e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is a dummy, block was not found on disk
|
// If it is a dummy, block was not found on disk
|
||||||
@ -3824,34 +3814,6 @@ Player *Server::emergePlayer(const char *name, const char *password,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Doesn't work, generating blocks is a bit too complicated for doing here
|
|
||||||
// Get block at point
|
|
||||||
v3s16 nodepos3d;
|
|
||||||
nodepos3d = v3s16(nodepos.X, groundheight+1, nodepos.Y);
|
|
||||||
v3s16 blockpos = getNodeBlockPos(nodepos3d);
|
|
||||||
((ServerMap*)(&m_env.getMap()))->emergeBlock(blockpos);
|
|
||||||
// Don't go inside ground
|
|
||||||
try{
|
|
||||||
/*v3s16 footpos(nodepos.X, groundheight+1, nodepos.Y);
|
|
||||||
v3s16 headpos(nodepos.X, groundheight+2, nodepos.Y);*/
|
|
||||||
v3s16 footpos = nodepos3d + v3s16(0,0,0);
|
|
||||||
v3s16 headpos = nodepos3d + v3s16(0,1,0);
|
|
||||||
if(m_env.getMap().getNode(footpos).d != CONTENT_AIR
|
|
||||||
|| m_env.getMap().getNode(headpos).d != CONTENT_AIR)
|
|
||||||
{
|
|
||||||
dstream<<"-> Inside ground"<<std::endl;
|
|
||||||
// In ground
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}catch(InvalidPositionException &e)
|
|
||||||
{
|
|
||||||
dstream<<"-> Invalid position"<<std::endl;
|
|
||||||
// Ignore invalid position
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Found a good place
|
// Found a good place
|
||||||
dstream<<"Searched through "<<i<<" places."<<std::endl;
|
dstream<<"Searched through "<<i<<" places."<<std::endl;
|
||||||
break;
|
break;
|
||||||
|
@ -272,7 +272,7 @@ RatSAO::RatSAO(ServerEnvironment *env, u16 id, v3f pos):
|
|||||||
ServerActiveObject(env, id, pos),
|
ServerActiveObject(env, id, pos),
|
||||||
m_speed_f(0,0,0)
|
m_speed_f(0,0,0)
|
||||||
{
|
{
|
||||||
dstream<<"Server: RatSAO created"<<std::endl;
|
//dstream<<"Server: RatSAO created"<<std::endl;
|
||||||
ServerActiveObject::registerType(getType(), create);
|
ServerActiveObject::registerType(getType(), create);
|
||||||
|
|
||||||
m_oldpos = v3f(0,0,0);
|
m_oldpos = v3f(0,0,0);
|
||||||
@ -425,7 +425,7 @@ std::string RatSAO::getClientInitializationData()
|
|||||||
|
|
||||||
std::string RatSAO::getStaticData()
|
std::string RatSAO::getStaticData()
|
||||||
{
|
{
|
||||||
dstream<<__FUNCTION_NAME<<std::endl;
|
//dstream<<__FUNCTION_NAME<<std::endl;
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// version
|
// version
|
||||||
writeU8(os, 0);
|
writeU8(os, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user