1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-22 12:25:23 +02:00

Rework server stepping and dtime calculation

This commit is contained in:
Desour
2023-03-29 11:42:50 +02:00
committed by sfan5
parent b6c7c5a7ab
commit 322c4a5b2b
5 changed files with 87 additions and 81 deletions

View File

@@ -1418,7 +1418,7 @@ void Connection::Disconnect()
putCommand(ConnectionCommand::disconnect());
}
bool Connection::Receive(NetworkPacket *pkt, u32 timeout)
bool Connection::ReceiveTimeoutMs(NetworkPacket *pkt, u32 timeout_ms)
{
/*
Note that this function can potentially wait infinitely if non-data
@@ -1426,7 +1426,7 @@ bool Connection::Receive(NetworkPacket *pkt, u32 timeout)
This is not considered to be a problem (is it?)
*/
for(;;) {
ConnectionEventPtr e_ptr = waitEvent(timeout);
ConnectionEventPtr e_ptr = waitEvent(timeout_ms);
const ConnectionEvent &e = *e_ptr;
if (e.type != CONNEVENT_NONE) {
@@ -1467,14 +1467,14 @@ bool Connection::Receive(NetworkPacket *pkt, u32 timeout)
void Connection::Receive(NetworkPacket *pkt)
{
bool any = Receive(pkt, m_bc_receive_timeout);
bool any = ReceiveTimeoutMs(pkt, m_bc_receive_timeout);
if (!any)
throw NoIncomingDataException("No incoming data");
}
bool Connection::TryReceive(NetworkPacket *pkt)
{
return Receive(pkt, 0);
return ReceiveTimeoutMs(pkt, 0);
}
void Connection::Send(session_t peer_id, u8 channelnum,

View File

@@ -714,7 +714,8 @@ public:
void Connect(Address address);
bool Connected();
void Disconnect();
void Receive(NetworkPacket* pkt);
bool ReceiveTimeoutMs(NetworkPacket *pkt, u32 timeout_ms);
void Receive(NetworkPacket *pkt);
bool TryReceive(NetworkPacket *pkt);
void Send(session_t peer_id, u8 channelnum, NetworkPacket *pkt, bool reliable);
session_t GetPeerID() const { return m_peer_id; }
@@ -747,8 +748,6 @@ protected:
// Command queue: user -> SendThread
MutexedQueue<ConnectionCommandPtr> m_command_queue;
bool Receive(NetworkPacket *pkt, u32 timeout);
void putEvent(ConnectionEventPtr e);
void TriggerSend();