/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #include "StdH.h" #include #include "CmdLine.h" extern CTString cmd_strWorld = ""; // world to load extern INDEX cmd_iGoToMarker = -1; // marker to go to extern CTString cmd_strScript = ""; // script to execute extern CTString cmd_strServer = ""; // server to connect to extern INDEX cmd_iPort = -1; // port to connect to extern CTString cmd_strPassword = ""; // network password extern CTString cmd_strOutput = ""; // output from parsing command line extern BOOL cmd_bServer = FALSE; // set to run as server extern BOOL cmd_bQuickJoin = FALSE; // do not ask for players and network settings static CTString _strCmd; // get first next word or quoted string CTString GetNextParam(void) { // strip leading spaces/tabs _strCmd.TrimSpacesLeft(); // if nothing left if (_strCmd=="") { // no word to return return ""; } // if the first char is quote if (_strCmd[0]=='"') { // find first next quote const char *pchClosingQuote = strchr(_strCmd+1, '"'); // if not found if (pchClosingQuote==NULL) { // error in command line cmd_strOutput+=CTString(0, TRANS("Command line error!\n")); // finish parsing _strCmd = ""; return ""; } INDEX iQuote = pchClosingQuote-_strCmd; // get the quoted string CTString strWord; CTString strRest; _strCmd.Split(iQuote, strWord, strRest); // remove the quotes strWord.DeleteChar(0); strRest.DeleteChar(0); // get the word _strCmd = strRest; return strWord; // if the first char is not quote } else { // find first next space INDEX iSpace; INDEX ctChars = strlen(_strCmd); for(iSpace=0; iSpace