diff options
-rw-r--r-- | src/client.cpp | 104 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 2 | ||||
-rw-r--r-- | src/game.cpp | 15 | ||||
-rw-r--r-- | src/server.cpp | 64 |
4 files changed, 111 insertions, 74 deletions
diff --git a/src/client.cpp b/src/client.cpp index 6d0e6860c..248cd8a4c 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -135,6 +135,15 @@ void * MeshUpdateThread::Thread() while(getRun()) { + /*// Wait for output queue to flush. + // Allow 2 in queue, this makes less frametime jitter. + // Umm actually, there is no much difference + if(m_queue_out.size() >= 2) + { + sleep_ms(3); + continue; + }*/ + QueuedMeshUpdate *q = m_queue_in.pop(); if(q == NULL) { @@ -794,56 +803,43 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) MapSector *sector; MapBlock *block; - { //envlock - //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out - - v2s16 p2d(p.X, p.Z); - sector = m_env.getMap().emergeSector(p2d); - - v2s16 sp = sector->getPos(); - if(sp != p2d) - { - dstream<<"ERROR: Got sector with getPos()=" - <<"("<<sp.X<<","<<sp.Y<<"), tried to get" - <<"("<<p2d.X<<","<<p2d.Y<<")"<<std::endl; - } - - assert(sp == p2d); - //assert(sector->getPos() == p2d); + v2s16 p2d(p.X, p.Z); + sector = m_env.getMap().emergeSector(p2d); + + assert(sector->getPos() == p2d); - //TimeTaker timer("MapBlock deSerialize"); - // 0ms - - block = sector->getBlockNoCreateNoEx(p.Y); - if(block) - { - /* - Update an existing block - */ - //dstream<<"Updating"<<std::endl; - block->deSerialize(istr, ser_version); - } - else - { - /* - Create a new block - */ - //dstream<<"Creating new"<<std::endl; - block = new MapBlock(&m_env.getMap(), p); - block->deSerialize(istr, ser_version); - sector->insertBlock(block); - - //DEBUG - /*NodeMod mod; - mod.type = NODEMOD_CHANGECONTENT; - mod.param = CONTENT_MESE; - block->setTempMod(v3s16(8,10,8), mod); - block->setTempMod(v3s16(8,9,8), mod); - block->setTempMod(v3s16(8,8,8), mod); - block->setTempMod(v3s16(8,7,8), mod); - block->setTempMod(v3s16(8,6,8), mod);*/ - } - } //envlock + //TimeTaker timer("MapBlock deSerialize"); + // 0ms + + block = sector->getBlockNoCreateNoEx(p.Y); + if(block) + { + /* + Update an existing block + */ + //dstream<<"Updating"<<std::endl; + block->deSerialize(istr, ser_version); + } + else + { + /* + Create a new block + */ + //dstream<<"Creating new"<<std::endl; + block = new MapBlock(&m_env.getMap(), p); + block->deSerialize(istr, ser_version); + sector->insertBlock(block); + + //DEBUG + /*NodeMod mod; + mod.type = NODEMOD_CHANGECONTENT; + mod.param = CONTENT_MESE; + block->setTempMod(v3s16(8,10,8), mod); + block->setTempMod(v3s16(8,9,8), mod); + block->setTempMod(v3s16(8,8,8), mod); + block->setTempMod(v3s16(8,7,8), mod); + block->setTempMod(v3s16(8,6,8), mod);*/ + } #if 0 /* @@ -876,6 +872,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) /* Add it to mesh update queue and set it to be acknowledged after update. */ + //std::cerr<<"Adding mesh update task for received block"<<std::endl; addUpdateMeshTaskWithEdge(p, true); } else if(command == TOCLIENT_PLAYERPOS) @@ -2118,7 +2115,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server) MapBlock *b = m_env.getMap().getBlockNoCreateNoEx(p); if(b == NULL) return; - + /* Create a task to update the mesh of the block */ @@ -2127,7 +2124,8 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server) { //TimeTaker timer("data fill"); - // 0ms + // Release: ~0ms + // Debug: 1-6ms, avg=2ms data->fill(getDayNightRatio(), b); } @@ -2153,6 +2151,10 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server) } #endif + /* + Mark mesh as non-expired at this point so that it can already + be marked as expired again if the data changes + */ b->setMeshExpired(false); } diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 74d323237..84fac75ec 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -42,6 +42,7 @@ void set_default_settings() g_settings.setDefault("keymap_rangeselect", "KEY_KEY_R"); g_settings.setDefault("keymap_freemove", "KEY_KEY_K"); g_settings.setDefault("keymap_fastmove", "KEY_KEY_J"); + g_settings.setDefault("keymap_frametime_graph", "KEY_F1"); // Some (temporary) keys for debugging g_settings.setDefault("keymap_special1", "KEY_KEY_E"); g_settings.setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); @@ -83,6 +84,7 @@ void set_default_settings() g_settings.setDefault("objectdata_interval", "0.2"); g_settings.setDefault("active_object_range", "2"); //g_settings.setDefault("max_simultaneous_block_sends_per_client", "1"); + // This causes frametime jitter on client side, or does it? g_settings.setDefault("max_simultaneous_block_sends_per_client", "2"); g_settings.setDefault("max_simultaneous_block_sends_server_total", "8"); g_settings.setDefault("max_block_send_distance", "8"); diff --git a/src/game.cpp b/src/game.cpp index 337879cb8..aa1cf4a70 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -940,6 +940,8 @@ void the_game( while(device->run() && kill == false) { + //std::cerr<<"frame"<<std::endl; + if(g_gamecallback->disconnect_requested) { g_gamecallback->disconnect_requested = false; @@ -1221,6 +1223,19 @@ void the_game( chat_lines.push_back(ChatLine(L"fast_move enabled")); } } + else if(input->wasKeyDown(getKeySetting("keymap_frametime_graph"))) + { + if(g_settings.getBool("frametime_graph")) + { + g_settings.set("frametime_graph","false"); + chat_lines.push_back(ChatLine(L"frametime_graph disabled")); + } + else + { + g_settings.set("frametime_graph","true"); + chat_lines.push_back(ChatLine(L"frametime_graph enabled")); + } + } // Item selection with mouse wheel { diff --git a/src/server.cpp b/src/server.cpp index 671c3bd4e..16346b870 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1657,7 +1657,13 @@ void Server::AsyncRunStep() */ { // Don't send too many at a time - u32 count = 0; + //u32 count = 0; + + // Single change sending is disabled if queue size is not small + bool disable_single_change_sending = false; + if(m_unsent_map_edit_queue.size() >= 4) + disable_single_change_sending = true; + while(m_unsent_map_edit_queue.size() != 0) { MapEditEvent* event = m_unsent_map_edit_queue.pop_front(); @@ -1670,14 +1676,22 @@ void Server::AsyncRunStep() if(event->type == MEET_ADDNODE) { dstream<<"Server: MEET_ADDNODE"<<std::endl; - sendAddNode(event->p, event->n, event->already_known_by_peer, - &far_players, 30); + if(disable_single_change_sending) + sendAddNode(event->p, event->n, event->already_known_by_peer, + &far_players, 5); + else + sendAddNode(event->p, event->n, event->already_known_by_peer, + &far_players, 30); } else if(event->type == MEET_REMOVENODE) { dstream<<"Server: MEET_REMOVENODE"<<std::endl; - sendRemoveNode(event->p, event->already_known_by_peer, - &far_players, 30); + if(disable_single_change_sending) + sendRemoveNode(event->p, event->already_known_by_peer, + &far_players, 5); + else + sendRemoveNode(event->p, event->already_known_by_peer, + &far_players, 30); } else if(event->type == MEET_BLOCK_NODE_METADATA_CHANGED) { @@ -1698,31 +1712,35 @@ void Server::AsyncRunStep() /* Set blocks not sent to far players */ - core::map<v3s16, MapBlock*> modified_blocks2; - for(core::map<v3s16, bool>::Iterator - i = event->modified_blocks.getIterator(); - i.atEnd()==false; i++) + if(far_players.size() > 0) { - v3s16 p = i.getNode()->getKey(); - modified_blocks2.insert(p, m_env.getMap().getBlockNoCreateNoEx(p)); - } - for(core::list<u16>::Iterator - i = far_players.begin(); - i != far_players.end(); i++) - { - u16 peer_id = *i; - RemoteClient *client = getClient(peer_id); - if(client==NULL) - continue; - client->SetBlocksNotSent(modified_blocks2); + core::map<v3s16, MapBlock*> modified_blocks2; + for(core::map<v3s16, bool>::Iterator + i = event->modified_blocks.getIterator(); + i.atEnd()==false; i++) + { + v3s16 p = i.getNode()->getKey(); + modified_blocks2.insert(p, + m_env.getMap().getBlockNoCreateNoEx(p)); + } + for(core::list<u16>::Iterator + i = far_players.begin(); + i != far_players.end(); i++) + { + u16 peer_id = *i; + RemoteClient *client = getClient(peer_id); + if(client==NULL) + continue; + client->SetBlocksNotSent(modified_blocks2); + } } delete event; - // Don't send too many at a time + /*// Don't send too many at a time count++; if(count >= 1 && m_unsent_map_edit_queue.size() < 100) - break; + break;*/ } } |