From 9edb91da5754cf194637d1d7faa513719b61f9b4 Mon Sep 17 00:00:00 2001 From: sapier Date: Mon, 6 Jan 2014 20:05:28 +0100 Subject: Fixed minetest reliable udp implementation (compatible to old clients) --- src/server.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index d8bedb260..b257448a1 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -90,14 +90,15 @@ public: void * ServerThread::Thread() { - ThreadStarted(); - log_register_thread("ServerThread"); DSTACK(__FUNCTION_NAME); - BEGIN_DEBUG_EXCEPTION_HANDLER + m_server->AsyncRunStep(true); + + ThreadStarted(); + while(!StopRequested()) { try{ @@ -1018,7 +1019,7 @@ void Server::step(float dtime) } } -void Server::AsyncRunStep() +void Server::AsyncRunStep(bool initial_step) { DSTACK(__FUNCTION_NAME); @@ -1035,7 +1036,7 @@ void Server::AsyncRunStep() SendBlocks(dtime); } - if(dtime < 0.001) + if((dtime < 0.001) && (initial_step == false)) return; g_profiler->add("Server::AsyncRunStep with dtime (num)", 1); @@ -1528,7 +1529,7 @@ void Server::AsyncRunStep() memcpy((char*)&reply[2], unreliable_data.c_str(), unreliable_data.size()); // Send as unreliable - m_con.Send(client->peer_id, 0, reply, false); + m_con.Send(client->peer_id, 1, reply, false); } /*if(reliable_data.size() > 0 || unreliable_data.size() > 0) @@ -3721,7 +3722,7 @@ void Server::SendHUDAdd(u16 peer_id, u32 id, HudElement *form) std::string s = os.str(); SharedBuffer data((u8*)s.c_str(), s.size()); // Send as reliable - m_con.Send(peer_id, 0, data, true); + m_con.Send(peer_id, 1, data, true); } void Server::SendHUDRemove(u16 peer_id, u32 id) @@ -3736,7 +3737,8 @@ void Server::SendHUDRemove(u16 peer_id, u32 id) std::string s = os.str(); SharedBuffer data((u8*)s.c_str(), s.size()); // Send as reliable - m_con.Send(peer_id, 0, data, true); + + m_con.Send(peer_id, 1, data, true); } void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value) @@ -4204,7 +4206,7 @@ void Server::SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto /* Send packet */ - m_con.Send(peer_id, 1, reply, true); + m_con.Send(peer_id, 2, reply, true); } void Server::SendBlocks(float dtime) @@ -4566,7 +4568,7 @@ void Server::sendRequestedMedia(u16 peer_id, <<" size=" < data((u8*)s.c_str(), s.size()); // Send as reliable - m_con.Send(peer_id, 0, data, true); + m_con.Send(peer_id, 2, data, true); } } -- cgit v1.2.3