CommandLine.cpp 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
  24. #include "Common/ArchiveFileSystem.h"
  25. #include "Common/CommandLine.h"
  26. #include "Common/CRCDebug.h"
  27. #include "Common/LocalFileSystem.h"
  28. #include "Common/Version.h"
  29. #include "GameClient/TerrainVisual.h" // for TERRAIN_LOD_MIN definition
  30. #include "GameClient/GameText.h"
  31. #ifdef _INTERNAL
  32. // for occasional debugging...
  33. //#pragma optimize("", off)
  34. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  35. #endif
  36. Bool TheDebugIgnoreSyncErrors = FALSE;
  37. extern Int DX8Wrapper_PreserveFPU;
  38. #ifdef DEBUG_CRC
  39. Int TheCRCFirstFrameToLog = -1;
  40. UnsignedInt TheCRCLastFrameToLog = 0xffffffff;
  41. Bool g_keepCRCSaves = FALSE;
  42. Bool g_crcModuleDataFromLogic = FALSE;
  43. Bool g_crcModuleDataFromClient = FALSE;
  44. Bool g_verifyClientCRC = FALSE; // verify that GameLogic CRC doesn't change from client
  45. Bool g_clientDeepCRC = FALSE;
  46. Bool g_logObjectCRCs = FALSE;
  47. #endif
  48. #if defined(_DEBUG) || defined(_INTERNAL)
  49. extern Bool g_useStringFile;
  50. #endif
  51. // Retval is number of cmd-line args eaten
  52. typedef Int (*FuncPtr)( char *args[], int num );
  53. static const UnsignedByte F_NOCASE = 1; // Case-insensitive
  54. struct CommandLineParam
  55. {
  56. const char *name;
  57. FuncPtr func;
  58. };
  59. static void ConvertShortMapPathToLongMapPath(AsciiString &mapName)
  60. {
  61. AsciiString path = mapName;
  62. AsciiString token;
  63. AsciiString actualpath;
  64. if ((path.find('\\') == NULL) && (path.find('/') == NULL))
  65. {
  66. DEBUG_CRASH(("Invalid map name %s", mapName.str()));
  67. return;
  68. }
  69. path.nextToken(&token, "\\/");
  70. while (!token.endsWithNoCase(".map") && (token.getLength() > 0))
  71. {
  72. actualpath.concat(token);
  73. actualpath.concat('\\');
  74. path.nextToken(&token, "\\/");
  75. }
  76. if (!token.endsWithNoCase(".map"))
  77. {
  78. DEBUG_CRASH(("Invalid map name %s", mapName.str()));
  79. }
  80. // remove the .map from the end.
  81. token.removeLastChar();
  82. token.removeLastChar();
  83. token.removeLastChar();
  84. token.removeLastChar();
  85. actualpath.concat(token);
  86. actualpath.concat('\\');
  87. actualpath.concat(token);
  88. actualpath.concat(".map");
  89. mapName = actualpath;
  90. }
  91. //=============================================================================
  92. //=============================================================================
  93. Int parseNoLogOrCrash(char *args[], int)
  94. {
  95. #ifdef ALLOW_DEBUG_UTILS
  96. DEBUG_CRASH(("-NoLogOrCrash not supported in this build\n"));
  97. #endif
  98. return 1;
  99. }
  100. //=============================================================================
  101. //=============================================================================
  102. Int parseWin(char *args[], int)
  103. {
  104. if (TheWritableGlobalData)
  105. {
  106. TheWritableGlobalData->m_windowed = true;
  107. }
  108. return 1;
  109. }
  110. //=============================================================================
  111. //=============================================================================
  112. Int parseNoMusic(char *args[], int)
  113. {
  114. if (TheWritableGlobalData)
  115. {
  116. TheWritableGlobalData->m_musicOn = false;
  117. }
  118. return 1;
  119. }
  120. //=============================================================================
  121. //=============================================================================
  122. Int parseNoVideo(char *args[], int)
  123. {
  124. if (TheWritableGlobalData)
  125. {
  126. TheWritableGlobalData->m_videoOn = false;
  127. }
  128. return 1;
  129. }
  130. //=============================================================================
  131. //=============================================================================
  132. Int parseFPUPreserve(char *args[], int argc)
  133. {
  134. if (argc > 1)
  135. {
  136. DX8Wrapper_PreserveFPU = atoi(args[1]);
  137. }
  138. return 2;
  139. }
  140. #if defined(_DEBUG) || defined(_INTERNAL)
  141. //=============================================================================
  142. //=============================================================================
  143. Int parseUseCSF(char *args[], int)
  144. {
  145. g_useStringFile = FALSE;
  146. return 1;
  147. }
  148. //=============================================================================
  149. //=============================================================================
  150. Int parseNoInputDisable(char *args[], int)
  151. {
  152. if (TheWritableGlobalData)
  153. {
  154. TheWritableGlobalData->m_disableScriptedInputDisabling = true;
  155. }
  156. return 1;
  157. }
  158. //=============================================================================
  159. //=============================================================================
  160. Int parseNoFade(char *args[], int)
  161. {
  162. if (TheWritableGlobalData)
  163. {
  164. TheWritableGlobalData->m_disableCameraFade = true;
  165. }
  166. return 1;
  167. }
  168. //=============================================================================
  169. //=============================================================================
  170. Int parseNoMilCap(char *args[], int)
  171. {
  172. if (TheWritableGlobalData)
  173. {
  174. TheWritableGlobalData->m_disableMilitaryCaption = true;
  175. }
  176. return 1;
  177. }
  178. //=============================================================================
  179. //=============================================================================
  180. Int parseDebugCRCFromFrame(char *args[], int argc)
  181. {
  182. #ifdef DEBUG_CRC
  183. if (argc > 1)
  184. {
  185. TheCRCFirstFrameToLog = atoi(args[1]);
  186. }
  187. #endif
  188. return 2;
  189. }
  190. //=============================================================================
  191. //=============================================================================
  192. Int parseDebugCRCUntilFrame(char *args[], int argc)
  193. {
  194. #ifdef DEBUG_CRC
  195. if (argc > 1)
  196. {
  197. TheCRCLastFrameToLog = atoi(args[1]);
  198. }
  199. #endif
  200. return 2;
  201. }
  202. //=============================================================================
  203. //=============================================================================
  204. Int parseKeepCRCSave(char *args[], int argc)
  205. {
  206. #ifdef DEBUG_CRC
  207. g_keepCRCSaves = TRUE;
  208. #endif
  209. return 1;
  210. }
  211. //=============================================================================
  212. //=============================================================================
  213. Int parseCRCLogicModuleData(char *args[], int argc)
  214. {
  215. #ifdef DEBUG_CRC
  216. g_crcModuleDataFromLogic = TRUE;
  217. #endif
  218. return 1;
  219. }
  220. //=============================================================================
  221. //=============================================================================
  222. Int parseCRCClientModuleData(char *args[], int argc)
  223. {
  224. #ifdef DEBUG_CRC
  225. g_crcModuleDataFromClient = TRUE;
  226. #endif
  227. return 1;
  228. }
  229. //=============================================================================
  230. //=============================================================================
  231. Int parseClientDeepCRC(char *args[], int argc)
  232. {
  233. #ifdef DEBUG_CRC
  234. g_clientDeepCRC = TRUE;
  235. #endif
  236. return 1;
  237. }
  238. //=============================================================================
  239. //=============================================================================
  240. Int parseVerifyClientCRC(char *args[], int argc)
  241. {
  242. #ifdef DEBUG_CRC
  243. g_verifyClientCRC = TRUE;
  244. #endif
  245. return 1;
  246. }
  247. //=============================================================================
  248. //=============================================================================
  249. Int parseLogObjectCRCs(char *args[], int argc)
  250. {
  251. #ifdef DEBUG_CRC
  252. g_logObjectCRCs = TRUE;
  253. #endif
  254. return 1;
  255. }
  256. //=============================================================================
  257. //=============================================================================
  258. Int parseNetCRCInterval(char *args[], int argc)
  259. {
  260. #ifdef DEBUG_CRC
  261. if (argc > 1)
  262. {
  263. NET_CRC_INTERVAL = atoi(args[1]);
  264. }
  265. #endif
  266. return 2;
  267. }
  268. //=============================================================================
  269. //=============================================================================
  270. Int parseReplayCRCInterval(char *args[], int argc)
  271. {
  272. #ifdef DEBUG_CRC
  273. if (argc > 1)
  274. {
  275. REPLAY_CRC_INTERVAL = atoi(args[1]);
  276. }
  277. #endif
  278. return 2;
  279. }
  280. //=============================================================================
  281. //=============================================================================
  282. Int parseNoDraw(char *args[], int argc)
  283. {
  284. #ifdef DEBUG_CRC
  285. if (TheWritableGlobalData)
  286. {
  287. TheWritableGlobalData->m_noDraw = TRUE;
  288. }
  289. #endif
  290. return 1;
  291. }
  292. //=============================================================================
  293. //=============================================================================
  294. Int parseLogToConsole(char *args[], int)
  295. {
  296. DebugSetFlags(DebugGetFlags() | DEBUG_FLAG_LOG_TO_CONSOLE);
  297. return 1;
  298. }
  299. #endif // _DEBUG || _INTERNAL
  300. //=============================================================================
  301. //=============================================================================
  302. Int parseNoAudio(char *args[], int)
  303. {
  304. if (TheWritableGlobalData)
  305. {
  306. TheWritableGlobalData->m_audioOn = false;
  307. TheWritableGlobalData->m_speechOn = false;
  308. TheWritableGlobalData->m_soundsOn = false;
  309. TheWritableGlobalData->m_musicOn = false;
  310. }
  311. return 1;
  312. }
  313. //=============================================================================
  314. //=============================================================================
  315. Int parseNoWin(char *args[], int)
  316. {
  317. if (TheWritableGlobalData)
  318. {
  319. TheWritableGlobalData->m_windowed = false;
  320. }
  321. return 1;
  322. }
  323. Int parseFullVersion(char *args[], int num)
  324. {
  325. if (TheVersion && num > 1)
  326. {
  327. TheVersion->setShowFullVersion(atoi(args[1]) != 0);
  328. }
  329. return 1;
  330. }
  331. Int parseNoShadows(char *args[], int)
  332. {
  333. if (TheWritableGlobalData)
  334. {
  335. TheWritableGlobalData->m_useShadowVolumes = false;
  336. TheWritableGlobalData->m_useShadowDecals = false;
  337. }
  338. return 1;
  339. }
  340. Int parseMapName(char *args[], int num)
  341. {
  342. if (TheWritableGlobalData && num == 2)
  343. {
  344. TheWritableGlobalData->m_mapName.set( args[ 1 ] );
  345. ConvertShortMapPathToLongMapPath(TheWritableGlobalData->m_mapName);
  346. }
  347. return 1;
  348. }
  349. Int parseXRes(char *args[], int num)
  350. {
  351. if (TheWritableGlobalData && num > 1)
  352. {
  353. TheWritableGlobalData->m_xResolution = atoi(args[1]);
  354. return 2;
  355. }
  356. return 1;
  357. }
  358. Int parseYRes(char *args[], int num)
  359. {
  360. if (TheWritableGlobalData && num > 1)
  361. {
  362. TheWritableGlobalData->m_yResolution = atoi(args[1]);
  363. return 2;
  364. }
  365. return 1;
  366. }
  367. #if defined(_DEBUG) || defined(_INTERNAL)
  368. //=============================================================================
  369. //=============================================================================
  370. Int parseLatencyAverage(char *args[], int num)
  371. {
  372. if (TheWritableGlobalData && num > 1)
  373. {
  374. TheWritableGlobalData->m_latencyAverage = atoi(args[1]);
  375. }
  376. return 2;
  377. }
  378. //=============================================================================
  379. //=============================================================================
  380. Int parseLatencyAmplitude(char *args[], int num)
  381. {
  382. if (TheWritableGlobalData && num > 1)
  383. {
  384. TheWritableGlobalData->m_latencyAmplitude = atoi(args[1]);
  385. }
  386. return 2;
  387. }
  388. //=============================================================================
  389. //=============================================================================
  390. Int parseLatencyPeriod(char *args[], int num)
  391. {
  392. if (TheWritableGlobalData && num > 1)
  393. {
  394. TheWritableGlobalData->m_latencyPeriod = atoi(args[1]);
  395. }
  396. return 2;
  397. }
  398. //=============================================================================
  399. //=============================================================================
  400. Int parseLatencyNoise(char *args[], int num)
  401. {
  402. if (TheWritableGlobalData && num > 1)
  403. {
  404. TheWritableGlobalData->m_latencyNoise = atoi(args[1]);
  405. }
  406. return 2;
  407. }
  408. //=============================================================================
  409. //=============================================================================
  410. Int parsePacketLoss(char *args[], int num)
  411. {
  412. if (TheWritableGlobalData && num > 1)
  413. {
  414. TheWritableGlobalData->m_packetLoss = atoi(args[1]);
  415. }
  416. return 2;
  417. }
  418. //=============================================================================
  419. //=============================================================================
  420. Int parseLowDetail(char *args[], int num)
  421. {
  422. if (TheWritableGlobalData)
  423. {
  424. TheWritableGlobalData->m_terrainLOD = TERRAIN_LOD_MIN;
  425. }
  426. return 1;
  427. }
  428. //=============================================================================
  429. //=============================================================================
  430. Int parseNoDynamicLOD(char *args[], int num)
  431. {
  432. if (TheWritableGlobalData)
  433. {
  434. TheWritableGlobalData->m_enableDynamicLOD = FALSE;
  435. }
  436. return 1;
  437. }
  438. //=============================================================================
  439. //=============================================================================
  440. Int parseNoStaticLOD(char *args[], int num)
  441. {
  442. if (TheWritableGlobalData)
  443. {
  444. TheWritableGlobalData->m_enableStaticLOD = FALSE;
  445. }
  446. return 1;
  447. }
  448. //=============================================================================
  449. //=============================================================================
  450. Int parseUseWaveEditor(char *args[], int num)
  451. {
  452. if (TheWritableGlobalData)
  453. {
  454. TheWritableGlobalData->m_usingWaterTrackEditor = TRUE;
  455. }
  456. return 1;
  457. }
  458. //=============================================================================
  459. //=============================================================================
  460. Int parseFPSLimit(char *args[], int num)
  461. {
  462. if (TheWritableGlobalData && num > 1)
  463. {
  464. TheWritableGlobalData->m_framesPerSecondLimit = atoi(args[1]);
  465. }
  466. return 2;
  467. }
  468. //=============================================================================
  469. Int parseNoViewLimit(char *args[], int)
  470. {
  471. if (TheWritableGlobalData)
  472. {
  473. TheWritableGlobalData->m_useCameraConstraints = FALSE;
  474. }
  475. return 1;
  476. }
  477. Int parseWireframe(char *args[], int)
  478. {
  479. if (TheWritableGlobalData)
  480. {
  481. TheWritableGlobalData->m_wireframe = TRUE;
  482. }
  483. return 1;
  484. }
  485. Int parseShowCollision(char *args[], int)
  486. {
  487. if (TheWritableGlobalData)
  488. {
  489. TheWritableGlobalData->m_showCollisionExtents = TRUE;
  490. }
  491. return 1;
  492. }
  493. Int parseNoShowClientPhysics(char *args[], int)
  494. {
  495. if (TheWritableGlobalData)
  496. {
  497. TheWritableGlobalData->m_showClientPhysics = FALSE;
  498. }
  499. return 1;
  500. }
  501. Int parseShowTerrainNormals(char *args[], int)
  502. {
  503. if (TheWritableGlobalData)
  504. {
  505. TheWritableGlobalData->m_showTerrainNormals = TRUE;
  506. }
  507. return 1;
  508. }
  509. Int parseStateMachineDebug(char *args[], int)
  510. {
  511. if (TheWritableGlobalData)
  512. {
  513. TheWritableGlobalData->m_stateMachineDebug = TRUE;
  514. }
  515. return 1;
  516. }
  517. Int parseJabber(char *args[], int)
  518. {
  519. if (TheWritableGlobalData)
  520. {
  521. TheWritableGlobalData->m_jabberOn = TRUE;
  522. }
  523. return 1;
  524. }
  525. Int parseMunkee(char *args[], int)
  526. {
  527. if (TheWritableGlobalData)
  528. {
  529. TheWritableGlobalData->m_munkeeOn = TRUE;
  530. }
  531. return 1;
  532. }
  533. #endif // defined(_DEBUG) || defined(_INTERNAL)
  534. Int parseScriptDebug(char *args[], int)
  535. {
  536. if (TheWritableGlobalData)
  537. {
  538. TheWritableGlobalData->m_scriptDebug = TRUE;
  539. TheWritableGlobalData->m_winCursors = TRUE;
  540. }
  541. return 1;
  542. }
  543. Int parseParticleEdit(char *args[], int)
  544. {
  545. if (TheWritableGlobalData)
  546. {
  547. TheWritableGlobalData->m_particleEdit = TRUE;
  548. TheWritableGlobalData->m_winCursors = TRUE;
  549. TheWritableGlobalData->m_windowed = TRUE;
  550. }
  551. return 1;
  552. }
  553. Int parseBuildMapCache(char *args[], int)
  554. {
  555. if (TheWritableGlobalData)
  556. {
  557. TheWritableGlobalData->m_buildMapCache = true;
  558. }
  559. return 1;
  560. }
  561. #if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
  562. Int parsePreload( char *args[], int num )
  563. {
  564. if( TheWritableGlobalData )
  565. TheWritableGlobalData->m_preloadAssets = TRUE;
  566. return 1;
  567. }
  568. #endif
  569. #if defined(_DEBUG) || defined(_INTERNAL)
  570. Int parseDisplayDebug(char *args[], int)
  571. {
  572. if (TheWritableGlobalData)
  573. {
  574. TheWritableGlobalData->m_displayDebug = TRUE;
  575. }
  576. return 1;
  577. }
  578. Int parseFile(char *args[], int num)
  579. {
  580. if (TheWritableGlobalData && num > 1)
  581. {
  582. TheWritableGlobalData->m_initialFile = args[1];
  583. ConvertShortMapPathToLongMapPath(TheWritableGlobalData->m_initialFile);
  584. }
  585. return 2;
  586. }
  587. Int parsePreloadEverything( char *args[], int num )
  588. {
  589. if( TheWritableGlobalData )
  590. {
  591. TheWritableGlobalData->m_preloadAssets = TRUE;
  592. TheWritableGlobalData->m_preloadEverything = TRUE;
  593. }
  594. return 1;
  595. }
  596. Int parseLogAssets( char *args[], int num )
  597. {
  598. if( TheWritableGlobalData )
  599. {
  600. FILE *logfile=fopen("PreloadedAssets.txt","w");
  601. if (logfile) //clear the file
  602. fclose(logfile);
  603. TheWritableGlobalData->m_preloadReport = TRUE;
  604. }
  605. return 1;
  606. }
  607. /// begin stuff for VTUNE
  608. Int parseVTune ( char *args[], int num )
  609. {
  610. if( TheWritableGlobalData )
  611. TheWritableGlobalData->m_vTune = TRUE;
  612. return 1;
  613. }
  614. /// end stuff for VTUNE
  615. #endif // defined(_DEBUG) || defined(_INTERNAL)
  616. //=============================================================================
  617. //=============================================================================
  618. Int parseNoFX(char *args[], int)
  619. {
  620. if (TheWritableGlobalData)
  621. {
  622. TheWritableGlobalData->m_useFX = FALSE;
  623. }
  624. return 1;
  625. }
  626. #if defined(_DEBUG) || defined(_INTERNAL)
  627. Int parseNoShroud(char *args[], int)
  628. {
  629. if (TheWritableGlobalData)
  630. {
  631. TheWritableGlobalData->m_shroudOn = FALSE;
  632. }
  633. return 1;
  634. }
  635. #endif
  636. Int parseForceBenchmark(char *args[], int)
  637. {
  638. if (TheWritableGlobalData)
  639. {
  640. TheWritableGlobalData->m_forceBenchmark = TRUE;
  641. }
  642. return 1;
  643. }
  644. Int parseNoMoveCamera(char *args[], int)
  645. {
  646. if (TheWritableGlobalData)
  647. {
  648. TheWritableGlobalData->m_disableCameraMovement = true;
  649. }
  650. return 1;
  651. }
  652. #if defined(_DEBUG) || defined(_INTERNAL)
  653. Int parseNoCinematic(char *args[], int)
  654. {
  655. if (TheWritableGlobalData)
  656. {
  657. TheWritableGlobalData->m_disableCameraMovement = true;
  658. TheWritableGlobalData->m_disableMilitaryCaption = true;
  659. TheWritableGlobalData->m_disableCameraFade = true;
  660. TheWritableGlobalData->m_disableScriptedInputDisabling = true;
  661. }
  662. return 1;
  663. }
  664. #endif
  665. Int parseSync(char *args[], int)
  666. {
  667. if (TheWritableGlobalData)
  668. {
  669. TheDebugIgnoreSyncErrors = true;
  670. }
  671. return 1;
  672. }
  673. Int parseNoShellMap(char *args[], int)
  674. {
  675. if (TheWritableGlobalData)
  676. {
  677. TheWritableGlobalData->m_shellMapOn = FALSE;
  678. }
  679. return 1;
  680. }
  681. Int parseNoShaders(char *args[], int)
  682. {
  683. if (TheWritableGlobalData)
  684. {
  685. TheWritableGlobalData->m_chipSetType = 1; //force to a voodoo card which uses least amount of features.
  686. }
  687. return 1;
  688. }
  689. #if (defined(_DEBUG) || defined(_INTERNAL))
  690. Int parseNoLogo(char *args[], int)
  691. {
  692. if (TheWritableGlobalData)
  693. {
  694. TheWritableGlobalData->m_playIntro = FALSE;
  695. TheWritableGlobalData->m_afterIntro = TRUE;
  696. TheWritableGlobalData->m_playSizzle = FALSE;
  697. }
  698. return 1;
  699. }
  700. #endif
  701. Int parseNoSizzle( char *args[], int )
  702. {
  703. if (TheWritableGlobalData)
  704. {
  705. TheWritableGlobalData->m_playSizzle = FALSE;
  706. }
  707. return 1;
  708. }
  709. Int parseShellMap(char *args[], int num)
  710. {
  711. if (TheWritableGlobalData && num > 1)
  712. {
  713. TheWritableGlobalData->m_shellMapName = args[1];
  714. }
  715. return 2;
  716. }
  717. Int parseNoWindowAnimation(char *args[], int num)
  718. {
  719. if (TheWritableGlobalData)
  720. {
  721. TheWritableGlobalData->m_animateWindows = FALSE;
  722. }
  723. return 1;
  724. }
  725. Int parseWinCursors(char *args[], int num)
  726. {
  727. if (TheWritableGlobalData)
  728. {
  729. TheWritableGlobalData->m_winCursors = TRUE;
  730. }
  731. return 1;
  732. }
  733. Int parseQuickStart( char *args[], int num )
  734. {
  735. #if (defined(_DEBUG) || defined(_INTERNAL))
  736. parseNoLogo( args, num );
  737. #else
  738. //Kris: Patch 1.01 -- Allow release builds to skip the sizzle video, but still force the EA logo to show up.
  739. //This is for legal reasons.
  740. parseNoSizzle( args, num );
  741. #endif
  742. parseNoShellMap( args, num );
  743. parseNoWindowAnimation( args, num );
  744. return 1;
  745. }
  746. Int parseConstantDebug( char *args[], int num )
  747. {
  748. if (TheWritableGlobalData)
  749. {
  750. TheWritableGlobalData->m_constantDebugUpdate = TRUE;
  751. }
  752. return 1;
  753. }
  754. #if (defined(_DEBUG) || defined(_INTERNAL))
  755. Int parseExtraLogging( char *args[], int num )
  756. {
  757. if (TheWritableGlobalData)
  758. {
  759. TheWritableGlobalData->m_extraLogging = TRUE;
  760. }
  761. return 1;
  762. }
  763. #endif
  764. //-allAdvice feature
  765. /*
  766. Int parseAllAdvice( char *args[], int num )
  767. {
  768. if( TheWritableGlobalData )
  769. {
  770. TheWritableGlobalData->m_allAdvice = TRUE;
  771. }
  772. return 1;
  773. }
  774. */
  775. Int parseShowTeamDot( char *args[], int num )
  776. {
  777. if( TheWritableGlobalData )
  778. {
  779. TheWritableGlobalData->m_showTeamDot = TRUE;
  780. }
  781. return 1;
  782. }
  783. #if defined(_DEBUG) || defined(_INTERNAL)
  784. Int parseSelectAll( char *args[], int num )
  785. {
  786. if( TheWritableGlobalData )
  787. {
  788. TheWritableGlobalData->m_allowUnselectableSelection = TRUE;
  789. }
  790. return 1;
  791. }
  792. Int parseRunAhead( char *args[], Int num )
  793. {
  794. if (num > 2)
  795. {
  796. MIN_RUNAHEAD = atoi(args[1]);
  797. MAX_FRAMES_AHEAD = atoi(args[2]);
  798. FRAME_DATA_LENGTH = (MAX_FRAMES_AHEAD + 1)*2;
  799. }
  800. return 3;
  801. }
  802. #endif
  803. Int parseSeed(char *args[], int num)
  804. {
  805. if (TheWritableGlobalData && num > 1)
  806. {
  807. TheWritableGlobalData->m_fixedSeed = atoi(args[1]);
  808. }
  809. return 2;
  810. }
  811. Int parseIncrAGPBuf(char *args[], int num)
  812. {
  813. if (TheWritableGlobalData)
  814. {
  815. TheWritableGlobalData->m_incrementalAGPBuf = TRUE;
  816. }
  817. return 1;
  818. }
  819. Int parseNetMinPlayers(char *args[], int num)
  820. {
  821. if (TheWritableGlobalData && num > 1)
  822. {
  823. TheWritableGlobalData->m_netMinPlayers = atoi(args[1]);
  824. }
  825. return 2;
  826. }
  827. Int parsePlayStats(char *args[], int num)
  828. {
  829. if (TheWritableGlobalData && num > 1)
  830. {
  831. TheWritableGlobalData->m_playStats = atoi(args[1]);
  832. }
  833. return 2;
  834. }
  835. Int parseDemoLoadScreen(char *args[], int num)
  836. {
  837. if (TheWritableGlobalData)
  838. {
  839. TheWritableGlobalData->m_loadScreenDemo = TRUE;
  840. }
  841. return 1;
  842. }
  843. #if defined(_DEBUG) || defined(_INTERNAL)
  844. Int parseSaveStats(char *args[], int num)
  845. {
  846. if (TheWritableGlobalData && num > 1)
  847. {
  848. TheWritableGlobalData->m_saveStats = TRUE;
  849. TheWritableGlobalData->m_baseStatsDir = args[1];
  850. }
  851. return 2;
  852. }
  853. #endif
  854. #if defined(_DEBUG) || defined(_INTERNAL)
  855. Int parseSaveAllStats(char *args[], int num)
  856. {
  857. if (TheWritableGlobalData && num > 1)
  858. {
  859. TheWritableGlobalData->m_saveStats = TRUE;
  860. TheWritableGlobalData->m_baseStatsDir = args[1];
  861. TheWritableGlobalData->m_saveAllStats = TRUE;
  862. }
  863. return 2;
  864. }
  865. #endif
  866. #if defined(_DEBUG) || defined(_INTERNAL)
  867. Int parseLocalMOTD(char *args[], int num)
  868. {
  869. if (TheWritableGlobalData && num > 1)
  870. {
  871. TheWritableGlobalData->m_useLocalMOTD = TRUE;
  872. TheWritableGlobalData->m_MOTDPath = args[1];
  873. }
  874. return 2;
  875. }
  876. #endif
  877. #if defined(_DEBUG) || defined(_INTERNAL)
  878. Int parseCameraDebug(char *args[], int num)
  879. {
  880. if (TheWritableGlobalData)
  881. {
  882. TheWritableGlobalData->m_debugCamera = TRUE;
  883. }
  884. return 1;
  885. }
  886. #endif
  887. #if defined(_DEBUG) || defined(_INTERNAL)
  888. Int parseBenchmark(char *args[], int num)
  889. {
  890. if (TheWritableGlobalData && num > 1)
  891. {
  892. TheWritableGlobalData->m_benchmarkTimer = atoi(args[1]);
  893. TheWritableGlobalData->m_playStats = atoi(args[1]);
  894. }
  895. return 2;
  896. }
  897. #endif
  898. #if defined(_DEBUG) || defined(_INTERNAL)
  899. #ifdef DUMP_PERF_STATS
  900. Int parseStats(char *args[], int num)
  901. {
  902. if (TheWritableGlobalData && num > 1)
  903. {
  904. TheWritableGlobalData->m_dumpStatsAtInterval = TRUE;
  905. TheWritableGlobalData->m_statsInterval = atoi(args[1]);
  906. }
  907. return 2;
  908. }
  909. #endif
  910. #endif
  911. #if defined(_DEBUG) || defined(_INTERNAL)
  912. Int parseIgnoreAsserts(char *args[], int num)
  913. {
  914. if (TheWritableGlobalData && num > 0)
  915. {
  916. TheWritableGlobalData->m_debugIgnoreAsserts = true;
  917. }
  918. return 1;
  919. }
  920. #endif
  921. #if defined(_DEBUG) || defined(_INTERNAL)
  922. Int parseIgnoreStackTrace(char *args[], int num)
  923. {
  924. if (TheWritableGlobalData && num > 0)
  925. {
  926. TheWritableGlobalData->m_debugIgnoreStackTrace = true;
  927. }
  928. return 1;
  929. }
  930. #endif
  931. Int parseNoFPSLimit(char *args[], int num)
  932. {
  933. if (TheWritableGlobalData)
  934. {
  935. TheWritableGlobalData->m_useFpsLimit = false;
  936. TheWritableGlobalData->m_framesPerSecondLimit = 30000;
  937. }
  938. return 1;
  939. }
  940. Int parseDumpAssetUsage(char *args[], int num)
  941. {
  942. if (TheWritableGlobalData)
  943. {
  944. TheWritableGlobalData->m_dumpAssetUsage = true;
  945. }
  946. return 1;
  947. }
  948. Int parseJumpToFrame(char *args[], int num)
  949. {
  950. if (TheWritableGlobalData && num > 1)
  951. {
  952. parseNoFPSLimit(args, num);
  953. TheWritableGlobalData->m_noDraw = atoi(args[1]);
  954. return 2;
  955. }
  956. return 1;
  957. }
  958. Int parseUpdateImages(char *args[], int num)
  959. {
  960. if (TheWritableGlobalData)
  961. {
  962. TheWritableGlobalData->m_shouldUpdateTGAToDDS = TRUE;
  963. }
  964. return 1;
  965. }
  966. Int parseMod(char *args[], Int num)
  967. {
  968. if (TheWritableGlobalData && num > 1)
  969. {
  970. AsciiString modPath = args[1];
  971. if (strchr(modPath.str(), ':') || modPath.startsWith("/") || modPath.startsWith("\\"))
  972. {
  973. // full path passed in. Don't append base path.
  974. }
  975. else
  976. {
  977. modPath.format("%s%s", TheGlobalData->getPath_UserData().str(), args[1]);
  978. }
  979. DEBUG_LOG(("Looking for mod '%s'\n", modPath.str()));
  980. if (!TheLocalFileSystem->doesFileExist(modPath.str()))
  981. {
  982. DEBUG_LOG(("Mod does not exist.\n"));
  983. return 2; // no such file/dir.
  984. }
  985. // now check for dir-ness
  986. struct _stat statBuf;
  987. if (_stat(modPath.str(), &statBuf) != 0)
  988. {
  989. DEBUG_LOG(("Could not _stat() mod.\n"));
  990. return 2; // could not stat the file/dir.
  991. }
  992. if (statBuf.st_mode & _S_IFDIR)
  993. {
  994. if (!modPath.endsWith("\\") && !modPath.endsWith("/"))
  995. modPath.concat('\\');
  996. DEBUG_LOG(("Mod dir is '%s'.\n", modPath.str()));
  997. TheWritableGlobalData->m_modDir = modPath;
  998. }
  999. else
  1000. {
  1001. DEBUG_LOG(("Mod file is '%s'.\n", modPath.str()));
  1002. TheWritableGlobalData->m_modBIG = modPath;
  1003. }
  1004. return 2;
  1005. }
  1006. return 1;
  1007. }
  1008. static CommandLineParam params[] =
  1009. {
  1010. { "-noshellmap", parseNoShellMap },
  1011. { "-win", parseWin },
  1012. { "-xres", parseXRes },
  1013. { "-yres", parseYRes },
  1014. { "-fullscreen", parseNoWin },
  1015. { "-fullVersion", parseFullVersion },
  1016. { "-particleEdit", parseParticleEdit },
  1017. { "-scriptDebug", parseScriptDebug },
  1018. { "-playStats", parsePlayStats },
  1019. { "-mod", parseMod },
  1020. { "-noshaders", parseNoShaders },
  1021. { "-quickstart", parseQuickStart },
  1022. #if (defined(_DEBUG) || defined(_INTERNAL))
  1023. { "-noaudio", parseNoAudio },
  1024. { "-map", parseMapName },
  1025. { "-nomusic", parseNoMusic },
  1026. { "-novideo", parseNoVideo },
  1027. { "-noLogOrCrash", parseNoLogOrCrash },
  1028. { "-FPUPreserve", parseFPUPreserve },
  1029. { "-benchmark", parseBenchmark },
  1030. #ifdef DUMP_PERF_STATS
  1031. { "-stats", parseStats },
  1032. #endif
  1033. { "-saveStats", parseSaveStats },
  1034. { "-localMOTD", parseLocalMOTD },
  1035. { "-UseCSF", parseUseCSF },
  1036. { "-NoInputDisable", parseNoInputDisable },
  1037. { "-DebugCRCFromFrame", parseDebugCRCFromFrame },
  1038. { "-DebugCRCUntilFrame", parseDebugCRCUntilFrame },
  1039. { "-KeepCRCSaves", parseKeepCRCSave },
  1040. { "-CRCLogicModuleData", parseCRCLogicModuleData },
  1041. { "-CRCClientModuleData", parseCRCClientModuleData },
  1042. { "-ClientDeepCRC", parseClientDeepCRC },
  1043. { "-VerifyClientCRC", parseVerifyClientCRC },
  1044. { "-LogObjectCRCs", parseLogObjectCRCs },
  1045. { "-saveAllStats", parseSaveAllStats },
  1046. { "-NetCRCInterval", parseNetCRCInterval },
  1047. { "-ReplayCRCInterval", parseReplayCRCInterval },
  1048. { "-noDraw", parseNoDraw },
  1049. { "-nomilcap", parseNoMilCap },
  1050. { "-nofade", parseNoFade },
  1051. { "-nomovecamera", parseNoMoveCamera },
  1052. { "-nocinematic", parseNoCinematic },
  1053. { "-packetloss", parsePacketLoss },
  1054. { "-latAvg", parseLatencyAverage },
  1055. { "-latAmp", parseLatencyAmplitude },
  1056. { "-latPeriod", parseLatencyPeriod },
  1057. { "-latNoise", parseLatencyNoise },
  1058. { "-noViewLimit", parseNoViewLimit },
  1059. { "-lowDetail", parseLowDetail },
  1060. { "-noDynamicLOD", parseNoDynamicLOD },
  1061. { "-noStaticLOD", parseNoStaticLOD },
  1062. { "-useWaveEditor", parseUseWaveEditor },
  1063. { "-fps", parseFPSLimit },
  1064. { "-wireframe", parseWireframe },
  1065. { "-showCollision", parseShowCollision },
  1066. { "-noShowClientPhysics", parseNoShowClientPhysics },
  1067. { "-showTerrainNormals", parseShowTerrainNormals },
  1068. { "-stateMachineDebug", parseStateMachineDebug },
  1069. { "-jabber", parseJabber },
  1070. { "-munkee", parseMunkee },
  1071. { "-displayDebug", parseDisplayDebug },
  1072. { "-file", parseFile },
  1073. // { "-preload", parsePreload },
  1074. { "-preloadEverything", parsePreloadEverything },
  1075. { "-logAssets", parseLogAssets },
  1076. { "-netMinPlayers", parseNetMinPlayers },
  1077. { "-DemoLoadScreen", parseDemoLoadScreen },
  1078. { "-cameraDebug", parseCameraDebug },
  1079. { "-ignoreAsserts", parseIgnoreAsserts },
  1080. { "-ignoreStackTrace", parseIgnoreStackTrace },
  1081. { "-logToCon", parseLogToConsole },
  1082. { "-vTune", parseVTune },
  1083. { "-selectTheUnselectable", parseSelectAll },
  1084. { "-RunAhead", parseRunAhead },
  1085. { "-noshroud", parseNoShroud },
  1086. { "-forceBenchmark", parseForceBenchmark },
  1087. { "-buildmapcache", parseBuildMapCache },
  1088. { "-noshadowvolumes", parseNoShadows },
  1089. { "-nofx", parseNoFX },
  1090. { "-ignoresync", parseSync },
  1091. { "-nologo", parseNoLogo },
  1092. { "-shellmap", parseShellMap },
  1093. { "-noShellAnim", parseNoWindowAnimation },
  1094. { "-winCursors", parseWinCursors },
  1095. { "-constantDebug", parseConstantDebug },
  1096. { "-seed", parseSeed },
  1097. { "-noagpfix", parseIncrAGPBuf },
  1098. { "-noFPSLimit", parseNoFPSLimit },
  1099. { "-dumpAssetUsage", parseDumpAssetUsage },
  1100. { "-jumpToFrame", parseJumpToFrame },
  1101. { "-updateImages", parseUpdateImages },
  1102. { "-showTeamDot", parseShowTeamDot },
  1103. { "-extraLogging", parseExtraLogging },
  1104. #endif
  1105. //-allAdvice feature
  1106. //{ "-allAdvice", parseAllAdvice },
  1107. #if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
  1108. { "-preload", parsePreload },
  1109. #endif
  1110. };
  1111. // parseCommandLine ===========================================================
  1112. /** Parse command-line parameters. */
  1113. //=============================================================================
  1114. void parseCommandLine(int argc, char *argv[])
  1115. {
  1116. // To parse command-line parameters, we loop through a table holding arguments
  1117. // and functions to handle them. Comparisons can be case-(in)sensitive, and
  1118. // can check the entire string (for testing the presence of a flag) or check
  1119. // just the start (for a key=val argument). The handling function can also
  1120. // look at the next argument(s), to accomodate multi-arg parameters, e.g. "-p 1234".
  1121. int arg=1, param;
  1122. Bool found;
  1123. #ifdef DEBUG_LOGGING
  1124. DEBUG_LOG(("Command-line args:"));
  1125. int debugFlags = DebugGetFlags();
  1126. DebugSetFlags(debugFlags & ~DEBUG_FLAG_PREPEND_TIME); // turn off timestamps
  1127. for (arg=1; arg<argc; arg++)
  1128. {
  1129. DEBUG_LOG((" %s", argv[arg]));
  1130. }
  1131. DEBUG_LOG(("\n"));
  1132. DebugSetFlags(debugFlags); // turn timestamps back on iff they were on before
  1133. arg = 1;
  1134. #endif // DEBUG_LOGGING
  1135. while (arg<argc)
  1136. {
  1137. // Look at arg #i
  1138. found = false;
  1139. for (param=0; !found && param<sizeof(params)/sizeof(params[0]); ++param)
  1140. {
  1141. int len = strlen(params[param].name);
  1142. int len2 = strlen(argv[arg]);
  1143. if (len2 != len)
  1144. continue;
  1145. if (!strnicmp(argv[arg], params[param].name, len))
  1146. {
  1147. arg += params[param].func(argv+arg, argc-arg);
  1148. found = true;
  1149. }
  1150. } // for
  1151. if (!found)
  1152. {
  1153. arg++;
  1154. }
  1155. }
  1156. TheArchiveFileSystem->loadMods();
  1157. }