/// <summary> /// Stream the field from a tag stream /// </summary> /// <param name="ts"></param> /// <exception cref="Exceptions.InvalidStringId"></exception> public override void Read(IO.ITagStream ts) { if (Handle.Set == -1) // HACK used to tell Read that we already read the string data (as this is an old halo 2 tag) { Handle = new Blam.StringId(Handle.Description, Handle.Index, Handle.Length, 0); return; } if (!ts.Flags.Test(IO.ITagStreamFlags.DontStreamStringData)) // stream the string id value if we can { IO.EndianReader s = ts.GetInputStream(); relativeOffset = s.PositionUnsigned; string value = null; try { value = new string(s.ReadChars(Handle.Length)); if (Handle != Blam.StringId.Null) { Program.GetTagIndex(OwnerId).StringIds.TryAndGetStringId(value, out Handle); } } catch (Exception ex) { throw new Exceptions.InvalidStringId(ex, base.headerOffset, base.relativeOffset, ts, Handle.Length, value); } } }
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); }