summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-02-28 02:01:40 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-02-28 02:01:40 +0200
commitc8be58a65ce5f06bc23353b41caf9495e3b9d484 (patch)
tree1dc57a45f1fac9c2f7730bb2c80201e46ec70997 /src/server.cpp
parent5707c309c9c84589a964067477027b775a511aeb (diff)
downloadminetest-c8be58a65ce5f06bc23353b41caf9495e3b9d484.tar.gz
minetest-c8be58a65ce5f06bc23353b41caf9495e3b9d484.tar.bz2
minetest-c8be58a65ce5f06bc23353b41caf9495e3b9d484.zip
A third try on terrain generation. No trees yet.
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 24f22c6b3..e4c92e356 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -167,6 +167,26 @@ void * EmergeThread::Thread()
only_from_disk,
changed_blocks,
lighting_invalidated_blocks);
+
+ /*
+ 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)
+ {
+ }
}
// If it is a dummy, block was not found on disk
@@ -208,23 +228,25 @@ void * EmergeThread::Thread()
Collect a list of blocks that have been modified in
addition to the fetched one.
*/
-
- // Add all the "changed blocks" to modified_blocks
- for(core::map<v3s16, MapBlock*>::Iterator i = changed_blocks.getIterator();
- i.atEnd() == false; i++)
- {
- MapBlock *block = i.getNode()->getValue();
- modified_blocks.insert(block->getPos(), block);
- }
- /*dstream<<"lighting "<<lighting_invalidated_blocks.size()
- <<" blocks"<<std::endl;*/
+ if(lighting_invalidated_blocks.size() > 0)
+ dstream<<"lighting "<<lighting_invalidated_blocks.size()
+ <<" blocks"<<std::endl;
- //TimeTaker timer("** updateLighting");
+ // 50-100ms for single block generation
+ //TimeTaker timer("** EmergeThread updateLighting");
// Update lighting without locking the environment mutex,
// add modified blocks to changed blocks
map.updateLighting(lighting_invalidated_blocks, modified_blocks);
+
+ // Add all from changed_blocks to modified_blocks
+ for(core::map<v3s16, MapBlock*>::Iterator i = changed_blocks.getIterator();
+ i.atEnd() == false; i++)
+ {
+ MapBlock *block = i.getNode()->getValue();
+ modified_blocks.insert(block->getPos(), block);
+ }
}
// If we got no block, there should be no invalidated blocks
else
@@ -551,7 +573,8 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
{
//TODO: Get value from somewhere
// Allow only one block in emerge queue
- if(server->m_emerge_queue.peerItemCount(peer_id) < 1)
+ //if(server->m_emerge_queue.peerItemCount(peer_id) < 1)
+ if(server->m_emerge_queue.peerItemCount(peer_id) < 2)
{
//dstream<<"Adding block to emerge queue"<<std::endl;
@@ -1681,10 +1704,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Now answer with a TOCLIENT_INIT
- SharedBuffer<u8> reply(2+1+6);
+ SharedBuffer<u8> reply(2+1+6+8);
writeU16(&reply[0], TOCLIENT_INIT);
writeU8(&reply[2], deployed);
- writeV3S16(&reply[3], floatToInt(player->getPosition()+v3f(0,BS/2,0), BS));
+ writeV3S16(&reply[2+1], floatToInt(player->getPosition()+v3f(0,BS/2,0), BS));
+ writeU64(&reply[2+1+6], m_env.getServerMap().getSeed());
// Send as reliable
m_con.Send(peer_id, 0, reply, true);