From 9e7d6cced127f616594525c483ea76b5bd5d7f14 Mon Sep 17 00:00:00 2001 From: darkrose Date: Wed, 6 Apr 2016 17:24:15 +1000 Subject: [PATCH] some meshgen tweaks --- src/client.cpp | 18 +++++++++++------- src/map.cpp | 7 +------ src/server.cpp | 27 +++++++++++---------------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index db805d1..2e46565 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -577,15 +577,19 @@ void Client::step(float dtime) while (m_mesh_update_thread.m_queue_out.size() > 0) { MeshUpdateResult r = m_mesh_update_thread.m_queue_out.pop_front(); MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(r.p); - if (block && r.mesh != NULL) { - JMutexAutoLock lock(block->mesh_mutex); + if (block) { + if (r.mesh != NULL) { + JMutexAutoLock lock(block->mesh_mutex); - MapBlockMesh *mesh_old = block->mesh; - block->mesh = r.mesh; - block->setMeshExpired(false); + MapBlockMesh *mesh_old = block->mesh; + block->mesh = r.mesh; + block->setMeshExpired(false); - if (mesh_old != NULL) - delete mesh_old; + if (mesh_old != NULL) + delete mesh_old; + }else{ + block->setMeshExpired(false); + } } if (r.ack_block_to_server) { /*infostream<<"Client: ACK block ("<getEnv().getDayNightRatio(); - m_camera_mutex.Lock(); v3f camera_position = m_camera_position; v3f camera_direction = m_camera_direction; @@ -3348,11 +3346,8 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) // Mesh has been expired: generate new mesh if (block->mesh) { - JMutexAutoLock lock(block->mesh_mutex); - block->mesh->refresh(daynight_ratio); - block->setMeshExpired(false); - }else{ m_client->addUpdateMeshTask(block->getPos(),false,true); + block->setMeshExpired(false); } mesh_expired = false; diff --git a/src/server.cpp b/src/server.cpp index 8cc6765..fe38203 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -783,11 +783,12 @@ void RemoteClient::GotBlock(v3s16 p) void RemoteClient::SentBlock(v3s16 p) { - if(m_blocks_sending.find(p) == NULL) + if (m_blocks_sending.find(p) == NULL) { m_blocks_sending.insert(p, 0.0); - else + }else{ infostream<<"RemoteClient::SentBlock(): Sent block" " already in m_blocks_sending"<getS32("max_simultaneous_block_sends_server_total"); + //TimeTaker timer("Server::SendBlocks"); core::array queue; @@ -5418,16 +5421,13 @@ void Server::SendBlocks(float dtime) { ScopeProfiler sp(g_profiler, "Server: selecting blocks for sending"); - for(core::map::Iterator - i = m_clients.getIterator(); - i.atEnd() == false; i++) - { + for (core::map::Iterator i = m_clients.getIterator(); i.atEnd() == false; i++) { RemoteClient *client = i.getNode()->getValue(); assert(client->peer_id == i.getNode()->getKey()); total_sending += client->SendingCount(); - if(client->serialization_version == SER_FMT_VER_INVALID) + if (client->serialization_version == SER_FMT_VER_INVALID) continue; client->GetNextBlocks(this, dtime, queue); @@ -5439,22 +5439,17 @@ void Server::SendBlocks(float dtime) // Lowest is most important. queue.sort(); - for(u32 i=0; i= g_settings->getS32 - ("max_simultaneous_block_sends_server_total")) + if (total_sending >= max) break; PrioritySortedBlockTransfer q = queue[i]; MapBlock *block = NULL; - try - { + try{ block = m_env.getMap().getBlockNoCreate(q.pos); - } - catch(InvalidPositionException &e) - { + }catch (InvalidPositionException &e) { continue; }