From d884b3f6d64390fa0259323a25cf5553da2774c0 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 1 Oct 2019 23:56:25 -0700 Subject: [PATCH] Fix netplay on modern versions of Visual Studio, from Ala-lala --- sc2/src/uqm/supermelee/netplay/netrcv.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/sc2/src/uqm/supermelee/netplay/netrcv.c b/sc2/src/uqm/supermelee/netplay/netrcv.c index 137cfcd88..b9ea5f7f7 100644 --- a/sc2/src/uqm/supermelee/netplay/netrcv.c +++ b/sc2/src/uqm/supermelee/netplay/netrcv.c @@ -146,19 +146,18 @@ dataReadyCallback(NetDescriptor *nd) { } if (numRead == -1) { - switch (errno) { - case EAGAIN: // No more data for now. - return; - case EINTR: // System call was interrupted. Retry. - continue; - default: { - int savedErrno = errno; - log_add(log_Error, "recv() failed: %s.\n", - strerror(errno)); - NetConnection_doErrorCallback(conn, savedErrno); - NetDescriptor_close(nd); - return; - } + if (errno == EWOULDBLOCK || errno == EAGAIN) + return; // No more data for now. + else if (errno == EINTR) + continue; // System call was interrupted. Retry. + else + { + int savedErrno = errno; + log_add(log_Error, "recv() failed: %s.\n", + strerror(errno)); + NetConnection_doErrorCallback(conn, savedErrno); + NetDescriptor_close(nd); + return; } }