1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Fixed minetest reliable udp implementation (compatible to old clients)

This commit is contained in:
sapier 2014-01-06 20:05:28 +01:00
parent 8b0b857eaa
commit 9edb91da57
8 changed files with 2844 additions and 1156 deletions

View file

@ -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<u8> 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<u8> 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=" <<s.size()<<std::endl;
SharedBuffer<u8> 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);
}
}