Network/ENetHost: Fix service time precision
This commit is contained in:
parent
7eff1f34f1
commit
f2506ee918
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Network/ENetCompressor.hpp>
|
||||
#include <Nazara/Network/ENetPeer.hpp>
|
||||
|
|
@ -95,6 +96,8 @@ namespace Nz
|
|||
|
||||
void ThrottleBandwidth();
|
||||
|
||||
inline void UpdateServiceTime();
|
||||
|
||||
static std::size_t GetCommandSize(UInt8 commandNumber);
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
|
|
|||
|
|
@ -73,6 +73,12 @@ namespace Nz
|
|||
|
||||
return ref;
|
||||
}
|
||||
|
||||
inline void ENetHost::UpdateServiceTime()
|
||||
{
|
||||
// Compute service time as microseconds for extra precision
|
||||
m_serviceTime = static_cast<UInt32>(GetElapsedMicroseconds() / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Network/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/ENetHost.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/OffsetOf.hpp>
|
||||
#include <Nazara/Network/Algorithm.hpp>
|
||||
#include <Nazara/Network/ENetPeer.hpp>
|
||||
|
|
@ -199,7 +198,7 @@ namespace Nz
|
|||
|
||||
void ENetHost::Flush()
|
||||
{
|
||||
m_serviceTime = GetElapsedMilliseconds();
|
||||
UpdateServiceTime();
|
||||
|
||||
SendOutgoingCommands(nullptr, false);
|
||||
}
|
||||
|
|
@ -216,7 +215,8 @@ namespace Nz
|
|||
return 1;
|
||||
}
|
||||
|
||||
m_serviceTime = GetElapsedMilliseconds();
|
||||
UpdateServiceTime();
|
||||
|
||||
timeout += m_serviceTime;
|
||||
|
||||
do
|
||||
|
|
@ -279,7 +279,7 @@ namespace Nz
|
|||
|
||||
for (;;)
|
||||
{
|
||||
m_serviceTime = GetElapsedMilliseconds();
|
||||
UpdateServiceTime();
|
||||
|
||||
if (ENetTimeGreaterEqual(m_serviceTime, timeout))
|
||||
return 0;
|
||||
|
|
@ -288,7 +288,7 @@ namespace Nz
|
|||
break;
|
||||
}
|
||||
|
||||
m_serviceTime = GetElapsedMilliseconds();
|
||||
UpdateServiceTime();
|
||||
}
|
||||
while (m_poller.IsReadyToRead(m_socket));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue