From 6ee60a1f76568a6a31e7d9fdc9a3fb48867cfb80 Mon Sep 17 00:00:00 2001 From: asmodai Date: Thu, 23 Mar 2017 00:47:27 +0300 Subject: [PATCH] invert condition --- rehlds/common/commandline.cpp | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/rehlds/common/commandline.cpp b/rehlds/common/commandline.cpp index 9f40d2f..b50fc4c 100644 --- a/rehlds/common/commandline.cpp +++ b/rehlds/common/commandline.cpp @@ -321,28 +321,30 @@ const char *CCommandLine::CheckParm(const char *psz, char **ppszValue) const return nullptr; char *pret = strstr(m_pszCmdLine, psz); - if (pret && ppszValue) { - *ppszValue = nullptr; + if (!pret || !ppszValue) + return pret; - // find the next whitespace - char *p1 = pret; - do { - ++p1; - } while (*p1 != ' ' && *p1); + *ppszValue = nullptr; - int i = 0; - char *p2 = p1 + 1; + // find the next whitespace + char *p1 = pret; + do { + ++p1; + } while (*p1 != ' ' && *p1); - do { - if (p2[i] == '\0' || p2[i] == ' ') - break; + int i = 0; + char *p2 = p1 + 1; - sz[i++] = p2[i]; - } while (i < sizeof(sz)); + do { + if (p2[i] == '\0' || p2[i] == ' ') + break; - sz[i] = '\0'; - *ppszValue = sz; - } + sz[i++] = p2[i]; + } while (i < sizeof(sz)); + + sz[i] = '\0'; + *ppszValue = sz; + return pret; }