| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
- #include "Common/ArchiveFileSystem.h"
- #include "Common/CommandLine.h"
- #include "Common/CRCDebug.h"
- #include "Common/LocalFileSystem.h"
- #include "Common/Version.h"
- #include "GameClient/TerrainVisual.h" // for TERRAIN_LOD_MIN definition
- #include "GameClient/GameText.h"
- Bool TheDebugIgnoreSyncErrors = FALSE;
- extern Int DX8Wrapper_PreserveFPU;
- #ifdef DEBUG_CRC
- Int TheCRCFirstFrameToLog = -1;
- UnsignedInt TheCRCLastFrameToLog = 0xffffffff;
- Bool g_keepCRCSaves = FALSE;
- Bool g_crcModuleDataFromLogic = FALSE;
- Bool g_crcModuleDataFromClient = FALSE;
- Bool g_verifyClientCRC = FALSE; // verify that GameLogic CRC doesn't change from client
- Bool g_clientDeepCRC = FALSE;
- Bool g_logObjectCRCs = FALSE;
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- extern Bool g_useStringFile;
- #endif
- // Retval is number of cmd-line args eaten
- typedef Int (*FuncPtr)( char *args[], int num );
- static const UnsignedByte F_NOCASE = 1; // Case-insensitive
- struct CommandLineParam
- {
- const char *name;
- FuncPtr func;
- };
- static void ConvertShortMapPathToLongMapPath(AsciiString &mapName)
- {
- AsciiString path = mapName;
- AsciiString token;
- AsciiString actualpath;
- if ((path.find('\\') == NULL) && (path.find('/') == NULL))
- {
- DEBUG_CRASH(("Invalid map name %s", mapName.str()));
- return;
- }
- path.nextToken(&token, "\\/");
- while (!token.endsWithNoCase(".map") && (token.getLength() > 0))
- {
- actualpath.concat(token);
- actualpath.concat('\\');
- path.nextToken(&token, "\\/");
- }
- if (!token.endsWithNoCase(".map"))
- {
- DEBUG_CRASH(("Invalid map name %s", mapName.str()));
- }
- // remove the .map from the end.
- token.removeLastChar();
- token.removeLastChar();
- token.removeLastChar();
- token.removeLastChar();
- actualpath.concat(token);
- actualpath.concat('\\');
- actualpath.concat(token);
- actualpath.concat(".map");
- mapName = actualpath;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoLogOrCrash(char *args[], int)
- {
- #ifdef ALLOW_DEBUG_UTILS
- DEBUG_CRASH(("-NoLogOrCrash not supported in this build\n"));
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseWin(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_windowed = true;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoMusic(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_musicOn = false;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoVideo(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_videoOn = false;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseFPUPreserve(char *args[], int argc)
- {
- if (argc > 1)
- {
- DX8Wrapper_PreserveFPU = atoi(args[1]);
- }
- return 2;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- //=============================================================================
- //=============================================================================
- Int parseUseCSF(char *args[], int)
- {
- g_useStringFile = FALSE;
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoInputDisable(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_disableScriptedInputDisabling = true;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoFade(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_disableCameraFade = true;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoMilCap(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_disableMilitaryCaption = true;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseDebugCRCFromFrame(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- if (argc > 1)
- {
- TheCRCFirstFrameToLog = atoi(args[1]);
- }
- #endif
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseDebugCRCUntilFrame(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- if (argc > 1)
- {
- TheCRCLastFrameToLog = atoi(args[1]);
- }
- #endif
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseKeepCRCSave(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- g_keepCRCSaves = TRUE;
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseCRCLogicModuleData(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- g_crcModuleDataFromLogic = TRUE;
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseCRCClientModuleData(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- g_crcModuleDataFromClient = TRUE;
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseClientDeepCRC(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- g_clientDeepCRC = TRUE;
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseVerifyClientCRC(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- g_verifyClientCRC = TRUE;
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseLogObjectCRCs(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- g_logObjectCRCs = TRUE;
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNetCRCInterval(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- if (argc > 1)
- {
- NET_CRC_INTERVAL = atoi(args[1]);
- }
- #endif
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseReplayCRCInterval(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- if (argc > 1)
- {
- REPLAY_CRC_INTERVAL = atoi(args[1]);
- }
- #endif
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoDraw(char *args[], int argc)
- {
- #ifdef DEBUG_CRC
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_noDraw = TRUE;
- }
- #endif
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseLogToConsole(char *args[], int)
- {
- DebugSetFlags(DebugGetFlags() | DEBUG_FLAG_LOG_TO_CONSOLE);
- return 1;
- }
- #endif // _DEBUG || _INTERNAL
- //=============================================================================
- //=============================================================================
- Int parseNoAudio(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_audioOn = false;
- TheWritableGlobalData->m_speechOn = false;
- TheWritableGlobalData->m_soundsOn = false;
- TheWritableGlobalData->m_musicOn = false;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoWin(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_windowed = false;
- }
- return 1;
- }
- Int parseFullVersion(char *args[], int num)
- {
- if (TheVersion && num > 1)
- {
- TheVersion->setShowFullVersion(atoi(args[1]) != 0);
- }
- return 1;
- }
- Int parseNoShadows(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_useShadowVolumes = false;
- TheWritableGlobalData->m_useShadowDecals = false;
- }
- return 1;
- }
- Int parseMapName(char *args[], int num)
- {
- if (TheWritableGlobalData && num == 2)
- {
- TheWritableGlobalData->m_mapName.set( args[ 1 ] );
- ConvertShortMapPathToLongMapPath(TheWritableGlobalData->m_mapName);
- }
- return 1;
- }
- Int parseXRes(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_xResolution = atoi(args[1]);
- return 2;
- }
- return 1;
- }
- Int parseYRes(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_yResolution = atoi(args[1]);
- return 2;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- //=============================================================================
- //=============================================================================
- Int parseLatencyAverage(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_latencyAverage = atoi(args[1]);
- }
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseLatencyAmplitude(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_latencyAmplitude = atoi(args[1]);
- }
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseLatencyPeriod(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_latencyPeriod = atoi(args[1]);
- }
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseLatencyNoise(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_latencyNoise = atoi(args[1]);
- }
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parsePacketLoss(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_packetLoss = atoi(args[1]);
- }
- return 2;
- }
- //=============================================================================
- //=============================================================================
- Int parseLowDetail(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_terrainLOD = TERRAIN_LOD_MIN;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoDynamicLOD(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_enableDynamicLOD = FALSE;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseNoStaticLOD(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_enableStaticLOD = FALSE;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseUseWaveEditor(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_usingWaterTrackEditor = TRUE;
- }
- return 1;
- }
- //=============================================================================
- //=============================================================================
- Int parseFPSLimit(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_framesPerSecondLimit = atoi(args[1]);
- }
- return 2;
- }
- //=============================================================================
- Int parseNoViewLimit(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_useCameraConstraints = FALSE;
- }
- return 1;
- }
- Int parseWireframe(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_wireframe = TRUE;
- }
- return 1;
- }
- Int parseShowCollision(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_showCollisionExtents = TRUE;
- }
- return 1;
- }
- Int parseNoShowClientPhysics(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_showClientPhysics = FALSE;
- }
- return 1;
- }
- Int parseShowTerrainNormals(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_showTerrainNormals = TRUE;
- }
- return 1;
- }
- Int parseStateMachineDebug(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_stateMachineDebug = TRUE;
- }
- return 1;
- }
- Int parseJabber(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_jabberOn = TRUE;
- }
- return 1;
- }
- Int parseMunkee(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_munkeeOn = TRUE;
- }
- return 1;
- }
- #endif // defined(_DEBUG) || defined(_INTERNAL)
- Int parseScriptDebug(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_scriptDebug = TRUE;
- TheWritableGlobalData->m_winCursors = TRUE;
- }
- return 1;
- }
- Int parseParticleEdit(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_particleEdit = TRUE;
- TheWritableGlobalData->m_winCursors = TRUE;
- TheWritableGlobalData->m_windowed = TRUE;
- }
- return 1;
- }
- Int parseBuildMapCache(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_buildMapCache = true;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseDisplayDebug(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_displayDebug = TRUE;
- }
- return 1;
- }
- Int parseFile(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_initialFile = args[1];
- ConvertShortMapPathToLongMapPath(TheWritableGlobalData->m_initialFile);
- }
- return 2;
- }
- Int parsePreload( char *args[], int num )
- {
- if( TheWritableGlobalData )
- TheWritableGlobalData->m_preloadAssets = TRUE;
- return 1;
- }
- Int parsePreloadEverything( char *args[], int num )
- {
- if( TheWritableGlobalData )
- {
- TheWritableGlobalData->m_preloadAssets = TRUE;
- TheWritableGlobalData->m_preloadEverything = TRUE;
- }
- return 1;
- }
- Int parseLogAssets( char *args[], int num )
- {
- if( TheWritableGlobalData )
- {
- FILE *logfile=fopen("PreloadedAssets.txt","w");
- if (logfile) //clear the file
- fclose(logfile);
- TheWritableGlobalData->m_preloadReport = TRUE;
- }
- return 1;
- }
- /// begin stuff for VTUNE
- Int parseVTune ( char *args[], int num )
- {
- if( TheWritableGlobalData )
- TheWritableGlobalData->m_vTune = TRUE;
- return 1;
- }
- /// end stuff for VTUNE
- #endif // defined(_DEBUG) || defined(_INTERNAL)
- //=============================================================================
- //=============================================================================
- Int parseNoFX(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_useFX = FALSE;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseNoShroud(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_shroudOn = FALSE;
- }
- return 1;
- }
- #endif
- Int parseForceBenchmark(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_forceBenchmark = TRUE;
- }
- return 1;
- }
- Int parseNoMoveCamera(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_disableCameraMovement = true;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseNoCinematic(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_disableCameraMovement = true;
- TheWritableGlobalData->m_disableMilitaryCaption = true;
- TheWritableGlobalData->m_disableCameraFade = true;
- TheWritableGlobalData->m_disableScriptedInputDisabling = true;
- }
- return 1;
- }
- #endif
- Int parseSync(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheDebugIgnoreSyncErrors = true;
- }
- return 1;
- }
- Int parseNoShellMap(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_shellMapOn = FALSE;
- }
- return 1;
- }
- #if !defined(_PLAYTEST) || (defined(_DEBUG) || defined(_INTERNAL))
- Int parseNoLogo(char *args[], int)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_playIntro = FALSE;
- TheWritableGlobalData->m_afterIntro = TRUE;
- }
- return 1;
- }
- #endif
- Int parseShellMap(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_shellMapName = args[1];
- }
- return 2;
- }
- Int parseNoWindowAnimation(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_animateWindows = FALSE;
- }
- return 1;
- }
- Int parseWinCursors(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_winCursors = TRUE;
- }
- return 1;
- }
- Int parseQuickStart( char *args[], int num )
- {
- parseNoLogo( args, num );
- parseNoShellMap( args, num );
- parseNoWindowAnimation( args, num );
- return 1;
- }
- Int parseConstantDebug( char *args[], int num )
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_constantDebugUpdate = TRUE;
- }
- return 1;
- }
- Int parseShowTeamDot( char *args[], int num )
- {
- if( TheWritableGlobalData )
- {
- TheWritableGlobalData->m_showTeamDot = TRUE;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseSelectAll( char *args[], int num )
- {
- if( TheWritableGlobalData )
- {
- TheWritableGlobalData->m_allowUnselectableSelection = TRUE;
- }
- return 1;
- }
- Int parseRunAhead( char *args[], Int num )
- {
- if (num > 2)
- {
- MIN_RUNAHEAD = atoi(args[1]);
- MAX_FRAMES_AHEAD = atoi(args[2]);
- FRAME_DATA_LENGTH = (MAX_FRAMES_AHEAD + 1)*2;
- }
- return 3;
- }
- #endif
- Int parseSeed(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_fixedSeed = atoi(args[1]);
- }
- return 2;
- }
- Int parseIncrAGPBuf(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_incrementalAGPBuf = TRUE;
- }
- return 1;
- }
- Int parseNetMinPlayers(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_netMinPlayers = atoi(args[1]);
- }
- return 2;
- }
- Int parsePlayStats(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_playStats = atoi(args[1]);
- }
- return 2;
- }
- Int parseDemoLoadScreen(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_loadScreenDemo = TRUE;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseSaveStats(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_saveStats = TRUE;
- TheWritableGlobalData->m_baseStatsDir = args[1];
- }
- return 2;
- }
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseSaveAllStats(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_saveStats = TRUE;
- TheWritableGlobalData->m_baseStatsDir = args[1];
- TheWritableGlobalData->m_saveAllStats = TRUE;
- }
- return 2;
- }
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseLocalMOTD(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_useLocalMOTD = TRUE;
- TheWritableGlobalData->m_MOTDPath = args[1];
- }
- return 2;
- }
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseCameraDebug(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_debugCamera = TRUE;
- }
- return 1;
- }
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseBenchmark(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_benchmarkTimer = atoi(args[1]);
- TheWritableGlobalData->m_playStats = atoi(args[1]);
- }
- return 2;
- }
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseIgnoreAsserts(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 0)
- {
- TheWritableGlobalData->m_debugIgnoreAsserts = true;
- }
- return 1;
- }
- #endif
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseIgnoreStackTrace(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 0)
- {
- TheWritableGlobalData->m_debugIgnoreStackTrace = true;
- }
- return 1;
- }
- #endif
- Int parseNoFPSLimit(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_useFpsLimit = false;
- TheWritableGlobalData->m_framesPerSecondLimit = 30000;
- }
- return 1;
- }
- Int parseDumpAssetUsage(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_dumpAssetUsage = true;
- }
- return 1;
- }
- Int parseJumpToFrame(char *args[], int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- parseNoFPSLimit(args, num);
- TheWritableGlobalData->m_noDraw = atoi(args[1]);
- return 2;
- }
- return 1;
- }
- Int parseUpdateImages(char *args[], int num)
- {
- if (TheWritableGlobalData)
- {
- TheWritableGlobalData->m_shouldUpdateTGAToDDS = TRUE;
- }
- return 1;
- }
- Int parseMod(char *args[], Int num)
- {
- if (TheWritableGlobalData && num > 1)
- {
- AsciiString modPath = args[1];
- if (strchr(modPath.str(), ':') || modPath.startsWith("/") || modPath.startsWith("\\"))
- {
- // full path passed in. Don't append base path.
- }
- else
- {
- modPath.format("%s%s", TheGlobalData->getPath_UserData().str(), args[1]);
- }
- DEBUG_LOG(("Looking for mod '%s'\n", modPath.str()));
- if (!TheLocalFileSystem->doesFileExist(modPath.str()))
- {
- DEBUG_LOG(("Mod does not exist.\n"));
- return 2; // no such file/dir.
- }
- // now check for dir-ness
- struct stat statBuf;
- if (stat(modPath.str(), &statBuf) != 0)
- {
- DEBUG_LOG(("Could not _stat() mod.\n"));
- return 2; // could not stat the file/dir.
- }
- if (statBuf.st_mode & S_IFDIR)
- {
- if (!modPath.endsWith("\\") && !modPath.endsWith("/"))
- modPath.concat('\\');
- DEBUG_LOG(("Mod dir is '%s'.\n", modPath.str()));
- TheWritableGlobalData->m_modDir = modPath;
- }
- else
- {
- DEBUG_LOG(("Mod file is '%s'.\n", modPath.str()));
- TheWritableGlobalData->m_modBIG = modPath;
- }
- return 2;
- }
- return 1;
- }
- #if defined(_DEBUG) || defined(_INTERNAL)
- Int parseSetDebugLevel(char *args[], int num)
- {
- if (num > 1)
- {
- AsciiString val = args[1];
- for (Int i=0; i<DEBUG_LEVEL_MAX; ++i)
- {
- if (val == TheDebugLevels[i])
- {
- DebugLevelMask |= 1<<i;
- break;
- }
- }
- }
- return 2;
- }
- Int parseClearDebugLevel(char *args[], int num)
- {
- if (num > 1)
- {
- AsciiString val = args[1];
- for (Int i=0; i<DEBUG_LEVEL_MAX; ++i)
- {
- if (val == TheDebugLevels[i])
- {
- DebugLevelMask &= ~(1<<i);
- break;
- }
- }
- }
- return 2;
- }
- #endif
- static CommandLineParam params[] =
- {
- { "-noshellmap", parseNoShellMap },
- { "-win", parseWin },
- { "-xres", parseXRes },
- { "-yres", parseYRes },
- { "-fullscreen", parseNoWin },
- { "-fullVersion", parseFullVersion },
- { "-particleEdit", parseParticleEdit },
- { "-scriptDebug", parseScriptDebug },
- { "-playStats", parsePlayStats },
- { "-mod", parseMod },
- #if !defined(_PLAYTEST) || (defined(_DEBUG) || defined(_INTERNAL))
- { "-noaudio", parseNoAudio },
- { "-map", parseMapName },
- { "-nomusic", parseNoMusic },
- { "-novideo", parseNoVideo },
- { "-noLogOrCrash", parseNoLogOrCrash },
- { "-FPUPreserve", parseFPUPreserve },
- #if defined(_DEBUG) || defined(_INTERNAL)
- { "-benchmark", parseBenchmark },
- { "-saveStats", parseSaveStats },
- { "-localMOTD", parseLocalMOTD },
- { "-UseCSF", parseUseCSF },
- { "-NoInputDisable", parseNoInputDisable },
- { "-DebugCRCFromFrame", parseDebugCRCFromFrame },
- { "-DebugCRCUntilFrame", parseDebugCRCUntilFrame },
- { "-KeepCRCSaves", parseKeepCRCSave },
- { "-CRCLogicModuleData", parseCRCLogicModuleData },
- { "-CRCClientModuleData", parseCRCClientModuleData },
- { "-ClientDeepCRC", parseClientDeepCRC },
- { "-VerifyClientCRC", parseVerifyClientCRC },
- { "-LogObjectCRCs", parseLogObjectCRCs },
- { "-saveAllStats", parseSaveAllStats },
- { "-NetCRCInterval", parseNetCRCInterval },
- { "-ReplayCRCInterval", parseReplayCRCInterval },
- { "-noDraw", parseNoDraw },
- { "-nomilcap", parseNoMilCap },
- { "-nofade", parseNoFade },
- { "-nomovecamera", parseNoMoveCamera },
- { "-nocinematic", parseNoCinematic },
- { "-packetloss", parsePacketLoss },
- { "-latAvg", parseLatencyAverage },
- { "-latAmp", parseLatencyAmplitude },
- { "-latPeriod", parseLatencyPeriod },
- { "-latNoise", parseLatencyNoise },
- { "-noViewLimit", parseNoViewLimit },
- { "-lowDetail", parseLowDetail },
- { "-noDynamicLOD", parseNoDynamicLOD },
- { "-noStaticLOD", parseNoStaticLOD },
- { "-useWaveEditor", parseUseWaveEditor },
- { "-fps", parseFPSLimit },
- { "-wireframe", parseWireframe },
- { "-showCollision", parseShowCollision },
- { "-noShowClientPhysics", parseNoShowClientPhysics },
- { "-showTerrainNormals", parseShowTerrainNormals },
- { "-stateMachineDebug", parseStateMachineDebug },
- { "-jabber", parseJabber },
- { "-munkee", parseMunkee },
- { "-displayDebug", parseDisplayDebug },
- { "-file", parseFile },
- { "-preload", parsePreload },
- { "-preloadEverything", parsePreloadEverything },
- { "-logAssets", parseLogAssets },
- { "-netMinPlayers", parseNetMinPlayers },
- { "-DemoLoadScreen", parseDemoLoadScreen },
- { "-cameraDebug", parseCameraDebug },
- { "-ignoreAsserts", parseIgnoreAsserts },
- { "-ignoreStackTrace", parseIgnoreStackTrace },
- { "-logToCon", parseLogToConsole },
- { "-vTune", parseVTune },
- { "-selectTheUnselectable", parseSelectAll },
- { "-RunAhead", parseRunAhead },
- { "-noshroud", parseNoShroud },
- { "-setDebugLevel", parseSetDebugLevel },
- { "-clearDebugLevel", parseClearDebugLevel },
- #endif
- { "-forceBenchmark", parseForceBenchmark },
- { "-buildmapcache", parseBuildMapCache },
- { "-noshadowvolumes", parseNoShadows },
- { "-nofx", parseNoFX },
- { "-ignoresync", parseSync },
- { "-nologo", parseNoLogo },
- { "-shellmap", parseShellMap },
- { "-noShellAnim", parseNoWindowAnimation },
- { "-winCursors", parseWinCursors },
- { "-constantDebug", parseConstantDebug },
- { "-quickstart", parseQuickStart },
- { "-seed", parseSeed },
- { "-noagpfix", parseIncrAGPBuf },
- { "-noFPSLimit", parseNoFPSLimit },
- { "-dumpAssetUsage", parseDumpAssetUsage },
- { "-jumpToFrame", parseJumpToFrame },
- { "-updateImages", parseUpdateImages },
- { "-showTeamDot", parseShowTeamDot },
- #endif
- };
- // parseCommandLine ===========================================================
- /** Parse command-line parameters. */
- //=============================================================================
- void parseCommandLine(int argc, char *argv[])
- {
- // To parse command-line parameters, we loop through a table holding arguments
- // and functions to handle them. Comparisons can be case-(in)sensitive, and
- // can check the entire string (for testing the presence of a flag) or check
- // just the start (for a key=val argument). The handling function can also
- // look at the next argument(s), to accomodate multi-arg parameters, e.g. "-p 1234".
- int arg=1, param;
- Bool found;
- #ifdef DEBUG_LOGGING
- DEBUG_LOG(("Command-line args:"));
- int debugFlags = DebugGetFlags();
- DebugSetFlags(debugFlags & ~DEBUG_FLAG_PREPEND_TIME); // turn off timestamps
- for (arg=1; arg<argc; arg++)
- {
- DEBUG_LOG((" %s", argv[arg]));
- }
- DEBUG_LOG(("\n"));
- DebugSetFlags(debugFlags); // turn timestamps back on iff they were on before
- arg = 1;
- #endif // DEBUG_LOGGING
- while (arg<argc)
- {
- // Look at arg #i
- found = false;
- for (param=0; !found && param<sizeof(params)/sizeof(params[0]); ++param)
- {
- int len = strlen(params[param].name);
- int len2 = strlen(argv[arg]);
- if (len2 != len)
- continue;
- if (!strnicmp(argv[arg], params[param].name, len))
- {
- arg += params[param].func(argv+arg, argc-arg);
- found = true;
- }
- } // for
- if (!found)
- {
- arg++;
- }
- }
- TheArchiveFileSystem->loadMods();
- }
|