NetCon: fix command line parsing bug

-ansicolor is the only possible command line parameter, if its passed we need to shift the indices for the next one if user provided address and key.
This commit is contained in:
Kawe Mazidjatari 2025-02-09 00:45:46 +01:00
parent f0f90e5c1b
commit 8b0bdae883

View File

@ -511,27 +511,23 @@ int main(int argc, char* argv[])
bool bEnableColor = false;
for (int i = 0; i < argc; i++)
if (argc >= 2)
{
if (V_strcmp(argv[i], "-ansicolor") == NULL)
{
bEnableColor = true;
break;
}
bEnableColor = V_strcmp(argv[1], "-ansicolor") == NULL;
}
// The address and key from command line if passed in.
const char* pAdr = nullptr;
const char* pKey = nullptr;
if (argc >= 2)
if (argc >= 2 + bEnableColor)
{
pAdr = argv[1];
pAdr = argv[1 + bEnableColor];
}
if (argc >= 3)
if (argc >= 3 + bEnableColor)
{
pKey = argv[2];
pKey = argv[2 + bEnableColor];
}
if (!NetConsole()->Init(bEnableColor, pAdr, pKey))