block->setChangedFlag();
}
else{
- dstream<<"WARNING: Server: Could not find a block for "
+ dstream<<"WARNING: ServerEnv: Could not find a block for "
<<"storing newly added static active object"<<std::endl;
}
StaticObject s_obj(obj->getType(), objectpos, staticdata);
// Add to the block where the object is located in
v3s16 blockpos = getNodeBlockPos(floatToInt(objectpos, BS));
- MapBlock *block = m_map->getBlockNoCreateNoEx(blockpos);
+ // Get or generate the block
+ MapBlock *block = m_map->emergeBlock(blockpos);
+
+ /*MapBlock *block = m_map->getBlockNoCreateNoEx(blockpos);
+ if(block == NULL)
+ {
+ // Block not found. Is the old block still ok?
+ if(oldblock)
+ block = oldblock;
+ // Load from disk or generate
+ else
+ block = m_map->emergeBlock(blockpos);
+ }*/
+
if(block)
{
block->m_static_objects.insert(0, s_obj);
obj->m_static_exists = true;
obj->m_static_block = block->getPos();
}
- // If not possible, add back to previous block
- else if(oldblock)
- {
- oldblock->m_static_objects.insert(0, s_obj);
- oldblock->setChangedFlag();
- obj->m_static_exists = true;
- obj->m_static_block = oldblock->getPos();
- }
else{
- dstream<<"WARNING: Server: Could not find a block for "
- <<"storing static object"<<std::endl;
+ dstream<<"WARNING: ServerEnv: Could not find or generate "
+ <<"a block for storing static object"<<std::endl;
obj->m_static_exists = false;
continue;
}
- Simulate rock falling from cliffs when water has removed\r
enough solid rock from the bottom\r
\r
+SUGG: For non-mapgen FarMesh: Add a per-sector database to store surface\r
+ stuff as simple flags/values\r
+ - Light?\r
+ - A building?\r
+ And at some point make the server send this data to the client too,\r
+ instead of referring to the noise functions\r
+ - Ground height\r
+ - Surface ground type\r
+ - Trees?\r
+\r
Gaming ideas:\r
-------------\r
\r
sectors that have very large amounts of blocks (on client)\r
- Is this necessary at all?\r
\r
-TODO: Flowing water animation\r
-\r
SUGG: Draw cubes in inventory directly with 3D drawing commands, so that\r
animating them is easier.\r
\r
SUGG: Option for enabling proper alpha channel for textures\r
+\r
+TODO: Flowing water animation\r
+\r
TODO: A setting for enabling bilinear filtering for textures\r
\r
TODO: Better control of draw_control.wanted_max_blocks\r
TODO: Move mineral to param2, increment map serialization version, add\r
conversion\r
\r
-TODO: Add a per-sector database to store surface stuff as simple flags/values\r
- - Light?\r
- - A building?\r
- And at some point make the server send this data to the client too,\r
- instead of referring to the noise functions\r
- - Ground height\r
- - Surface ground type\r
- - Trees?\r
-\r
TODO: Restart irrlicht completely when coming back to main menu from game.\r
- This gets rid of everything that is stored in irrlicht's caches.\r
\r
return block;
}
-#if 0
-MapBlock * ServerMap::emergeBlock(
- v3s16 p,
- bool only_from_disk,
- core::map<v3s16, MapBlock*> &changed_blocks,
- core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
-)
+MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
{
- DSTACKF("%s: p=(%d,%d,%d), only_from_disk=%d",
+ DSTACKF("%s: p=(%d,%d,%d), allow_generate=%d",
__FUNCTION_NAME,
- p.X, p.Y, p.Z, only_from_disk);
+ p.X, p.Y, p.Z, allow_generate);
- // This has to be redone or removed
- assert(0);
+ {
+ MapBlock *block = getBlockNoCreateNoEx(p);
+ if(block)
+ return block;
+ }
+
+ {
+ MapBlock *block = loadBlock(p);
+ if(block)
+ return block;
+ }
+
+ if(allow_generate)
+ {
+ core::map<v3s16, MapBlock*> modified_blocks;
+ MapBlock *block = generateBlock(p, modified_blocks);
+ if(block)
+ {
+ MapEditEvent event;
+ event.type = MEET_OTHER;
+ event.p = p;
+
+ // Copy modified_blocks to event
+ for(core::map<v3s16, MapBlock*>::Iterator
+ i = modified_blocks.getIterator();
+ i.atEnd()==false; i++)
+ {
+ event.modified_blocks.insert(i.getNode()->getKey(), false);
+ }
+
+ // Queue event
+ dispatchEvent(&event);
+
+ return block;
+ }
+ }
+
return NULL;
}
-#endif
#if 0
/*
// Node metadata of block changed (not knowing which node exactly)
// p stores block coordinate
MEET_BLOCK_NODE_METADATA_CHANGED,
- // Anything else
+ // Anything else (modified_blocks are set unsent)
MEET_OTHER
};
*/
MapBlock * createBlock(v3s16 p);
-#if 0
/*
- NOTE: This comment might be outdated
-
Forcefully get a block from somewhere.
-
- InvalidPositionException possible if only_from_disk==true
-
- Parameters:
- changed_blocks: Blocks that have been modified
+ - Memory
+ - Load from disk
+ - Generate
*/
- MapBlock * emergeBlock(
- v3s16 p,
- bool only_from_disk,
- core::map<v3s16, MapBlock*> &changed_blocks,
- core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
- );
-#endif
+ MapBlock * emergeBlock(v3s16 p, bool allow_generate=true);
// Helper for placing objects on ground level
s16 findGroundLevel(v2s16 p2d);
*/
if(far_players.size() > 0)
{
+ // Convert list format to that wanted by SetBlocksNotSent
core::map<v3s16, MapBlock*> modified_blocks2;
for(core::map<v3s16, bool>::Iterator
i = event->modified_blocks.getIterator();
modified_blocks2.insert(p,
m_env.getMap().getBlockNoCreateNoEx(p));
}
+ // Set blocks not sent
for(core::list<u16>::Iterator
i = far_players.begin();
i != far_players.end(); i++)