a commit before starting to reorganize the map loading/generation logic

master
Perttu Ahola 2011-04-10 19:12:56 +03:00
parent 7aa2d4d109
commit 6fa85c8502
5 changed files with 357 additions and 542 deletions

View File

@ -528,8 +528,8 @@ void ServerEnvironment::step(float dtime)
i = block->m_static_objects.m_stored.begin();
i != block->m_static_objects.m_stored.end(); i++)
{
dstream<<"INFO: Server: Creating an active object from "
<<"static data"<<std::endl;
/*dstream<<"INFO: Server: Creating an active object from "
<<"static data"<<std::endl;*/
StaticObject &s_obj = *i;
// Create an active object from the data
ServerActiveObject *obj = ServerActiveObject::create
@ -643,9 +643,9 @@ void ServerEnvironment::step(float dtime)
obj->m_static_exists = false;
continue;
}
/*dstream<<"INFO: Server: Stored static data. Deleting object."
<<std::endl;*/
// Delete active object
dstream<<"INFO: Server: Stored static data. Deleting object."
<<std::endl;
delete obj;
// Id to be removed from m_active_objects
objects_to_remove.push_back(id);
@ -767,8 +767,8 @@ u16 ServerEnvironment::addActiveObject(ServerActiveObject *object)
delete object;
return 0;
}
dstream<<"INGO: ServerEnvironment::addActiveObject(): "
<<"added (id="<<object->getId()<<")"<<std::endl;
/*dstream<<"INGO: ServerEnvironment::addActiveObject(): "
<<"added (id="<<object->getId()<<")"<<std::endl;*/
m_active_objects.insert(object->getId(), object);

File diff suppressed because it is too large Load Diff

View File

@ -731,6 +731,9 @@ class ManualMapVoxelManipulator : public MapVoxelManipulator
public:
ManualMapVoxelManipulator(Map *map);
virtual ~ManualMapVoxelManipulator();
void setMap(Map *map)
{m_map = map;}
virtual void emerge(VoxelArea a, s32 caller_id=-1);

View File

@ -139,6 +139,22 @@ void * EmergeThread::Thread()
bool got_block = true;
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
//TimeTaker envlockwaittimer("block emerge envlock wait time");
@ -151,10 +167,6 @@ void * EmergeThread::Thread()
//TimeTaker timer("block emerge (while env locked)");
try{
bool only_from_disk = false;
if(optional)
only_from_disk = true;
// First check if the block already exists
//block = map.getBlockNoCreate(p);
@ -167,28 +179,6 @@ void * EmergeThread::Thread()
only_from_disk,
changed_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
@ -3824,34 +3814,6 @@ Player *Server::emergePlayer(const char *name, const char *password,
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
dstream<<"Searched through "<<i<<" places."<<std::endl;
break;

View File

@ -272,7 +272,7 @@ RatSAO::RatSAO(ServerEnvironment *env, u16 id, v3f pos):
ServerActiveObject(env, id, pos),
m_speed_f(0,0,0)
{
dstream<<"Server: RatSAO created"<<std::endl;
//dstream<<"Server: RatSAO created"<<std::endl;
ServerActiveObject::registerType(getType(), create);
m_oldpos = v3f(0,0,0);
@ -425,7 +425,7 @@ std::string RatSAO::getClientInitializationData()
std::string RatSAO::getStaticData()
{
dstream<<__FUNCTION_NAME<<std::endl;
//dstream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary);
// version
writeU8(os, 0);