3
0

ISystem.h 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/PlatformDef.h>
  10. #ifdef CRYSYSTEM_EXPORTS
  11. #define CRYSYSTEM_API AZ_DLL_EXPORT
  12. #else
  13. #define CRYSYSTEM_API AZ_DLL_IMPORT
  14. #endif
  15. #include <AzCore/IO/SystemFile.h>
  16. #include "CryAssert.h"
  17. #include <CryCommon/IValidator.h>
  18. #if defined(AZ_RESTRICTED_PLATFORM)
  19. #undef AZ_RESTRICTED_SECTION
  20. #define ISYSTEM_H_SECTION_1 1
  21. #define ISYSTEM_H_SECTION_2 2
  22. #define ISYSTEM_H_SECTION_3 3
  23. #define ISYSTEM_H_SECTION_4 4
  24. #define ISYSTEM_H_SECTION_5 5
  25. #endif
  26. ////////////////////////////////////////////////////////////////////////////////////////////////
  27. // Forward declarations
  28. ////////////////////////////////////////////////////////////////////////////////////////////////
  29. #include <IXml.h> // <> required for Interfuscator
  30. #include <ILog.h> // <> required for Interfuscator
  31. #include "CryVersion.h"
  32. #include "smartptr.h"
  33. #include <memory> // shared_ptr
  34. #include <CrySystemBus.h>
  35. struct ISystem;
  36. struct ILog;
  37. namespace AZ::IO
  38. {
  39. struct IArchive;
  40. }
  41. struct IConsole;
  42. struct IRemoteConsole;
  43. struct IRenderer;
  44. struct ICryFont;
  45. struct IMovieSystem;
  46. struct SFileVersion;
  47. struct INameTable;
  48. struct ILevelSystem;
  49. class IXMLBinarySerializer;
  50. struct IAVI_Reader;
  51. class CPNoise3;
  52. struct ILocalizationManager;
  53. struct IOutputPrintSink;
  54. struct IWindowMessageHandler;
  55. namespace AZ
  56. {
  57. namespace IO
  58. {
  59. class FileIOBase;
  60. }
  61. }
  62. typedef void* WIN_HWND;
  63. struct CLoadingTimeProfiler;
  64. class ICmdLine;
  65. class ILyShine;
  66. enum EValidatorModule : int;
  67. enum EValidatorSeverity : int;
  68. enum ESystemUpdateFlags
  69. {
  70. // Summary:
  71. // Special update mode for editor.
  72. ESYSUPDATE_EDITOR = 0x0004
  73. };
  74. // Description:
  75. // Configuration platform. Autodetected at start, can be modified through the editor.
  76. enum ESystemConfigPlatform
  77. {
  78. CONFIG_INVALID_PLATFORM = 0,
  79. CONFIG_PC = 1,
  80. CONFIG_MAC = 2,
  81. CONFIG_OSX_METAL = 3,
  82. CONFIG_ANDROID = 4,
  83. CONFIG_IOS = 5,
  84. CONFIG_PROVO = 7,
  85. CONFIG_SALEM = 8,
  86. CONFIG_JASPER = 9,
  87. END_CONFIG_PLATFORM_ENUM, // MUST BE LAST VALUE. USED FOR ERROR CHECKING.
  88. };
  89. enum ESystemGlobalState
  90. {
  91. ESYSTEM_GLOBAL_STATE_UNKNOWN,
  92. ESYSTEM_GLOBAL_STATE_INIT,
  93. ESYSTEM_GLOBAL_STATE_RUNNING,
  94. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PREPARE,
  95. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START,
  96. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_MATERIALS,
  97. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_OBJECTS,
  98. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_STATIC_WORLD,
  99. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PRECACHE,
  100. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_TEXTURES,
  101. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_END,
  102. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_COMPLETE
  103. };
  104. // Summary:
  105. // System wide events.
  106. enum ESystemEvent
  107. {
  108. // Description:
  109. // Seeds all random number generators to the same seed number, WParam will hold seed value.
  110. //##@{
  111. ESYSTEM_EVENT_RANDOM_SEED = 1,
  112. ESYSTEM_EVENT_RANDOM_ENABLE,
  113. ESYSTEM_EVENT_RANDOM_DISABLE,
  114. //##@}
  115. // Description:
  116. // Changes to main window focus.
  117. // wparam is not 0 is focused, 0 if not focused
  118. ESYSTEM_EVENT_CHANGE_FOCUS = 10,
  119. // Description:
  120. // Moves of the main window.
  121. // wparam=x, lparam=y
  122. ESYSTEM_EVENT_MOVE = 11,
  123. // Description:
  124. // Resizes of the main window.
  125. // wparam=width, lparam=height
  126. ESYSTEM_EVENT_RESIZE = 12,
  127. // Description:
  128. // Activation of the main window.
  129. // wparam=1/0, 1=active 0=inactive
  130. ESYSTEM_EVENT_ACTIVATE = 13,
  131. // Description:
  132. // Main window position changed.
  133. ESYSTEM_EVENT_POS_CHANGED = 14,
  134. // Description:
  135. // Main window style changed.
  136. ESYSTEM_EVENT_STYLE_CHANGED = 15,
  137. // Description:
  138. // Sent before the loading movie is begun
  139. ESYSTEM_EVENT_LEVEL_LOAD_START_PRELOADINGSCREEN,
  140. // Description:
  141. // Sent before the loading last save
  142. ESYSTEM_EVENT_LEVEL_LOAD_RESUME_GAME,
  143. // Description:
  144. // Sent before starting level, before game rules initialization and before ESYSTEM_EVENT_LEVEL_LOAD_START event
  145. // Used mostly for level loading profiling
  146. ESYSTEM_EVENT_LEVEL_LOAD_PREPARE,
  147. // Description:
  148. // Sent to start the active loading screen rendering.
  149. ESYSTEM_EVENT_LEVEL_LOAD_START_LOADINGSCREEN,
  150. // Description:
  151. // Sent when loading screen is active
  152. ESYSTEM_EVENT_LEVEL_LOAD_LOADINGSCREEN_ACTIVE,
  153. // Description:
  154. // Sent before starting loading a new level.
  155. // Used for a more efficient resource management.
  156. ESYSTEM_EVENT_LEVEL_LOAD_START,
  157. // Description:
  158. // Sent after loading a level finished.
  159. // Used for a more efficient resource management.
  160. ESYSTEM_EVENT_LEVEL_LOAD_END,
  161. // Description:
  162. // Sent after trying to load a level failed.
  163. // Used for resetting the front end.
  164. ESYSTEM_EVENT_LEVEL_LOAD_ERROR,
  165. // Description:
  166. // Sent in case the level was requested to load, but it's not ready
  167. // Used in streaming install scenario for notifying the front end.
  168. ESYSTEM_EVENT_LEVEL_NOT_READY,
  169. // Description:
  170. // Sent after precaching of the streaming system has been done
  171. ESYSTEM_EVENT_LEVEL_PRECACHE_START,
  172. // Description:
  173. // Sent before object/texture precache stream requests are submitted
  174. ESYSTEM_EVENT_LEVEL_PRECACHE_FIRST_FRAME,
  175. // Description:
  176. // Sent when level loading is completely finished with no more onscreen
  177. // movie or info rendering, and when actual gameplay can start
  178. ESYSTEM_EVENT_LEVEL_GAMEPLAY_START,
  179. // Level is unloading.
  180. ESYSTEM_EVENT_LEVEL_UNLOAD,
  181. // Summary:
  182. // Sent after level have been unloaded. For cleanup code.
  183. ESYSTEM_EVENT_LEVEL_POST_UNLOAD,
  184. // Summary:
  185. // Called when the game framework has been initialized.
  186. ESYSTEM_EVENT_GAME_POST_INIT,
  187. // Summary:
  188. // Called when the game framework has been initialized, not loading should happen in this event.
  189. ESYSTEM_EVENT_GAME_POST_INIT_DONE,
  190. // Summary:
  191. // Sent when the system is doing a full shutdown.
  192. ESYSTEM_EVENT_FULL_SHUTDOWN,
  193. // Summary:
  194. // Sent when the system is doing a fast shutdown.
  195. ESYSTEM_EVENT_FAST_SHUTDOWN,
  196. // Summary:
  197. // When keyboard layout changed.
  198. ESYSTEM_EVENT_LANGUAGE_CHANGE,
  199. // Description:
  200. // Toggled fullscreen.
  201. // wparam is 1 means we switched to fullscreen, 0 if for windowed
  202. ESYSTEM_EVENT_TOGGLE_FULLSCREEN,
  203. ESYSTEM_EVENT_SHARE_SHADER_COMBINATIONS,
  204. // Summary:
  205. // Start 3D post rendering
  206. ESYSTEM_EVENT_3D_POST_RENDERING_START,
  207. // Summary:
  208. // End 3D post rendering
  209. ESYSTEM_EVENT_3D_POST_RENDERING_END,
  210. // Summary:
  211. // Called before switching to level memory heap
  212. ESYSTEM_EVENT_SWITCHING_TO_LEVEL_HEAP_DEPRECATED,
  213. // Summary:
  214. // Called after switching to level memory heap
  215. ESYSTEM_EVENT_SWITCHED_TO_LEVEL_HEAP_DEPRECATED,
  216. // Summary:
  217. // Called before switching to global memory heap
  218. ESYSTEM_EVENT_SWITCHING_TO_GLOBAL_HEAP_DEPRECATED,
  219. // Summary:
  220. // Called after switching to global memory heap
  221. ESYSTEM_EVENT_SWITCHED_TO_GLOBAL_HEAP_DEPRECATED,
  222. // Description:
  223. // Sent after precaching of the streaming system has been done
  224. ESYSTEM_EVENT_LEVEL_PRECACHE_END,
  225. // Description:
  226. // Sent when game mode switch begins
  227. ESYSTEM_EVENT_GAME_MODE_SWITCH_START,
  228. // Description:
  229. // Sent when game mode switch ends
  230. ESYSTEM_EVENT_GAME_MODE_SWITCH_END,
  231. // Description:
  232. // Video notifications
  233. // wparam=[0/1/2/3] : [stop/play/pause/resume]
  234. ESYSTEM_EVENT_VIDEO,
  235. // Description:
  236. // Sent if the game is paused
  237. ESYSTEM_EVENT_GAME_PAUSED,
  238. // Description:
  239. // Sent if the game is resumed
  240. ESYSTEM_EVENT_GAME_RESUMED,
  241. // Description:
  242. // Sent when time of day is set
  243. ESYSTEM_EVENT_TIME_OF_DAY_SET,
  244. // Description:
  245. // Sent once the Editor finished initialization.
  246. ESYSTEM_EVENT_EDITOR_ON_INIT,
  247. // Description:
  248. // Sent when frontend is initialised
  249. ESYSTEM_EVENT_FRONTEND_INITIALISED,
  250. // Description:
  251. // Sent once the Editor switches between in-game and editing mode.
  252. ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED,
  253. // Description:
  254. // Sent once the Editor switches simulation mode (AI/Physics).
  255. ESYSTEM_EVENT_EDITOR_SIMULATION_MODE_CHANGED,
  256. // Description:
  257. // Sent when frontend is reloaded
  258. ESYSTEM_EVENT_FRONTEND_RELOADED,
  259. #if defined(AZ_RESTRICTED_PLATFORM)
  260. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_1
  261. #include AZ_RESTRICTED_FILE(ISystem_h)
  262. #endif
  263. #if defined(AZ_RESTRICTED_PLATFORM)
  264. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_2
  265. #include AZ_RESTRICTED_FILE(ISystem_h)
  266. #endif
  267. ESYSTEM_EVENT_STREAMING_INSTALL_ERROR,
  268. // Description:
  269. // Sent when the online services are initialized.
  270. ESYSTEM_EVENT_ONLINE_SERVICES_INITIALISED,
  271. // Description:
  272. // Sent when a new audio implementation is loaded
  273. ESYSTEM_EVENT_AUDIO_IMPLEMENTATION_LOADED,
  274. // Description:
  275. // Sent when simulation mode switch begins
  276. ESYSTEM_EVENT_EDITOR_SIMULATION_MODE_SWITCH_START,
  277. // Description:
  278. // Sent when simluation mode switch ends
  279. ESYSTEM_EVENT_EDITOR_SIMULATION_MODE_SWITCH_END,
  280. ESYSTEM_EVENT_USER = 0x1000,
  281. ESYSTEM_BEAM_PLAYER_TO_CAMERA_POS
  282. };
  283. // Description:
  284. // User defined callback, which can be passed to ISystem.
  285. struct ISystemUserCallback
  286. {
  287. // <interfuscator:shuffle>
  288. virtual ~ISystemUserCallback() {}
  289. // Description:
  290. // This method is called at the earliest point the ISystem pointer can be used
  291. // the log might not be yet there.
  292. virtual void OnSystemConnect([[maybe_unused]] ISystem* pSystem) {}
  293. // Summary:
  294. // Signals to User that engine error occurred.
  295. // Return Value:
  296. // True to Halt execution or false to ignore this error
  297. virtual bool OnError(const char* szErrorString) = 0;
  298. // Notes:
  299. // If working in Editor environment notify user that engine want to Save current document.
  300. // This happens if critical error have occurred and engine gives a user way to save data and not lose it
  301. // due to crash.
  302. virtual bool OnSaveDocument() = 0;
  303. // Notes:
  304. // If working in Editor environment and a critical error occurs notify the user to backup
  305. // the current document to prevent data loss due to crash.
  306. virtual bool OnBackupDocument() = 0;
  307. // Description:
  308. // Notifies user that system wants to switch out of current process.
  309. // Example:
  310. // Called when pressing ESC in game mode to go to Menu.
  311. virtual void OnProcessSwitch() = 0;
  312. // Description:
  313. // Notifies user, usually editor, about initialization progress in system.
  314. virtual void OnInitProgress(const char* sProgressMsg) = 0;
  315. // Description:
  316. // Initialization callback. This is called early in CSystem::Init(), before
  317. // any of the other callback methods is called.
  318. // See also:
  319. // CSystem::Init()
  320. virtual void OnInit(ISystem*) { }
  321. // Summary:
  322. // Shutdown callback.
  323. virtual void OnShutdown() { }
  324. // Summary:
  325. // Quit callback.
  326. // See also:
  327. // CSystem::Quit()
  328. virtual void OnQuit() { }
  329. // Description:
  330. // Notify user of an update iteration. Called in the update loop.
  331. virtual void OnUpdate() { }
  332. // Description:
  333. // Show message by provider.
  334. virtual void ShowMessage(const char* text, const char* caption, unsigned int uType) { CryMessageBox(text, caption, uType); }
  335. // </interfuscator:shuffle>
  336. // Post console load, for cvar setting
  337. virtual void OnConsoleCreated([[maybe_unused]] ::IConsole* pConsole) {}
  338. };
  339. // Description:
  340. // Interface used for getting notified when a system event occurs.
  341. struct ISystemEventListener
  342. {
  343. // <interfuscator:shuffle>
  344. virtual ~ISystemEventListener() {}
  345. virtual void OnSystemEventAnyThread([[maybe_unused]] ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam) {}
  346. virtual void OnSystemEvent([[maybe_unused]] ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam) { }
  347. // </interfuscator:shuffle>
  348. };
  349. // Description:
  350. // Structure used for getting notified when a system event occurs.
  351. struct ISystemEventDispatcher
  352. {
  353. // <interfuscator:shuffle>
  354. virtual ~ISystemEventDispatcher() {}
  355. virtual bool RegisterListener(ISystemEventListener* pListener) = 0;
  356. virtual bool RemoveListener(ISystemEventListener* pListener) = 0;
  357. virtual void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) = 0;
  358. virtual void Update() = 0;
  359. //virtual void OnLocaleChange() = 0;
  360. // </interfuscator:shuffle>
  361. };
  362. struct IErrorObserver
  363. {
  364. // <interfuscator:shuffle>
  365. virtual ~IErrorObserver() {}
  366. virtual void OnAssert(const char* condition, const char* message, const char* fileName, unsigned int fileLineNumber) = 0;
  367. virtual void OnFatalError(const char* message) = 0;
  368. // </interfuscator:shuffle>
  369. };
  370. #if defined(AZ_RESTRICTED_PLATFORM)
  371. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_3
  372. #include AZ_RESTRICTED_FILE(ISystem_h)
  373. #endif
  374. namespace AZ
  375. {
  376. namespace Internal
  377. {
  378. class EnvironmentInterface;
  379. } // namespace Internal
  380. } // namespace AZ
  381. // Description:
  382. // Structure passed to Init method of ISystem interface.
  383. struct SSystemInitParams
  384. {
  385. void* hInstance; //
  386. void* hWnd; //
  387. ILog* pLog; // You can specify your own ILog to be used by System.
  388. ILogCallback* pLogCallback; // You can specify your own ILogCallback to be added on log creation (used by Editor).
  389. ISystemUserCallback* pUserCallback;
  390. const char* sLogFileName; // File name to use for log.
  391. bool autoBackupLogs; // if true, logs will be automatically backed up each startup
  392. IOutputPrintSink* pPrintSync; // Print Sync which can be used to catch all output from engine
  393. char szSystemCmdLine[2048]; // Command line.
  394. bool bEditor; // When running in Editor mode.
  395. bool bPreview; // When running in Preview mode (Minimal initialization).
  396. bool bTestMode; // When running in Automated testing mode.
  397. bool bDedicatedServer; // When running a dedicated server.
  398. bool bSkipConsole; // Don't create console
  399. bool bUnattendedMode; // When running as part of a build on build-machines: Prevent popping up of any dialog
  400. bool bSkipMovie; // Don't load movie
  401. bool bToolMode; // System is running inside a tool. Will not create USER directory or anything else that the game needs to do
  402. ISystem* pSystem; // Pointer to existing ISystem interface, it will be reused if not NULL.
  403. // Summary:
  404. // Initialization defaults.
  405. SSystemInitParams()
  406. {
  407. hInstance = NULL;
  408. hWnd = NULL;
  409. pLog = NULL;
  410. pLogCallback = NULL;
  411. pUserCallback = NULL;
  412. sLogFileName = NULL;
  413. autoBackupLogs = true;
  414. pPrintSync = NULL;
  415. memset(szSystemCmdLine, 0, sizeof(szSystemCmdLine));
  416. bEditor = false;
  417. bPreview = false;
  418. bTestMode = false;
  419. bDedicatedServer = false;
  420. bSkipConsole = false;
  421. bUnattendedMode = false;
  422. bSkipMovie = false;
  423. bToolMode = false;
  424. pSystem = NULL;
  425. }
  426. };
  427. // Notes:
  428. // Can be used for LoadConfiguration().
  429. // See also:
  430. // LoadConfiguration()
  431. struct ILoadConfigurationEntrySink
  432. {
  433. // <interfuscator:shuffle>
  434. virtual ~ILoadConfigurationEntrySink() {}
  435. virtual void OnLoadConfigurationEntry(const char* szKey, const char* szValue, const char* szGroup) = 0;
  436. virtual void OnLoadConfigurationEntry_End() {}
  437. // </interfuscator:shuffle>
  438. };
  439. struct SPlatformInfo
  440. {
  441. unsigned int numCoresAvailableToProcess;
  442. unsigned int numLogicalProcessors;
  443. #if defined(WIN32) || defined(WIN64)
  444. enum EWinVersion
  445. {
  446. WinUndetected,
  447. Win2000,
  448. WinXP,
  449. WinSrv2003,
  450. WinVista,
  451. Win7,
  452. Win8,
  453. Win81,
  454. Win10
  455. };
  456. EWinVersion winVer;
  457. bool win64Bit;
  458. bool vistaKB940105Required;
  459. #endif
  460. };
  461. // Description:
  462. // Holds info about system update stats over perior of time (cvar-tweakable)
  463. struct SSystemUpdateStats
  464. {
  465. SSystemUpdateStats()
  466. : avgUpdateTime(0.0f)
  467. , minUpdateTime(0.0f)
  468. , maxUpdateTime(0.0f) {}
  469. float avgUpdateTime;
  470. float minUpdateTime;
  471. float maxUpdateTime;
  472. };
  473. // Description:
  474. // Global environment.
  475. // Contains pointers to all global often needed interfaces.
  476. // This is a faster way to get interface pointer then calling ISystem interface to retrieve one.
  477. // Notes:
  478. // Some pointers can be NULL, use with care.
  479. // See also:
  480. // ISystem
  481. struct SSystemGlobalEnvironment
  482. {
  483. AZ::IO::IArchive* pCryPak;
  484. AZ::IO::FileIOBase* pFileIO;
  485. ICryFont* pCryFont;
  486. ::IConsole* pConsole;
  487. ISystem* pSystem = nullptr;
  488. ILog* pLog;
  489. IMovieSystem* pMovieSystem;
  490. #if defined(AZ_RESTRICTED_PLATFORM)
  491. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_4
  492. #include AZ_RESTRICTED_FILE(ISystem_h)
  493. #endif
  494. threadID mMainThreadId; //The main thread ID is used in multiple systems so should be stored globally
  495. //////////////////////////////////////////////////////////////////////////
  496. // Used by CRY_ASSERT
  497. bool bIgnoreAllAsserts;
  498. bool bNoAssertDialog;
  499. //////////////////////////////////////////////////////////////////////////
  500. bool bToolMode;
  501. int retCode = 0;
  502. ILINE const bool IsDedicated() const
  503. {
  504. #if defined(CONSOLE)
  505. return false;
  506. #else
  507. return bDedicated;
  508. #endif
  509. }
  510. #if !defined(CONSOLE)
  511. ILINE void SetIsEditor(bool isEditor)
  512. {
  513. bEditor = isEditor;
  514. }
  515. ILINE void SetIsEditorGameMode(bool isEditorGameMode)
  516. {
  517. bEditorGameMode = isEditorGameMode;
  518. }
  519. ILINE void SetIsEditorSimulationMode(bool isEditorSimulationMode)
  520. {
  521. bEditorSimulationMode = isEditorSimulationMode;
  522. }
  523. ILINE void SetIsDedicated(bool isDedicated)
  524. {
  525. bDedicated = isDedicated;
  526. }
  527. #endif
  528. //this way the compiler can strip out code for consoles
  529. ILINE const bool IsEditor() const
  530. {
  531. #if defined(CONSOLE)
  532. return false;
  533. #else
  534. return bEditor;
  535. #endif
  536. }
  537. ILINE const bool IsEditorGameMode() const
  538. {
  539. #if defined(CONSOLE)
  540. return false;
  541. #else
  542. return bEditorGameMode;
  543. #endif
  544. }
  545. ILINE const bool IsEditorSimulationMode() const
  546. {
  547. #if defined(CONSOLE)
  548. return false;
  549. #else
  550. return bEditorSimulationMode;
  551. #endif
  552. }
  553. ILINE const bool IsEditing() const
  554. {
  555. #if defined(CONSOLE)
  556. return false;
  557. #else
  558. return bEditor && !bEditorGameMode;
  559. #endif
  560. }
  561. ILINE bool IsInToolMode() const
  562. {
  563. return bToolMode;
  564. }
  565. ILINE void SetToolMode(bool bNewToolMode)
  566. {
  567. bToolMode = bNewToolMode;
  568. }
  569. #if !defined(CONSOLE)
  570. private:
  571. bool bEditor; // Engine is running under editor.
  572. bool bEditorGameMode; // Engine is in editor game mode.
  573. bool bEditorSimulationMode; // Engine is in editor simulation mode.
  574. bool bDedicated; // Engine is in dedicated
  575. #endif
  576. public:
  577. SSystemGlobalEnvironment()
  578. : bToolMode(false)
  579. {
  580. };
  581. };
  582. // NOTE Nov 25, 2008: <pvl> the ISystem interface that follows has a member function
  583. // called 'GetUserName'. If we don't #undef'ine the same-named Win32 symbol here
  584. // ISystem wouldn't even compile.
  585. // TODO Nov 25, 2008: <pvl> there might be a better place for this?
  586. #ifdef GetUserName
  587. #undef GetUserName
  588. #endif
  589. ////////////////////////////////////////////////////////////////////////////////////////////////
  590. // Description:
  591. // Main Engine Interface.
  592. // Initialize and dispatch all engine's subsystems.
  593. struct ISystem
  594. {
  595. // <interfuscator:shuffle>
  596. virtual ~ISystem() {}
  597. // Summary:
  598. // Releases ISystem.
  599. virtual void Release() = 0;
  600. // Summary:
  601. // Returns pointer to the global environment structure.
  602. virtual SSystemGlobalEnvironment* GetGlobalEnvironment() = 0;
  603. // Summary:
  604. // Updates all subsystems (including the ScriptSink() )
  605. // Arguments:
  606. // flags - One or more flags from ESystemUpdateFlags structure.
  607. // nPauseMode - 0=normal(no pause), 1=menu/pause, 2=cutscene
  608. virtual bool UpdatePreTickBus(int updateFlags = 0, int nPauseMode = 0) = 0;
  609. // Summary:
  610. // Updates all subsystems (including the ScriptSink() )
  611. // Arguments:
  612. // flags - One or more flags from ESystemUpdateFlags structure.
  613. // nPauseMode - 0=normal(no pause), 1=menu/pause, 2=cutscene
  614. virtual bool UpdatePostTickBus(int updateFlags = 0, int nPauseMode = 0) = 0;
  615. // Summary:
  616. // Updates only require components during loading
  617. virtual bool UpdateLoadtime() = 0;
  618. // Summary:
  619. // Retrieve the name of the user currently logged in to the computer.
  620. virtual const char* GetUserName() = 0;
  621. // Summary:
  622. // Quits the application.
  623. virtual void Quit() = 0;
  624. // Summary:
  625. // Tells the system if it is relaunching or not.
  626. virtual void Relaunch(bool bRelaunch) = 0;
  627. // Summary:
  628. // Returns true if the application is in the shutdown phase.
  629. virtual bool IsQuitting() const = 0;
  630. // Summary:
  631. // Tells the system in which way we are using the serialization system.
  632. virtual void SerializingFile(int mode) = 0;
  633. virtual int IsSerializingFile() const = 0;
  634. virtual bool IsRelaunch() const = 0;
  635. // Description:
  636. // Displays error message.
  637. // Logs it to console and file and error message box then terminates execution.
  638. virtual void FatalError(const char* sFormat, ...) PRINTF_PARAMS(2, 3) = 0;
  639. // Description:
  640. // Reports a bug using the crash handler.
  641. // Logs an error to the console and launches the crash handler, then continues execution.
  642. virtual void ReportBug(const char* sFormat, ...) PRINTF_PARAMS(2, 3) = 0;
  643. // Description:
  644. // Report warning to current Validator object.
  645. // Doesn't terminate the execution.
  646. //##@{
  647. virtual void WarningV(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, va_list args) = 0;
  648. virtual void Warning(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, ...) = 0;
  649. //##@}
  650. // Description:
  651. // Report message by provider or by using CryMessageBox.
  652. // Doesn't terminate the execution.
  653. virtual void ShowMessage(const char* text, const char* caption, unsigned int uType) = 0;
  654. // Summary:
  655. // Compare specified verbosity level to the one currently set.
  656. virtual bool CheckLogVerbosity(int verbosity) = 0;
  657. // return the related subsystem interface
  658. virtual ILevelSystem* GetILevelSystem() = 0;
  659. virtual ICmdLine* GetICmdLine() = 0;
  660. virtual ILog* GetILog() = 0;
  661. virtual AZ::IO::IArchive* GetIPak() = 0;
  662. virtual ICryFont* GetICryFont() = 0;
  663. virtual IMovieSystem* GetIMovieSystem() = 0;
  664. virtual ::IConsole* GetIConsole() = 0;
  665. virtual IRemoteConsole* GetIRemoteConsole() = 0;
  666. virtual ISystemEventDispatcher* GetISystemEventDispatcher() = 0;
  667. virtual bool IsDevMode() const = 0;
  668. //////////////////////////////////////////////////////////////////////////
  669. //////////////////////////////////////////////////////////////////////////
  670. // IXmlNode interface.
  671. //////////////////////////////////////////////////////////////////////////
  672. // Summary:
  673. // Creates new xml node.
  674. virtual XmlNodeRef CreateXmlNode(const char* sNodeName = "", bool bReuseStrings = false, bool bIsProcessingInstruction = false) = 0;
  675. // Summary:
  676. // Loads xml from memory buffer, returns 0 if load failed.
  677. virtual XmlNodeRef LoadXmlFromBuffer(const char* buffer, size_t size, bool bReuseStrings = false, bool bSuppressWarnings = false) = 0;
  678. // Summary:
  679. // Loads xml file, returns 0 if load failed.
  680. virtual XmlNodeRef LoadXmlFromFile(const char* sFilename, bool bReuseStrings = false) = 0;
  681. // Summary:
  682. // Retrieves access to XML utilities interface.
  683. virtual IXmlUtils* GetXmlUtils() = 0;
  684. // Description:
  685. // When ignore update sets to true, system will ignore and updates and render calls.
  686. virtual void IgnoreUpdates(bool bIgnore) = 0;
  687. // Return Value:
  688. // True if system running in Test mode.
  689. virtual bool IsTestMode() const = 0;
  690. //////////////////////////////////////////////////////////////////////////
  691. // File version.
  692. //////////////////////////////////////////////////////////////////////////
  693. // Summary:
  694. // Gets file version.
  695. virtual const SFileVersion& GetFileVersion() = 0;
  696. // Summary:
  697. // Gets product version.
  698. virtual const SFileVersion& GetProductVersion() = 0;
  699. // Summary:
  700. // Gets build version.
  701. virtual const SFileVersion& GetBuildVersion() = 0;
  702. //////////////////////////////////////////////////////////////////////////
  703. // Configuration.
  704. //////////////////////////////////////////////////////////////////////////
  705. // Summary:
  706. // Loads configurations from CVarGroup directory recursively
  707. // If m_GraphicsSettingsMap is defined (in Graphics Settings Dialog box), fills in mapping based on sys_spec_Full
  708. // Arguments:
  709. // sPath - e.g. "Game/Config/CVarGroups"
  710. virtual void AddCVarGroupDirectory(const AZStd::string& sPath) = 0;
  711. // Summary:
  712. // Saves system configuration.
  713. virtual void SaveConfiguration() = 0;
  714. // Summary:
  715. // Loads system configuration
  716. // Arguments:
  717. // pCallback - 0 means normal LoadConfigVar behaviour is used
  718. virtual void LoadConfiguration(const char* sFilename, ILoadConfigurationEntrySink* pSink = 0, bool warnIfMissing = true) = 0;
  719. //////////////////////////////////////////////////////////////////////////
  720. // Summary:
  721. // Retrieves current configuration platform
  722. virtual ESystemConfigPlatform GetConfigPlatform() const = 0;
  723. // Summary:
  724. // Changes current configuration platform.
  725. virtual void SetConfigPlatform(ESystemConfigPlatform platform) = 0;
  726. //////////////////////////////////////////////////////////////////////////
  727. // Summary:
  728. // Query if system is now paused.
  729. // Pause flag is set when calling system update with pause mode.
  730. virtual bool IsPaused() const = 0;
  731. // Summary:
  732. // Retrieves localized strings manager interface.
  733. virtual ILocalizationManager* GetLocalizationManager() = 0;
  734. // Summary:
  735. // Retrieves the perlin noise singleton instance.
  736. virtual CPNoise3* GetNoiseGen() = 0;
  737. //////////////////////////////////////////////////////////////////////////
  738. // Error callback handling
  739. // Summary:
  740. // Registers listeners to CryAssert and error messages. (may not be called if asserts are disabled)
  741. // Each pointer can be registered only once. (stl::push_back_unique)
  742. // It will return false if the pointer is already registered. Returns true, otherwise.
  743. virtual bool RegisterErrorObserver(IErrorObserver* errorObserver) = 0;
  744. // Summary:
  745. // Unregisters listeners to CryAssert and error messages.
  746. // It will return false if the pointer is not registered. Otherwise, returns true.
  747. virtual bool UnregisterErrorObserver(IErrorObserver* errorObserver) = 0;
  748. // Summary:
  749. // Called after the processing of the assert message box on some platforms.
  750. // It will be called even when asserts are disabled by the console variables.
  751. virtual void OnAssert(const char* condition, const char* message, const char* fileName, unsigned int fileLineNumber) = 0;
  752. // Summary:
  753. // Returns if the assert window from CryAssert is visible.
  754. // OBS1: needed by the editor, as in some cases it can freeze if during an assert engine it will handle
  755. // some events such as mouse movement in a CryPhysics assert.
  756. // OBS2: it will always return false, if asserts are disabled or ignored.
  757. virtual bool IsAssertDialogVisible() const = 0;
  758. // Summary:
  759. // Sets the AssertVisisble internal variable.
  760. // Typically it should only be called by CryAssert.
  761. virtual void SetAssertVisible(bool bAssertVisble) = 0;
  762. //////////////////////////////////////////////////////////////////////////
  763. // Summary:
  764. // Get the index of the currently running O3DE application. (0 = first instance, 1 = second instance, etc)
  765. virtual int GetApplicationInstance() = 0;
  766. // Summary:
  767. // Get log index of the currently running Open 3D Engine application. (0 = first instance, 1 = second instance, etc)
  768. virtual int GetApplicationLogInstance(const char* logFilePath) = 0;
  769. // Summary:
  770. // Clear all currently logged and drawn on screen error messages
  771. virtual void ClearErrorMessages() = 0;
  772. //////////////////////////////////////////////////////////////////////////
  773. // For debugging use only!, query current C++ call stack.
  774. //////////////////////////////////////////////////////////////////////////
  775. // Notes:
  776. // Pass nCount to indicate maximum number of functions to get.
  777. // For debugging use only, query current C++ call stack.
  778. // Description:
  779. // Fills array of function pointers, nCount return number of functions.
  780. virtual void debug_GetCallStack(const char** pFunctions, int& nCount) = 0;
  781. // Summary:
  782. // Logs current callstack.
  783. // Notes:
  784. // For debugging use only!, query current C++ call stack.
  785. virtual void debug_LogCallStack(int nMaxFuncs = 32, int nFlags = 0) = 0;
  786. // Description:
  787. // Execute command line arguments.
  788. // Should be after init game.
  789. // Example:
  790. // +g_gametype ASSAULT +LoadLevel "testy"
  791. virtual void ExecuteCommandLine(bool deferred=true) = 0;
  792. // Description:
  793. // GetSystemUpdate stats (all systems update without except console)
  794. // very useful on dedicated server as we throttle it to fixed frequency
  795. // returns zeroes if no updates happened yet
  796. virtual void GetUpdateStats(SSystemUpdateStats& stats) = 0;
  797. virtual ESystemGlobalState GetSystemGlobalState(void) = 0;
  798. virtual void SetSystemGlobalState(ESystemGlobalState systemGlobalState) = 0;
  799. #if !defined(_RELEASE)
  800. virtual bool IsSavingResourceList() const = 0;
  801. #endif
  802. // Summary:
  803. // Register a IWindowMessageHandler that will be informed about window messages
  804. // The delivered messages are platform-specific
  805. virtual void RegisterWindowMessageHandler(IWindowMessageHandler* pHandler) = 0;
  806. // Summary:
  807. // Unregister an IWindowMessageHandler that was previously registered using RegisterWindowMessageHandler
  808. virtual void UnregisterWindowMessageHandler(IWindowMessageHandler* pHandler) = 0;
  809. ////////////////////////////////////////////////////////////////////////////////////////////////
  810. // EBus interface used to listen for cry system notifications
  811. class CrySystemNotifications : public AZ::EBusTraits
  812. {
  813. public:
  814. virtual ~CrySystemNotifications() = default;
  815. // Override to be notified right before the call to ISystem::Render
  816. virtual void OnPreRender() {}
  817. // Override to be notified right after the call to ISystem::Render (but before RenderEnd)
  818. virtual void OnPostRender() {}
  819. };
  820. using CrySystemNotificationBus = AZ::EBus<CrySystemNotifications>;
  821. };
  822. //////////////////////////////////////////////////////////////////////////
  823. // CrySystem DLL Exports.
  824. //////////////////////////////////////////////////////////////////////////
  825. typedef ISystem* (*PFNCREATESYSTEMINTERFACE)(SSystemInitParams& initParams);
  826. //////////////////////////////////////////////////////////////////////////
  827. // Global environment variable.
  828. //////////////////////////////////////////////////////////////////////////
  829. extern SSystemGlobalEnvironment* gEnv;
  830. // Summary:
  831. // Gets the system interface.
  832. inline ISystem* GetISystem()
  833. {
  834. // Some unit tests temporarily install and then uninstall ISystem* mocks.
  835. // It is generally okay for runtime and tool systems which call this function to cache the returned pointer,
  836. // because their lifetime is usually shorter than the lifetime of the ISystem* implementation.
  837. // It is NOT safe for this function to cache it as a static itself, though, as the static it would cache
  838. // it inside may outlive the the actual instance implementing ISystem* when unit tests are torn down and then restarted.
  839. ISystem* systemInterface = gEnv ? gEnv->pSystem : nullptr;
  840. if (!systemInterface)
  841. {
  842. CrySystemRequestBus::BroadcastResult(systemInterface, &CrySystemRequests::GetCrySystem);
  843. }
  844. return systemInterface;
  845. };
  846. //////////////////////////////////////////////////////////////////////////
  847. // Description:
  848. // This function must be called once by each module at the beginning, to setup global pointers.
  849. void ModuleInitISystem(ISystem* pSystem, const char* moduleName);
  850. void ModuleShutdownISystem(ISystem* pSystem);
  851. void* GetModuleInitISystemSymbol();
  852. void* GetModuleShutdownISystemSymbol();
  853. #define PREVENT_MODULE_AND_ENVIRONMENT_SYMBOL_STRIPPING \
  854. AZ_UNUSED(GetModuleInitISystemSymbol()); \
  855. AZ_UNUSED(GetModuleShutdownISystemSymbol());
  856. // Summary:
  857. // Interface of the DLL.
  858. extern "C"
  859. {
  860. #if !defined(AZ_MONOLITHIC_BUILD)
  861. CRYSYSTEM_API
  862. #endif
  863. ISystem* CreateSystemInterface(const SSystemInitParams& initParams);
  864. }
  865. // Description:
  866. // Displays error message.
  867. // Logs it to console and file and error message box.
  868. // Then terminates execution.
  869. void CryFatalError(const char*, ...) PRINTF_PARAMS(1, 2);
  870. inline void CryFatalError(const char* format, ...)
  871. {
  872. if (!gEnv || !gEnv->pSystem)
  873. {
  874. return;
  875. }
  876. va_list ArgList;
  877. char szBuffer[MAX_WARNING_LENGTH];
  878. va_start(ArgList, format);
  879. int count = azvsnprintf(szBuffer, sizeof(szBuffer), format, ArgList);
  880. if (count == -1 || count >= sizeof(szBuffer))
  881. {
  882. szBuffer[sizeof(szBuffer) - 1] = '\0';
  883. }
  884. va_end(ArgList);
  885. gEnv->pSystem->FatalError("%s", szBuffer);
  886. }
  887. //////////////////////////////////////////////////////////////////////////
  888. // Description:
  889. // Displays warning message.
  890. // Logs it to console and file and display a warning message box.
  891. // Doesn't terminate execution.
  892. void CryWarning(EValidatorModule, EValidatorSeverity, const char*, ...) PRINTF_PARAMS(3, 4);
  893. inline void CryWarning(EValidatorModule module, EValidatorSeverity severity, const char* format, ...)
  894. {
  895. if (!gEnv || !gEnv->pSystem || !format)
  896. {
  897. return;
  898. }
  899. va_list args;
  900. va_start(args, format);
  901. GetISystem()->WarningV(module, severity, 0, 0, format, args);
  902. va_end(args);
  903. }
  904. #ifdef EXCLUDE_CVARHELP
  905. #define CVARHELP(_comment) 0
  906. #else
  907. #define CVARHELP(_comment) _comment
  908. #endif
  909. //Provide macros for fixing cvars for release mode on consoles to enums to allow for code stripping
  910. //Do not enable for PC, apply VF_CHEAT there if required
  911. #if defined(CONSOLE)
  912. #define CONST_CVAR_FLAGS (VF_CHEAT)
  913. #else
  914. #define CONST_CVAR_FLAGS (VF_NULL)
  915. #endif
  916. #if defined(AZ_RESTRICTED_PLATFORM)
  917. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_5
  918. #include AZ_RESTRICTED_FILE(ISystem_h)
  919. #endif
  920. #if defined(_RELEASE) && defined(IS_CONSOLE_PLATFORM)
  921. #ifndef LOG_CONST_CVAR_ACCESS
  922. #error LOG_CONST_CVAR_ACCESS should be defined in ProjectDefines.h
  923. #endif
  924. #include "IConsole.h"
  925. namespace Detail
  926. {
  927. template<typename T>
  928. struct SQueryTypeEnum;
  929. template<>
  930. struct SQueryTypeEnum<int>
  931. {
  932. static const int type = CVAR_INT;
  933. static int ParseString(const char* s) { return atoi(s); }
  934. };
  935. template<>
  936. struct SQueryTypeEnum<float>
  937. {
  938. static const int type = CVAR_FLOAT;
  939. static float ParseString(const char* s) { return (float)atof(s); }
  940. };
  941. template<typename T>
  942. struct SDummyCVar
  943. : ICVar
  944. {
  945. const T value;
  946. #if LOG_CONST_CVAR_ACCESS
  947. mutable bool bWasRead;
  948. mutable bool bWasChanged;
  949. SDummyCVar(T val)
  950. : value(val)
  951. , bWasChanged(false)
  952. , bWasRead(false) {}
  953. #else
  954. SDummyCVar(T val)
  955. : value(val) {}
  956. #endif
  957. void WarnUse() const
  958. {
  959. #if LOG_CONST_CVAR_ACCESS
  960. if (!bWasRead)
  961. {
  962. CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "[CVAR] Read from const CVar '%s' via name look-up, this is non-optimal", GetName());
  963. bWasRead = true;
  964. }
  965. #endif
  966. }
  967. void InvalidAccess() const
  968. {
  969. #if LOG_CONST_CVAR_ACCESS
  970. if (!bWasChanged)
  971. {
  972. CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, "[CVAR] Write to const CVar '%s' with wrong value '%f' was ignored. This indicates a bug in code or a config file", GetName(), GetFVal());
  973. bWasChanged = true;
  974. }
  975. #endif
  976. }
  977. void Release() {}
  978. int GetIVal() const { WarnUse(); return static_cast<int>(value); }
  979. int64 GetI64Val() const { WarnUse(); return static_cast<int64>(value); }
  980. float GetFVal() const { WarnUse(); return static_cast<float>(value); }
  981. const char* GetString() const { return ""; }
  982. const char* GetDataProbeString() const { return ""; }
  983. void Set(const char* s)
  984. {
  985. if (SQueryTypeEnum<T>::ParseString(s) != value)
  986. {
  987. InvalidAccess();
  988. }
  989. }
  990. void ForceSet(const char* s) { Set(s); }
  991. void Set(const float f)
  992. {
  993. if (static_cast<T>(f) != value)
  994. {
  995. InvalidAccess();
  996. }
  997. }
  998. void Set(const int i)
  999. {
  1000. if (static_cast<T>(i) != value)
  1001. {
  1002. InvalidAccess();
  1003. }
  1004. }
  1005. void ClearFlags([[maybe_unused]] int flags) {}
  1006. int GetFlags() const { return VF_CONST_CVAR | VF_READONLY; }
  1007. int SetFlags([[maybe_unused]] int flags) { return 0; }
  1008. int GetType() { return SQueryTypeEnum<T>::type; }
  1009. const char* GetHelp() { return NULL; }
  1010. bool IsConstCVar() const { return true; }
  1011. void SetOnChangeCallback(ConsoleVarFunc pChangeFunc) { (void)pChangeFunc; }
  1012. bool AddOnChangeFunctor(AZ::Name, const AZStd::function<void()>&)
  1013. {
  1014. return false;
  1015. }
  1016. ConsoleVarFunc GetOnChangeCallback() const { InvalidAccess(); return NULL; }
  1017. int GetRealIVal() const { return GetIVal(); }
  1018. void SetLimits([[maybe_unused]] float min, [[maybe_unused]] float max) { return; }
  1019. void GetLimits([[maybe_unused]] float& min, [[maybe_unused]] float& max) { return; }
  1020. bool HasCustomLimits() { return false; }
  1021. void SetDataProbeString([[maybe_unused]] const char* pDataProbeString) { InvalidAccess(); }
  1022. };
  1023. }
  1024. #define REGISTER_DUMMY_CVAR(type, name, value) \
  1025. do { \
  1026. static struct DummyCVar \
  1027. : Detail::SDummyCVar<type> \
  1028. { \
  1029. DummyCVar() \
  1030. : Detail::SDummyCVar<type>(value) {} \
  1031. const char* GetName() const { return name; } \
  1032. } DummyStaticInstance; \
  1033. if (!(gEnv->pConsole != 0 ? gEnv->pConsole->Register(&DummyStaticInstance) : 0)) \
  1034. { \
  1035. AZ::Debug::Trace::Instance().Break(); \
  1036. CryFatalError("Can not register dummy CVar"); \
  1037. } \
  1038. } while (0)
  1039. # define CONSOLE_CONST_CVAR_MODE
  1040. # define DeclareConstIntCVar(name, defaultValue) enum : int { name = (defaultValue) }
  1041. # define DeclareStaticConstIntCVar(name, defaultValue) enum : int { name = (defaultValue) }
  1042. # define DefineConstIntCVarName(strname, name, defaultValue, flags, help) { static_assert((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, strname, defaultValue); }
  1043. # define DefineConstIntCVar(name, defaultValue, flags, help) { static_assert((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, (#name), defaultValue); }
  1044. // DefineConstIntCVar2 is deprecated, any such instance can be converted to the 3 variant by removing the quotes around the first parameter
  1045. # define DefineConstIntCVar3(name, _var_, defaultValue, flags, help) { static_assert((int)(defaultValue) == (int)(_var_)); REGISTER_DUMMY_CVAR(int, name, defaultValue); }
  1046. # define AllocateConstIntCVar(scope, name)
  1047. # define DefineConstFloatCVar(name, flags, help) { REGISTER_DUMMY_CVAR(float, (#name), name ## Default); }
  1048. # define DeclareConstFloatCVar(name)
  1049. # define DeclareStaticConstFloatCVar(name)
  1050. # define AllocateConstFloatCVar(scope, name)
  1051. # define IsCVarConstAccess(expr) expr
  1052. #else
  1053. # define DeclareConstIntCVar(name, defaultValue) int name { defaultValue }
  1054. # define DeclareStaticConstIntCVar(name, defaultValue) static int name
  1055. # define DefineConstIntCVarName(strname, name, defaultValue, flags, help) \
  1056. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(strname, &name, defaultValue, flags | CONST_CVAR_FLAGS, CVARHELP(help)))
  1057. # define DefineConstIntCVar(name, defaultValue, flags, help) \
  1058. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#name), &name, defaultValue, flags | CONST_CVAR_FLAGS, CVARHELP(help), 0, false))
  1059. // DefineConstIntCVar2 is deprecated, any such instance can be converted to the 3 variant by removing the quotes around the first parameter
  1060. # define DefineConstIntCVar3(_name, _var, _def_val, _flags, help) \
  1061. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags) | CONST_CVAR_FLAGS, CVARHELP(help), 0, false))
  1062. # define AllocateConstIntCVar(scope, name) int scope:: name
  1063. # define DefineConstFloatCVar(name, flags, help) \
  1064. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#name), &name, name ## Default, flags | CONST_CVAR_FLAGS, CVARHELP(help), 0, false))
  1065. # define DeclareConstFloatCVar(name) float name
  1066. # define DeclareStaticConstFloatCVar(name) static float name
  1067. # define AllocateConstFloatCVar(scope, name) float scope:: name
  1068. # define IsCVarConstAccess(expr)
  1069. #endif
  1070. // the following macros allow the help text to be easily stripped out
  1071. // Summary:
  1072. // Preferred way to register a CVar
  1073. #define REGISTER_CVAR(_var, _def_val, _flags, _comment) \
  1074. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment)))
  1075. // Summary:
  1076. // Preferred way to register a CVar with a callback
  1077. #define REGISTER_CVAR_CB(_var, _def_val, _flags, _comment, _onchangefunction) \
  1078. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1079. // Summary:
  1080. // Preferred way to register a string CVar
  1081. #define REGISTER_STRING(_name, _def_val, _flags, _comment) \
  1082. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1083. // Summary:
  1084. // Preferred way to register a string CVar with a callback
  1085. #define REGISTER_STRING_CB(_name, _def_val, _flags, _comment, _onchangefunction) \
  1086. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1087. // Summary:
  1088. // Preferred way to register an int CVar
  1089. #define REGISTER_INT(_name, _def_val, _flags, _comment) \
  1090. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1091. // Summary:
  1092. // Preferred way to register an int CVar with a callback
  1093. #define REGISTER_INT_CB(_name, _def_val, _flags, _comment, _onchangefunction) \
  1094. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1095. // Summary:
  1096. // Preferred way to register a float CVar
  1097. #define REGISTER_FLOAT(_name, _def_val, _flags, _comment) \
  1098. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1099. // Summary:
  1100. // Offers more flexibility but more code is required
  1101. #define REGISTER_CVAR2(_name, _var, _def_val, _flags, _comment) \
  1102. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment)))
  1103. // Summary:
  1104. // Offers more flexibility but more code is required
  1105. #define REGISTER_CVAR2_CB(_name, _var, _def_val, _flags, _comment, _onchangefunction) \
  1106. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1107. // Summary:
  1108. // Offers more flexibility but more code is required, explicit address taking of destination variable
  1109. #define REGISTER_CVAR3(_name, _var, _def_val, _flags, _comment) \
  1110. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment)))
  1111. // Summary:
  1112. // Preferred way to register a console command
  1113. #define REGISTER_COMMAND(_name, _func, _flags, _comment) \
  1114. (gEnv->pConsole == 0 ? false : gEnv->pConsole->AddCommand(_name, _func, (_flags), CVARHELP(_comment)))
  1115. // Summary:
  1116. // Preferred way to unregister a CVar
  1117. #define UNREGISTER_CVAR(_name) \
  1118. (gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->UnregisterVariable(_name))
  1119. // Summary:
  1120. // Preferred way to unregister a console command
  1121. #define UNREGISTER_COMMAND(_name) \
  1122. (gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->RemoveCommand(_name))
  1123. ////////////////////////////////////////////////////////////////////////////////
  1124. //
  1125. // Development only cvars
  1126. //
  1127. // N.B:
  1128. // (1) Registered as real cvars *in non release builds only*.
  1129. // (2) Can still be manipulated in release by the mapped variable, so not the same as const cvars.
  1130. // (3) Any 'OnChanged' callback will need guarding against in release builds since the cvar won't exist
  1131. // (4) Any code that tries to get ICVar* will need guarding against in release builds since the cvar won't exist
  1132. //
  1133. // ILLEGAL_DEV_FLAGS is a mask of all those flags which make no sense in a _DEV_ONLY or _DEDI_ONLY cvar since the
  1134. // cvar potentially won't exist in a release build.
  1135. //
  1136. #define ILLEGAL_DEV_FLAGS (VF_NET_SYNCED | VF_CHEAT | VF_CHEAT_ALWAYS_CHECK | VF_CHEAT_NOCHECK | VF_READONLY | VF_CONST_CVAR)
  1137. #if defined(_RELEASE)
  1138. #define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
  1139. #define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val /* _onchangefunction consumed; callback not available */
  1140. #define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1141. #define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1142. #define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1143. #define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1144. #define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1145. #define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
  1146. #define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
  1147. #define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
  1148. #define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) /* consumed; command not available */
  1149. #else
  1150. #define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1151. #define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1152. #define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1153. #define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1154. #define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1155. #define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1156. #define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1157. #define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1158. #define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1159. #define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1160. #define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1161. #endif // defined(_RELEASE)
  1162. //
  1163. ////////////////////////////////////////////////////////////////////////////////
  1164. ////////////////////////////////////////////////////////////////////////////////
  1165. //
  1166. // Dedicated server only cvars
  1167. //
  1168. // N.B:
  1169. // (1) Registered as real cvars in all non release builds
  1170. // (2) Registered as real cvars in release on dedi servers only, otherwise treated as DEV_ONLY type cvars (see above)
  1171. //
  1172. // TODO Registering all cvars for Dedicated server as well. Currently CrySystems have no concept of Dedicated server with cmake.
  1173. // If we introduce server specific targets for CrySystems, we can add DEDICATED_SERVER flags to those and add the flag back in here.
  1174. #if defined(_RELEASE)
  1175. #define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1176. #define REGISTER_CVAR_CB_DEDI_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1177. #define REGISTER_STRING_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1178. #define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1179. #define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1180. #define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1181. #define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1182. #define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1183. #define REGISTER_CVAR2_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1184. #define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1185. #else
  1186. #define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR_DEV_ONLY(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1187. #define REGISTER_CVAR_CB_DEDI_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
  1188. #define REGISTER_STRING_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1189. #define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
  1190. #define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1191. #define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
  1192. #define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1193. #define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1194. #define REGISTER_CVAR2_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
  1195. #define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND_DEV_ONLY(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment)
  1196. #endif // defined(_RELEASE)
  1197. //
  1198. ////////////////////////////////////////////////////////////////////////////////
  1199. #ifdef EXCLUDE_NORMAL_LOG // setting this removes a lot of logging to reduced code size (useful for consoles)
  1200. #define CryLog(...) ((void)0)
  1201. #define CryComment(...) ((void)0)
  1202. #define CryLogAlways(...) ((void)0)
  1203. #define CryOutputToCallback(...) ((void)0)
  1204. #else // EXCLUDE_NORMAL_LOG
  1205. // Summary:
  1206. // Simple logs of data with low verbosity.
  1207. void CryLog(const char*, ...) PRINTF_PARAMS(1, 2);
  1208. inline void CryLog(const char* format, ...)
  1209. {
  1210. // Fran: we need these guards for the testing framework to work
  1211. if (gEnv && gEnv->pSystem && gEnv->pLog)
  1212. {
  1213. va_list args;
  1214. va_start(args, format);
  1215. gEnv->pLog->LogV(ILog::eMessage, format, args);
  1216. va_end(args);
  1217. }
  1218. }
  1219. // Notes:
  1220. // Very rarely used log comment.
  1221. void CryComment(const char*, ...) PRINTF_PARAMS(1, 2);
  1222. inline void CryComment(const char* format, ...)
  1223. {
  1224. // Fran: we need these guards for the testing framework to work
  1225. if (gEnv && gEnv->pSystem && gEnv->pLog)
  1226. {
  1227. va_list args;
  1228. va_start(args, format);
  1229. gEnv->pLog->LogV(ILog::eComment, format, args);
  1230. va_end(args);
  1231. }
  1232. }
  1233. // Summary:
  1234. // Logs important data that must be printed regardless verbosity.
  1235. void CryLogAlways(const char*, ...) PRINTF_PARAMS(1, 2);
  1236. inline void CryLogAlways(const char* format, ...)
  1237. {
  1238. // log should not be used before system is ready
  1239. // error before system init should be handled explicitly
  1240. // Fran: we need these guards for the testing framework to work
  1241. if (gEnv && gEnv->pSystem && gEnv->pLog)
  1242. {
  1243. // assert(gEnv);
  1244. // assert(gEnv->pSystem);
  1245. va_list args;
  1246. va_start(args, format);
  1247. gEnv->pLog->LogV(ILog::eAlways, format, args);
  1248. va_end(args);
  1249. }
  1250. }
  1251. //! Writes to CLog via a callback function
  1252. //! Any formatting is the responsiblity of the callback function
  1253. //! The callback function should write to the supplied stream argument
  1254. inline void CryOutputToCallback(ILog::ELogType logType, const ILog::LogWriteCallback& messageCallback)
  1255. {
  1256. // writes directly to the log without formatting
  1257. // This is able to bypase the format limits of 4096 + 32 characters for output
  1258. if (gEnv && gEnv->pLog)
  1259. {
  1260. gEnv->pLog->LogWithCallback(logType, messageCallback);
  1261. }
  1262. }
  1263. #endif // EXCLUDE_NORMAL_LOG