Beispiel #1
0
        public static void LoadMemoryMap()
        {
            if (_memoryMap != null && _mapViewSteam != null)
            {
                return;
            }

            if (string.IsNullOrEmpty(TerrainFilePath))
            {
                SetTerrainDataPath();
            }

            string memoryMapFile = Path.Combine(TerrainFilePath, TERRAIN_FILE_NAME);

            if (!System.IO.File.Exists(memoryMapFile))
            {
                memoryMapFile = "C:\\terrain.bin"; //hack for unit tests!
            }

            try
            {
                GameManager.Instance.Log.LogDebug("TerrainReader->LoadMemoryMap initializing. Reading terrain file: <" + memoryMapFile + "> .");
                _memoryMap    = MemoryMappedFile.Create(memoryMapFile, MapProtection.PageReadOnly);
                _mapViewSteam = _memoryMap.MapAsStream();
            }
            catch (Exception ex)
            {
                GameManager.Instance.Log.LogError("TerrainReader->LoadMemoryMap failed to load terrain from <" + memoryMapFile + "> ." + ex.Message);
                GameManager.Instance.Log.LogError(ex.ToString());
            }
        }