Пример #1
0
 public Map(string Path, bool Loaded)
 {
     this.Path   = Path;
     this.Loaded = Loaded;
     if (!Loaded)
     {
         FS     = new FileStream(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
         Reader = new BinaryReader(FS);
         Writer = new BinaryWriter(FS);
     }
     else
     {
         FS     = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read);
         Reader = new BinaryReader(FS);
         Writer = new BinaryWriter(new FileStream(Environment.GetLogicalDrives()[0] + "\\Data.Ambiguous", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite));
     }
     Header = MapHeader.GetHeader(Reader);
     FS.Flush();
     Index = MapIndex.GetMapIndex(Reader, Header);
     FS.Flush();
     StringTable = new SIDTable(this);
     FS.Flush();
     Tags = new TagTable(this);
     if (Header.MapName.Trim('\0') == "shared")
     {
         Index.SecondaryMagic += 0x3C000;
     }
 }
Пример #2
0
 public Map(string Path, bool Loaded)
 {
     this.Path = Path;
     this.Loaded = Loaded;
     if (!Loaded)
     {
         FS = new FileStream(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
         Reader = new BinaryReader(FS);
         Writer = new BinaryWriter(FS);
     }
     else
     {
         FS = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read);
         Reader = new BinaryReader(FS);
         Writer = new BinaryWriter(new FileStream(Environment.GetLogicalDrives()[0] + "\\Data.Ambiguous", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite));
     }
     Header = MapHeader.GetHeader(Reader);
     FS.Flush();
     Index = MapIndex.GetMapIndex(Reader, Header);
     FS.Flush();
     StringTable = new SIDTable(this);
     FS.Flush();
     Tags = new TagTable(this);
     if (Header.MapName.Trim('\0') == "shared")
         Index.SecondaryMagic += 0x3C000;
 }
Пример #3
0
        public static MapIndex GetMapIndex(BinaryReader Reader, MapHeader Header)
        {
            MapIndex Base = new MapIndex();

            Reader.BaseStream.Position = Header.IndexOffset;
            Base.IndexHeaderSize       = Reader.ReadInt32();
            Reader.ReadInt32();
            Base.TagStart              = Reader.ReadInt32() + Header.IndexOffset;
            Base.PrimaryMagic          = Reader.ReadInt32() - (Header.IndexOffset + 32);
            Reader.BaseStream.Position = Base.TagStart + 8;
            Base.SecondaryMagic        = Reader.ReadInt32() - (Header.IndexOffset + Header.IndexSize);
            return(Base);
        }
Пример #4
0
        public static MapHeader GetHeader(BinaryReader Reader)
        {
            MapHeader Base = new MapHeader();

            Reader.BaseStream.Position = 4;
            Base.EngineBuildVersion    = Reader.ReadInt32();
            if (Base.EngineBuildVersion != 8)
            {
                throw new Exception("Not a Halo 2 Map Stupid.");
            }
            Base.MapFileSize            = Reader.ReadInt32();
            Reader.BaseStream.Position += 4;
            Base.IndexOffset            = Reader.ReadInt32();
            Base.IndexSize              = Reader.ReadInt32();
            Base.MetaTableSize          = Reader.ReadInt32();
            Base.UnRawSize              = Reader.ReadInt32();
            Reader.BaseStream.Position  = 300;
            Base.BuildDate              = new string(Reader.ReadChars(32));
            Reader.BaseStream.Position  = 420;
            Base.MapName  = new string(Reader.ReadChars(36));
            Base.Scenario = new string(Reader.ReadChars(80));
            Reader.BaseStream.Position = 364;
            Base.SIDMetaTableOffset    = Reader.ReadInt32();
            Base.SIDCount              = Reader.ReadInt32();
            Base.SIDTableSize          = Reader.ReadInt32();
            Base.SIDIndexOffset        = Reader.ReadInt32();
            Base.SIDTableOffset        = Reader.ReadInt32();
            Reader.BaseStream.Position = 716;
            Base.TagCount              = Reader.ReadInt32();
            Base.FileTableOffset       = Reader.ReadInt32();
            Base.FileTableSize         = Reader.ReadInt32();
            Base.FileTableIndexOffset  = Reader.ReadInt32();
            Reader.BaseStream.Position = 744;
            Base.ModelRawTableStart    = Reader.ReadInt32();
            Base.ModelRawTableSize     = Reader.ReadInt32();
            Base.Checksum              = Reader.ReadInt32();
            return(Base);
        }
Пример #5
0
 public static MapIndex GetMapIndex(BinaryReader Reader, MapHeader Header)
 {
     MapIndex Base = new MapIndex();
     Reader.BaseStream.Position = Header.IndexOffset;
     Base.IndexHeaderSize = Reader.ReadInt32();
     Reader.ReadInt32();
     Base.TagStart = Reader.ReadInt32() + Header.IndexOffset;
     Base.PrimaryMagic = Reader.ReadInt32() - (Header.IndexOffset + 32);
     Reader.BaseStream.Position = Base.TagStart + 8;
     Base.SecondaryMagic = Reader.ReadInt32() - (Header.IndexOffset + Header.IndexSize);
     return Base;
 }
Пример #6
0
 public static MapHeader GetHeader(BinaryReader Reader)
 {
     MapHeader Base = new MapHeader();
     Reader.BaseStream.Position = 4;
     Base.EngineBuildVersion = Reader.ReadInt32();
     if (Base.EngineBuildVersion != 8)
         throw new Exception("Not a Halo 2 Map Stupid.");
     Base.MapFileSize = Reader.ReadInt32();
     Reader.BaseStream.Position += 4;
     Base.IndexOffset = Reader.ReadInt32();
     Base.IndexSize = Reader.ReadInt32();
     Base.MetaTableSize = Reader.ReadInt32();
     Base.UnRawSize = Reader.ReadInt32();
     Reader.BaseStream.Position = 300;
     Base.BuildDate = new string(Reader.ReadChars(32));
     Reader.BaseStream.Position = 420;
     Base.MapName = new string(Reader.ReadChars(36));
     Base.Scenario = new string(Reader.ReadChars(80));
     Reader.BaseStream.Position = 364;
     Base.SIDMetaTableOffset = Reader.ReadInt32();
     Base.SIDCount = Reader.ReadInt32();
     Base.SIDTableSize = Reader.ReadInt32();
     Base.SIDIndexOffset = Reader.ReadInt32();
     Base.SIDTableOffset = Reader.ReadInt32();
     Reader.BaseStream.Position = 716;
     Base.TagCount = Reader.ReadInt32();
     Base.FileTableOffset = Reader.ReadInt32();
     Base.FileTableSize = Reader.ReadInt32();
     Base.FileTableIndexOffset = Reader.ReadInt32();
     Reader.BaseStream.Position = 744;
     Base.ModelRawTableStart = Reader.ReadInt32();
     Base.ModelRawTableSize = Reader.ReadInt32();
     Base.Checksum = Reader.ReadInt32();
     return Base;
 }