Exemplo n.º 1
0
        /// <summary>
        /// Closes the map resources
        /// </summary>
        /// <remarks>Eg, tag manager, string id manager, IO streams, etc</remarks>
        public virtual void Close()
        {
            if (!CacheId.IsNull)
            {
                CloseTagIndexManager();

                refManager = null;

                StringIdManagerDispose();

                if (!IsSharedReference && InputStream != null)
                {
                    InputStream.Close();
                }
                InputStream = null;

                if (!IsSharedReference && OutputStream != null)
                {
                    OutputStream.Close();
                }
                OutputStream = null;

                CacheId = DatumIndex.Null;
            }
        }
Exemplo n.º 2
0
 public void Close()
 {
     if (InputStream != null)
     {
         InputStream.Close(); InputStream = null;
     }
     if (OutputStream != null)
     {
         OutputStream.Close(); OutputStream = null;
     }
 }
        /// <summary>
        /// Creates the file
        /// </summary>
        /// <remarks>Closes existing file streams</remarks>
        public void Create()
        {
            string dir = System.IO.Path.GetDirectoryName(path);

            if (!System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.CreateDirectory(dir);
            }

            if (!System.IO.File.Exists(path))
            {
                System.IO.File.Create(path).Close();
            }

            if (InputStream != null)
            {
                InputStream.Close(); InputStream = null;
            }
            if (OutputStream != null)
            {
                OutputStream.Close(); OutputStream = null;
            }
        }
Exemplo n.º 4
0
        public static bool DetermineEngineFromMapFile(string fileName, out string engine, out string mapName)
        {
            // Clear our out values
            engine  = "";
            mapName = "";

            // Check the file exists
            if (System.IO.File.Exists(fileName) == false)
            {
                // Output error and return false
                Console.WriteLine("Error file \"{0}\" not found!", fileName);
                return(false);
            }

            // Create a new endian reader
            IO.EndianReader br = new IO.EndianReader(IO.Endianness.Little, new System.IO.FileStream(fileName,
                                                                                                    System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read));

            // Check for the 'head' or 'daeh' identifier
            bool result    = false;
            int  headMagic = br.ReadInt32();

            if (headMagic == /* 'head' */ 0x64616568)
            {
                // Big endian map, ex halo 3
            }
            else if (headMagic == /* 'daeh' */ 0x68656164)
            {
                // Check engine version
                int engineVersion = br.ReadInt32();
                if (engineVersion == 8)
                {
                    // Halo 2 map, but we need to check the build date to determine which version of halo 2
                    br.BaseStream.Position = 288;
                    if (br.ReadInt32() == 0)
                    {
                        // There is no build date at 288, advance to 300 and check if it is a halo 2 vista map
                        br.BaseStream.Position = 300;
                    }
                    else
                    {
                        // Parse the whole build date so we can check it
                        br.BaseStream.Position = 288;
                        string buildDate = new string(br.ReadChars(32)).Replace("\0", "");

                        // Check if the map is a final or beta build map
                        if (buildDate.Equals("02.09.27.09809") == true)
                        {
                            // It's a final halo 2 xbox map
                            engine = "Halo2Xbox";

                            // Read the map name
                            br.BaseStream.Position = 408;
                            mapName = new string(br.ReadChars(32)).Replace("\0", "");

                            // Done
                            result = true;
                        }
                        else if (buildDate.Equals("02.06.28.07902") == true)
                        {
                            // It's a halo 2 beta map
                            engine = "Halo2Beta";

                            // Read the map name
                            br.BaseStream.Position = 408;
                            mapName = new string(br.ReadChars(32)).Replace("\0", "");

                            // Done
                            result = true;
                        }
                    }
                }
            }

            // Close the reader
            br.Close();

            // Done
            return(result);
        }