ISystem.h 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. // Original file Copyright Crytek GMBH or its affiliates, used under license.
  13. // In Mac, including ISystem without including platform.h first fails because platform.h
  14. // includes CryThread.h which includes CryThread_pthreads.h which uses ISystem (gEnv).
  15. // So plaform.h needs the contents of ISystem.h.
  16. // By including platform.h outside of the guard, we give platform.h the right include order
  17. #include <platform.h> // Needed for LARGE_INTEGER (for consoles).
  18. #ifndef CRYINCLUDE_CRYCOMMON_ISYSTEM_H
  19. #define CRYINCLUDE_CRYCOMMON_ISYSTEM_H
  20. #pragma once
  21. #ifdef CRYSYSTEM_EXPORTS
  22. #define CRYSYSTEM_API DLL_EXPORT
  23. #else
  24. #define CRYSYSTEM_API DLL_IMPORT
  25. #endif
  26. #include "CryAssert.h"
  27. #include "CompileTimeAssert.h"
  28. #include <AzCore/IO/SystemFile.h>
  29. #if defined(AZ_RESTRICTED_PLATFORM)
  30. #undef AZ_RESTRICTED_SECTION
  31. #define ISYSTEM_H_SECTION_1 1
  32. #define ISYSTEM_H_SECTION_2 2
  33. #define ISYSTEM_H_SECTION_3 3
  34. #define ISYSTEM_H_SECTION_4 4
  35. #define ISYSTEM_H_SECTION_5 5
  36. #endif
  37. ////////////////////////////////////////////////////////////////////////////////////////////////
  38. // Forward declarations
  39. ////////////////////////////////////////////////////////////////////////////////////////////////
  40. #include <IXml.h> // <> required for Interfuscator
  41. #include "IValidator.h" // <> required for Interfuscator
  42. #include <ILog.h> // <> required for Interfuscator
  43. #include "CryVersion.h"
  44. #include "smartptr.h"
  45. #include <ISystemScheduler.h> // <> required for Interfuscator
  46. #include <memory> // shared_ptr
  47. #include <CrySystemBus.h>
  48. struct ISystem;
  49. struct ILog;
  50. struct IProfileLogSystem;
  51. namespace AZ::IO
  52. {
  53. struct IArchive;
  54. }
  55. struct IKeyboard;
  56. struct IMouse;
  57. struct IConsole;
  58. struct IRemoteConsole;
  59. struct IRenderer;
  60. struct IProcess;
  61. struct I3DEngine;
  62. struct ITimer;
  63. struct ICryFont;
  64. struct IMovieSystem;
  65. struct IMemoryManager;
  66. namespace Audio
  67. {
  68. struct IAudioSystem;
  69. } // namespace Audio
  70. struct IStreamEngine;
  71. struct SFileVersion;
  72. struct INameTable;
  73. struct ILevelSystem;
  74. struct IViewSystem;
  75. struct IMaterialEffects;
  76. class IOpticsManager;
  77. class ICrySizer;
  78. class IXMLBinarySerializer;
  79. struct IReadWriteXMLSink;
  80. struct IThreadTaskManager;
  81. struct IResourceManager;
  82. struct ITextModeConsole;
  83. struct IAVI_Reader;
  84. class CPNoise3;
  85. struct IFileChangeMonitor;
  86. struct IVisualLog;
  87. struct ILocalizationManager;
  88. struct ICryFactoryRegistry;
  89. struct ISoftCodeMgr;
  90. struct IZLibCompressor;
  91. struct IZLibDecompressor;
  92. struct ILZ4Decompressor;
  93. class IZStdDecompressor;
  94. struct IOutputPrintSink;
  95. struct IOverloadSceneManager;
  96. struct IThreadManager;
  97. struct IServiceNetwork;
  98. struct IRemoteCommandManager;
  99. struct IWindowMessageHandler;
  100. struct IImageHandler;
  101. class IResourceCompilerHelper;
  102. class ILmbrAWS;
  103. namespace AZ
  104. {
  105. namespace IO
  106. {
  107. class FileIOBase;
  108. }
  109. }
  110. class IResourceCompilerHelper;
  111. namespace Serialization {
  112. struct IArchiveHost;
  113. }
  114. struct ILocalMemoryUsage;
  115. typedef void* WIN_HWND;
  116. class CCamera;
  117. struct CLoadingTimeProfiler;
  118. class ICmdLine;
  119. struct INotificationNetwork;
  120. struct ICryPerfHUD;
  121. class ILyShine;
  122. namespace JobManager {
  123. struct IJobManager;
  124. }
  125. #define PROC_MENU 1
  126. #define PROC_3DENGINE 2
  127. // Summary:
  128. // IDs for script userdata typing.
  129. // Remarks:
  130. // Maybe they should be moved into the game.dll .
  131. //##@{
  132. #define USER_DATA_SOUND 1
  133. #define USER_DATA_TEXTURE 2
  134. #define USER_DATA_OBJECT 3
  135. #define USER_DATA_LIGHT 4
  136. #define USER_DATA_BONEHANDLER 5
  137. #define USER_DATA_POINTER 6
  138. //##@}
  139. enum ESystemUpdateFlags
  140. {
  141. ESYSUPDATE_IGNORE_PHYSICS = 0x0002,
  142. // Summary:
  143. // Special update mode for editor.
  144. ESYSUPDATE_EDITOR = 0x0004,
  145. ESYSUPDATE_MULTIPLAYER = 0x0008,
  146. ESYSUPDATE_EDITOR_AI_PHYSICS = 0x0010,
  147. ESYSUPDATE_EDITOR_ONLY = 0x0020,
  148. ESYSUPDATE_UPDATE_VIEW_ONLY = 0x0040
  149. };
  150. // Description:
  151. // Configuration specification, depends on user selected machine specification.
  152. enum ESystemConfigSpec
  153. {
  154. CONFIG_AUTO_SPEC = 0,
  155. CONFIG_LOW_SPEC = 1,
  156. CONFIG_MEDIUM_SPEC = 2,
  157. CONFIG_HIGH_SPEC = 3,
  158. CONFIG_VERYHIGH_SPEC = 4,
  159. END_CONFIG_SPEC_ENUM, // MUST BE LAST VALUE. USED FOR ERROR CHECKING.
  160. };
  161. // Description:
  162. // Configuration platform. Autodetected at start, can be modified through the editor.
  163. enum ESystemConfigPlatform
  164. {
  165. CONFIG_INVALID_PLATFORM = 0,
  166. CONFIG_PC = 1,
  167. CONFIG_OSX_GL = 2,
  168. CONFIG_OSX_METAL = 3,
  169. CONFIG_ANDROID = 4,
  170. CONFIG_IOS = 5,
  171. CONFIG_PROVO = 7,
  172. CONFIG_SALEM = 8,
  173. CONFIG_JASPER = 9,
  174. END_CONFIG_PLATFORM_ENUM, // MUST BE LAST VALUE. USED FOR ERROR CHECKING.
  175. };
  176. enum ESubsystem
  177. {
  178. ESubsys_3DEngine = 0,
  179. ESubsys_AI = 1,
  180. ESubsys_Physics = 2,
  181. ESubsys_Renderer = 3,
  182. ESubsys_Script = 4
  183. };
  184. // Summary:
  185. // Collates cycles taken per update.
  186. struct sUpdateTimes
  187. {
  188. uint32 PhysYields;
  189. uint64 SysUpdateTime;
  190. uint64 PhysStepTime;
  191. uint64 RenderTime;
  192. //extended yimes info
  193. uint64 physWaitTime;
  194. uint64 streamingWaitTime;
  195. uint64 animationWaitTime;
  196. };
  197. enum ESystemGlobalState
  198. {
  199. ESYSTEM_GLOBAL_STATE_UNKNOWN,
  200. ESYSTEM_GLOBAL_STATE_INIT,
  201. ESYSTEM_GLOBAL_STATE_RUNNING,
  202. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PREPARE,
  203. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START,
  204. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_MATERIALS,
  205. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_OBJECTS,
  206. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_STATIC_WORLD,
  207. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PRECACHE,
  208. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_TEXTURES,
  209. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_END,
  210. ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_COMPLETE
  211. };
  212. // Summary:
  213. // System wide events.
  214. enum ESystemEvent
  215. {
  216. // Description:
  217. // Seeds all random number generators to the same seed number, WParam will hold seed value.
  218. //##@{
  219. ESYSTEM_EVENT_RANDOM_SEED = 1,
  220. ESYSTEM_EVENT_RANDOM_ENABLE,
  221. ESYSTEM_EVENT_RANDOM_DISABLE,
  222. //##@}
  223. // Description:
  224. // Changes to main window focus.
  225. // wparam is not 0 is focused, 0 if not focused
  226. ESYSTEM_EVENT_CHANGE_FOCUS = 10,
  227. // Description:
  228. // Moves of the main window.
  229. // wparam=x, lparam=y
  230. ESYSTEM_EVENT_MOVE = 11,
  231. // Description:
  232. // Resizes of the main window.
  233. // wparam=width, lparam=height
  234. ESYSTEM_EVENT_RESIZE = 12,
  235. // Description:
  236. // Activation of the main window.
  237. // wparam=1/0, 1=active 0=inactive
  238. ESYSTEM_EVENT_ACTIVATE = 13,
  239. // Description:
  240. // Main window position changed.
  241. ESYSTEM_EVENT_POS_CHANGED = 14,
  242. // Description:
  243. // Main window style changed.
  244. ESYSTEM_EVENT_STYLE_CHANGED = 15,
  245. // Description:
  246. // Sent before the loading movie is begun
  247. ESYSTEM_EVENT_LEVEL_LOAD_START_PRELOADINGSCREEN,
  248. // Description:
  249. // Sent before the loading last save
  250. ESYSTEM_EVENT_LEVEL_LOAD_RESUME_GAME,
  251. // Description:
  252. // Sent before starting level, before game rules initialization and before ESYSTEM_EVENT_LEVEL_LOAD_START event
  253. // Used mostly for level loading profiling
  254. ESYSTEM_EVENT_LEVEL_LOAD_PREPARE,
  255. // Description:
  256. // Sent to start the active loading screen rendering.
  257. ESYSTEM_EVENT_LEVEL_LOAD_START_LOADINGSCREEN,
  258. // Description:
  259. // Sent when loading screen is active
  260. ESYSTEM_EVENT_LEVEL_LOAD_LOADINGSCREEN_ACTIVE,
  261. // Description:
  262. // Sent before starting loading a new level.
  263. // Used for a more efficient resource management.
  264. ESYSTEM_EVENT_LEVEL_LOAD_START,
  265. // Description:
  266. // Sent after loading a level finished.
  267. // Used for a more efficient resource management.
  268. ESYSTEM_EVENT_LEVEL_LOAD_END,
  269. // Description:
  270. // Sent after trying to load a level failed.
  271. // Used for resetting the front end.
  272. ESYSTEM_EVENT_LEVEL_LOAD_ERROR,
  273. // Description:
  274. // Sent in case the level was requested to load, but it's not ready
  275. // Used in streaming install scenario for notifying the front end.
  276. ESYSTEM_EVENT_LEVEL_NOT_READY,
  277. // Description:
  278. // Sent after precaching of the streaming system has been done
  279. ESYSTEM_EVENT_LEVEL_PRECACHE_START,
  280. // Description:
  281. // Sent before object/texture precache stream requests are submitted
  282. ESYSTEM_EVENT_LEVEL_PRECACHE_FIRST_FRAME,
  283. // Description:
  284. // Sent when level loading is completely finished with no more onscreen
  285. // movie or info rendering, and when actual gameplay can start
  286. ESYSTEM_EVENT_LEVEL_GAMEPLAY_START,
  287. // Level is unloading.
  288. ESYSTEM_EVENT_LEVEL_UNLOAD,
  289. // Summary:
  290. // Sent after level have been unloaded. For cleanup code.
  291. ESYSTEM_EVENT_LEVEL_POST_UNLOAD,
  292. // Summary:
  293. // Called when the game framework has been initialized.
  294. ESYSTEM_EVENT_GAME_POST_INIT,
  295. // Summary:
  296. // Called when the game framework has been initialized, not loading should happen in this event.
  297. ESYSTEM_EVENT_GAME_POST_INIT_DONE,
  298. // Summary:
  299. // Sent when the system is doing a full shutdown.
  300. ESYSTEM_EVENT_FULL_SHUTDOWN,
  301. // Summary:
  302. // Sent when the system is doing a fast shutdown.
  303. ESYSTEM_EVENT_FAST_SHUTDOWN,
  304. // Summary:
  305. // When keyboard layout changed.
  306. ESYSTEM_EVENT_LANGUAGE_CHANGE,
  307. // Description:
  308. // Toggled fullscreen.
  309. // wparam is 1 means we switched to fullscreen, 0 if for windowed
  310. ESYSTEM_EVENT_TOGGLE_FULLSCREEN,
  311. ESYSTEM_EVENT_SHARE_SHADER_COMBINATIONS,
  312. // Summary:
  313. // Start 3D post rendering
  314. ESYSTEM_EVENT_3D_POST_RENDERING_START,
  315. // Summary:
  316. // End 3D post rendering
  317. ESYSTEM_EVENT_3D_POST_RENDERING_END,
  318. // Summary:
  319. // Called before switching to level memory heap
  320. ESYSTEM_EVENT_SWITCHING_TO_LEVEL_HEAP_DEPRECATED,
  321. // Summary:
  322. // Called after switching to level memory heap
  323. ESYSTEM_EVENT_SWITCHED_TO_LEVEL_HEAP_DEPRECATED,
  324. // Summary:
  325. // Called before switching to global memory heap
  326. ESYSTEM_EVENT_SWITCHING_TO_GLOBAL_HEAP_DEPRECATED,
  327. // Summary:
  328. // Called after switching to global memory heap
  329. ESYSTEM_EVENT_SWITCHED_TO_GLOBAL_HEAP_DEPRECATED,
  330. // Description:
  331. // Sent after precaching of the streaming system has been done
  332. ESYSTEM_EVENT_LEVEL_PRECACHE_END,
  333. // Description:
  334. // Sent when game mode switch begins
  335. ESYSTEM_EVENT_GAME_MODE_SWITCH_START,
  336. // Description:
  337. // Sent when game mode switch ends
  338. ESYSTEM_EVENT_GAME_MODE_SWITCH_END,
  339. // Description:
  340. // Video notifications
  341. // wparam=[0/1/2/3] : [stop/play/pause/resume]
  342. ESYSTEM_EVENT_VIDEO,
  343. // Description:
  344. // Sent if the game is paused
  345. ESYSTEM_EVENT_GAME_PAUSED,
  346. // Description:
  347. // Sent if the game is resumed
  348. ESYSTEM_EVENT_GAME_RESUMED,
  349. // Description:
  350. // Sent when time of day is set
  351. ESYSTEM_EVENT_TIME_OF_DAY_SET,
  352. // Description:
  353. // Sent once the Editor finished initialization.
  354. ESYSTEM_EVENT_EDITOR_ON_INIT,
  355. // Description:
  356. // Sent when frontend is initialised
  357. ESYSTEM_EVENT_FRONTEND_INITIALISED,
  358. // Description:
  359. // Sent once the Editor switches between in-game and editing mode.
  360. ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED,
  361. // Description:
  362. // Sent once the Editor switches simulation mode (AI/Physics).
  363. ESYSTEM_EVENT_EDITOR_SIMULATION_MODE_CHANGED,
  364. // Description:
  365. // Sent when frontend is reloaded
  366. ESYSTEM_EVENT_FRONTEND_RELOADED,
  367. #if defined(AZ_RESTRICTED_PLATFORM)
  368. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_1
  369. #include AZ_RESTRICTED_FILE(ISystem_h)
  370. #endif
  371. #if defined(AZ_RESTRICTED_PLATFORM)
  372. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_2
  373. #include AZ_RESTRICTED_FILE(ISystem_h)
  374. #endif
  375. ESYSTEM_EVENT_STREAMING_INSTALL_ERROR,
  376. // Description:
  377. // Sent when the online services are initialized.
  378. ESYSTEM_EVENT_ONLINE_SERVICES_INITIALISED,
  379. // Description:
  380. // Sent when a new audio implementation is loaded
  381. ESYSTEM_EVENT_AUDIO_IMPLEMENTATION_LOADED,
  382. // Description:
  383. // Sent when simulation mode switch begins
  384. ESYSTEM_EVENT_EDITOR_SIMULATION_MODE_SWITCH_START,
  385. // Description:
  386. // Sent when simluation mode switch ends
  387. ESYSTEM_EVENT_EDITOR_SIMULATION_MODE_SWITCH_END,
  388. ESYSTEM_EVENT_USER = 0x1000,
  389. ESYSTEM_BEAM_PLAYER_TO_CAMERA_POS
  390. };
  391. // Description:
  392. // User defined callback, which can be passed to ISystem.
  393. struct ISystemUserCallback
  394. {
  395. // <interfuscator:shuffle>
  396. virtual ~ISystemUserCallback() {}
  397. // Description:
  398. // This method is called at the earliest point the ISystem pointer can be used
  399. // the log might not be yet there.
  400. virtual void OnSystemConnect([[maybe_unused]] ISystem* pSystem) {}
  401. // Summary:
  402. // Signals to User that engine error occurred.
  403. // Return Value:
  404. // True to Halt execution or false to ignore this error
  405. virtual bool OnError(const char* szErrorString) = 0;
  406. // Notes:
  407. // If working in Editor environment notify user that engine want to Save current document.
  408. // This happens if critical error have occurred and engine gives a user way to save data and not lose it
  409. // due to crash.
  410. virtual bool OnSaveDocument() = 0;
  411. // Notes:
  412. // If working in Editor environment and a critical error occurs notify the user to backup
  413. // the current document to prevent data loss due to crash.
  414. virtual bool OnBackupDocument() = 0;
  415. // Description:
  416. // Notifies user that system wants to switch out of current process.
  417. // Example:
  418. // Called when pressing ESC in game mode to go to Menu.
  419. virtual void OnProcessSwitch() = 0;
  420. // Description:
  421. // Notifies user, usually editor, about initialization progress in system.
  422. virtual void OnInitProgress(const char* sProgressMsg) = 0;
  423. // Description:
  424. // Initialization callback. This is called early in CSystem::Init(), before
  425. // any of the other callback methods is called.
  426. // See also:
  427. // CSystem::Init()
  428. virtual void OnInit(ISystem*) { }
  429. // Summary:
  430. // Shutdown callback.
  431. virtual void OnShutdown() { }
  432. // Summary:
  433. // Quit callback.
  434. // See also:
  435. // CSystem::Quit()
  436. virtual void OnQuit() { }
  437. // Description:
  438. // Notify user of an update iteration. Called in the update loop.
  439. virtual void OnUpdate() { }
  440. // Description:
  441. // Show message by provider.
  442. virtual int ShowMessage(const char* text, const char* caption, unsigned int uType) { return CryMessageBox(text, caption, uType); }
  443. // Description:
  444. // Collects the memory information in the user program/application.
  445. virtual void GetMemoryUsage(ICrySizer* pSizer) = 0;
  446. // </interfuscator:shuffle>
  447. // Post console load, for cvar setting
  448. virtual void OnConsoleCreated([[maybe_unused]] ::IConsole* pConsole) {}
  449. };
  450. // Description:
  451. // Interface used for getting notified when a system event occurs.
  452. struct ISystemEventListener
  453. {
  454. // <interfuscator:shuffle>
  455. virtual ~ISystemEventListener() {}
  456. virtual void OnSystemEventAnyThread([[maybe_unused]] ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam) {}
  457. virtual void OnSystemEvent([[maybe_unused]] ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam) { }
  458. // </interfuscator:shuffle>
  459. };
  460. // Description:
  461. // Structure used for getting notified when a system event occurs.
  462. struct ISystemEventDispatcher
  463. {
  464. // <interfuscator:shuffle>
  465. virtual ~ISystemEventDispatcher() {}
  466. virtual bool RegisterListener(ISystemEventListener* pListener) = 0;
  467. virtual bool RemoveListener(ISystemEventListener* pListener) = 0;
  468. virtual void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) = 0;
  469. virtual void Update() = 0;
  470. //virtual void OnLocaleChange() = 0;
  471. // </interfuscator:shuffle>
  472. };
  473. struct IErrorObserver
  474. {
  475. // <interfuscator:shuffle>
  476. virtual ~IErrorObserver() {}
  477. virtual void OnAssert(const char* condition, const char* message, const char* fileName, unsigned int fileLineNumber) = 0;
  478. virtual void OnFatalError(const char* message) = 0;
  479. // </interfuscator:shuffle>
  480. };
  481. enum ESystemProtectedFunctions
  482. {
  483. eProtectedFunc_Save = 0,
  484. eProtectedFunc_Load = 1,
  485. eProtectedFuncsLast = 10,
  486. };
  487. struct SCvarsDefault
  488. {
  489. SCvarsDefault()
  490. {
  491. sz_r_DriverDef = NULL;
  492. }
  493. const char* sz_r_DriverDef;
  494. };
  495. #if defined(CVARS_WHITELIST)
  496. struct ICVarsWhitelist
  497. {
  498. // <interfuscator:shuffle>
  499. virtual ~ICVarsWhitelist() {};
  500. virtual bool IsWhiteListed(const string& command, bool silent) = 0;
  501. // </interfuscator:shuffle>
  502. };
  503. #endif // defined(CVARS_WHITELIST)
  504. #if defined(AZ_RESTRICTED_PLATFORM)
  505. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_3
  506. #include AZ_RESTRICTED_FILE(ISystem_h)
  507. #endif
  508. namespace AZ
  509. {
  510. namespace Internal
  511. {
  512. class EnvironmentInterface;
  513. } // namespace Internal
  514. } // namespace AZ
  515. typedef AZ::Internal::EnvironmentInterface SharedEnvironmentInstance;
  516. // Description:
  517. // Structure passed to Init method of ISystem interface.
  518. struct SSystemInitParams
  519. {
  520. void* hInstance; //
  521. void* hWnd; //
  522. void* hWndForInputSystem; // the HWND for the input devices, distinct from the hWnd, which the rendering system overrides anyways
  523. bool remoteResourceCompiler;
  524. ILog* pLog; // You can specify your own ILog to be used by System.
  525. ILogCallback* pLogCallback; // You can specify your own ILogCallback to be added on log creation (used by Editor).
  526. ISystemUserCallback* pUserCallback;
  527. const char* sLogFileName; // File name to use for log.
  528. bool autoBackupLogs; // if true, logs will be automatically backed up each startup
  529. IValidator* pValidator; // You can specify different validator object to use by System.
  530. IOutputPrintSink* pPrintSync; // Print Sync which can be used to catch all output from engine
  531. char szSystemCmdLine[2048]; // Command line.
  532. bool bEditor; // When running in Editor mode.
  533. bool bPreview; // When running in Preview mode (Minimal initialization).
  534. bool bTestMode; // When running in Automated testing mode.
  535. bool bDedicatedServer; // When running a dedicated server.
  536. bool bExecuteCommandLine; // can be switched of to suppress the feature or do it later during the initialization.
  537. bool bSkipFont; // Don't load CryFont.dll
  538. bool bSkipRenderer; // Don't load Renderer
  539. bool bSkipConsole; // Don't create console
  540. bool bSkipNetwork; // Don't create Network
  541. bool bSkipWebsocketServer; // Don't create the WebSocket server
  542. bool bMinimal; // Don't load banks
  543. bool bTesting; // CryUnit
  544. bool bNoRandom; //use fixed generator init/seed
  545. bool bShaderCacheGen; // When running in shadercache gen mode
  546. bool bUnattendedMode; // When running as part of a build on build-machines: Prevent popping up of any dialog
  547. bool bSkipMovie; // Don't load movie
  548. bool bSkipAnimation; // Don't load animation
  549. bool bToolMode; // System is running inside a tool. Will not create USER directory or anything else that the game needs to do
  550. bool bSkipPhysics; // Don't initialize CryPhysics.
  551. ISystem* pSystem; // Pointer to existing ISystem interface, it will be reused if not NULL.
  552. typedef void* (*ProtectedFunction)(void* param1, void* param2);
  553. ProtectedFunction pProtectedFunctions[eProtectedFuncsLast]; // Protected functions.
  554. SCvarsDefault* pCvarsDefault; // to override the default value of some cvar
  555. #if defined(CVARS_WHITELIST)
  556. ICVarsWhitelist* pCVarsWhitelist; // CVars whitelist callback
  557. #endif // defined(CVARS_WHITELIST)
  558. SharedEnvironmentInstance* pSharedEnvironment;
  559. // Summary:
  560. // Initialization defaults.
  561. SSystemInitParams()
  562. {
  563. hInstance = NULL;
  564. hWnd = NULL;
  565. hWndForInputSystem = NULL;
  566. remoteResourceCompiler = false;
  567. pLog = NULL;
  568. pLogCallback = NULL;
  569. pUserCallback = NULL;
  570. #if defined(CVARS_WHITELIST)
  571. pCVarsWhitelist = NULL;
  572. #endif // defined(CVARS_WHITELIST)
  573. sLogFileName = NULL;
  574. autoBackupLogs = true;
  575. pValidator = NULL;
  576. pPrintSync = NULL;
  577. memset(szSystemCmdLine, 0, sizeof(szSystemCmdLine));
  578. bEditor = false;
  579. bPreview = false;
  580. bTestMode = false;
  581. bDedicatedServer = false;
  582. bExecuteCommandLine = true;
  583. bExecuteCommandLine = true;
  584. bSkipFont = false;
  585. bSkipRenderer = false;
  586. bSkipConsole = false;
  587. bSkipNetwork = false;
  588. #if defined(WIN32) || defined(WIN64)
  589. // create websocket server by default. bear in mind that USE_HTTP_WEBSOCKETS is not defined in release.
  590. bSkipWebsocketServer = false;
  591. #else
  592. // CTCPStreamSocket only seems to fully support Win32 and 64
  593. bSkipWebsocketServer = true;
  594. #endif
  595. bMinimal = false;
  596. bTesting = false;
  597. bNoRandom = false;
  598. bShaderCacheGen = false;
  599. bUnattendedMode = false;
  600. bSkipMovie = false;
  601. bSkipAnimation = false;
  602. bToolMode = false;
  603. bSkipPhysics = false;
  604. pSystem = NULL;
  605. memset(pProtectedFunctions, 0, sizeof(pProtectedFunctions));
  606. pCvarsDefault = NULL;
  607. pSharedEnvironment = nullptr;
  608. }
  609. };
  610. // Notes:
  611. // Can be used for LoadConfiguration().
  612. // See also:
  613. // LoadConfiguration()
  614. struct ILoadConfigurationEntrySink
  615. {
  616. // <interfuscator:shuffle>
  617. virtual ~ILoadConfigurationEntrySink() {}
  618. virtual void OnLoadConfigurationEntry(const char* szKey, const char* szValue, const char* szGroup) = 0;
  619. virtual void OnLoadConfigurationEntry_End() {}
  620. // </interfuscator:shuffle>
  621. };
  622. struct SPlatformInfo
  623. {
  624. unsigned int numCoresAvailableToProcess;
  625. unsigned int numLogicalProcessors;
  626. #if defined(WIN32) || defined(WIN64)
  627. enum EWinVersion
  628. {
  629. WinUndetected,
  630. Win2000,
  631. WinXP,
  632. WinSrv2003,
  633. WinVista,
  634. Win7,
  635. Win8,
  636. Win81,
  637. Win10
  638. };
  639. EWinVersion winVer;
  640. bool win64Bit;
  641. bool vistaKB940105Required;
  642. #endif
  643. };
  644. // Description:
  645. // Holds info about system update stats over perior of time (cvar-tweakable)
  646. struct SSystemUpdateStats
  647. {
  648. SSystemUpdateStats()
  649. : avgUpdateTime(0.0f)
  650. , minUpdateTime(0.0f)
  651. , maxUpdateTime(0.0f) {}
  652. float avgUpdateTime;
  653. float minUpdateTime;
  654. float maxUpdateTime;
  655. };
  656. // Description:
  657. // Global environment.
  658. // Contains pointers to all global often needed interfaces.
  659. // This is a faster way to get interface pointer then calling ISystem interface to retrieve one.
  660. // Notes:
  661. // Some pointers can be NULL, use with care.
  662. // See also:
  663. // ISystem
  664. struct SSystemGlobalEnvironment
  665. {
  666. I3DEngine* p3DEngine;
  667. AZ::IO::IArchive* pCryPak;
  668. AZ::IO::FileIOBase* pFileIO;
  669. IFileChangeMonitor* pFileChangeMonitor;
  670. IProfileLogSystem* pProfileLogSystem;
  671. IOpticsManager* pOpticsManager;
  672. ITimer* pTimer;
  673. ICryFont* pCryFont;
  674. ILocalMemoryUsage* pLocalMemoryUsage;
  675. ::IConsole* pConsole;
  676. ISystem* pSystem = nullptr;
  677. ILog* pLog;
  678. IMovieSystem* pMovieSystem;
  679. INameTable* pNameTable;
  680. IVisualLog* pVisualLog;
  681. IRenderer* pRenderer;
  682. IMaterialEffects* pMaterialEffects;
  683. ISoftCodeMgr* pSoftCodeMgr;
  684. IOverloadSceneManager* pOverloadSceneManager;
  685. IServiceNetwork* pServiceNetwork;
  686. IRemoteCommandManager* pRemoteCommandManager;
  687. ILyShine* pLyShine;
  688. IResourceCompilerHelper* pResourceCompilerHelper;
  689. SharedEnvironmentInstance* pSharedEnvironment;
  690. IThreadManager* pThreadManager;
  691. #if defined(AZ_RESTRICTED_PLATFORM)
  692. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_4
  693. #include AZ_RESTRICTED_FILE(ISystem_h)
  694. #endif
  695. ISystemScheduler* pSystemScheduler;
  696. threadID mMainThreadId; //The main thread ID is used in multiple systems so should be stored globally
  697. //////////////////////////////////////////////////////////////////////////
  698. uint32 nMainFrameID;
  699. //////////////////////////////////////////////////////////////////////////
  700. const char* szCmdLine; // Startup command line.
  701. //////////////////////////////////////////////////////////////////////////
  702. // Generic debug string which can be easily updated by any system and output by the debug handler
  703. enum
  704. {
  705. MAX_DEBUG_STRING_LENGTH = 128
  706. };
  707. char szDebugStatus[MAX_DEBUG_STRING_LENGTH];
  708. //////////////////////////////////////////////////////////////////////////
  709. // Used to tell if this is a server/multiplayer instance
  710. bool bServer;
  711. bool bMultiplayer;
  712. bool bHostMigrating;
  713. //////////////////////////////////////////////////////////////////////////
  714. //////////////////////////////////////////////////////////////////////////
  715. // Indicate Editor status.
  716. //////////////////////////////////////////////////////////////////////////
  717. //////////////////////////////////////////////////////////////////////////
  718. // Used by CRY_ASSERT
  719. bool bIgnoreAllAsserts;
  720. bool bNoAssertDialog;
  721. bool bTesting;
  722. //////////////////////////////////////////////////////////////////////////
  723. bool bNoRandomSeed;
  724. SPlatformInfo pi;
  725. // Protected functions.
  726. SSystemInitParams::ProtectedFunction pProtectedFunctions[eProtectedFuncsLast]; // Protected functions.
  727. //////////////////////////////////////////////////////////////////////////
  728. // Flag to able to print out of memory conditon
  729. bool bIsOutOfMemory;
  730. bool bIsOutOfVideoMemory;
  731. bool bToolMode;
  732. int retCode = 0;
  733. ILINE const bool IsClient() const
  734. {
  735. #if defined(CONSOLE)
  736. return true;
  737. #else
  738. return bClient;
  739. #endif
  740. }
  741. ILINE const bool IsDedicated() const
  742. {
  743. #if defined(CONSOLE)
  744. return false;
  745. #else
  746. return bDedicated;
  747. #endif
  748. }
  749. #if !defined(CONSOLE)
  750. ILINE void SetIsEditor(bool isEditor)
  751. {
  752. bEditor = isEditor;
  753. }
  754. ILINE void SetIsEditorGameMode(bool isEditorGameMode)
  755. {
  756. bEditorGameMode = isEditorGameMode;
  757. }
  758. ILINE void SetIsEditorSimulationMode(bool isEditorSimulationMode)
  759. {
  760. bEditorSimulationMode = isEditorSimulationMode;
  761. }
  762. ILINE void SetIsDedicated(bool isDedicated)
  763. {
  764. bDedicated = isDedicated;
  765. }
  766. ILINE void SetIsClient(bool isClient)
  767. {
  768. bClient = isClient;
  769. }
  770. #endif
  771. //this way the compiler can strip out code for consoles
  772. ILINE const bool IsEditor() const
  773. {
  774. #if defined(CONSOLE)
  775. return false;
  776. #else
  777. return bEditor;
  778. #endif
  779. }
  780. ILINE const bool IsEditorGameMode() const
  781. {
  782. #if defined(CONSOLE)
  783. return false;
  784. #else
  785. return bEditorGameMode;
  786. #endif
  787. }
  788. ILINE const bool IsEditorSimulationMode() const
  789. {
  790. #if defined(CONSOLE)
  791. return false;
  792. #else
  793. return bEditorSimulationMode;
  794. #endif
  795. }
  796. ILINE const bool IsEditing() const
  797. {
  798. #if defined(CONSOLE)
  799. return false;
  800. #else
  801. return bEditor && !bEditorGameMode;
  802. #endif
  803. }
  804. ILINE const bool IsFMVPlaying() const
  805. {
  806. return m_isFMVPlaying;
  807. }
  808. ILINE void SetFMVIsPlaying(const bool isPlaying)
  809. {
  810. m_isFMVPlaying = isPlaying;
  811. }
  812. ILINE const bool IsCutscenePlaying() const
  813. {
  814. return m_isCutscenePlaying;
  815. }
  816. ILINE void SetCutsceneIsPlaying(const bool isPlaying)
  817. {
  818. m_isCutscenePlaying = isPlaying;
  819. }
  820. ILINE bool IsInToolMode() const
  821. {
  822. return bToolMode;
  823. }
  824. ILINE void SetToolMode(bool bNewToolMode)
  825. {
  826. bToolMode = bNewToolMode;
  827. }
  828. ILINE void SetDynamicMergedMeshGenerationEnabled(bool mmgenEnable)
  829. {
  830. m_bDynamicMergedMeshGenerationEnabled = mmgenEnable;
  831. }
  832. ILINE const bool IsDynamicMergedMeshGenerationEnabled() const
  833. {
  834. return m_bDynamicMergedMeshGenerationEnabled;
  835. }
  836. #if !defined(CONSOLE)
  837. private:
  838. bool bClient;
  839. bool bEditor; // Engine is running under editor.
  840. bool bEditorGameMode; // Engine is in editor game mode.
  841. bool bEditorSimulationMode; // Engine is in editor simulation mode.
  842. bool bDedicated; // Engine is in dedicated
  843. #endif
  844. bool m_isFMVPlaying;
  845. bool m_isCutscenePlaying;
  846. bool m_bDynamicMergedMeshGenerationEnabled;
  847. public:
  848. SSystemGlobalEnvironment()
  849. : pSystemScheduler(nullptr)
  850. , szCmdLine("")
  851. , bToolMode(false)
  852. , m_bDynamicMergedMeshGenerationEnabled(false)
  853. {
  854. };
  855. };
  856. // NOTE Nov 25, 2008: <pvl> the ISystem interface that follows has a member function
  857. // called 'GetUserName'. If we don't #undef'ine the same-named Win32 symbol here
  858. // ISystem wouldn't even compile.
  859. // TODO Nov 25, 2008: <pvl> there might be a better place for this?
  860. #ifdef GetUserName
  861. #undef GetUserName
  862. #endif
  863. struct IProfilingSystem
  864. {
  865. // <interfuscator:shuffle>
  866. virtual ~IProfilingSystem() {}
  867. //////////////////////////////////////////////////////////////////////////
  868. // VTune Profiling interface.
  869. // Summary:
  870. // Resumes vtune data collection.
  871. virtual void VTuneResume() = 0;
  872. // Summary:
  873. // Pauses vtune data collection.
  874. virtual void VTunePause() = 0;
  875. //////////////////////////////////////////////////////////////////////////
  876. // </interfuscator:shuffle>
  877. };
  878. ////////////////////////////////////////////////////////////////////////////////////////////////
  879. // Description:
  880. // Main Engine Interface.
  881. // Initialize and dispatch all engine's subsystems.
  882. struct ISystem
  883. {
  884. struct ILoadingProgressListener
  885. {
  886. // <interfuscator:shuffle>
  887. virtual ~ILoadingProgressListener() {}
  888. virtual void OnLoadingProgress(int steps) = 0;
  889. // </interfuscator:shuffle>
  890. };
  891. #ifndef _RELEASE
  892. enum LevelLoadOrigin
  893. {
  894. eLLO_Unknown,
  895. eLLO_NewLevel,
  896. eLLO_Level2Level,
  897. eLLO_Resumed,
  898. eLLO_MapCmd,
  899. };
  900. struct ICheckpointData
  901. {
  902. int m_totalLoads;
  903. LevelLoadOrigin m_loadOrigin;
  904. };
  905. #endif
  906. // <interfuscator:shuffle>
  907. virtual ~ISystem() {}
  908. // Summary:
  909. // Releases ISystem.
  910. virtual void Release() = 0;
  911. virtual ILoadConfigurationEntrySink* GetCVarsWhiteListConfigSink() const = 0; // will return NULL if no whitelisting
  912. // Summary:
  913. // Returns pointer to the global environment structure.
  914. virtual SSystemGlobalEnvironment* GetGlobalEnvironment() = 0;
  915. // Summary:
  916. // Updates all subsystems (including the ScriptSink() )
  917. // Arguments:
  918. // flags - One or more flags from ESystemUpdateFlags structure.
  919. // nPauseMode - 0=normal(no pause), 1=menu/pause, 2=cutscene
  920. virtual bool UpdatePreTickBus(int updateFlags = 0, int nPauseMode = 0) = 0;
  921. // Summary:
  922. // Updates all subsystems (including the ScriptSink() )
  923. // Arguments:
  924. // flags - One or more flags from ESystemUpdateFlags structure.
  925. // nPauseMode - 0=normal(no pause), 1=menu/pause, 2=cutscene
  926. virtual bool UpdatePostTickBus(int updateFlags = 0, int nPauseMode = 0) = 0;
  927. // Summary:
  928. // Updates only require components during loading
  929. virtual bool UpdateLoadtime() = 0;
  930. // Summary:
  931. // Optimisation: do part of the update while waiting for occlusion queries to complete
  932. virtual void DoWorkDuringOcclusionChecks() = 0;
  933. virtual bool NeedDoWorkDuringOcclusionChecks() = 0;
  934. // Summary:
  935. // Renders subsystems.
  936. virtual void Render() = 0;
  937. // Summary:
  938. // Begins rendering frame.
  939. virtual void RenderBegin() = 0;
  940. // Summary:
  941. // Ends rendering frame and swap back buffer.
  942. virtual void RenderEnd(bool bRenderStats = true, bool bMainWindow = true) = 0;
  943. //! Update screen and call some important tick functions during loading.
  944. virtual void SynchronousLoadingTick(const char* pFunc, int line) = 0;
  945. // Description:
  946. // Renders the statistics; this is called from RenderEnd, but if the
  947. // Host application (Editor) doesn't employ the Render cycle in ISystem,
  948. // it may call this method to render the essential statistics.
  949. virtual void RenderStatistics() = 0;
  950. // Summary:
  951. // Returns the current used memory.
  952. virtual uint32 GetUsedMemory() = 0;
  953. // Summary:
  954. // Retrieve the name of the user currently logged in to the computer.
  955. virtual const char* GetUserName() = 0;
  956. // Summary:
  957. // Gets current supported CPU features flags. (CPUF_SSE, CPUF_SSE2, CPUF_3DNOW, CPUF_MMX)
  958. virtual int GetCPUFlags() = 0;
  959. // Summary:
  960. // Gets number of CPUs
  961. virtual int GetLogicalCPUCount() = 0;
  962. // Summary:
  963. // Return the rendering driver name. GL or Metal
  964. virtual const char* GetRenderingDriverName() const = 0;
  965. // Summary:
  966. // Dumps the memory usage statistics to the logging default MB. (can be KB)
  967. virtual void DumpMemoryUsageStatistics(bool bUseKB = false) = 0;
  968. // Summary:
  969. // Quits the application.
  970. virtual void Quit() = 0;
  971. // Summary:
  972. // Tells the system if it is relaunching or not.
  973. virtual void Relaunch(bool bRelaunch) = 0;
  974. // Summary:
  975. // Returns true if the application is in the shutdown phase.
  976. virtual bool IsQuitting() const = 0;
  977. // Summary:
  978. // Returns true if the application was initialized to generate the shader cache.
  979. virtual bool IsShaderCacheGenMode() const = 0;
  980. // Summary:
  981. // Tells the system in which way we are using the serialization system.
  982. virtual void SerializingFile(int mode) = 0;
  983. virtual int IsSerializingFile() const = 0;
  984. virtual bool IsRelaunch() const = 0;
  985. // Summary:
  986. // Displays an error message to display info for certain time
  987. // Arguments:
  988. // acMessage - Message to show
  989. // fTime - Amount of seconds to show onscreen
  990. virtual void DisplayErrorMessage(const char* acMessage, float fTime, const float* pfColor = 0, bool bHardError = true) = 0;
  991. // Description:
  992. // Displays error message.
  993. // Logs it to console and file and error message box then terminates execution.
  994. virtual void FatalError(const char* sFormat, ...) PRINTF_PARAMS(2, 3) = 0;
  995. // Description:
  996. // Reports a bug using the crash handler.
  997. // Logs an error to the console and launches the crash handler, then continues execution.
  998. virtual void ReportBug(const char* sFormat, ...) PRINTF_PARAMS(2, 3) = 0;
  999. // Description:
  1000. // Report warning to current Validator object.
  1001. // Doesn't terminate the execution.
  1002. //##@{
  1003. virtual void WarningV(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, va_list args) = 0;
  1004. virtual void Warning(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, ...) = 0;
  1005. //##@}
  1006. // Description:
  1007. // Report message by provider or by using CryMessageBox.
  1008. // Doesn't terminate the execution.
  1009. virtual int ShowMessage(const char* text, const char* caption, unsigned int uType) = 0;
  1010. // Summary:
  1011. // Compare specified verbosity level to the one currently set.
  1012. virtual bool CheckLogVerbosity(int verbosity) = 0;
  1013. // return the related subsystem interface
  1014. //
  1015. virtual IZLibCompressor* GetIZLibCompressor() = 0;
  1016. virtual IZLibDecompressor* GetIZLibDecompressor() = 0;
  1017. virtual ILZ4Decompressor* GetLZ4Decompressor() = 0;
  1018. virtual IZStdDecompressor* GetZStdDecompressor() = 0;
  1019. virtual ICryPerfHUD* GetPerfHUD() = 0;
  1020. virtual INotificationNetwork* GetINotificationNetwork() = 0;
  1021. virtual IViewSystem* GetIViewSystem() = 0;
  1022. virtual ILevelSystem* GetILevelSystem() = 0;
  1023. virtual INameTable* GetINameTable() = 0;
  1024. virtual IValidator* GetIValidator() = 0;
  1025. virtual IStreamEngine* GetStreamEngine() = 0;
  1026. virtual ICmdLine* GetICmdLine() = 0;
  1027. virtual ILog* GetILog() = 0;
  1028. virtual AZ::IO::IArchive* GetIPak() = 0;
  1029. virtual ICryFont* GetICryFont() = 0;
  1030. virtual IMemoryManager* GetIMemoryManager() = 0;
  1031. virtual IMovieSystem* GetIMovieSystem() = 0;
  1032. virtual I3DEngine* GetI3DEngine() = 0;
  1033. virtual ::IConsole* GetIConsole() = 0;
  1034. virtual IRemoteConsole* GetIRemoteConsole() = 0;
  1035. // Returns:
  1036. // Can be NULL, because it only exists when running through the editor, not in pure game mode.
  1037. virtual IResourceManager* GetIResourceManager() = 0;
  1038. virtual IThreadTaskManager* GetIThreadTaskManager() = 0;
  1039. virtual IProfilingSystem* GetIProfilingSystem() = 0;
  1040. virtual ISystemEventDispatcher* GetISystemEventDispatcher() = 0;
  1041. virtual IVisualLog* GetIVisualLog() = 0;
  1042. virtual IFileChangeMonitor* GetIFileChangeMonitor() = 0;
  1043. virtual WIN_HWND GetHWND() = 0;
  1044. virtual IRenderer* GetIRenderer() = 0;
  1045. virtual ITimer* GetITimer() = 0;
  1046. virtual IThreadManager* GetIThreadManager() = 0;
  1047. //irtual IThreadManager* GetIThreadManager() = 0;
  1048. virtual void SetLoadingProgressListener(ILoadingProgressListener* pListener) = 0;
  1049. virtual ISystem::ILoadingProgressListener* GetLoadingProgressListener() const = 0;
  1050. // Summary:
  1051. // Game is created after System init, so has to be set explicitly.
  1052. virtual void SetIMaterialEffects(IMaterialEffects* pMaterialEffects) = 0;
  1053. virtual void SetIOpticsManager(IOpticsManager* pOpticsManager) = 0;
  1054. virtual void SetIFileChangeMonitor(IFileChangeMonitor* pFileChangeMonitor) = 0;
  1055. virtual void SetIVisualLog(IVisualLog* pVisualLog) = 0;
  1056. //virtual const char *GetGamePath()=0;
  1057. virtual void DebugStats(bool checkpoint, bool leaks) = 0;
  1058. virtual void DumpWinHeaps() = 0;
  1059. virtual int DumpMMStats(bool log) = 0;
  1060. // Arguments:
  1061. // bValue - Set to true when running on a cheat protected server or a client that is connected to it (not used in singleplayer).
  1062. virtual void SetForceNonDevMode(const bool bValue) = 0;
  1063. // Return Value:
  1064. // True when running on a cheat protected server or a client that is connected to it (not used in singleplayer).
  1065. virtual bool GetForceNonDevMode() const = 0;
  1066. virtual bool WasInDevMode() const = 0;
  1067. virtual bool IsDevMode() const = 0;
  1068. virtual bool IsMODValid(const char* szMODName) const = 0;
  1069. virtual bool IsMinimalMode() const = 0;
  1070. //////////////////////////////////////////////////////////////////////////
  1071. //////////////////////////////////////////////////////////////////////////
  1072. // IXmlNode interface.
  1073. //////////////////////////////////////////////////////////////////////////
  1074. // Summary:
  1075. // Creates new xml node.
  1076. virtual XmlNodeRef CreateXmlNode(const char* sNodeName = "", bool bReuseStrings = false, bool bIsProcessingInstruction = false) = 0;
  1077. // Summary:
  1078. // Loads xml from memory buffer, returns 0 if load failed.
  1079. virtual XmlNodeRef LoadXmlFromBuffer(const char* buffer, size_t size, bool bReuseStrings = false, bool bSuppressWarnings = false) = 0;
  1080. // Summary:
  1081. // Loads xml file, returns 0 if load failed.
  1082. virtual XmlNodeRef LoadXmlFromFile(const char* sFilename, bool bReuseStrings = false) = 0;
  1083. // Summary:
  1084. // Retrieves access to XML utilities interface.
  1085. virtual IXmlUtils* GetXmlUtils() = 0;
  1086. // Summary:
  1087. // Interface to access different implementations of Serialization::IArchive in a centralized way.
  1088. virtual Serialization::IArchiveHost* GetArchiveHost() const = 0;
  1089. virtual void SetViewCamera(CCamera& Camera) = 0;
  1090. virtual CCamera& GetViewCamera() = 0;
  1091. // Description:
  1092. // When ignore update sets to true, system will ignore and updates and render calls.
  1093. virtual void IgnoreUpdates(bool bIgnore) = 0;
  1094. // Summary:
  1095. // Sets the active process
  1096. // Arguments:
  1097. // process - A pointer to a class that implement the IProcess interface.
  1098. virtual void SetIProcess(IProcess* process) = 0;
  1099. // Summary:
  1100. // Gets the active process.
  1101. // Return Value:
  1102. // A pointer to the current active process.
  1103. virtual IProcess* GetIProcess() = 0;
  1104. // Return Value:
  1105. // True if system running in Test mode.
  1106. virtual bool IsTestMode() const = 0;
  1107. //////////////////////////////////////////////////////////////////////////
  1108. // File version.
  1109. //////////////////////////////////////////////////////////////////////////
  1110. // Summary:
  1111. // Gets file version.
  1112. virtual const SFileVersion& GetFileVersion() = 0;
  1113. // Summary:
  1114. // Gets product version.
  1115. virtual const SFileVersion& GetProductVersion() = 0;
  1116. // Summary:
  1117. // Gets build version.
  1118. virtual const SFileVersion& GetBuildVersion() = 0;
  1119. // Summary:
  1120. // Data compression
  1121. //##@{
  1122. virtual bool CompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize, int level = 3) = 0;
  1123. virtual bool DecompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize) = 0;
  1124. //##@}
  1125. //////////////////////////////////////////////////////////////////////////
  1126. // Configuration.
  1127. //////////////////////////////////////////////////////////////////////////
  1128. // Summary:
  1129. // Loads configurations from CVarGroup directory recursively
  1130. // If m_GraphicsSettingsMap is defined (in Graphics Settings Dialog box), fills in mapping based on sys_spec_Full
  1131. // Arguments:
  1132. // sPath - e.g. "Game/Config/CVarGroups"
  1133. virtual void AddCVarGroupDirectory(const string& sPath) = 0;
  1134. // Summary:
  1135. // Saves system configuration.
  1136. virtual void SaveConfiguration() = 0;
  1137. // Summary:
  1138. // Loads system configuration
  1139. // Arguments:
  1140. // pCallback - 0 means normal LoadConfigVar behaviour is used
  1141. virtual void LoadConfiguration(const char* sFilename, ILoadConfigurationEntrySink* pSink = 0, bool warnIfMissing = true) = 0;
  1142. // Summary:
  1143. // Retrieves current configuration specification for client or server.
  1144. // Arguments:
  1145. // bClient - If true returns local client config spec, if false returns server config spec.
  1146. virtual ESystemConfigSpec GetConfigSpec(bool bClient = true) = 0;
  1147. virtual ESystemConfigSpec GetMaxConfigSpec() const = 0;
  1148. // Summary:
  1149. // Changes current configuration specification for client or server.
  1150. // Arguments:
  1151. // bClient - If true changes client config spec (sys_spec variable changed),
  1152. // if false changes only server config spec (as known on the client).
  1153. virtual void SetConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform, bool bClient) = 0;
  1154. //////////////////////////////////////////////////////////////////////////
  1155. // Summary:
  1156. // Retrieves current configuration platform
  1157. virtual ESystemConfigPlatform GetConfigPlatform() const = 0;
  1158. // Summary:
  1159. // Changes current configuration platform.
  1160. virtual void SetConfigPlatform(const ESystemConfigPlatform platform) = 0;
  1161. //////////////////////////////////////////////////////////////////////////
  1162. // Summary:
  1163. // Detects and set optimal spec.
  1164. virtual void AutoDetectSpec(const bool detectResolution) = 0;
  1165. // Summary:
  1166. // Thread management for subsystems
  1167. // Return Value:
  1168. // Non-0 if the state was indeed changed, 0 if already in that state.
  1169. virtual int SetThreadState(ESubsystem subsys, bool bActive) = 0;
  1170. // Summary:
  1171. // Creates and returns a usable object implementing ICrySizer interface.
  1172. virtual ICrySizer* CreateSizer() = 0;
  1173. // Summary:
  1174. // Query if system is now paused.
  1175. // Pause flag is set when calling system update with pause mode.
  1176. virtual bool IsPaused() const = 0;
  1177. // Summary:
  1178. // Retrieves localized strings manager interface.
  1179. virtual ILocalizationManager* GetLocalizationManager() = 0;
  1180. virtual ITextModeConsole* GetITextModeConsole() = 0;
  1181. // Summary:
  1182. // Retrieves the perlin noise singleton instance.
  1183. virtual CPNoise3* GetNoiseGen() = 0;
  1184. // Summary:
  1185. // Retrieves system update counter.
  1186. virtual uint64 GetUpdateCounter() = 0;
  1187. // Summary:
  1188. // Gets access to all registered factories.
  1189. virtual ICryFactoryRegistry* GetCryFactoryRegistry() const = 0;
  1190. //////////////////////////////////////////////////////////////////////////
  1191. // Error callback handling
  1192. // Summary:
  1193. // Registers listeners to CryAssert and error messages. (may not be called if asserts are disabled)
  1194. // Each pointer can be registered only once. (stl::push_back_unique)
  1195. // It will return false if the pointer is already registered. Returns true, otherwise.
  1196. virtual bool RegisterErrorObserver(IErrorObserver* errorObserver) = 0;
  1197. // Summary:
  1198. // Unregisters listeners to CryAssert and error messages.
  1199. // It will return false if the pointer is not registered. Otherwise, returns true.
  1200. virtual bool UnregisterErrorObserver(IErrorObserver* errorObserver) = 0;
  1201. // Summary:
  1202. // Called after the processing of the assert message box on some platforms.
  1203. // It will be called even when asserts are disabled by the console variables.
  1204. virtual void OnAssert(const char* condition, const char* message, const char* fileName, unsigned int fileLineNumber) = 0;
  1205. // Summary:
  1206. // Returns if the assert window from CryAssert is visible.
  1207. // OBS1: needed by the editor, as in some cases it can freeze if during an assert engine it will handle
  1208. // some events such as mouse movement in a CryPhysics assert.
  1209. // OBS2: it will always return false, if asserts are disabled or ignored.
  1210. virtual bool IsAssertDialogVisible() const = 0;
  1211. // Summary:
  1212. // Sets the AssertVisisble internal variable.
  1213. // Typically it should only be called by CryAssert.
  1214. virtual void SetAssertVisible(bool bAssertVisble) = 0;
  1215. //////////////////////////////////////////////////////////////////////////
  1216. // Summary:
  1217. // Enable/Disable drawing the console
  1218. virtual void SetConsoleDrawEnabled(bool enabled) = 0;
  1219. // Enable/Disable drawing the UI
  1220. virtual void SetUIDrawEnabled(bool enabled) = 0;
  1221. // Summary:
  1222. // Get the index of the currently running Crytek application. (0 = first instance, 1 = second instance, etc)
  1223. virtual int GetApplicationInstance() = 0;
  1224. // Summary:
  1225. // Get log index of the currently running lumberyard application. (0 = first instance, 1 = second instance, etc)
  1226. virtual int GetApplicationLogInstance(const char* logFilePath) = 0;
  1227. // Summary:
  1228. // Retrieves the current stats for systems to update the respective time taken
  1229. virtual sUpdateTimes& GetCurrentUpdateTimeStats() = 0;
  1230. // Summary:
  1231. // Retrieves the array of update times and the number of entries
  1232. virtual const sUpdateTimes* GetUpdateTimeStats(uint32&, uint32&) = 0;
  1233. // Summary:
  1234. // Clear all currently logged and drawn on screen error messages
  1235. virtual void ClearErrorMessages() = 0;
  1236. //////////////////////////////////////////////////////////////////////////
  1237. // For debugging use only!, query current C++ call stack.
  1238. //////////////////////////////////////////////////////////////////////////
  1239. // Notes:
  1240. // Pass nCount to indicate maximum number of functions to get.
  1241. // For debugging use only, query current C++ call stack.
  1242. // Description:
  1243. // Fills array of function pointers, nCount return number of functions.
  1244. virtual void debug_GetCallStack(const char** pFunctions, int& nCount) = 0;
  1245. // Summary:
  1246. // Logs current callstack.
  1247. // Notes:
  1248. // For debugging use only!, query current C++ call stack.
  1249. virtual void debug_LogCallStack(int nMaxFuncs = 32, int nFlags = 0) = 0;
  1250. // Description:
  1251. // Execute command line arguments.
  1252. // Should be after init game.
  1253. // Example:
  1254. // +g_gametype ASSAULT +map "testy"
  1255. virtual void ExecuteCommandLine(bool deferred=true) = 0;
  1256. // Description:
  1257. // GetSystemUpdate stats (all systems update without except console)
  1258. // very useful on dedicated server as we throttle it to fixed frequency
  1259. // returns zeroes if no updates happened yet
  1260. virtual void GetUpdateStats(SSystemUpdateStats& stats) = 0;
  1261. // Description:
  1262. // Useful to investigate memory fragmentation.
  1263. // Every time you call this from the console: #System.DumpMemoryCoverage()
  1264. // it adds a line to "MemoryCoverage.bmp" (generated the first time, there is a max line count).
  1265. virtual void DumpMemoryCoverage() = 0;
  1266. virtual ESystemGlobalState GetSystemGlobalState(void) = 0;
  1267. virtual void SetSystemGlobalState(const ESystemGlobalState systemGlobalState) = 0;
  1268. // Summary:
  1269. // Asynchronous memcpy
  1270. // Note sync variable will be incremented (in calling thread) before job starts
  1271. // and decremented when job finishes. Multiple async copies can therefore be
  1272. // tied to the same sync variable, therefore it's advised to wait for completion with
  1273. // while(*sync) (yield());
  1274. virtual void AsyncMemcpy(void* dst, const void* src, size_t size, int nFlags, volatile int* sync) = 0;
  1275. // </interfuscator:shuffle>
  1276. #if defined(CVARS_WHITELIST)
  1277. virtual ICVarsWhitelist* GetCVarsWhiteList() const = 0;
  1278. #endif // defined(CVARS_WHITELIST)
  1279. #ifndef _RELEASE
  1280. virtual void GetCheckpointData(ICheckpointData& data) = 0;
  1281. virtual void IncreaseCheckpointLoadCount() = 0;
  1282. virtual void SetLoadOrigin(LevelLoadOrigin origin) = 0;
  1283. #endif
  1284. #if !defined(_RELEASE)
  1285. virtual bool IsSavingResourceList() const = 0;
  1286. #endif
  1287. // Initializes Steam if needed and returns if it was successful
  1288. virtual bool SteamInit() = 0;
  1289. virtual const IImageHandler* GetImageHandler() const = 0;
  1290. // Summary:
  1291. // Loads a dynamic library, creates and initializes an instance of the module class
  1292. virtual bool InitializeEngineModule(const char* dllName, const char* moduleClassName, const SSystemInitParams& initParams) = 0;
  1293. // Summary:
  1294. // Unloads a dynamic library as well as the corresponding instance of the module class
  1295. virtual bool UnloadEngineModule(const char* dllName, const char* moduleClassName) = 0;
  1296. // Summary:
  1297. // Gets the root window message handler function
  1298. // The returned pointer is platform-specific:
  1299. // For Windows OS, the pointer is of type WNDPROC
  1300. virtual void* GetRootWindowMessageHandler() = 0;
  1301. // Summary:
  1302. // Register a IWindowMessageHandler that will be informed about window messages
  1303. // The delivered messages are platform-specific
  1304. virtual void RegisterWindowMessageHandler(IWindowMessageHandler* pHandler) = 0;
  1305. // Summary:
  1306. // Unregister an IWindowMessageHandler that was previously registered using RegisterWindowMessageHandler
  1307. virtual void UnregisterWindowMessageHandler(IWindowMessageHandler* pHandler) = 0;
  1308. // Create an instance of a Local File IO object (which reads directly off the local filesystem, instead of,
  1309. // for example, reading from the network or a pack or USB or such.
  1310. virtual std::shared_ptr<AZ::IO::FileIOBase> CreateLocalFileIO() = 0;
  1311. ////////////////////////////////////////////////////////////////////////////////////////////////
  1312. // EBus interface used to listen for cry system notifications
  1313. class CrySystemNotifications : public AZ::EBusTraits
  1314. {
  1315. public:
  1316. virtual ~CrySystemNotifications() = default;
  1317. // Override to be notified right before the call to ISystem::Render
  1318. virtual void OnPreRender() {}
  1319. // Override to be notified right after the call to ISystem::Render (but before RenderEnd)
  1320. virtual void OnPostRender() {}
  1321. };
  1322. using CrySystemNotificationBus = AZ::EBus<CrySystemNotifications>;
  1323. };
  1324. //JAT - this is a very important function for the dedicated server - it lets us run >1000 players per piece of server hardware
  1325. //JAT - this saves us lots of money on the dedicated server hardware
  1326. #define SYNCHRONOUS_LOADING_TICK() do { if (gEnv && gEnv->pSystem) {gEnv->pSystem->SynchronousLoadingTick(__FUNC__, __LINE__); } \
  1327. } while (0)
  1328. #if defined(USE_DISK_PROFILER)
  1329. struct DiskOperationInfo
  1330. {
  1331. DiskOperationInfo()
  1332. : m_nSeeksCount(0)
  1333. , m_nFileOpenCount(0)
  1334. , m_nFileReadCount(0)
  1335. , m_dOperationSize(0.)
  1336. , m_dOperationTime(0.) {}
  1337. int m_nSeeksCount;
  1338. int m_nFileOpenCount;
  1339. int m_nFileReadCount;
  1340. double m_dOperationTime;
  1341. double m_dOperationSize;
  1342. DiskOperationInfo& operator -= (const DiskOperationInfo& rv)
  1343. {
  1344. m_nSeeksCount -= rv.m_nSeeksCount;
  1345. m_nFileOpenCount -= rv.m_nFileOpenCount;
  1346. m_nFileReadCount -= rv.m_nFileReadCount;
  1347. m_dOperationSize -= rv.m_dOperationSize;
  1348. m_dOperationTime -= rv.m_dOperationTime;
  1349. return *this;
  1350. }
  1351. DiskOperationInfo& operator += (const DiskOperationInfo& rv)
  1352. {
  1353. m_nSeeksCount += rv.m_nSeeksCount;
  1354. m_nFileOpenCount += rv.m_nFileOpenCount;
  1355. m_nFileReadCount += rv.m_nFileReadCount;
  1356. m_dOperationSize += rv.m_dOperationSize;
  1357. m_dOperationTime += rv.m_dOperationTime;
  1358. return *this;
  1359. }
  1360. DiskOperationInfo& operator - (const DiskOperationInfo& rv)
  1361. {
  1362. DiskOperationInfo res(*this);
  1363. return res -= rv;
  1364. }
  1365. DiskOperationInfo& operator + (const DiskOperationInfo& rv)
  1366. {
  1367. DiskOperationInfo res(*this);
  1368. return res += rv;
  1369. }
  1370. };
  1371. #endif
  1372. #if defined(ENABLE_LOADING_PROFILER) && AZ_PROFILE_TELEMETRY
  1373. #define LOADING_TIME_PROFILE_SECTION AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore)
  1374. #define LOADING_TIME_PROFILE_SECTION_ARGS(...) AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::AzCore, __VA_ARGS__)
  1375. #define LOADING_TIME_PROFILE_SECTION_NAMED(sectionName) AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzCore, sectionName)
  1376. #define LOADING_TIME_PROFILE_SECTION_NAMED_ARGS(sectionName, ...) AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::AzCore, sectionName, __VA_ARGS__)
  1377. #else
  1378. #define LOADING_TIME_PROFILE_SECTION
  1379. #define LOADING_TIME_PROFILE_SECTION_ARGS(...)
  1380. #define LOADING_TIME_PROFILE_SECTION_NAMED(sectionName)
  1381. #define LOADING_TIME_PROFILE_SECTION_NAMED_ARGS(sectionName, ...)
  1382. #endif
  1383. //////////////////////////////////////////////////////////////////////////
  1384. // CrySystem DLL Exports.
  1385. //////////////////////////////////////////////////////////////////////////
  1386. typedef ISystem* (*PFNCREATESYSTEMINTERFACE)(SSystemInitParams& initParams);
  1387. //////////////////////////////////////////////////////////////////////////
  1388. // Global environment variable.
  1389. //////////////////////////////////////////////////////////////////////////
  1390. extern SC_API SSystemGlobalEnvironment* gEnv;
  1391. // Summary:
  1392. // Gets the system interface.
  1393. inline ISystem* GetISystem()
  1394. {
  1395. // Some unit tests temporarily install and then uninstall ISystem* mocks.
  1396. // It is generally okay for runtime and tool systems which call this function to cache the returned pointer,
  1397. // because their lifetime is usually shorter than the lifetime of the ISystem* implementation.
  1398. // It is NOT safe for this function to cache it as a static itself, though, as the static it would cache
  1399. // it inside may outlive the the actual instance implementing ISystem* when unit tests are torn down and then restarted.
  1400. ISystem* systemInterface = gEnv ? gEnv->pSystem : nullptr;
  1401. if (!systemInterface)
  1402. {
  1403. CrySystemRequestBus::BroadcastResult(systemInterface, &CrySystemRequests::GetCrySystem);
  1404. }
  1405. return systemInterface;
  1406. };
  1407. inline ISystemScheduler* GetISystemScheduler(void)
  1408. {
  1409. return gEnv->pSystemScheduler;
  1410. };
  1411. //////////////////////////////////////////////////////////////////////////
  1412. // Description:
  1413. // This function must be called once by each module at the beginning, to setup global pointers.
  1414. extern "C" AZ_DLL_EXPORT void ModuleInitISystem(ISystem* pSystem, const char* moduleName);
  1415. extern "C" AZ_DLL_EXPORT void ModuleShutdownISystem(ISystem* pSystem);
  1416. extern "C" AZ_DLL_EXPORT void InjectEnvironment(void* env);
  1417. extern "C" AZ_DLL_EXPORT void DetachEnvironment();
  1418. void* GetModuleInitISystemSymbol();
  1419. void* GetModuleShutdownISystemSymbol();
  1420. void* GetInjectEnvironmentSymbol();
  1421. void* GetDetachEnvironmentSymbol();
  1422. #define PREVENT_MODULE_AND_ENVIRONMENT_SYMBOL_STRIPPING \
  1423. AZ_UNUSED(GetModuleInitISystemSymbol()); \
  1424. AZ_UNUSED(GetModuleShutdownISystemSymbol()); \
  1425. AZ_UNUSED(GetInjectEnvironmentSymbol()); \
  1426. AZ_UNUSED(GetDetachEnvironmentSymbol());
  1427. extern bool g_bProfilerEnabled;
  1428. extern int g_iTraceAllocations;
  1429. // Summary:
  1430. // Interface of the DLL.
  1431. extern "C"
  1432. {
  1433. CRYSYSTEM_API ISystem* CreateSystemInterface(const SSystemInitParams& initParams);
  1434. }
  1435. // Description:
  1436. // Displays error message.
  1437. // Logs it to console and file and error message box.
  1438. // Then terminates execution.
  1439. void CryFatalError(const char*, ...) PRINTF_PARAMS(1, 2);
  1440. inline void CryFatalError(const char* format, ...)
  1441. {
  1442. if (!gEnv || !gEnv->pSystem)
  1443. {
  1444. return;
  1445. }
  1446. va_list ArgList;
  1447. char szBuffer[MAX_WARNING_LENGTH];
  1448. va_start(ArgList, format);
  1449. int count = azvsnprintf(szBuffer, sizeof(szBuffer), format, ArgList);
  1450. if (count == -1 || count >= sizeof(szBuffer))
  1451. {
  1452. szBuffer[sizeof(szBuffer) - 1] = '\0';
  1453. }
  1454. va_end(ArgList);
  1455. gEnv->pSystem->FatalError("%s", szBuffer);
  1456. }
  1457. //////////////////////////////////////////////////////////////////////////
  1458. // Description:
  1459. // Displays warning message.
  1460. // Logs it to console and file and display a warning message box.
  1461. // Doesn't terminate execution.
  1462. void CryWarning(EValidatorModule, EValidatorSeverity, const char*, ...) PRINTF_PARAMS(3, 4);
  1463. inline void CryWarning(EValidatorModule module, EValidatorSeverity severity, const char* format, ...)
  1464. {
  1465. if (!gEnv || !gEnv->pSystem || !format)
  1466. {
  1467. return;
  1468. }
  1469. va_list args;
  1470. va_start(args, format);
  1471. GetISystem()->WarningV(module, severity, 0, 0, format, args);
  1472. va_end(args);
  1473. }
  1474. #ifdef EXCLUDE_CVARHELP
  1475. #define CVARHELP(_comment) 0
  1476. #else
  1477. #define CVARHELP(_comment) _comment
  1478. #endif
  1479. //Provide macros for fixing cvars for release mode on consoles to enums to allow for code stripping
  1480. //Do not enable for PC, apply VF_CHEAT there if required
  1481. #if defined(CONSOLE)
  1482. #define CONST_CVAR_FLAGS (VF_CHEAT)
  1483. #else
  1484. #define CONST_CVAR_FLAGS (VF_NULL)
  1485. #endif
  1486. #if defined(AZ_RESTRICTED_PLATFORM)
  1487. #define AZ_RESTRICTED_SECTION ISYSTEM_H_SECTION_5
  1488. #include AZ_RESTRICTED_FILE(ISystem_h)
  1489. #endif
  1490. #if defined(_RELEASE) && defined(IS_CONSOLE_PLATFORM)
  1491. #ifndef LOG_CONST_CVAR_ACCESS
  1492. #error LOG_CONST_CVAR_ACCESS should be defined in ProjectDefines.h
  1493. #endif
  1494. #include "IConsole.h"
  1495. namespace Detail
  1496. {
  1497. template<typename T>
  1498. struct SQueryTypeEnum;
  1499. template<>
  1500. struct SQueryTypeEnum<int>
  1501. {
  1502. static const int type = CVAR_INT;
  1503. static int ParseString(const char* s) { return atoi(s); }
  1504. };
  1505. template<>
  1506. struct SQueryTypeEnum<float>
  1507. {
  1508. static const int type = CVAR_FLOAT;
  1509. static float ParseString(const char* s) { return (float)atof(s); }
  1510. };
  1511. template<typename T>
  1512. struct SDummyCVar
  1513. : ICVar
  1514. {
  1515. const T value;
  1516. #if LOG_CONST_CVAR_ACCESS
  1517. mutable bool bWasRead;
  1518. mutable bool bWasChanged;
  1519. SDummyCVar(T val)
  1520. : value(val)
  1521. , bWasChanged(false)
  1522. , bWasRead(false) {}
  1523. #else
  1524. SDummyCVar(T val)
  1525. : value(val) {}
  1526. #endif
  1527. void WarnUse() const
  1528. {
  1529. #if LOG_CONST_CVAR_ACCESS
  1530. if (!bWasRead)
  1531. {
  1532. CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "[CVAR] Read from const CVar '%s' via name look-up, this is non-optimal", GetName());
  1533. bWasRead = true;
  1534. }
  1535. #endif
  1536. }
  1537. void InvalidAccess() const
  1538. {
  1539. #if LOG_CONST_CVAR_ACCESS
  1540. if (!bWasChanged)
  1541. {
  1542. 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());
  1543. bWasChanged = true;
  1544. }
  1545. #endif
  1546. }
  1547. void Release() {}
  1548. int GetIVal() const { WarnUse(); return static_cast<int>(value); }
  1549. int64 GetI64Val() const { WarnUse(); return static_cast<int64>(value); }
  1550. float GetFVal() const { WarnUse(); return static_cast<float>(value); }
  1551. const char* GetString() const { return ""; }
  1552. const char* GetDataProbeString() const { return ""; }
  1553. void Set(const char* s)
  1554. {
  1555. if (SQueryTypeEnum<T>::ParseString(s) != value)
  1556. {
  1557. InvalidAccess();
  1558. }
  1559. }
  1560. void ForceSet(const char* s) { Set(s); }
  1561. void Set(const float f)
  1562. {
  1563. if (static_cast<T>(f) != value)
  1564. {
  1565. InvalidAccess();
  1566. }
  1567. }
  1568. void Set(const int i)
  1569. {
  1570. if (static_cast<T>(i) != value)
  1571. {
  1572. InvalidAccess();
  1573. }
  1574. }
  1575. void ClearFlags([[maybe_unused]] int flags) {}
  1576. int GetFlags() const { return VF_CONST_CVAR | VF_READONLY; }
  1577. int SetFlags([[maybe_unused]] int flags) { return 0; }
  1578. int GetType() { return SQueryTypeEnum<T>::type; }
  1579. const char* GetHelp() { return NULL; }
  1580. bool IsConstCVar() const { return true; }
  1581. void SetOnChangeCallback(ConsoleVarFunc pChangeFunc) { (void)pChangeFunc; }
  1582. uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) { (void)pChangeFunctor; return 0; }
  1583. uint64 GetNumberOfOnChangeFunctors() const { return 0; }
  1584. const SFunctor& GetOnChangeFunctor([[maybe_unused]] uint64 nFunctorIndex) const { InvalidAccess(); SFunctor* pNull = nullptr; return *pNull; }
  1585. bool RemoveOnChangeFunctor([[maybe_unused]] const uint64 nElement) { return true; }
  1586. ConsoleVarFunc GetOnChangeCallback() const { InvalidAccess(); return NULL; }
  1587. void GetMemoryUsage([[maybe_unused]] class ICrySizer* pSizer) const {}
  1588. int GetRealIVal() const { return GetIVal(); }
  1589. void SetLimits([[maybe_unused]] float min, [[maybe_unused]] float max) { return; }
  1590. void GetLimits([[maybe_unused]] float& min, [[maybe_unused]] float& max) { return; }
  1591. bool HasCustomLimits() { return false; }
  1592. void SetDataProbeString([[maybe_unused]] const char* pDataProbeString) { InvalidAccess(); }
  1593. };
  1594. }
  1595. #define REGISTER_DUMMY_CVAR(type, name, value) \
  1596. do { \
  1597. static struct DummyCVar \
  1598. : Detail::SDummyCVar<type> \
  1599. { \
  1600. DummyCVar() \
  1601. : Detail::SDummyCVar<type>(value) {} \
  1602. const char* GetName() const { return name; } \
  1603. } DummyStaticInstance; \
  1604. if (!(gEnv->pConsole != 0 ? gEnv->pConsole->Register(&DummyStaticInstance) : 0)) \
  1605. { \
  1606. DEBUG_BREAK; \
  1607. CryFatalError("Can not register dummy CVar"); \
  1608. } \
  1609. } while (0)
  1610. # define CONSOLE_CONST_CVAR_MODE
  1611. # define DeclareConstIntCVar(name, defaultValue) enum : int { name = (defaultValue) }
  1612. # define DeclareStaticConstIntCVar(name, defaultValue) enum : int { name = (defaultValue) }
  1613. # define DefineConstIntCVarName(strname, name, defaultValue, flags, help) { COMPILE_TIME_ASSERT((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, strname, defaultValue); }
  1614. # define DefineConstIntCVar(name, defaultValue, flags, help) { COMPILE_TIME_ASSERT((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, (#name), defaultValue); }
  1615. // DefineConstIntCVar2 is deprecated, any such instance can be converted to the 3 variant by removing the quotes around the first parameter
  1616. # define DefineConstIntCVar3(name, _var_, defaultValue, flags, help) { COMPILE_TIME_ASSERT((int)(defaultValue) == (int)(_var_)); REGISTER_DUMMY_CVAR(int, name, defaultValue); }
  1617. # define AllocateConstIntCVar(scope, name)
  1618. # define DefineConstFloatCVar(name, flags, help) { REGISTER_DUMMY_CVAR(float, (#name), name ## Default); }
  1619. # define DeclareConstFloatCVar(name)
  1620. # define DeclareStaticConstFloatCVar(name)
  1621. # define AllocateConstFloatCVar(scope, name)
  1622. # define IsCVarConstAccess(expr) expr
  1623. #else
  1624. # define DeclareConstIntCVar(name, defaultValue) int name { defaultValue }
  1625. # define DeclareStaticConstIntCVar(name, defaultValue) static int name
  1626. # define DefineConstIntCVarName(strname, name, defaultValue, flags, help) \
  1627. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(strname, &name, defaultValue, flags | CONST_CVAR_FLAGS, CVARHELP(help)))
  1628. # define DefineConstIntCVar(name, defaultValue, flags, help) \
  1629. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#name), &name, defaultValue, flags | CONST_CVAR_FLAGS, CVARHELP(help), 0, false))
  1630. // DefineConstIntCVar2 is deprecated, any such instance can be converted to the 3 variant by removing the quotes around the first parameter
  1631. # define DefineConstIntCVar3(_name, _var, _def_val, _flags, help) \
  1632. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags) | CONST_CVAR_FLAGS, CVARHELP(help), 0, false))
  1633. # define AllocateConstIntCVar(scope, name) int scope:: name
  1634. # define DefineConstFloatCVar(name, flags, help) \
  1635. (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#name), &name, name ## Default, flags | CONST_CVAR_FLAGS, CVARHELP(help), 0, false))
  1636. # define DeclareConstFloatCVar(name) float name
  1637. # define DeclareStaticConstFloatCVar(name) static float name
  1638. # define AllocateConstFloatCVar(scope, name) float scope:: name
  1639. # define IsCVarConstAccess(expr)
  1640. #endif
  1641. #if defined(USE_CRY_ASSERT)
  1642. static void AssertConsoleExists(void)
  1643. {
  1644. CRY_ASSERT(gEnv->pConsole != NULL);
  1645. }
  1646. #define ASSERT_CONSOLE_EXISTS AssertConsoleExists()
  1647. #else
  1648. #define ASSERT_CONSOLE_EXISTS 0
  1649. #endif // defined(USE_CRY_ASSERT)
  1650. // the following macros allow the help text to be easily stripped out
  1651. // Summary:
  1652. // Preferred way to register a CVar
  1653. #define REGISTER_CVAR(_var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment)))
  1654. // Summary:
  1655. // Preferred way to register a CVar with a callback
  1656. #define REGISTER_CVAR_CB(_var, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1657. // Summary:
  1658. // Preferred way to register a string CVar
  1659. #define REGISTER_STRING(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1660. // Summary:
  1661. // Preferred way to register a string CVar with a callback
  1662. #define REGISTER_STRING_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1663. // Summary:
  1664. // Preferred way to register an int CVar
  1665. #define REGISTER_INT(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1666. // Summary:
  1667. // Preferred way to register an int CVar with a callback
  1668. #define REGISTER_INT_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1669. // Summary:
  1670. // Preferred way to register an int64 CVar
  1671. #define REGISTER_INT64(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt64(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1672. // Summary:
  1673. // Preferred way to register an int64 CVar with a callback
  1674. #define REGISTER_INT64_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt64(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1675. // Summary:
  1676. // Preferred way to register a float CVar
  1677. #define REGISTER_FLOAT(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment)))
  1678. // Summary:
  1679. // Preferred way to register a float CVar with a callback
  1680. #define REGISTER_FLOAT_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1681. // Summary:
  1682. // Offers more flexibility but more code is required
  1683. #define REGISTER_CVAR2(_name, _var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment)))
  1684. // Summary:
  1685. // Offers more flexibility but more code is required
  1686. #define REGISTER_CVAR2_CB(_name, _var, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1687. // Summary:
  1688. // Offers more flexibility but more code is required, explicit address taking of destination variable
  1689. #define REGISTER_CVAR3(_name, _var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment)))
  1690. // Summary:
  1691. // Offers more flexibility but more code is required, explicit address taking of destination variable
  1692. #define REGISTER_CVAR3_CB(_name, _var, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
  1693. // Summary:
  1694. // Preferred way to register a console command
  1695. #define REGISTER_COMMAND(_name, _func, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? false : gEnv->pConsole->AddCommand(_name, _func, (_flags), CVARHELP(_comment)))
  1696. // Summary:
  1697. // Preferred way to unregister a CVar
  1698. #define UNREGISTER_CVAR(_name) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->UnregisterVariable(_name))
  1699. // Preferred way to unregister a console command
  1700. #define UNREGISTER_COMMAND(_name) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->RemoveCommand(_name))
  1701. ////////////////////////////////////////////////////////////////////////////////
  1702. //
  1703. // Development only cvars
  1704. //
  1705. // N.B:
  1706. // (1) Registered as real cvars *in non release builds only*.
  1707. // (2) Can still be manipulated in release by the mapped variable, so not the same as const cvars.
  1708. // (3) Any 'OnChanged' callback will need guarding against in release builds since the cvar won't exist
  1709. // (4) Any code that tries to get ICVar* will need guarding against in release builds since the cvar won't exist
  1710. //
  1711. // ILLEGAL_DEV_FLAGS is a mask of all those flags which make no sense in a _DEV_ONLY or _DEDI_ONLY cvar since the
  1712. // cvar potentially won't exist in a release build.
  1713. //
  1714. #define ILLEGAL_DEV_FLAGS (VF_NET_SYNCED | VF_CHEAT | VF_CHEAT_ALWAYS_CHECK | VF_CHEAT_NOCHECK | VF_READONLY | VF_CONST_CVAR)
  1715. #if defined(_RELEASE)
  1716. #define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
  1717. #define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val /* _onchangefunction consumed; callback not available */
  1718. #define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1719. #define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1720. #define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1721. #define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1722. #define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1723. #define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
  1724. #define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
  1725. #define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
  1726. #define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
  1727. #define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
  1728. #define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) /* consumed; command not available */
  1729. #else
  1730. #define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1731. #define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1732. #define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1733. #define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1734. #define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1735. #define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1736. #define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1737. #define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1738. #define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1739. #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); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1740. #define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1741. #define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1742. #define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1743. #endif // defined(_RELEASE)
  1744. //
  1745. ////////////////////////////////////////////////////////////////////////////////
  1746. ////////////////////////////////////////////////////////////////////////////////
  1747. //
  1748. // Dedicated server only cvars
  1749. //
  1750. // N.B:
  1751. // (1) Registered as real cvars in all non release builds
  1752. // (2) Registered as real cvars in release on dedi servers only, otherwise treated as DEV_ONLY type cvars (see above)
  1753. //
  1754. // TODO Registering all cvars for Dedicated server as well. Currently CrySystems have no concept of Dedicated server with cmake.
  1755. // If we introduce server specific targets for CrySystems, we can add DEDICATED_SERVER flags to those and add the flag back in here.
  1756. #if defined(_RELEASE)
  1757. #define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1758. #define REGISTER_CVAR_CB_DEDI_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1759. #define REGISTER_STRING_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1760. #define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1761. #define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1762. #define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1763. #define REGISTER_INT64_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1764. #define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1765. #define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1766. #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); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1767. #define REGISTER_CVAR3_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1768. #define REGISTER_CVAR3_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1769. #define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
  1770. #else
  1771. #define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR_DEV_ONLY(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1772. #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)
  1773. #define REGISTER_STRING_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1774. #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)
  1775. #define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1776. #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)
  1777. #define REGISTER_INT64_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1778. #define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1779. #define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1780. #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)
  1781. #define REGISTER_CVAR3_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
  1782. #define REGISTER_CVAR3_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
  1783. #define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND_DEV_ONLY(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment)
  1784. #endif // defined(_RELEASE)
  1785. //
  1786. ////////////////////////////////////////////////////////////////////////////////
  1787. #ifdef EXCLUDE_NORMAL_LOG // setting this removes a lot of logging to reduced code size (useful for consoles)
  1788. #define CryLog(...) ((void)0)
  1789. #define CryComment(...) ((void)0)
  1790. #define CryLogAlways(...) ((void)0)
  1791. #else // EXCLUDE_NORMAL_LOG
  1792. // Summary:
  1793. // Simple logs of data with low verbosity.
  1794. void CryLog(const char*, ...) PRINTF_PARAMS(1, 2);
  1795. inline void CryLog(const char* format, ...)
  1796. {
  1797. // Fran: we need these guards for the testing framework to work
  1798. if (gEnv && gEnv->pSystem && gEnv->pLog)
  1799. {
  1800. va_list args;
  1801. va_start(args, format);
  1802. gEnv->pLog->LogV(ILog::eMessage, format, args);
  1803. va_end(args);
  1804. }
  1805. }
  1806. // Notes:
  1807. // Very rarely used log comment.
  1808. void CryComment(const char*, ...) PRINTF_PARAMS(1, 2);
  1809. inline void CryComment(const char* format, ...)
  1810. {
  1811. // Fran: we need these guards for the testing framework to work
  1812. if (gEnv && gEnv->pSystem && gEnv->pLog)
  1813. {
  1814. va_list args;
  1815. va_start(args, format);
  1816. gEnv->pLog->LogV(ILog::eComment, format, args);
  1817. va_end(args);
  1818. }
  1819. }
  1820. // Summary:
  1821. // Logs important data that must be printed regardless verbosity.
  1822. void CryLogAlways(const char*, ...) PRINTF_PARAMS(1, 2);
  1823. inline void CryLogAlways(const char* format, ...)
  1824. {
  1825. // log should not be used before system is ready
  1826. // error before system init should be handled explicitly
  1827. // Fran: we need these guards for the testing framework to work
  1828. if (gEnv && gEnv->pSystem && gEnv->pLog)
  1829. {
  1830. // assert(gEnv);
  1831. // assert(gEnv->pSystem);
  1832. va_list args;
  1833. va_start(args, format);
  1834. gEnv->pLog->LogV(ILog::eAlways, format, args);
  1835. va_end(args);
  1836. }
  1837. }
  1838. #endif // EXCLUDE_NORMAL_LOG
  1839. /*****************************************************
  1840. ASYNC MEMCPY FUNCTIONS
  1841. *****************************************************/
  1842. // Complex delegation required because it is not really easy to
  1843. // export a external standalone symbol like a memcpy function when
  1844. // building with modules. Dll pay an extra indirection cost for calling this
  1845. // function.
  1846. #if !defined(AZ_MONOLITHIC_BUILD)
  1847. # define CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM
  1848. #endif
  1849. #define CRY_ASYNC_MEMCPY_API extern "C"
  1850. // Note sync variable will be incremented (in calling thread) before job starts
  1851. // and decremented when job finishes. Multiple async copies can therefore be
  1852. // tied to the same sync variable, therefore wait for completion with
  1853. // while(*sync) (yield());
  1854. #if defined(CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM)
  1855. inline void cryAsyncMemcpy(
  1856. void* dst
  1857. , const void* src
  1858. , size_t size
  1859. , int nFlags
  1860. , volatile int* sync)
  1861. {
  1862. GetISystem()->AsyncMemcpy(dst, src, size, nFlags, sync);
  1863. }
  1864. # else
  1865. CRY_ASYNC_MEMCPY_API void cryAsyncMemcpy(
  1866. void* dst
  1867. , const void* src
  1868. , size_t size
  1869. , int nFlags
  1870. , volatile int* sync);
  1871. #endif
  1872. //////////////////////////////////////////////////////////////////////////
  1873. // Additional headers.
  1874. //////////////////////////////////////////////////////////////////////////
  1875. #include <FrameProfiler.h>
  1876. #endif // CRYINCLUDE_CRYCOMMON_ISYSTEM_H