mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6781
6781: Continue sleeping, with `cl_refresh_rate` if packet waked client up r=def- a=Jupeyy Notice i changed the check to > 0 microseconds.. The net wait cant handle nanos, busy waiting sounds bit overkill.. Notice also, i added a comment to the issue, which might be interesting before merging fixes #6751 ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
commit
0e72dc331f
|
@ -3343,8 +3343,15 @@ void CClient::Run()
|
|||
else if(g_Config.m_ClRefreshRate)
|
||||
{
|
||||
SleepTimeInNanoSeconds = (std::chrono::nanoseconds(1s) / (int64_t)g_Config.m_ClRefreshRate) - (Now - LastTime);
|
||||
if(SleepTimeInNanoSeconds > 0ns)
|
||||
net_socket_read_wait(m_aNetClient[CONN_MAIN].m_Socket, SleepTimeInNanoSeconds);
|
||||
auto SleepTimeInNanoSecondsInner = SleepTimeInNanoSeconds;
|
||||
auto NowInner = Now;
|
||||
while((SleepTimeInNanoSecondsInner / std::chrono::nanoseconds(1us).count()) > 0ns)
|
||||
{
|
||||
net_socket_read_wait(m_aNetClient[CONN_MAIN].m_Socket, SleepTimeInNanoSecondsInner);
|
||||
auto NowInnerCalc = time_get_nanoseconds();
|
||||
SleepTimeInNanoSecondsInner -= (NowInnerCalc - NowInner);
|
||||
NowInner = NowInnerCalc;
|
||||
}
|
||||
Slept = true;
|
||||
}
|
||||
if(Slept)
|
||||
|
|
Loading…
Reference in a new issue