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)
{
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
/*
/*
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)
MapBlock *b = m_env.getMap().getBlockNoCreateNoEx(p);
if(b == NULL)
return;
-
+
/*
Create a task to update the mesh of the block
*/
{
//TimeTaker timer("data fill");
- // 0ms
+ // Release: ~0ms
+ // Debug: 1-6ms, avg=2ms
data->fill(getDayNightRatio(), b);
}
}
#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);
}
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");
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");
while(device->run() && kill == false)
{
+ //std::cerr<<"frame"<<std::endl;
+
if(g_gamecallback->disconnect_requested)
{
g_gamecallback->disconnect_requested = false;
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
{
*/
{
// 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();
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)
{
/*
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;*/
}
}