added and commented out some debug output

This commit is contained in:
Perttu Ahola 2011-06-26 03:14:52 +03:00
parent bb940a946d
commit c1ceabef71
4 changed files with 110 additions and 73 deletions

@ -135,6 +135,15 @@ void * MeshUpdateThread::Thread()
while(getRun()) 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(); QueuedMeshUpdate *q = m_queue_in.pop();
if(q == NULL) if(q == NULL)
{ {
@ -794,56 +803,43 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
MapSector *sector; MapSector *sector;
MapBlock *block; MapBlock *block;
{ //envlock v2s16 p2d(p.X, p.Z);
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out sector = m_env.getMap().emergeSector(p2d);
v2s16 p2d(p.X, p.Z); assert(sector->getPos() == p2d);
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); //TimeTaker timer("MapBlock deSerialize");
//assert(sector->getPos() == p2d); // 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);
//TimeTaker timer("MapBlock deSerialize"); //DEBUG
// 0ms /*NodeMod mod;
mod.type = NODEMOD_CHANGECONTENT;
block = sector->getBlockNoCreateNoEx(p.Y); mod.param = CONTENT_MESE;
if(block) block->setTempMod(v3s16(8,10,8), mod);
{ block->setTempMod(v3s16(8,9,8), mod);
/* block->setTempMod(v3s16(8,8,8), mod);
Update an existing block block->setTempMod(v3s16(8,7,8), mod);
*/ block->setTempMod(v3s16(8,6,8), mod);*/
//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
#if 0 #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. 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); addUpdateMeshTaskWithEdge(p, true);
} }
else if(command == TOCLIENT_PLAYERPOS) 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); MapBlock *b = m_env.getMap().getBlockNoCreateNoEx(p);
if(b == NULL) if(b == NULL)
return; return;
/* /*
Create a task to update the mesh of the block 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"); //TimeTaker timer("data fill");
// 0ms // Release: ~0ms
// Debug: 1-6ms, avg=2ms
data->fill(getDayNightRatio(), b); data->fill(getDayNightRatio(), b);
} }
@ -2153,6 +2151,10 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
} }
#endif #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); b->setMeshExpired(false);
} }

@ -42,6 +42,7 @@ void set_default_settings()
g_settings.setDefault("keymap_rangeselect", "KEY_KEY_R"); g_settings.setDefault("keymap_rangeselect", "KEY_KEY_R");
g_settings.setDefault("keymap_freemove", "KEY_KEY_K"); g_settings.setDefault("keymap_freemove", "KEY_KEY_K");
g_settings.setDefault("keymap_fastmove", "KEY_KEY_J"); g_settings.setDefault("keymap_fastmove", "KEY_KEY_J");
g_settings.setDefault("keymap_frametime_graph", "KEY_F1");
// Some (temporary) keys for debugging // Some (temporary) keys for debugging
g_settings.setDefault("keymap_special1", "KEY_KEY_E"); g_settings.setDefault("keymap_special1", "KEY_KEY_E");
g_settings.setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); 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("objectdata_interval", "0.2");
g_settings.setDefault("active_object_range", "2"); g_settings.setDefault("active_object_range", "2");
//g_settings.setDefault("max_simultaneous_block_sends_per_client", "1"); //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_per_client", "2");
g_settings.setDefault("max_simultaneous_block_sends_server_total", "8"); g_settings.setDefault("max_simultaneous_block_sends_server_total", "8");
g_settings.setDefault("max_block_send_distance", "8"); g_settings.setDefault("max_block_send_distance", "8");

@ -940,6 +940,8 @@ void the_game(
while(device->run() && kill == false) while(device->run() && kill == false)
{ {
//std::cerr<<"frame"<<std::endl;
if(g_gamecallback->disconnect_requested) if(g_gamecallback->disconnect_requested)
{ {
g_gamecallback->disconnect_requested = false; g_gamecallback->disconnect_requested = false;
@ -1221,6 +1223,19 @@ void the_game(
chat_lines.push_back(ChatLine(L"fast_move enabled")); 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 // Item selection with mouse wheel
{ {

@ -1657,7 +1657,13 @@ void Server::AsyncRunStep()
*/ */
{ {
// Don't send too many at a time // 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) while(m_unsent_map_edit_queue.size() != 0)
{ {
MapEditEvent* event = m_unsent_map_edit_queue.pop_front(); MapEditEvent* event = m_unsent_map_edit_queue.pop_front();
@ -1670,14 +1676,22 @@ void Server::AsyncRunStep()
if(event->type == MEET_ADDNODE) if(event->type == MEET_ADDNODE)
{ {
dstream<<"Server: MEET_ADDNODE"<<std::endl; dstream<<"Server: MEET_ADDNODE"<<std::endl;
sendAddNode(event->p, event->n, event->already_known_by_peer, if(disable_single_change_sending)
&far_players, 30); 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) else if(event->type == MEET_REMOVENODE)
{ {
dstream<<"Server: MEET_REMOVENODE"<<std::endl; dstream<<"Server: MEET_REMOVENODE"<<std::endl;
sendRemoveNode(event->p, event->already_known_by_peer, if(disable_single_change_sending)
&far_players, 30); 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) else if(event->type == MEET_BLOCK_NODE_METADATA_CHANGED)
{ {
@ -1698,31 +1712,35 @@ void Server::AsyncRunStep()
/* /*
Set blocks not sent to far players Set blocks not sent to far players
*/ */
core::map<v3s16, MapBlock*> modified_blocks2; if(far_players.size() > 0)
for(core::map<v3s16, bool>::Iterator
i = event->modified_blocks.getIterator();
i.atEnd()==false; i++)
{ {
v3s16 p = i.getNode()->getKey(); core::map<v3s16, MapBlock*> modified_blocks2;
modified_blocks2.insert(p, m_env.getMap().getBlockNoCreateNoEx(p)); for(core::map<v3s16, bool>::Iterator
} i = event->modified_blocks.getIterator();
for(core::list<u16>::Iterator i.atEnd()==false; i++)
i = far_players.begin(); {
i != far_players.end(); i++) v3s16 p = i.getNode()->getKey();
{ modified_blocks2.insert(p,
u16 peer_id = *i; m_env.getMap().getBlockNoCreateNoEx(p));
RemoteClient *client = getClient(peer_id); }
if(client==NULL) for(core::list<u16>::Iterator
continue; i = far_players.begin();
client->SetBlocksNotSent(modified_blocks2); i != far_players.end(); i++)
{
u16 peer_id = *i;
RemoteClient *client = getClient(peer_id);
if(client==NULL)
continue;
client->SetBlocksNotSent(modified_blocks2);
}
} }
delete event; delete event;
// Don't send too many at a time /*// Don't send too many at a time
count++; count++;
if(count >= 1 && m_unsent_map_edit_queue.size() < 100) if(count >= 1 && m_unsent_map_edit_queue.size() < 100)
break; break;*/
} }
} }