mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
avoid possible problems with blocking
This commit is contained in:
parent
a571837604
commit
a430821ad9
@ -616,11 +616,13 @@ bool StartClient(const char* playername, const char* host)
|
|||||||
ENetEvent event;
|
ENetEvent event;
|
||||||
int conn = 0;
|
int conn = 0;
|
||||||
u32 starttick = SDL_GetTicks();
|
u32 starttick = SDL_GetTicks();
|
||||||
const u32 conntimeout = 5000;
|
const int conntimeout = 5000;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
u32 curtick = SDL_GetTicks();
|
u32 curtick = SDL_GetTicks();
|
||||||
u32 timeout = conntimeout - (curtick - starttick);
|
if (curtick < starttick) break;
|
||||||
|
int timeout = conntimeout - (int)(curtick - starttick);
|
||||||
|
if (timeout < 0) break;
|
||||||
if (enet_host_service(Host, &event, timeout) > 0)
|
if (enet_host_service(Host, &event, timeout) > 0)
|
||||||
{
|
{
|
||||||
if (conn == 0 && event.type == ENET_EVENT_TYPE_CONNECT)
|
if (conn == 0 && event.type == ENET_EVENT_TYPE_CONNECT)
|
||||||
@ -1083,8 +1085,10 @@ void Process(bool block)
|
|||||||
if (block)
|
if (block)
|
||||||
{
|
{
|
||||||
u32 time = SDL_GetTicks();
|
u32 time = SDL_GetTicks();
|
||||||
timeout -= (time - time_last);
|
if (time < time_last) return;
|
||||||
|
timeout -= (int)(time - time_last);
|
||||||
if (timeout <= 0) return;
|
if (timeout <= 0) return;
|
||||||
|
time_last = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user