System.h 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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. #pragma once
  14. #include <ISystem.h>
  15. #include <IRenderer.h>
  16. #include <IPhysics.h>
  17. #include <IWindowMessageHandler.h>
  18. #include "Timer.h"
  19. #include <CryVersion.h>
  20. #include "CmdLine.h"
  21. #include "CryName.h"
  22. #include "MTSafeAllocator.h"
  23. #include "CPUDetect.h"
  24. #include <AzFramework/Archive/ArchiveVars.h>
  25. #include "MemoryFragmentationProfiler.h" // CMemoryFragmentationProfiler
  26. #include "ThreadTask.h"
  27. #include "RenderBus.h"
  28. #include <LoadScreenBus.h>
  29. #include <ThermalInfo.h>
  30. #include <AzCore/Module/DynamicModuleHandle.h>
  31. #include <AzFramework/Terrain/TerrainDataRequestBus.h>
  32. namespace AzFramework
  33. {
  34. class MissingAssetLogger;
  35. }
  36. struct IConsoleCmdArgs;
  37. class CServerThrottle;
  38. struct ICryFactoryRegistryImpl;
  39. struct IZLibCompressor;
  40. class CWatchdogThread;
  41. class CThreadManager;
  42. struct ICryPerfHUD;
  43. namespace minigui
  44. {
  45. struct IMiniGUI;
  46. }
  47. #if defined(AZ_RESTRICTED_PLATFORM)
  48. #undef AZ_RESTRICTED_SECTION
  49. #define SYSTEM_H_SECTION_1 1
  50. #define SYSTEM_H_SECTION_2 2
  51. #define SYSTEM_H_SECTION_3 3
  52. #define SYSTEM_H_SECTION_4 4
  53. #endif
  54. #if defined(ANDROID)
  55. #define USE_ANDROIDCONSOLE
  56. #elif defined(MAC) // || defined(LINUX)
  57. #define USE_UNIXCONSOLE
  58. #elif defined(IOS)
  59. #define USE_IOSCONSOLE
  60. #elif defined(WIN32) || defined(WIN64)
  61. #define USE_WINDOWSCONSOLE
  62. #else
  63. #define USE_NULLCONSOLE
  64. #endif
  65. #if defined(AZ_RESTRICTED_PLATFORM)
  66. #define AZ_RESTRICTED_SECTION SYSTEM_H_SECTION_1
  67. #include AZ_RESTRICTED_FILE(System_h)
  68. #else
  69. #if defined(WIN32) || defined(LINUX) || defined(APPLE)
  70. #define AZ_LEGACY_CRYSYSTEM_TRAIT_ALLOW_CREATE_BACKUP_LOG_FILE 1
  71. #endif
  72. #if defined(WIN32) || (defined(LINUX) && !defined(ANDROID)) || defined(MAC)
  73. #define AZ_LEGACY_CRYSYSTEM_TRAIT_DEFINE_DETECT_PROCESSOR 1
  74. #endif
  75. //////////////////////////////////////////////////////////////////////////
  76. #if defined(WIN32) || defined(APPLE) || defined(LINUX)
  77. #define AZ_LEGACY_CRYSYSTEM_TRAIT_DO_PREASSERT 1
  78. #endif
  79. #if defined(MAC) || (defined(LINUX) && !defined(ANDROID))
  80. #define AZ_LEGACY_CRYSYSTEM_TRAIT_ASM_VOLATILE_CPUID 1
  81. #endif
  82. #if (defined(WIN32) && !defined(WIN64)) || (defined(LINUX) && !defined(ANDROID) && !defined(LINUX64))
  83. #define AZ_LEGACY_CRYSYSTEM_TRAIT_HAS64BITEXT 1
  84. #endif
  85. #if defined(WIN32) || (defined(LINUX) && !defined(ANDROID)) || defined(MAC)
  86. #define AZ_LEGACY_CRYSYSTEM_TRAIT_HTSUPPORTED 1
  87. #endif
  88. #if defined(WIN32) || (defined(LINUX) && !defined(ANDROID)) || defined(MAC)
  89. #define AZ_LEGACY_CRYSYSTEM_TRAIT_HASCPUID 1
  90. #endif
  91. #if defined(WIN32)
  92. #define AZ_LEGACY_CRYSYSTEM_TRAIT_HASAFFINITYMASK 1
  93. #endif
  94. #if defined(LINUX) || defined(APPLE)
  95. #define AZ_LEGACY_CRYSYSTEM_TRAIT_CRYPAK_POSIX 1
  96. #endif
  97. #if defined(WIN64)
  98. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_BIT64 1
  99. #endif
  100. #if defined(WIN32)
  101. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_PACKED_PEHEADER 1
  102. #endif
  103. #if defined(WIN32) || defined(LINUX)
  104. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_RENDERMEMORY_INFO 1
  105. #endif
  106. #if defined(WIN32)
  107. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_HANDLER_SYNC_AFFINITY 1
  108. #endif
  109. #if defined(LINUX) || defined(APPLE)
  110. #define AZ_LEGACY_CRYSYSTEM_TRAIT_FORWARD_EXCEPTION_POINTERS 1
  111. #endif
  112. #if !defined(_WIN32)
  113. #define AZ_LEGACY_CRYSYSTEM_TRAIT_DEBUGCALLSTACK_SINGLETON 1
  114. #endif
  115. #if !defined(LINUX) && !defined(APPLE)
  116. #define AZ_LEGACY_CRYSYSTEM_TRAIT_DEBUGCALLSTACK_TRANSLATE 1
  117. #endif
  118. #if !defined(LINUX) && !defined(APPLE)
  119. #define AZ_LEGACY_CRYSYSTEM_TRAIT_DEBUGCALLSTACK_APPEND_MODULENAME 1
  120. #endif
  121. #if !(defined(ANDROID) || defined(IOS) || defined(LINUX))
  122. #define AZ_LEGACY_CRYSYSTEM_TRAIT_IMAGEHANDLER_TIFFIO 1
  123. #endif
  124. #if 1
  125. #define AZ_LEGACY_CRYSYSTEM_TRAIT_JOBMANAGER_SIXWORKERTHREADS 0
  126. #endif
  127. #if defined(WIN32)
  128. #define AZ_LEGACY_CRYSYSTEM_TRAIT_MEMADDRESSRANGE_WINDOWS_STYLE 1
  129. #endif
  130. #if 1
  131. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_EXCLUDEUPDATE_ON_CONSOLE 0
  132. #endif
  133. #if defined(WIN32)
  134. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_MESSAGE_HANDLER 1
  135. #endif
  136. #if defined(WIN64) || defined(WIN32)
  137. #define AZ_LEGACY_CRYSYSTEM_TRAIT_CAPTURESTACK 1
  138. #endif
  139. #if !defined(LINUX) && !defined(APPLE)
  140. #define AZ_LEGACY_CRYSYSTEM_TRAIT_SYSTEMCFG_MODULENAME 1
  141. #endif
  142. #if defined(WIN32) || defined(WIN64)
  143. #define AZ_LEGACY_CRYSYSTEM_TRAIT_THREADINFO_WINDOWS_STYLE 1
  144. #endif
  145. #if defined(WIN32)
  146. #define AZ_LEGACY_CRYSYSTEM_TRAIT_THREADTASK_EXCEPTIONS 1
  147. #endif
  148. //////////////////////////////////////////////////////////////////////////
  149. #if defined(APPLE) || defined(LINUX)
  150. #define AZ_LEGACY_CRYSYSTEM_TRAIT_FACTORY_REGISTRY_USE_PRINTF_FOR_FATAL 1
  151. #endif
  152. #if defined(LINUX) || defined(APPLE)
  153. #define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_FTELL_NOT_FTELLI64 1
  154. #endif
  155. #endif
  156. #if defined(USE_UNIXCONSOLE) || defined(USE_ANDROIDCONSOLE) || defined(USE_WINDOWSCONSOLE) || defined(USE_IOSCONSOLE) || defined(USE_NULLCONSOLE)
  157. #define USE_DEDICATED_SERVER_CONSOLE
  158. #endif
  159. #if defined(LINUX)
  160. #include "CryLibrary.h"
  161. #endif
  162. #define NUM_UPDATE_TIMES (128U)
  163. #ifdef WIN32
  164. typedef void* WIN_HMODULE;
  165. #else
  166. typedef void* WIN_HMODULE;
  167. #endif
  168. #if !defined(CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM)
  169. CRY_ASYNC_MEMCPY_API void cryAsyncMemcpy(void* dst, const void* src, size_t size, int nFlags, volatile int* sync);
  170. #else
  171. CRY_ASYNC_MEMCPY_API void cryAsyncMemcpyDelegate(void* dst, const void* src, size_t size, int nFlags, volatile int* sync);
  172. #endif
  173. //forward declarations
  174. namespace Audio
  175. {
  176. struct IAudioSystem;
  177. struct IMusicSystem;
  178. } // namespace Audio
  179. struct SDefaultValidator;
  180. struct IDataProbe;
  181. class CVisRegTest;
  182. #define PHSYICS_OBJECT_ENTITY 0
  183. typedef void (__cdecl * VTuneFunction)(void);
  184. extern VTuneFunction VTResume;
  185. extern VTuneFunction VTPause;
  186. #define MAX_STREAMING_POOL_INDEX 6
  187. #define MAX_THREAD_POOL_INDEX 6
  188. struct SSystemCVars
  189. {
  190. int az_streaming_stats;
  191. int sys_streaming_requests_grouping_time_period;
  192. int sys_streaming_sleep;
  193. int sys_streaming_memory_budget;
  194. int sys_streaming_max_finalize_per_frame;
  195. float sys_streaming_max_bandwidth;
  196. int sys_streaming_cpu;
  197. int sys_streaming_cpu_worker;
  198. int sys_streaming_debug;
  199. int sys_streaming_resetstats;
  200. int sys_streaming_debug_filter;
  201. float sys_streaming_debug_filter_min_time;
  202. int sys_streaming_use_optical_drive_thread;
  203. ICVar* sys_streaming_debug_filter_file_name;
  204. ICVar* sys_localization_folder;
  205. int sys_streaming_in_blocks;
  206. int sys_float_exceptions;
  207. int sys_no_crash_dialog;
  208. int sys_no_error_report_window;
  209. int sys_dump_aux_threads;
  210. int sys_WER;
  211. int sys_dump_type;
  212. int sys_ai;
  213. int sys_physics;
  214. int sys_entitysystem;
  215. int sys_trackview;
  216. int sys_vtune;
  217. float sys_update_profile_time;
  218. int sys_limit_phys_thread_count;
  219. int sys_MaxFPS;
  220. float sys_maxTimeStepForMovieSystem;
  221. int sys_force_installtohdd_mode;
  222. int sys_report_files_not_found_in_paks = 0;
  223. #ifdef USE_HTTP_WEBSOCKETS
  224. int sys_simple_http_base_port;
  225. #endif
  226. int sys_asserts;
  227. int sys_error_debugbreak;
  228. int sys_FilesystemCaseSensitivity;
  229. int sys_rendersplashscreen;
  230. const char* sys_splashscreen;
  231. enum SplashScreenScaleMode
  232. {
  233. SplashScreenScaleMode_Fit = 0,
  234. SplashScreenScaleMode_Fill
  235. };
  236. int sys_splashScreenScaleMode;
  237. int sys_deferAudioUpdateOptim;
  238. #if USE_STEAM
  239. #ifndef RELEASE
  240. int sys_steamAppId;
  241. #endif // RELEASE
  242. int sys_useSteamCloudForPlatformSaving;
  243. #endif // USE_STEAM
  244. AZ::IO::ArchiveVars archiveVars;
  245. #if defined(WIN32)
  246. int sys_display_threads;
  247. #elif defined(AZ_RESTRICTED_PLATFORM)
  248. #define AZ_RESTRICTED_SECTION SYSTEM_H_SECTION_2
  249. #include AZ_RESTRICTED_FILE(System_h)
  250. #endif
  251. };
  252. extern SSystemCVars g_cvars;
  253. class CSystem;
  254. struct SmallModuleInfo
  255. {
  256. string name;
  257. CryModuleMemoryInfo memInfo;
  258. };
  259. struct SCryEngineStatsModuleInfo
  260. {
  261. string name;
  262. CryModuleMemoryInfo memInfo;
  263. uint32 moduleStaticSize;
  264. uint32 usedInModule;
  265. uint32 SizeOfCode;
  266. uint32 SizeOfInitializedData;
  267. uint32 SizeOfUninitializedData;
  268. };
  269. struct SCryEngineStatsGlobalMemInfo
  270. {
  271. int totalUsedInModules;
  272. int totalCodeAndStatic;
  273. int countedMemoryModules;
  274. uint64 totalAllocatedInModules;
  275. int totalNumAllocsInModules;
  276. std::vector<SCryEngineStatsModuleInfo> modules;
  277. };
  278. struct CProfilingSystem
  279. : public IProfilingSystem
  280. {
  281. //////////////////////////////////////////////////////////////////////////
  282. // VTune Profiling interface.
  283. // Summary:
  284. // Resumes vtune data collection.
  285. virtual void VTuneResume();
  286. // Summary:
  287. // Pauses vtune data collection.
  288. virtual void VTunePause();
  289. //////////////////////////////////////////////////////////////////////////
  290. };
  291. class AssetSystem;
  292. /*
  293. ===========================================
  294. The System interface Class
  295. ===========================================
  296. */
  297. class CXConsole;
  298. //////////////////////////////////////////////////////////////////////
  299. //! ISystem implementation
  300. class CSystem
  301. : public ISystem
  302. , public ILoadConfigurationEntrySink
  303. , public ISystemEventListener
  304. , public IWindowMessageHandler
  305. , public AZ::RenderNotificationsBus::Handler
  306. , public CrySystemRequestBus::Handler
  307. , private AzFramework::Terrain::TerrainDataNotificationBus::Handler
  308. {
  309. public:
  310. inline void* operator new(std::size_t)
  311. {
  312. size_t allocated = 0;
  313. return CryMalloc(sizeof(CSystem), allocated, 64);
  314. }
  315. inline void operator delete(void* p)
  316. {
  317. CryFree(p, 64);
  318. }
  319. CSystem(SharedEnvironmentInstance* pSharedEnvironment);
  320. ~CSystem();
  321. static void OnLanguageCVarChanged(ICVar* language);
  322. static void OnLanguageAudioCVarChanged(ICVar* language);
  323. static void OnLocalizationFolderCVarChanged(ICVar* const pLocalizationFolder);
  324. // adding CVAR to toggle assert verbosity level
  325. static void OnAssertLevelCvarChanged(ICVar* pArgs);
  326. static void SetAssertLevel(int _assertlevel);
  327. static void OnLogLevelCvarChanged(ICVar* pArgs);
  328. static void SetLogLevel(int _logLevel);
  329. // interface ILoadConfigurationEntrySink ----------------------------------
  330. virtual void OnLoadConfigurationEntry(const char* szKey, const char* szValue, const char* szGroup);
  331. // ISystemEventListener
  332. virtual void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam);
  333. ///////////////////////////////////////////////////////////////////////////
  334. //! @name ISystem implementation
  335. //@{
  336. virtual bool Init(const SSystemInitParams& startupParams);
  337. virtual void Release();
  338. virtual SSystemGlobalEnvironment* GetGlobalEnvironment() { return &m_env; }
  339. virtual bool UpdatePreTickBus(int updateFlags = 0, int nPauseMode = 0);
  340. virtual bool UpdatePostTickBus(int updateFlags = 0, int nPauseMode = 0);
  341. virtual bool UpdateLoadtime();
  342. virtual void DoWorkDuringOcclusionChecks();
  343. virtual bool NeedDoWorkDuringOcclusionChecks() { return m_bNeedDoWorkDuringOcclusionChecks; }
  344. //! Begin rendering frame.
  345. void RenderBegin();
  346. //! Render subsystems.
  347. void Render();
  348. //! End rendering frame and swap back buffer.
  349. void RenderEnd(bool bRenderStats = true, bool bMainWindow = true);
  350. //Called when the renderer finishes rendering the scene
  351. void OnScene3DEnd() override;
  352. ////////////////////////////////////////////////////////////////////////
  353. // CrySystemRequestBus interface implementation
  354. ISystem* GetCrySystem() override;
  355. ////////////////////////////////////////////////////////////////////////
  356. //! Update screen during loading.
  357. void UpdateLoadingScreen();
  358. //! Update screen and call some important tick functions during loading.
  359. void SynchronousLoadingTick(const char* pFunc, int line);
  360. //! Renders the statistics; this is called from RenderEnd, but if the
  361. //! Host application (Editor) doesn't employ the Render cycle in ISystem,
  362. //! it may call this method to render the essential statistics
  363. void RenderStatistics() override;
  364. uint32 GetUsedMemory();
  365. virtual void DumpMemoryUsageStatistics(bool bUseKB);
  366. virtual void DumpMemoryCoverage();
  367. void CollectMemInfo(SCryEngineStatsGlobalMemInfo&);
  368. #ifndef _RELEASE
  369. virtual void GetCheckpointData(ICheckpointData& data);
  370. virtual void IncreaseCheckpointLoadCount();
  371. virtual void SetLoadOrigin(LevelLoadOrigin origin);
  372. #endif
  373. virtual bool SteamInit();
  374. void Relaunch(bool bRelaunch);
  375. bool IsRelaunch() const { return m_bRelaunch; };
  376. void SerializingFile(int mode) { m_iLoadingMode = mode; }
  377. int IsSerializingFile() const { return m_iLoadingMode; }
  378. void Quit();
  379. bool IsQuitting() const;
  380. void ShutdownFileSystem(); // used to cleanup any file resources, such as cache handle.
  381. bool IsShaderCacheGenMode() const { return m_bShaderCacheGenMode; }
  382. void SetAffinity();
  383. virtual const char* GetUserName();
  384. virtual int GetApplicationInstance();
  385. int GetApplicationLogInstance(const char* logFilePath) override;
  386. virtual sUpdateTimes& GetCurrentUpdateTimeStats();
  387. virtual const sUpdateTimes* GetUpdateTimeStats(uint32&, uint32&);
  388. IRenderer* GetIRenderer(){ return m_env.pRenderer; }
  389. ITimer* GetITimer(){ return m_env.pTimer; }
  390. AZ::IO::IArchive* GetIPak() { return m_env.pCryPak; };
  391. IConsole* GetIConsole() { return m_env.pConsole; };
  392. IRemoteConsole* GetIRemoteConsole();
  393. I3DEngine* GetI3DEngine(){ return m_env.p3DEngine; }
  394. IMovieSystem* GetIMovieSystem() { return m_env.pMovieSystem; };
  395. IMemoryManager* GetIMemoryManager(){ return m_pMemoryManager; }
  396. IThreadManager* GetIThreadManager() override {return m_env.pThreadManager; }
  397. ICryFont* GetICryFont(){ return m_env.pCryFont; }
  398. ILog* GetILog(){ return m_env.pLog; }
  399. ICmdLine* GetICmdLine(){ return m_pCmdLine; }
  400. IStreamEngine* GetStreamEngine();
  401. IValidator* GetIValidator() { return m_pValidator; };
  402. INameTable* GetINameTable() { return m_env.pNameTable; };
  403. IViewSystem* GetIViewSystem();
  404. ILevelSystem* GetILevelSystem();
  405. ISystemEventDispatcher* GetISystemEventDispatcher() { return m_pSystemEventDispatcher; }
  406. IThreadTaskManager* GetIThreadTaskManager();
  407. IResourceManager* GetIResourceManager();
  408. ITextModeConsole* GetITextModeConsole();
  409. IFileChangeMonitor* GetIFileChangeMonitor() { return m_env.pFileChangeMonitor; }
  410. IVisualLog* GetIVisualLog() { return m_env.pVisualLog; }
  411. INotificationNetwork* GetINotificationNetwork() { return m_pNotificationNetwork; }
  412. IProfilingSystem* GetIProfilingSystem() { return &m_ProfilingSystem; }
  413. ICryPerfHUD* GetPerfHUD() { return m_pPerfHUD; }
  414. IZLibCompressor* GetIZLibCompressor() { return m_pIZLibCompressor; }
  415. IZLibDecompressor* GetIZLibDecompressor() { return m_pIZLibDecompressor; }
  416. ILZ4Decompressor* GetLZ4Decompressor() { return m_pILZ4Decompressor; }
  417. IZStdDecompressor* GetZStdDecompressor() { return m_pIZStdDecompressor; }
  418. WIN_HWND GetHWND(){ return m_hWnd; }
  419. //////////////////////////////////////////////////////////////////////////
  420. // retrieves the perlin noise singleton instance
  421. CPNoise3* GetNoiseGen();
  422. virtual uint64 GetUpdateCounter() { return m_nUpdateCounter; };
  423. virtual void SetLoadingProgressListener(ILoadingProgressListener* pLoadingProgressListener)
  424. {
  425. m_pProgressListener = pLoadingProgressListener;
  426. };
  427. virtual ILoadingProgressListener* GetLoadingProgressListener() const
  428. {
  429. return m_pProgressListener;
  430. };
  431. void SetIMaterialEffects(IMaterialEffects* pMaterialEffects) { m_env.pMaterialEffects = pMaterialEffects; }
  432. void SetIOpticsManager(IOpticsManager* pOpticsManager) { m_env.pOpticsManager = pOpticsManager; }
  433. void SetIFileChangeMonitor(IFileChangeMonitor* pFileChangeMonitor) { m_env.pFileChangeMonitor = pFileChangeMonitor; }
  434. void SetIVisualLog(IVisualLog* pVisualLog) { m_env.pVisualLog = pVisualLog; }
  435. void DetectGameFolderAccessRights();
  436. virtual void ExecuteCommandLine(bool deferred=true);
  437. virtual void GetUpdateStats(SSystemUpdateStats& stats);
  438. //////////////////////////////////////////////////////////////////////////
  439. virtual XmlNodeRef CreateXmlNode(const char* sNodeName = "", bool bReuseStrings = false, bool bIsProcessingInstruction = false);
  440. virtual XmlNodeRef LoadXmlFromFile(const char* sFilename, bool bReuseStrings = false);
  441. virtual XmlNodeRef LoadXmlFromBuffer(const char* buffer, size_t size, bool bReuseStrings = false, bool bSuppressWarnings = false);
  442. virtual IXmlUtils* GetXmlUtils();
  443. //////////////////////////////////////////////////////////////////////////
  444. virtual Serialization::IArchiveHost* GetArchiveHost() const { return m_pArchiveHost; }
  445. void SetViewCamera(CCamera& Camera){ m_ViewCamera = Camera; }
  446. CCamera& GetViewCamera() { return m_ViewCamera; }
  447. virtual int GetCPUFlags()
  448. {
  449. int Flags = 0;
  450. if (!m_pCpu)
  451. {
  452. return Flags;
  453. }
  454. if (m_pCpu->hasMMX())
  455. {
  456. Flags |= CPUF_MMX;
  457. }
  458. if (m_pCpu->hasSSE())
  459. {
  460. Flags |= CPUF_SSE;
  461. }
  462. if (m_pCpu->hasSSE2())
  463. {
  464. Flags |= CPUF_SSE2;
  465. }
  466. if (m_pCpu->has3DNow())
  467. {
  468. Flags |= CPUF_3DNOW;
  469. }
  470. if (m_pCpu->hasF16C())
  471. {
  472. Flags |= CPUF_F16C;
  473. }
  474. return Flags;
  475. }
  476. virtual int GetLogicalCPUCount()
  477. {
  478. if (m_pCpu)
  479. {
  480. return m_pCpu->GetLogicalCPUCount();
  481. }
  482. return 0;
  483. }
  484. void IgnoreUpdates(bool bIgnore) { m_bIgnoreUpdates = bIgnore; };
  485. void SetIProcess(IProcess* process);
  486. IProcess* GetIProcess(){ return m_pProcess; }
  487. bool IsTestMode() const { return m_bTestMode; }
  488. //@}
  489. void SleepIfNeeded();
  490. virtual void DisplayErrorMessage(const char* acMessage, float fTime, const float* pfColor = 0, bool bHardError = true);
  491. virtual void FatalError(const char* format, ...) PRINTF_PARAMS(2, 3);
  492. virtual void ReportBug(const char* format, ...) PRINTF_PARAMS(2, 3);
  493. // Validator Warning.
  494. void WarningV(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, va_list args);
  495. void Warning(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, ...);
  496. virtual int ShowMessage(const char* text, const char* caption, unsigned int uType);
  497. bool CheckLogVerbosity(int verbosity);
  498. virtual void DebugStats(bool checkpoint, bool leaks);
  499. void DumpWinHeaps();
  500. virtual int DumpMMStats(bool log);
  501. //! Return pointer to user defined callback.
  502. ISystemUserCallback* GetUserCallback() const { return m_pUserCallback; };
  503. #if defined(CVARS_WHITELIST)
  504. virtual ICVarsWhitelist* GetCVarsWhiteList() const { return m_pCVarsWhitelist; };
  505. virtual ILoadConfigurationEntrySink* GetCVarsWhiteListConfigSink() const { return m_pCVarsWhitelistConfigSink; }
  506. #else
  507. virtual ILoadConfigurationEntrySink* GetCVarsWhiteListConfigSink() const { return nullptr; }
  508. #endif // defined(CVARS_WHITELIST)
  509. //////////////////////////////////////////////////////////////////////////
  510. virtual void SaveConfiguration();
  511. virtual void LoadConfiguration(const char* sFilename, ILoadConfigurationEntrySink* pSink = 0, bool warnIfMissing = true);
  512. virtual ESystemConfigSpec GetConfigSpec(bool bClient = true);
  513. virtual void SetConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform, bool bClient);
  514. virtual ESystemConfigSpec GetMaxConfigSpec() const;
  515. virtual ESystemConfigPlatform GetConfigPlatform() const;
  516. virtual void SetConfigPlatform(const ESystemConfigPlatform platform);
  517. //////////////////////////////////////////////////////////////////////////
  518. virtual int SetThreadState(ESubsystem subsys, bool bActive);
  519. virtual ICrySizer* CreateSizer();
  520. virtual bool IsPaused() const { return m_bPaused; };
  521. virtual ILocalizationManager* GetLocalizationManager();
  522. virtual void debug_GetCallStack(const char** pFunctions, int& nCount);
  523. virtual void debug_LogCallStack(int nMaxFuncs = 32, int nFlags = 0);
  524. // Get the current callstack in raw address form (more lightweight than the above functions)
  525. // static as memReplay needs it before CSystem has been setup - expose a ISystem interface to this function if you need it outside CrySystem
  526. static void debug_GetCallStackRaw(void** callstack, uint32& callstackLength);
  527. virtual ICryFactoryRegistry* GetCryFactoryRegistry() const;
  528. public:
  529. // this enumeration describes the purpose for which the statistics is gathered.
  530. // if it's gathered to be dumped, then some different rules may be applied
  531. enum MemStatsPurposeEnum
  532. {
  533. nMSP_ForDisplay, nMSP_ForDump, nMSP_ForCrashLog, nMSP_ForBudget
  534. };
  535. // collects the whole memory statistics into the given sizer object
  536. void CollectMemStats (class ICrySizer* pSizer, MemStatsPurposeEnum nPurpose = nMSP_ForDisplay, std::vector<SmallModuleInfo>* pStats = 0);
  537. void GetExeSizes (ICrySizer* pSizer, MemStatsPurposeEnum nPurpose = nMSP_ForDisplay);
  538. //! refreshes the m_pMemStats if necessary; creates it if it's not created
  539. void TickMemStats(MemStatsPurposeEnum nPurpose = nMSP_ForDisplay, IResourceCollector* pResourceCollector = 0);
  540. #if !defined(RELEASE)
  541. void SetVersionInfo(const char* const szVersion);
  542. #endif
  543. virtual bool InitializeEngineModule(const char* dllName, const char* moduleClassName, const SSystemInitParams& initParams) override;
  544. virtual bool UnloadEngineModule(const char* dllName, const char* moduleClassName);
  545. virtual const IImageHandler* GetImageHandler() const override { return m_imageHandler.get(); }
  546. void ShutdownModuleLibraries();
  547. #if defined(WIN32)
  548. friend LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  549. #endif
  550. virtual void* GetRootWindowMessageHandler();
  551. virtual void RegisterWindowMessageHandler(IWindowMessageHandler* pHandler);
  552. virtual void UnregisterWindowMessageHandler(IWindowMessageHandler* pHandler);
  553. // IWindowMessageHandler
  554. #if defined(WIN32)
  555. virtual bool HandleMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  556. #endif
  557. // ~IWindowMessageHandler
  558. private:
  559. // Release all resources.
  560. void ShutDown();
  561. void SleepIfInactive();
  562. bool LoadEngineDLLs();
  563. //! @name Initialization routines
  564. //@{
  565. bool InitConsole();
  566. bool InitRenderer(WIN_HINSTANCE hinst, WIN_HWND hwnd, const SSystemInitParams& initParams);
  567. bool InitFont(const SSystemInitParams& initParams);
  568. bool InitFileSystem();
  569. bool InitFileSystem_LoadEngineFolders(const SSystemInitParams& initParams);
  570. bool InitStreamEngine();
  571. bool Init3DEngine(const SSystemInitParams& initParams);
  572. bool InitAudioSystem(const SSystemInitParams& initParams);
  573. bool InitShine(const SSystemInitParams& initParams);
  574. bool OpenRenderLibrary(int type, const SSystemInitParams& initParams);
  575. bool OpenRenderLibrary(const char* t_rend, const SSystemInitParams& initParams);
  576. //@}
  577. //////////////////////////////////////////////////////////////////////////
  578. // Threading functions.
  579. //////////////////////////////////////////////////////////////////////////
  580. void InitThreadSystem();
  581. void ShutDownThreadSystem();
  582. //////////////////////////////////////////////////////////////////////////
  583. // Helper functions.
  584. //////////////////////////////////////////////////////////////////////////
  585. void CreateRendererVars(const SSystemInitParams& startupParams);
  586. void CreateSystemVars();
  587. void CreateAudioVars();
  588. void RenderStats();
  589. void RenderOverscanBorders();
  590. void RenderMemStats();
  591. AZStd::unique_ptr<AZ::DynamicModuleHandle> LoadDLL(const char* dllName);
  592. void FreeLib(AZStd::unique_ptr<AZ::DynamicModuleHandle>& hLibModule);
  593. bool UnloadDLL(const char* dllName);
  594. void QueryVersionInfo();
  595. void LogVersion();
  596. void LogBuildInfo();
  597. void SetDevMode(bool bEnable);
  598. void CreatePhysicsThread();
  599. void KillPhysicsThread();
  600. #ifndef _RELEASE
  601. static void SystemVersionChanged(ICVar* pCVar);
  602. #endif // #ifndef _RELEASE
  603. bool ReLaunchMediaCenter();
  604. void LogSystemInfo();
  605. void UpdateAudioSystems();
  606. void AddCVarGroupDirectory(const string& sPath);
  607. AZStd::unique_ptr<AZ::DynamicModuleHandle> LoadDynamiclibrary(const char* dllName) const;
  608. #if defined(AZ_RESTRICTED_PLATFORM)
  609. #define AZ_RESTRICTED_SECTION SYSTEM_H_SECTION_3
  610. #include AZ_RESTRICTED_FILE(System_h)
  611. #elif defined(WIN32)
  612. bool GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize);
  613. #endif
  614. //! \brief Initializes the given IFFont member variable with the given name (internal use only).
  615. bool LoadFontInternal(IFFont*& font, const string& fontName);
  616. public:
  617. void EnableFloatExceptions(int type);
  618. // interface ISystem -------------------------------------------
  619. virtual IDataProbe* GetIDataProbe() { return m_pDataProbe; };
  620. virtual void SetForceNonDevMode(const bool bValue);
  621. virtual bool GetForceNonDevMode() const;
  622. virtual bool WasInDevMode() const { return m_bWasInDevMode; };
  623. virtual bool IsDevMode() const { return m_bInDevMode && !GetForceNonDevMode(); }
  624. virtual bool IsMinimalMode() const { return m_bMinimal; }
  625. virtual bool IsMODValid(const char* szMODName) const
  626. {
  627. if (!szMODName || strstr(szMODName, ".") || strstr(szMODName, "\\"))
  628. {
  629. return (false);
  630. }
  631. return (true);
  632. }
  633. virtual void AutoDetectSpec(const bool detectResolution);
  634. virtual void AsyncMemcpy(void* dst, const void* src, size_t size, int nFlags, volatile int* sync)
  635. {
  636. #if !defined(CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM)
  637. cryAsyncMemcpy(dst, src, size, nFlags, sync);
  638. #else
  639. cryAsyncMemcpyDelegate(dst, src, size, nFlags, sync);
  640. #endif
  641. }
  642. virtual void SetConsoleDrawEnabled(bool enabled) { m_bDrawConsole = enabled; }
  643. virtual void SetUIDrawEnabled(bool enabled) { m_bDrawUI = enabled; }
  644. // -------------------------------------------------------------
  645. //! attaches the given variable to the given container;
  646. //! recreates the variable if necessary
  647. ICVar* attachVariable (const char* szVarName, int* pContainer, const char* szComment, int dwFlags = 0);
  648. CCpuFeatures* GetCPUFeatures() { return m_pCpu; };
  649. string& GetDelayedScreeenshot() {return m_sDelayedScreeenshot; }
  650. CVisRegTest*& GetVisRegTestPtrRef() {return m_pVisRegTest; }
  651. const CTimeValue& GetLastTickTime(void) const { return m_lastTickTime; }
  652. const ICVar* GetDedicatedMaxRate(void) const { return m_svDedicatedMaxRate; }
  653. const char* GetRenderingDriverName(void) const
  654. {
  655. if(m_rDriver)
  656. {
  657. return m_rDriver->GetString();
  658. }
  659. return nullptr;
  660. }
  661. std::shared_ptr<AZ::IO::FileIOBase> CreateLocalFileIO();
  662. // Gets the dimensions (in pixels) of the primary physical display.
  663. // Returns true if this info is available, returns false otherwise.
  664. bool GetPrimaryPhysicalDisplayDimensions(int& o_widthPixels, int& o_heightPixels);
  665. bool IsTablet();
  666. private: // ------------------------------------------------------
  667. // System environment.
  668. SSystemGlobalEnvironment m_env;
  669. CTimer m_Time; //!<
  670. CCamera m_ViewCamera; //!<
  671. bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps
  672. bool m_bShaderCacheGenMode;//!< true if the application runs in shader cache generation mode
  673. bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch)
  674. int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading)
  675. bool m_bTestMode; //!< If running in testing mode.
  676. bool m_bMinimal; //!< If running in 'minimal mode'.
  677. bool m_bEditor; //!< If running in Editor.
  678. bool m_bNoCrashDialog;
  679. bool m_bNoErrorReportWindow;
  680. bool m_bPreviewMode; //!< If running in Preview mode.
  681. bool m_bDedicatedServer; //!< If running as Dedicated server.
  682. bool m_bIgnoreUpdates; //!< When set to true will ignore Update and Render calls,
  683. IValidator* m_pValidator; //!< Pointer to validator interface.
  684. bool m_bForceNonDevMode; //!< true when running on a cheat protected server or a client that is connected to it (not used in singlplayer)
  685. bool m_bWasInDevMode; //!< Set to true if was in dev mode.
  686. bool m_bInDevMode; //!< Set to true if was in dev mode.
  687. bool m_bGameFolderWritable;//!< True when verified that current game folder have write access.
  688. SDefaultValidator* m_pDefaultValidator; //!<
  689. string m_sDelayedScreeenshot;//!< to delay a screenshot call for a frame
  690. CCpuFeatures* m_pCpu; //!< CPU features
  691. int m_ttMemStatSS; //!< Time to memstat screenshot
  692. string m_szCmdLine;
  693. int m_iTraceAllocations;
  694. #ifndef _RELEASE
  695. int m_checkpointLoadCount;// Total times game has loaded from a checkpoint
  696. LevelLoadOrigin m_loadOrigin; // Where the load was initiated from
  697. bool m_hasJustResumed; // Has resume game just been called
  698. bool m_expectingMapCommand;
  699. #endif
  700. bool m_bDrawConsole; //!< Set to true if OK to draw the console.
  701. bool m_bDrawUI; //!< Set to true if OK to draw UI.
  702. std::map<CCryNameCRC, AZStd::unique_ptr<AZ::DynamicModuleHandle> > m_moduleDLLHandles;
  703. //! THe streaming engine
  704. class CStreamEngine* m_pStreamEngine;
  705. //! current active process
  706. IProcess* m_pProcess;
  707. IMemoryManager* m_pMemoryManager;
  708. CCamera m_PhysRendererCamera;
  709. ICVar* m_p_draw_helpers_str;
  710. int m_iJumpToPhysProfileEnt;
  711. CTimeValue m_lastTickTime;
  712. //! system event dispatcher
  713. ISystemEventDispatcher* m_pSystemEventDispatcher;
  714. //! The default mono-spaced font for internal usage (profiling, debug info, etc.)
  715. IFFont* m_pIFont;
  716. //! The default font for end-user UI interfaces
  717. IFFont* m_pIFontUi;
  718. //! System to manage levels.
  719. ILevelSystem* m_pLevelSystem;
  720. //! System to manage views.
  721. IViewSystem* m_pViewSystem;
  722. //! System to access zlib compressor
  723. IZLibCompressor* m_pIZLibCompressor;
  724. //! System to access zlib decompressor
  725. IZLibDecompressor* m_pIZLibDecompressor;
  726. //! System to access lz4 hc decompressor
  727. ILZ4Decompressor* m_pILZ4Decompressor;
  728. //! System access to zstd decompressor
  729. IZStdDecompressor* m_pIZStdDecompressor;
  730. // XML Utils interface.
  731. class CXmlUtils* m_pXMLUtils;
  732. Serialization::IArchiveHost* m_pArchiveHost;
  733. int m_iApplicationInstance;
  734. //! to hold the values stored in system.cfg
  735. //! because editor uses it's own values,
  736. //! and then saves them to file, overwriting the user's resolution.
  737. int m_iHeight;
  738. int m_iWidth;
  739. int m_iColorBits;
  740. // System console variables.
  741. //////////////////////////////////////////////////////////////////////////
  742. // DLL names
  743. ICVar* m_sys_dll_response_system;
  744. #if !defined(_RELEASE)
  745. ICVar* m_sys_resource_cache_folder;
  746. #endif
  747. #if AZ_LOADSCREENCOMPONENT_ENABLED
  748. ICVar* m_game_load_screen_uicanvas_path;
  749. ICVar* m_level_load_screen_uicanvas_path;
  750. ICVar* m_game_load_screen_sequence_to_auto_play;
  751. ICVar* m_level_load_screen_sequence_to_auto_play;
  752. ICVar* m_game_load_screen_sequence_fixed_fps;
  753. ICVar* m_level_load_screen_sequence_fixed_fps;
  754. ICVar* m_game_load_screen_max_fps;
  755. ICVar* m_level_load_screen_max_fps;
  756. ICVar* m_game_load_screen_minimum_time{};
  757. ICVar* m_level_load_screen_minimum_time{};
  758. #endif // if AZ_LOADSCREENCOMPONENT_ENABLED
  759. ICVar* m_sys_initpreloadpacks;
  760. ICVar* m_sys_menupreloadpacks;
  761. ICVar* m_cvAIUpdate;
  762. ICVar* m_rWidth;
  763. ICVar* m_rHeight;
  764. ICVar* m_rWidthAndHeightAsFractionOfScreenSize;
  765. ICVar* m_rTabletWidthAndHeightAsFractionOfScreenSize;
  766. ICVar* m_rHDRDolby;
  767. ICVar* m_rMaxWidth;
  768. ICVar* m_rMaxHeight;
  769. ICVar* m_rColorBits;
  770. ICVar* m_rDepthBits;
  771. ICVar* m_rStencilBits;
  772. ICVar* m_rFullscreen;
  773. ICVar* m_rFullscreenWindow;
  774. ICVar* m_rFullscreenNativeRes;
  775. ICVar* m_rDriver;
  776. ICVar* m_rDisplayInfo;
  777. ICVar* m_rOverscanBordersDrawDebugView;
  778. ICVar* m_sysNoUpdate;
  779. ICVar* m_cvEntitySuppressionLevel;
  780. ICVar* m_pCVarQuit;
  781. ICVar* m_cvMemStats;
  782. ICVar* m_cvMemStatsThreshold;
  783. ICVar* m_cvMemStatsMaxDepth;
  784. ICVar* m_sysKeyboard;
  785. ICVar* m_sysWarnings; //!< might be 0, "sys_warnings" - Treat warning as errors.
  786. ICVar* m_cvSSInfo; //!< might be 0, "sys_SSInfo" 0/1 - get file sourcesafe info
  787. ICVar* m_svDedicatedMaxRate;
  788. ICVar* m_sys_GraphicsQuality;
  789. ICVar* m_sys_firstlaunch;
  790. ICVar* m_sys_asset_processor;
  791. ICVar* m_sys_load_files_to_memory;
  792. ICVar* m_sys_physics_CPU;
  793. #if defined(AZ_RESTRICTED_PLATFORM)
  794. #define AZ_RESTRICTED_SECTION SYSTEM_H_SECTION_4
  795. #include AZ_RESTRICTED_FILE(System_h)
  796. #endif
  797. ICVar* m_sys_audio_disable;
  798. ICVar* m_sys_min_step;
  799. ICVar* m_sys_max_step;
  800. ICVar* m_sys_enable_budgetmonitoring;
  801. ICVar* m_sys_memory_debug;
  802. ICVar* m_sys_preload;
  803. // ICVar *m_sys_filecache;
  804. ICVar* m_gpu_particle_physics;
  805. string m_sSavedRDriver; //!< to restore the driver when quitting the dedicated server
  806. //////////////////////////////////////////////////////////////////////////
  807. //! User define callback for system events.
  808. ISystemUserCallback* m_pUserCallback;
  809. #if defined(CVARS_WHITELIST)
  810. //////////////////////////////////////////////////////////////////////////
  811. //! User define callback for whitelisting cvars
  812. ICVarsWhitelist* m_pCVarsWhitelist;
  813. ILoadConfigurationEntrySink* m_pCVarsWhitelistConfigSink;
  814. #endif // defined(CVARS_WHITELIST)
  815. WIN_HWND m_hWnd;
  816. WIN_HINSTANCE m_hInst;
  817. // this is the memory statistics that is retained in memory between frames
  818. // in which it's not gathered
  819. class CrySizerStats* m_pMemStats;
  820. class CrySizerImpl* m_pSizer;
  821. ICryPerfHUD* m_pPerfHUD;
  822. minigui::IMiniGUI* m_pMiniGUI;
  823. //int m_nCurrentLogVerbosity;
  824. SFileVersion m_fileVersion;
  825. SFileVersion m_productVersion;
  826. SFileVersion m_buildVersion;
  827. IDataProbe* m_pDataProbe;
  828. class CLocalizedStringsManager* m_pLocalizationManager;
  829. // Name table.
  830. CNameTable m_nameTable;
  831. IThreadTask* m_PhysThread;
  832. ESystemConfigSpec m_nServerConfigSpec;
  833. ESystemConfigSpec m_nMaxConfigSpec;
  834. ESystemConfigPlatform m_ConfigPlatform;
  835. std::unique_ptr<CServerThrottle> m_pServerThrottle;
  836. CProfilingSystem m_ProfilingSystem;
  837. sUpdateTimes m_UpdateTimes[NUM_UPDATE_TIMES];
  838. uint32 m_UpdateTimesIdx;
  839. // Pause mode.
  840. bool m_bPaused;
  841. bool m_bNoUpdate;
  842. uint64 m_nUpdateCounter;
  843. bool m_executedCommandLine = false;
  844. AZStd::unique_ptr<AzFramework::MissingAssetLogger> m_missingAssetLogger;
  845. public:
  846. ICVar* m_sys_main_CPU;
  847. ICVar* m_sys_streaming_CPU;
  848. ICVar* m_sys_TaskThread_CPU[MAX_THREAD_POOL_INDEX];
  849. //////////////////////////////////////////////////////////////////////////
  850. // File version.
  851. //////////////////////////////////////////////////////////////////////////
  852. virtual const SFileVersion& GetFileVersion();
  853. virtual const SFileVersion& GetProductVersion();
  854. virtual const SFileVersion& GetBuildVersion();
  855. bool CompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize, int level);
  856. bool DecompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize);
  857. bool InitVTuneProfiler();
  858. void OpenBasicPaks();
  859. void OpenLanguagePak(const char* sLanguage);
  860. void OpenLanguageAudioPak(const char* sLanguage);
  861. void GetLocalizedPath(const char* sLanguage, string& sLocalizedPath);
  862. void GetLocalizedAudioPath(const char* sLanguage, string& sLocalizedPath);
  863. void CloseLanguagePak(const char* sLanguage);
  864. void CloseLanguageAudioPak(const char* sLanguage);
  865. void UpdateMovieSystem(const int updateFlags, const float fFrameTime, const bool bPreUpdate);
  866. //////////////////////////////////////////////////////////////////////////
  867. // CryAssert and error related.
  868. virtual bool RegisterErrorObserver(IErrorObserver* errorObserver);
  869. bool UnregisterErrorObserver(IErrorObserver* errorObserver);
  870. virtual void OnAssert(const char* condition, const char* message, const char* fileName, unsigned int fileLineNumber);
  871. void OnFatalError(const char* message);
  872. bool IsAssertDialogVisible() const;
  873. void SetAssertVisible(bool bAssertVisble);
  874. //////////////////////////////////////////////////////////////////////////
  875. virtual void ClearErrorMessages()
  876. {
  877. m_ErrorMessages.clear();
  878. }
  879. bool IsLoading()
  880. {
  881. return m_eRuntimeState == ESYSTEM_EVENT_LEVEL_LOAD_START_LOADINGSCREEN;
  882. }
  883. virtual ESystemGlobalState GetSystemGlobalState(void);
  884. virtual void SetSystemGlobalState(const ESystemGlobalState systemGlobalState);
  885. #if !defined(_RELEASE)
  886. virtual bool IsSavingResourceList() const { return (g_cvars.archiveVars.nSaveLevelResourceList != 0); }
  887. #endif
  888. private:
  889. std::vector<IErrorObserver*> m_errorObservers;
  890. ESystemGlobalState m_systemGlobalState;
  891. static const char* GetSystemGlobalStateName(const ESystemGlobalState systemGlobalState);
  892. ///////////////////////////////////////////////////////////////////////////
  893. // AzFramework::Terrain::TerrainDataNotificationBus START
  894. void OnTerrainDataCreateBegin() override;
  895. void OnTerrainDataDestroyBegin() override;
  896. // AzFramework::Terrain::TerrainDataNotificationBus END
  897. ///////////////////////////////////////////////////////////////////////////
  898. public:
  899. void InitLocalization();
  900. void UpdateUpdateTimes();
  901. protected: // -------------------------------------------------------------
  902. ILoadingProgressListener* m_pProgressListener;
  903. CCmdLine* m_pCmdLine;
  904. CVisRegTest* m_pVisRegTest;
  905. CThreadManager* m_pThreadManager;
  906. CThreadTaskManager* m_pThreadTaskManager;
  907. class CResourceManager* m_pResourceManager;
  908. ITextModeConsole* m_pTextModeConsole;
  909. INotificationNetwork* m_pNotificationNetwork;
  910. string m_currentLanguageAudio;
  911. string m_systemConfigName; // computed from system_(hardwareplatform)_(assetsPlatform) - eg, system_android_es3.cfg or system_android_opengl.cfg or system_windows_pc.cfg
  912. std::vector< std::pair<CTimeValue, float> > m_updateTimes;
  913. CMemoryFragmentationProfiler m_MemoryFragmentationProfiler;
  914. struct SErrorMessage
  915. {
  916. string m_Message;
  917. float m_fTimeToShow;
  918. float m_Color[4];
  919. bool m_HardFailure;
  920. };
  921. typedef std::list<SErrorMessage> TErrorMessages;
  922. TErrorMessages m_ErrorMessages;
  923. bool m_bHasRenderedErrorMessage;
  924. bool m_bNeedDoWorkDuringOcclusionChecks;
  925. ESystemEvent m_eRuntimeState;
  926. bool m_bIsAsserting;
  927. friend struct SDefaultValidator;
  928. friend struct SCryEngineFoldersLoader;
  929. // friend void ScreenshotCmd( IConsoleCmdArgs *pParams );
  930. bool m_bIsSteamInitialized;
  931. std::unique_ptr<IImageHandler> m_imageHandler;
  932. std::vector<IWindowMessageHandler*> m_windowMessageHandlers;
  933. bool m_initedOSAllocator = false;
  934. bool m_initedSysAllocator = false;
  935. AZStd::unique_ptr<ThermalInfoHandler> m_thermalInfoHandler;
  936. };