mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 19:45:33 +00:00
[Browser] Fix freeze when server is unreachable
This commit is contained in:
parent
24d4e1c222
commit
f8c6ed8028
1 changed files with 6 additions and 1 deletions
|
@ -25,8 +25,13 @@ unsigned int PingRakNetServer(const char *addr, unsigned short port)
|
||||||
peer->Startup(1, &socketDescriptor, 1);
|
peer->Startup(1, &socketDescriptor, 1);
|
||||||
if (!peer->Ping(addr, port, false))
|
if (!peer->Ping(addr, port, false))
|
||||||
return time;
|
return time;
|
||||||
|
RakNet::TimeMS start = RakNet::GetTimeMS();
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
|
RakNet::TimeMS now = RakNet::GetTimeMS();
|
||||||
|
if(now - start >= PING_UNREACHABLE)
|
||||||
|
break;
|
||||||
|
|
||||||
packet = peer->Receive();
|
packet = peer->Receive();
|
||||||
if (!packet)
|
if (!packet)
|
||||||
continue;
|
continue;
|
||||||
|
@ -41,7 +46,7 @@ unsigned int PingRakNetServer(const char *addr, unsigned short port)
|
||||||
case ID_UNCONNECTED_PONG:
|
case ID_UNCONNECTED_PONG:
|
||||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||||
bsIn.Read(time);
|
bsIn.Read(time);
|
||||||
time = RakNet::GetTimeMS() - time;
|
time = now - time;
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue