diff --git a/Generals/Code/GameEngine/Source/Common/Recorder.cpp b/Generals/Code/GameEngine/Source/Common/Recorder.cpp index b80c7abe6b..668b5902d7 100644 --- a/Generals/Code/GameEngine/Source/Common/Recorder.cpp +++ b/Generals/Code/GameEngine/Source/Common/Recorder.cpp @@ -1445,117 +1445,142 @@ void RecorderClass::appendNextCommand() { } void RecorderClass::readArgument(GameMessageArgumentDataType type, GameMessage *msg) { - if (type == ARGUMENTDATATYPE_INTEGER) { - Int theint; - m_file->read(&theint, sizeof(theint)); - msg->appendIntegerArgument(theint); + switch (type) { + case ARGUMENTDATATYPE_INTEGER: { + Int theint; + m_file->read(&theint, sizeof(theint)); + msg->appendIntegerArgument(theint); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Integer argument: %d (%8.8X)", theint, theint)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Integer argument: %d (%8.8X)", theint, theint)); + } #endif - } else if (type == ARGUMENTDATATYPE_REAL) { - Real thereal; - m_file->read(&thereal, sizeof(thereal)); - msg->appendRealArgument(thereal); + break; + } + case ARGUMENTDATATYPE_REAL: { + Real thereal; + m_file->read(&thereal, sizeof(thereal)); + msg->appendRealArgument(thereal); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Real argument: %g (%8.8X)", thereal, *(int *)&thereal)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Real argument: %g (%8.8X)", thereal, *(int *)&thereal)); + } #endif - } else if (type == ARGUMENTDATATYPE_BOOLEAN) { - Bool thebool; - m_file->read(&thebool, sizeof(thebool)); - msg->appendBooleanArgument(thebool); + break; + } + case ARGUMENTDATATYPE_BOOLEAN: { + Bool thebool; + m_file->read(&thebool, sizeof(thebool)); + msg->appendBooleanArgument(thebool); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Bool argument: %d", thebool)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Bool argument: %d", thebool)); + } #endif - } else if (type == ARGUMENTDATATYPE_OBJECTID) { - ObjectID theid; - m_file->read(&theid, sizeof(theid)); - msg->appendObjectIDArgument(theid); + break; + } + case ARGUMENTDATATYPE_OBJECTID: { + ObjectID theid; + m_file->read(&theid, sizeof(theid)); + msg->appendObjectIDArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Object ID argument: %d", theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Object ID argument: %d", theid)); + } #endif - } else if (type == ARGUMENTDATATYPE_DRAWABLEID) { - DrawableID theid; - m_file->read(&theid, sizeof(theid)); - msg->appendDrawableIDArgument(theid); + break; + } + case ARGUMENTDATATYPE_DRAWABLEID: { + DrawableID theid; + m_file->read(&theid, sizeof(theid)); + msg->appendDrawableIDArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Drawable ID argument: %d", theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Drawable ID argument: %d", theid)); + } #endif - } else if (type == ARGUMENTDATATYPE_TEAMID) { - UnsignedInt theid; - m_file->read(&theid, sizeof(theid)); - msg->appendTeamIDArgument(theid); + break; + } + case ARGUMENTDATATYPE_TEAMID: { + UnsignedInt theid; + m_file->read(&theid, sizeof(theid)); + msg->appendTeamIDArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Team ID argument: %d", theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Team ID argument: %d", theid)); + } #endif - } else if (type == ARGUMENTDATATYPE_LOCATION) { - Coord3D loc; - m_file->read(&loc, sizeof(loc)); - msg->appendLocationArgument(loc); + break; + } + case ARGUMENTDATATYPE_LOCATION: { + Coord3D loc; + m_file->read(&loc, sizeof(loc)); + msg->appendLocationArgument(loc); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Coord3D argument: %g %g %g (%8.8X %8.8X %8.8X)", loc.x, loc.y, loc.z, - *(int *)&loc.x, *(int *)&loc.y, *(int *)&loc.z)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Coord3D argument: %g %g %g (%8.8X %8.8X %8.8X)", loc.x, loc.y, loc.z, + *(int *)&loc.x, *(int *)&loc.y, *(int *)&loc.z)); + } #endif - } else if (type == ARGUMENTDATATYPE_PIXEL) { - ICoord2D pixel; - m_file->read(&pixel, sizeof(pixel)); - msg->appendPixelArgument(pixel); + break; + } + case ARGUMENTDATATYPE_PIXEL: { + ICoord2D pixel; + m_file->read(&pixel, sizeof(pixel)); + msg->appendPixelArgument(pixel); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Pixel argument: %d,%d", pixel.x, pixel.y)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Pixel argument: %d,%d", pixel.x, pixel.y)); + } #endif - } else if (type == ARGUMENTDATATYPE_PIXELREGION) { - IRegion2D reg; - m_file->read(®, sizeof(reg)); - msg->appendPixelRegionArgument(reg); + break; + } + case ARGUMENTDATATYPE_PIXELREGION: { + IRegion2D reg; + m_file->read(®, sizeof(reg)); + msg->appendPixelRegionArgument(reg); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Pixel Region argument: %d,%d -> %d,%d", reg.lo.x, reg.lo.y, reg.hi.x, reg.hi.y)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Pixel Region argument: %d,%d -> %d,%d", reg.lo.x, reg.lo.y, reg.hi.x, reg.hi.y)); + } #endif - } else if (type == ARGUMENTDATATYPE_TIMESTAMP) { // Not to be confused with Terrance Stamp... Kneel before Zod!!! - UnsignedInt stamp; - m_file->read(&stamp, sizeof(stamp)); - msg->appendTimestampArgument(stamp); + break; + } + case ARGUMENTDATATYPE_TIMESTAMP: { // Not to be confused with Terrance Stamp... Kneel before Zod!!! + UnsignedInt stamp; + m_file->read(&stamp, sizeof(stamp)); + msg->appendTimestampArgument(stamp); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Timestamp argument: %d", stamp)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Timestamp argument: %d", stamp)); + } #endif - } else if (type == ARGUMENTDATATYPE_WIDECHAR) { - WideChar theid; - m_file->read(&theid, sizeof(theid)); - msg->appendWideCharArgument(theid); + break; + } + case ARGUMENTDATATYPE_WIDECHAR: { + WideChar theid; + m_file->read(&theid, sizeof(theid)); + msg->appendWideCharArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("WideChar argument: %d (%lc)", theid, theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("WideChar argument: %d (%lc)", theid, theid)); + } #endif + break; + } + default: + break; } } diff --git a/Generals/Code/GameEngine/Source/GameNetwork/NAT.cpp b/Generals/Code/GameEngine/Source/GameNetwork/NAT.cpp index e53dd8ffab..f84a6449d9 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/NAT.cpp +++ b/Generals/Code/GameEngine/Source/GameNetwork/NAT.cpp @@ -907,36 +907,11 @@ void NAT::processManglerResponse(UnsignedShort mangledPort) { // check to see if we've completed all the rounds // this is kind of a cheesy way to check, but it works. Bool NAT::allConnectionsDone() { - if (m_numNodes == 2) { - if (m_connectionRound >= 1) { - return TRUE; - } - } else if (m_numNodes == 3) { - if (m_connectionRound >= 3) { - return TRUE; - } - } else if (m_numNodes == 4) { - if (m_connectionRound >= 3) { - return TRUE; - } - } else if (m_numNodes == 5) { - if (m_connectionRound >= 5) { - return TRUE; - } - } else if (m_numNodes == 6) { - if (m_connectionRound >= 5) { - return TRUE; - } - } else if (m_numNodes == 7) { - if (m_connectionRound >= 7) { - return TRUE; - } - } else if (m_numNodes == 8) { - if (m_connectionRound >= 7) { - return TRUE; - } + if (m_numNodes < 2) { + return FALSE; } - return FALSE; + const Int requiredRounds = (m_numNodes & 1) ? m_numNodes : m_numNodes - 1; + return m_connectionRound >= requiredRounds; } Bool NAT::allConnectionsDoneThisRound() { diff --git a/Generals/Code/GameEngine/Source/GameNetwork/udp.cpp b/Generals/Code/GameEngine/Source/GameNetwork/udp.cpp index bcbc61b5f8..5ad9cec6cc 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/udp.cpp +++ b/Generals/Code/GameEngine/Source/GameNetwork/udp.cpp @@ -327,33 +327,62 @@ UDP::sockStat UDP::GetStatus(void) Int status = m_lastError; #ifdef _WINDOWS //int status=WSAGetLastError(); - if (status==0) return(OK); - else if (status==WSAEINTR) return(INTR); - else if (status==WSAEINPROGRESS) return(INPROGRESS); - else if (status==WSAECONNREFUSED) return(CONNREFUSED); - else if (status==WSAEINVAL) return(INVAL); - else if (status==WSAEISCONN) return(ISCONN); - else if (status==WSAENOTSOCK) return(NOTSOCK); - else if (status==WSAETIMEDOUT) return(TIMEDOUT); - else if (status==WSAEALREADY) return(ALREADY); - else if (status==WSAEWOULDBLOCK) return(WOULDBLOCK); - else if (status==WSAEBADF) return(BADF); - else return((UDP::sockStat)status); + switch (status) { + case NO_ERROR: + return OK; + case WSAEINTR: + return INTR; + case WSAEINPROGRESS: + return INPROGRESS; + case WSAECONNREFUSED: + return CONNREFUSED; + case WSAEINVAL: + return INVAL; + case WSAEISCONN: + return ISCONN; + case WSAENOTSOCK: + return NOTSOCK; + case WSAETIMEDOUT: + return TIMEDOUT; + case WSAEALREADY: + return ALREADY; + case WSAEWOULDBLOCK: + return WOULDBLOCK; + case WSAEBADF: + return BADF; + default: + return (UDP::sockStat)status; + } #else //int status=errno; - if (status==0) return(OK); - else if (status==EINTR) return(INTR); - else if (status==EINPROGRESS) return(INPROGRESS); - else if (status==ECONNREFUSED) return(CONNREFUSED); - else if (status==EINVAL) return(INVAL); - else if (status==EISCONN) return(ISCONN); - else if (status==ENOTSOCK) return(NOTSOCK); - else if (status==ETIMEDOUT) return(TIMEDOUT); - else if (status==EALREADY) return(ALREADY); - else if (status==EAGAIN) return(AGAIN); - else if (status==EWOULDBLOCK) return(WOULDBLOCK); - else if (status==EBADF) return(BADF); - else return(UNKNOWN); + switch (status) { + case 0: + return OK; + case EINTR: + return INTR; + case EINPROGRESS: + return INPROGRESS; + case ECONNREFUSED: + return CONNREFUSED; + case EINVAL: + return INVAL; + case EISCONN: + return ISCONN; + case ENOTSOCK: + return NOTSOCK; + case ETIMEDOUT: + return TIMEDOUT; + case EALREADY: + return ALREADY; + case EAGAIN: + return AGAIN; + case EWOULDBLOCK: + return WOULDBLOCK; + case EBADF: + return BADF; + default: + return UNKNOWN; + } #endif } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp index 99e70f26c5..b88018a87f 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp @@ -1448,117 +1448,142 @@ void RecorderClass::appendNextCommand() { } void RecorderClass::readArgument(GameMessageArgumentDataType type, GameMessage *msg) { - if (type == ARGUMENTDATATYPE_INTEGER) { - Int theint; - m_file->read(&theint, sizeof(theint)); - msg->appendIntegerArgument(theint); + switch (type) { + case ARGUMENTDATATYPE_INTEGER: { + Int theint; + m_file->read(&theint, sizeof(theint)); + msg->appendIntegerArgument(theint); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Integer argument: %d (%8.8X)", theint, theint)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Integer argument: %d (%8.8X)", theint, theint)); + } #endif - } else if (type == ARGUMENTDATATYPE_REAL) { - Real thereal; - m_file->read(&thereal, sizeof(thereal)); - msg->appendRealArgument(thereal); + break; + } + case ARGUMENTDATATYPE_REAL: { + Real thereal; + m_file->read(&thereal, sizeof(thereal)); + msg->appendRealArgument(thereal); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Real argument: %g (%8.8X)", thereal, *(int *)&thereal)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Real argument: %g (%8.8X)", thereal, *(int *)&thereal)); + } #endif - } else if (type == ARGUMENTDATATYPE_BOOLEAN) { - Bool thebool; - m_file->read(&thebool, sizeof(thebool)); - msg->appendBooleanArgument(thebool); + break; + } + case ARGUMENTDATATYPE_BOOLEAN: { + Bool thebool; + m_file->read(&thebool, sizeof(thebool)); + msg->appendBooleanArgument(thebool); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Bool argument: %d", thebool)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Bool argument: %d", thebool)); + } #endif - } else if (type == ARGUMENTDATATYPE_OBJECTID) { - ObjectID theid; - m_file->read(&theid, sizeof(theid)); - msg->appendObjectIDArgument(theid); + break; + } + case ARGUMENTDATATYPE_OBJECTID: { + ObjectID theid; + m_file->read(&theid, sizeof(theid)); + msg->appendObjectIDArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Object ID argument: %d", theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Object ID argument: %d", theid)); + } #endif - } else if (type == ARGUMENTDATATYPE_DRAWABLEID) { - DrawableID theid; - m_file->read(&theid, sizeof(theid)); - msg->appendDrawableIDArgument(theid); + break; + } + case ARGUMENTDATATYPE_DRAWABLEID: { + DrawableID theid; + m_file->read(&theid, sizeof(theid)); + msg->appendDrawableIDArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Drawable ID argument: %d", theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Drawable ID argument: %d", theid)); + } #endif - } else if (type == ARGUMENTDATATYPE_TEAMID) { - UnsignedInt theid; - m_file->read(&theid, sizeof(theid)); - msg->appendTeamIDArgument(theid); + break; + } + case ARGUMENTDATATYPE_TEAMID: { + UnsignedInt theid; + m_file->read(&theid, sizeof(theid)); + msg->appendTeamIDArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Team ID argument: %d", theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Team ID argument: %d", theid)); + } #endif - } else if (type == ARGUMENTDATATYPE_LOCATION) { - Coord3D loc; - m_file->read(&loc, sizeof(loc)); - msg->appendLocationArgument(loc); + break; + } + case ARGUMENTDATATYPE_LOCATION: { + Coord3D loc; + m_file->read(&loc, sizeof(loc)); + msg->appendLocationArgument(loc); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Coord3D argument: %g %g %g (%8.8X %8.8X %8.8X)", loc.x, loc.y, loc.z, - *(int *)&loc.x, *(int *)&loc.y, *(int *)&loc.z)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Coord3D argument: %g %g %g (%8.8X %8.8X %8.8X)", loc.x, loc.y, loc.z, + *(int *)&loc.x, *(int *)&loc.y, *(int *)&loc.z)); + } #endif - } else if (type == ARGUMENTDATATYPE_PIXEL) { - ICoord2D pixel; - m_file->read(&pixel, sizeof(pixel)); - msg->appendPixelArgument(pixel); + break; + } + case ARGUMENTDATATYPE_PIXEL: { + ICoord2D pixel; + m_file->read(&pixel, sizeof(pixel)); + msg->appendPixelArgument(pixel); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Pixel argument: %d,%d", pixel.x, pixel.y)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Pixel argument: %d,%d", pixel.x, pixel.y)); + } #endif - } else if (type == ARGUMENTDATATYPE_PIXELREGION) { - IRegion2D reg; - m_file->read(®, sizeof(reg)); - msg->appendPixelRegionArgument(reg); + break; + } + case ARGUMENTDATATYPE_PIXELREGION: { + IRegion2D reg; + m_file->read(®, sizeof(reg)); + msg->appendPixelRegionArgument(reg); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Pixel Region argument: %d,%d -> %d,%d", reg.lo.x, reg.lo.y, reg.hi.x, reg.hi.y)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Pixel Region argument: %d,%d -> %d,%d", reg.lo.x, reg.lo.y, reg.hi.x, reg.hi.y)); + } #endif - } else if (type == ARGUMENTDATATYPE_TIMESTAMP) { // Not to be confused with Terrance Stamp... Kneel before Zod!!! - UnsignedInt stamp; - m_file->read(&stamp, sizeof(stamp)); - msg->appendTimestampArgument(stamp); + break; + } + case ARGUMENTDATATYPE_TIMESTAMP: { // Not to be confused with Terrance Stamp... Kneel before Zod!!! + UnsignedInt stamp; + m_file->read(&stamp, sizeof(stamp)); + msg->appendTimestampArgument(stamp); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("Timestamp argument: %d", stamp)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("Timestamp argument: %d", stamp)); + } #endif - } else if (type == ARGUMENTDATATYPE_WIDECHAR) { - WideChar theid; - m_file->read(&theid, sizeof(theid)); - msg->appendWideCharArgument(theid); + break; + } + case ARGUMENTDATATYPE_WIDECHAR: { + WideChar theid; + m_file->read(&theid, sizeof(theid)); + msg->appendWideCharArgument(theid); #ifdef DEBUG_LOGGING - if (m_doingAnalysis) - { - DEBUG_LOG(("WideChar argument: %d (%lc)", theid, theid)); - } + if (m_doingAnalysis) + { + DEBUG_LOG(("WideChar argument: %d (%lc)", theid, theid)); + } #endif + break; + } + default: + break; } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp index 80b932ae31..d2d9ae85b9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp @@ -907,36 +907,11 @@ void NAT::processManglerResponse(UnsignedShort mangledPort) { // check to see if we've completed all the rounds // this is kind of a cheesy way to check, but it works. Bool NAT::allConnectionsDone() { - if (m_numNodes == 2) { - if (m_connectionRound >= 1) { - return TRUE; - } - } else if (m_numNodes == 3) { - if (m_connectionRound >= 3) { - return TRUE; - } - } else if (m_numNodes == 4) { - if (m_connectionRound >= 3) { - return TRUE; - } - } else if (m_numNodes == 5) { - if (m_connectionRound >= 5) { - return TRUE; - } - } else if (m_numNodes == 6) { - if (m_connectionRound >= 5) { - return TRUE; - } - } else if (m_numNodes == 7) { - if (m_connectionRound >= 7) { - return TRUE; - } - } else if (m_numNodes == 8) { - if (m_connectionRound >= 7) { - return TRUE; - } + if (m_numNodes < 2) { + return FALSE; } - return FALSE; + const Int requiredRounds = (m_numNodes & 1) ? m_numNodes : m_numNodes - 1; + return m_connectionRound >= requiredRounds; } Bool NAT::allConnectionsDoneThisRound() { diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/udp.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/udp.cpp index 58dc8a3cd5..b77cc325ce 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/udp.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/udp.cpp @@ -327,33 +327,62 @@ UDP::sockStat UDP::GetStatus(void) Int status = m_lastError; #ifdef _WINDOWS //int status=WSAGetLastError(); - if (status==0) return(OK); - else if (status==WSAEINTR) return(INTR); - else if (status==WSAEINPROGRESS) return(INPROGRESS); - else if (status==WSAECONNREFUSED) return(CONNREFUSED); - else if (status==WSAEINVAL) return(INVAL); - else if (status==WSAEISCONN) return(ISCONN); - else if (status==WSAENOTSOCK) return(NOTSOCK); - else if (status==WSAETIMEDOUT) return(TIMEDOUT); - else if (status==WSAEALREADY) return(ALREADY); - else if (status==WSAEWOULDBLOCK) return(WOULDBLOCK); - else if (status==WSAEBADF) return(BADF); - else return((UDP::sockStat)status); + switch (status) { + case NO_ERROR: + return OK; + case WSAEINTR: + return INTR; + case WSAEINPROGRESS: + return INPROGRESS; + case WSAECONNREFUSED: + return CONNREFUSED; + case WSAEINVAL: + return INVAL; + case WSAEISCONN: + return ISCONN; + case WSAENOTSOCK: + return NOTSOCK; + case WSAETIMEDOUT: + return TIMEDOUT; + case WSAEALREADY: + return ALREADY; + case WSAEWOULDBLOCK: + return WOULDBLOCK; + case WSAEBADF: + return BADF; + default: + return (UDP::sockStat)status; + } #else //int status=errno; - if (status==0) return(OK); - else if (status==EINTR) return(INTR); - else if (status==EINPROGRESS) return(INPROGRESS); - else if (status==ECONNREFUSED) return(CONNREFUSED); - else if (status==EINVAL) return(INVAL); - else if (status==EISCONN) return(ISCONN); - else if (status==ENOTSOCK) return(NOTSOCK); - else if (status==ETIMEDOUT) return(TIMEDOUT); - else if (status==EALREADY) return(ALREADY); - else if (status==EAGAIN) return(AGAIN); - else if (status==EWOULDBLOCK) return(WOULDBLOCK); - else if (status==EBADF) return(BADF); - else return(UNKNOWN); + switch (status) { + case 0: + return OK; + case EINTR: + return INTR; + case EINPROGRESS: + return INPROGRESS; + case ECONNREFUSED: + return CONNREFUSED; + case EINVAL: + return INVAL; + case EISCONN: + return ISCONN; + case ENOTSOCK: + return NOTSOCK; + case ETIMEDOUT: + return TIMEDOUT; + case EALREADY: + return ALREADY; + case EAGAIN: + return AGAIN; + case EWOULDBLOCK: + return WOULDBLOCK; + case EBADF: + return BADF; + default: + return UNKNOWN; + } #endif }