aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-01-06 20:05:28 +0100
committersapier <Sapier at GMX dot net>2014-01-10 10:10:45 +0100
commit9edb91da5754cf194637d1d7faa513719b61f9b4 (patch)
tree66adfd87cb43e9b24adc70bcaabfae205fc10f8f /src/server.cpp
parent8b0b857eaaa50c6ec217a46c0577395c78ec04c7 (diff)
downloadminetest-9edb91da5754cf194637d1d7faa513719b61f9b4.tar.gz
minetest-9edb91da5754cf194637d1d7faa513719b61f9b4.tar.bz2
minetest-9edb91da5754cf194637d1d7faa513719b61f9b4.zip
Fixed minetest reliable udp implementation (compatible to old clients)
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp22
1 files changed, 12 insertions, 10 deletions
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<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);
}
}