Exemplo n.º 1
0
        public void Read(BlamLib.IO.EndianReader s)
        {
            DataOffset = s.ReadInt32();
            DataSize   = s.ReadInt32();
            int name_length = s.ReadInt32();

            if (name_length > 0)
            {
                Name = s.ReadAsciiString(name_length);
            }
            else
            {
                Name = string.Empty;
            }
            Type     = (DataType)s.ReadInt32();
            unknown1 = s.ReadInt32();
            unknown2 = s.ReadInt32();

            if (unknown1 != 0)
            {
                System.Diagnostics.Debugger.Break();
            }
            if (unknown2 != 0)
            {
                System.Diagnostics.Debugger.Break();
            }
        }
Exemplo n.º 2
0
            void DisallowTags()
            {
                BlamLib.IO.EndianReader input = new BlamLib.IO.EndianReader(output.FileName);
                input.BaseAddress = Program.PeAddressMask;
                input.Seek(AddressOf.TagGroupDefinitions[Platform.Guerilla] - Program.PeAddressMask);

                uint[] offsets = new uint[Constants.StockTagGroupCount];
                for (int x = 0; x < offsets.Length; x++)
                {
                    offsets[x] = input.ReadPointer();
                }

                for (int x = 0; x < offsets.Length; x++)
                {
                    input.Seek(offsets[x]);
                    string name = Program.ReadCString(input.ReadPointer(), input);
                    if (IsDisallowedTag(name))
                    {
                        input.Seek(0x20, System.IO.SeekOrigin.Current);
                        output.Seek(input.Position - 2);
                        output.Write((short)1);
                        output.Seek(input.ReadPointer() + 0x14);
                        output.Write(0);
                        output.Write(0);
                        output.Write(0);
                    }
                }
                input.Close();
            }
        public override void Read(BlamLib.IO.EndianReader s)
        {
            if (isLoaded)
            {
                return;
            }

            // goto the start if we're leaching off another cache's IO
            if (IsSharedReference)
            {
                s.Seek(0);
            }

            cacheHeader.Read(s);

            DetermineEngineVersion();

            // Shared caches can't be loaded from here
            if (cacheHeader.SharedType == Cache.SharedType.Shared ||
                cacheHeader.SharedType == Cache.SharedType.Campaign)
            {
                throw new SharedCacheAccessException();
            }

            TagIndexInitializeAndRead(s);

            isLoaded = true;
        }
 public void Read(BlamLib.IO.EndianReader s)
 {
     X = s.ReadSingle();
     Y = s.ReadSingle();
     Z = s.ReadSingle();
     W = s.ReadSingle();
 }
Exemplo n.º 5
0
 public void Read(BlamLib.IO.EndianReader s)
 {
     Stubbs.Read(s);
     Halo1.Read(s);
     Halo2.Read(s);
     Halo3.Read(s);
 }
 public void Read(BlamLib.IO.EndianReader s)
 {
     X = s.ReadUInt16();
     Y = s.ReadUInt16();
     Z = s.ReadUInt16();
     W = s.ReadUInt16();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Postprocess a tag block that has been streamed to a cache block
        /// </summary>
        /// <param name="locator">Offset of the tag block header in the section</param>
        /// <param name="block"></param>
        /// <returns></returns>
        internal bool ReconstructTagBlock(short locator, TagInterface.IBlock block)
        {
            int index = 0;

            if (GeometryBlock == null)
            {
                return(false);
            }

            foreach (geometry_block_resource_block gb in Resources)
            {
                using (IO.EndianReader er = new BlamLib.IO.EndianReader(GeometryBlock[index]))
                {
                    switch (gb.Type.Value)
                    {
                        #region TagBlock
                    case (int)geometry_block_resource_type.TagBlock:
                        int count = gb.GetCount();
                        if (gb.PrimaryLocater.Value == locator)
                        {
                            block.Resize(count);
                            block.Read(er);
                        }
                        break;
                        #endregion
                    }

                    index++;
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        public static string ReadCString(uint offset, BlamLib.IO.EndianReader io)
        {
            if (offset == 0)
            {
                return(string.Empty);
            }

            uint pos = io.PositionUnsigned;

            io.Seek(offset);

            byte btchar  = 0;
            var  cstring = new System.Text.StringBuilder();

            do
            {
                btchar = io.ReadByte();
                if (btchar != 0)
                {
                    cstring.Append((char)btchar);
                }
            } while (btchar != 0);

            io.Seek(pos);

            return(cstring.ToString());
        }
Exemplo n.º 9
0
        /// <summary>
        /// Postprocess tag data that has been streamed to a cache block
        /// </summary>
        /// <param name="locator">Offset of the tag data header in the section</param>
        /// <param name="data"></param>
        /// <returns></returns>
        internal bool ReconstructTagData(short locator, TagInterface.Data data)
        {
            int index = 0;

            IO.EndianReader er;

            if (GeometryBlock == null)
            {
                return(false);
            }

            foreach (geometry_block_resource_block gb in Resources)
            {
                er = new BlamLib.IO.EndianReader(GeometryBlock[index]);

                switch (gb.Type.Value)
                {
                    #region TagData
                case (int)geometry_block_resource_type.TagData:
                    if (gb.PrimaryLocater.Value == locator)
                    {
                        data.Reset(er.ReadBytes(gb.Size));
                    }
                    break;
                    #endregion
                }

                index++;
                er.Close();
                er = null;
            }

            return(true);
        }
        public override void Read(BlamLib.IO.EndianReader s)
        {
            CacheFile cache = s.Owner as CacheFile;
            bool      isPC  = cache.EngineVersion.IsPc() || cache.EngineVersion == BlamVersion.Halo1_XboxX;

            #region base address
            Managers.BlamDefinition bdef = Program.GetManager(cache.EngineVersion);

            cache.AddressMask = bdef[cache.EngineVersion].CacheTypes.BaseAddress
                                - (uint)cache.Header.OffsetToIndex;
            #endregion

            address = s.ReadUInt32();
            scenario.Read(s);
            s.ReadInt32();             // CRC
            tagCount            = s.ReadInt32();
            vertexBufferCount   = s.ReadInt32();
            vertexBufferAddress = s.ReadUInt32(); vertexBufferOffset = (int)(vertexBufferAddress - cache.AddressMask);
            indexBufferCount    = s.ReadInt32();
            indexBufferAddress  = s.ReadUInt32(); indexBufferOffset = (int)(indexBufferAddress - cache.AddressMask);
            if (isPC)
            {
                s.ReadInt32();         // total vertex and index buffer size
            }
            s.ReadInt32();             // 'tags'

            tagsOffset = s.PositionUnsigned;

            ReadTagInstances(s, cache);

            InitializeBspTags(s, cache);
        }
Exemplo n.º 11
0
        public override void Read(BlamLib.IO.EndianReader s)
        {
            var gd = Program.Halo2.Manager;

            uint gt = s.ReadUInt32();

            if (gt != uint.MaxValue)
            {
                GroupTag1 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
            }
            else
            {
                GroupTag1 = TagInterface.TagGroup.Null;
            }

            gt = s.ReadUInt32();
            if (gt != uint.MaxValue)
            {
                GroupTag2 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
            }
            else
            {
                GroupTag2 = TagInterface.TagGroup.Null;
            }

            gt = s.ReadUInt32();
            if (gt != uint.MaxValue)
            {
                GroupTag3 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
            }
            else
            {
                GroupTag3 = TagInterface.TagGroup.Null;
            }
        }
Exemplo n.º 12
0
 public override void Read(BlamLib.IO.EndianReader s)
 {
     GroupIndex = (short)(datum.Index = s.ReadUInt16());
     datum.Salt = (short)s.ReadUInt16();
     address    = s.ReadUInt32();
     offset     = (int)(address - s.BaseAddress);
     size       = 0;
 }
 protected void ReadTagInstances(BlamLib.IO.EndianReader s)
 {
     items = new Cache.CacheItemGen3[tagCount];
     s.Seek(tagsOffset, System.IO.SeekOrigin.Begin);
     for (int x = 0; x < tagCount; x++)
     {
         (items[x] = new Cache.CacheItemGen3()).Read(s);
     }
 }
Exemplo n.º 14
0
 public void Read(BlamLib.IO.EndianReader s)
 {
     s.Seek(4 + 4, System.IO.SeekOrigin.Current);
     Count.Read(s);
     Size.Read(s);
     OffsetReferences.Read(s);
     OffsetStrings.Read(s);
     s.Seek(1 + 3, System.IO.SeekOrigin.Current);
 }
 void ReadGroupTags(BlamLib.IO.EndianReader s)
 {
     groupTags = new Halo4.CacheItemGroupTag[groupTagsCount];
     s.Seek(groupTagsOffset, System.IO.SeekOrigin.Begin);
     for (int x = 0; x < groupTagsCount; x++)
     {
         (groupTags[x] = new Halo4.CacheItemGroupTag()).Read(s);
     }
 }
Exemplo n.º 16
0
        internal bool Reconstruct(geometry_block_info_struct gbi)
        {
            int index = 0;

            byte[][] data = gbi.GeometryBlock;

            if (data == null)
            {
                return(false);
            }

            foreach (geometry_block_resource_block gb in gbi.Resources)
            {
                using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
                {
                    switch (gb.Type.Value)
                    {
                        #region TagBlock
                    case (int)geometry_block_resource_type.TagBlock:
                        int count = gb.GetCount();
                        switch (gb.PrimaryLocater.Value)
                        {
                        case OffsetPlacements:
                            Placements.Resize(count);
                            Placements.Read(er);
                            break;

                        case OffsetDecalVertices:
                            DecalVertices.Resize(count);
                            DecalVertices.Read(er);
                            break;

                        case OffsetDecalIndices:
                            DecalIndices.Resize(count);
                            DecalIndices.Read(er);
                            break;

                        case OffsetSpriteVertices:
                            SpriteVertices.Resize(count);
                            SpriteVertices.Read(er);
                            break;

                        case OffsetSpriteIndices:
                            SpriteIndices.Resize(count);
                            SpriteIndices.Read(er);
                            break;
                        }
                        break;
                        #endregion
                    }
                }

                index++;
            }

            return(true);
        }
Exemplo n.º 17
0
 void ReadGroupTags(BlamLib.IO.EndianReader s)
 {
     groupTags = CreateEngineItemGroupTags(groupTagsCount);
     s.Seek(groupTagsOffset, System.IO.SeekOrigin.Begin);
     for (int x = 0; x < groupTagsCount; x++)
     {
         (groupTags[x] = CreateEngineItemGroupTag()).Read(s);
     }
 }
Exemplo n.º 18
0
        protected void TagIndexInitializeAndRead(BlamLib.IO.EndianReader s)
        {
            base.StringIdManagerInitializeAndRead();
            base.InitializeReferenceManager(s.FileName);
            base.InitializeTagIndexManager();

            s.Seek(cacheHeader.OffsetToIndex, System.IO.SeekOrigin.Begin);
            cacheIndex.Read(s);
        }
 protected void ReadDependents(BlamLib.IO.EndianReader s)
 {
     DependentDatums = new DatumIndex[dependentTagsCount];
     s.Seek(dependentTagsOffset, System.IO.SeekOrigin.Begin);
     for (int x = 0; x < dependentTagsCount; x++)
     {
         s.Seek(sizeof(uint), System.IO.SeekOrigin.Current);                 // group tag
         DependentDatums[x].Read(s);
     }
 }
Exemplo n.º 20
0
 public void Read(BlamLib.IO.EndianReader s)
 {
     // cache resource object ptr
     s.ReadInt32();             // only used at runtime, reset when read from disk
     size = s.ReadInt32();
     // data ptr
     s.ReadInt32();             // only used at runtime, reset when read from disk
     nameHash = s.ReadUInt32();
     offset.Read(s);
 }
Exemplo n.º 21
0
        public CacheItemGroupTag[] ReadGroupTags(BlamLib.IO.EndianReader s)
        {
            CacheItemGroupTag[] group_tags = new CacheItemGroupTag[groupTagsCount];
            s.Seek(groupTagsOffset, System.IO.SeekOrigin.Begin);
            for (int x = 0; x < groupTagsCount; x++)
            {
                (group_tags[x] = new CacheItemGroupTag()).Read(s);
            }

            return(group_tags);
        }
Exemplo n.º 22
0
		internal bool Reconstruct(geometry_block_info_struct gbi)
		{
			int index = 0;
			byte[][] data = gbi.GeometryBlock;

			if (data == null) return false;

			foreach (geometry_block_resource_block gb in gbi.Resources)
			{
				using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
				{
					switch (gb.Type.Value)
					{
						#region TagBlock
						case (int)geometry_block_resource_type.TagBlock:
							int count = gb.GetCount();
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetPlacements:
									Placements.Resize(count);
									Placements.Read(er);
									break;

								case OffsetDecalVertices:
									DecalVertices.Resize(count);
									DecalVertices.Read(er);
									break;

								case OffsetDecalIndices:
									DecalIndices.Resize(count);
									DecalIndices.Read(er);
									break;

								case OffsetSpriteVertices:
									SpriteVertices.Resize(count);
									SpriteVertices.Read(er);
									break;

								case OffsetSpriteIndices:
									SpriteIndices.Resize(count);
									SpriteIndices.Read(er);
									break;
							}
							break;
						#endregion
					}
				}

				index++;
			}

			return true;
		}
            public void Read(BlamLib.IO.EndianReader s)
            {
                ResourceBaseAddress = s.ReadUInt32();
                DebugSectionSize    = s.ReadInt32();
                RuntimeBaseAddress  = s.ReadUInt32();
                UnknownBaseAddress  = s.ReadUInt32();

                foreach (var sec in sections)
                {
                    sec.Read(s);
                }
            }
Exemplo n.º 24
0
        public virtual void Read(BlamLib.IO.EndianReader s)
        {
            int entries_count = s.ReadInt32();

            m_entries = new List <PakFileEntry>(entries_count);
            for (int x = 0; x < m_entries.Count; x++)
            {
                var entry = new PakFileEntry();
                entry.Read(s);

                m_entries.Add(entry);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates the tag file and opens it for reading and writing
        /// </summary>
        /// <remarks>Closes existing tag streams</remarks>
        public void CreateForReadWrite()
        {
            if (InCache)
            {
                return;
            }
            string path = CreateInternal();

            InputStream            = new BlamLib.IO.EndianReader(path, endianState, this);
            OutputStream           = new BlamLib.IO.EndianWriter(path, endianState, this, true);
            OutputStream.AutoFlush = false;

            SetupBaseAddress();
        }
Exemplo n.º 26
0
        public CacheFile(string map_name)
        {
            if (!SharableReferenceXbox(map_name) && !SharableReferencePc(map_name))
            {
                InputStream = new BlamLib.IO.EndianReader(map_name, BlamLib.IO.EndianState.Little, this);
                if (!CacheIsReadonly(map_name))
                {
                    OutputStream = new BlamLib.IO.EndianWriter(map_name, BlamLib.IO.EndianState.Little, this);
                }
            }

            cacheHeader = new CacheHeader();
            cacheIndex  = new CacheIndex();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Opens the tag file for reading
        /// </summary>
        /// <remarks>Closes existing tag streams</remarks>
        public void OpenForRead()
        {
            if (InCache)
            {
                return;
            }
            Close();

            string path = this.Path;

            InputStream = new BlamLib.IO.EndianReader(path, endianState, this);

            SetupBaseAddress();
        }
Exemplo n.º 28
0
        /// <summary>
        /// Opens the tag file for reading and writing
        /// </summary>
        /// <remarks>Closes existing tag streams</remarks>
        public void OpenForReadWrite()
        {
            if (InCache)
            {
                return;
            }
            Close();

            string path = this.Path;

            InputStream            = new BlamLib.IO.EndianReader(path, endianState, this);
            OutputStream           = new BlamLib.IO.EndianWriter(path, endianState, this);
            OutputStream.AutoFlush = false;

            SetupBaseAddress();
        }
Exemplo n.º 29
0
 public void Read(BlamLib.IO.EndianReader s)
 {
     if (!MiscGroups.crdb.Test(s.ReadTag()))
     {
         throw new Debug.ExceptionLog("{0} is not a resource db!", s.FileName);
     }
     if (s.ReadInt32() != kVersion)
     {
         throw new Debug.ExceptionLog("{0} is an unsupported db!", s.FileName);
     }
     items = new List <CacheResourceDatabaseItem>(s.ReadInt32());
     for (int x = 0; x < items.Count; x++)
     {
         (items[x] = new CacheResourceDatabaseItem()).Read(s);
     }
 }
Exemplo n.º 30
0
        internal bool Reconstruct(geometry_block_info_struct gbi)
        {
            int index = 0;

            byte[][] data = gbi.GeometryBlock;

            if (data == null)
            {
                return(false);
            }

            foreach (geometry_block_resource_block gb in gbi.Resources)
            {
                using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
                {
                    switch (gb.Type.Value)
                    {
                        #region TagBlock
                    case (int)geometry_block_resource_type.TagBlock:
                        int count = gb.GetCount();
                        switch (gb.PrimaryLocater.Value)
                        {
                        case OffsetSoundDialogueInfo:
                            SoundDialogueInfo.Resize(count);
                            SoundDialogueInfo.Read(er);
                            break;
                        }
                        break;

                        #endregion
                        #region TagData
                    case (int)geometry_block_resource_type.TagData:
                        if (gb.PrimaryLocater.Value == OffsetEncodedData)
                        {
                            EncodedData.Reset(er.ReadBytes(gb.Size));
                        }
                        break;
                        #endregion
                    }
                }

                index++;
            }

            return(true);
        }
        public override void Read(BlamLib.IO.EndianReader s)
        {
            CacheFile cache  = s.Owner as CacheFile;
            bool      isHA10 = cache.EngineVersion == BlamVersion.Halo1_XboxX || cache.EngineVersion == BlamVersion.Halo1_PCX;

            GameDefinition gd = Program.Halo1.Manager;

            GroupTagInt = s.ReadUInt32();
            groupTag    = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(GroupTagInt));
            IO.ByteSwap.SwapUDWord(ref GroupTagInt);

            uint group_tag_int = s.ReadUInt32();

            if (group_tag_int != uint.MaxValue)
            {
                groupParent1 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(group_tag_int));
            }
            else
            {
                groupParent1 = TagInterface.TagGroup.Null;
            }

            group_tag_int = s.ReadUInt32();
            if (group_tag_int != uint.MaxValue)
            {
                groupParent2 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(group_tag_int));
            }
            else
            {
                groupParent2 = TagInterface.TagGroup.Null;
            }

            datum.Read(s);
            tagNameOffset = s.ReadPointer();

            address = s.ReadUInt32();             // external index for pc\ce, if its a bitmap, ptr if its a sound or anything else
            // TODO: HA10 Xbox doesn't use data files (and a PC port probably won't either)
            if (isHA10 || address > s.BaseAddress)
            {
                offset = (int)(address - s.BaseAddress);
            }
            this.location = (CacheIndex.ItemLocation)s.ReadInt32();             // bool_in_data_file

            s.ReadInt32();
        }
Exemplo n.º 32
0
		bool ReconstructRawPcaData(Blam.CacheFile c,
			geometry_block_info_struct gbi)
		{
			int index = 0;
			int x;
			byte[][] data = gbi.GeometryBlock;

			if (data == null) return false;

			foreach (geometry_block_resource_block gb in gbi.Resources)
			{
				using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
				{
					switch (gb.Type.Value)
					{
						#region TagBlock
						case (int)geometry_block_resource_type.TagBlock:
							int count = gb.GetCount();
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetVertexBuffers:
									VertexBuffers.Resize(count);
									VertexBuffers.Read(er);
									break;
							}
							break;
						#endregion
						#region VertexBuffer
						case (int)geometry_block_resource_type.VertexBuffer:
							var vb_defs = (c.TagIndexManager as InternalCacheTagIndex).kVertexBuffers;

							// HACK: Figure out why we PRT stores the vertex buffer in the geometry block info's
							// "section data" and not in a tag block resource
							if (VertexBuffers.Count == 0 && !ReadVertexBufferHack(c, gbi))
								break;

							var stream_readers = new Render.VertexBufferInterface.StreamReader[VertexBuffers.Count];
							for (x = 0; x < VertexBuffers.Count; x++)
								VertexBuffers[x].VertexBuffer.InitializeStreamReader(vb_defs, out stream_readers[x]);

							int vertex_count = gb.Size.Value / VertexBuffers[0].VertexBuffer.StrideSize;
							if (RawPcaData.Count == 0)
								RawPcaData.Resize(vertex_count * 5); // 5x as there are 5 fields in the Pca data

							for (x = 0; x < vertex_count; x++)
								ReconstructRawPcaData(x, gb, er, stream_readers);
							break;
						#endregion
					}
				}
				index++;
			}

			VertexBuffers.DeleteAll();

			return true;
		}
Exemplo n.º 33
0
		/// <summary></summary>
		/// <param name="c"></param>
		/// <param name="section_info">Can be null if tag data doesn't have it</param>
		/// <param name="gbi"></param>
		/// <returns></returns>
		internal bool Reconstruct(Blam.CacheFile c,
			global_geometry_section_info_struct section_info,
			geometry_block_info_struct gbi)
		{
			int index = 0;
			int x;
			byte[][] data = gbi.GeometryBlock;

			if (data == null) return false;

			foreach (geometry_block_resource_block gb in gbi.Resources)
			{
				using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
				{
					switch (gb.Type.Value)
					{
						#region TagBlock
						case (int)geometry_block_resource_type.TagBlock:
							int count = gb.GetCount();
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetParts:
									Parts.Resize(count);
									Parts.Read(er);
									break;

								case OffsetSubparts:
									Subparts.Resize(count);
									Subparts.Read(er);
									break;

								case OffsetVisibilityBounds:
									VisibilityBounds.Resize(count);
									VisibilityBounds.Read(er);
									break;

								case OffsetStripIndices:
									StripIndices.Resize(count);
									StripIndices.Read(er);
									break;

								case OffsetMoppReorderTable:
									MoppReorderTable.Resize(count);
									MoppReorderTable.Read(er);
									break;

								case OffsetVertexBuffers:
									VertexBuffers.Resize(count);
									VertexBuffers.Read(er);
									break;
							}
							break;
						#endregion
						#region TagData
						case (int)geometry_block_resource_type.TagData:
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetVisibilityMoppCode:
									VisibilityMoppCode.Reset(er.ReadBytes(gb.Size));
									break;
							}
							break;
						#endregion
						#region VertexBuffer
						case (int)geometry_block_resource_type.VertexBuffer:
							var vb_defs = (c.TagIndexManager as InternalCacheTagIndex).kVertexBuffers;

							var stream_readers = new Render.VertexBufferInterface.StreamReader[VertexBuffers.Count];
							for (x = 0; x < VertexBuffers.Count; x++)
								VertexBuffers[x].VertexBuffer.InitializeStreamReader(vb_defs, out stream_readers[x]);

							if (RawVertices.Count == 0)
							{
								int vertex_count = section_info != null ?
									section_info.TotalVertexCount :
									gb.Size.Value / VertexBuffers[0].VertexBuffer.StrideSize;

								RawVertices.Resize(vertex_count);
							}

							for (x = 0; x < RawVertices.Count; x++)
								RawVertices[x].Reconstruct(section_info, gb, 
									er, stream_readers);
							break;
						#endregion
					}
				}

				index++;
			}

			VertexBuffers.DeleteAll();

			return true;
		}
Exemplo n.º 34
0
		internal bool Reconstruct(
			BlamLib.Blam.CacheFile c,
			global_geometry_section_info_struct section,
			geometry_block_info_struct gbi
			)
		{
			int index = 0;
			byte[][] data = gbi.GeometryBlock;

			if (data == null) return false;

			foreach (geometry_block_resource_block gb in gbi.Resources)
			{
				using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
				{
					switch (gb.Type.Value)
					{
						#region TagBlock
						case (int)geometry_block_resource_type.TagBlock:
							int count = gb.GetCount();
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetRawPoints:
									RawPoints.Resize(count);
									RawPoints.Read(er);
									break;

								case OffsetRigidPointGroups:
									RigidPointGroups.Resize(count);
									RigidPointGroups.Read(er);
									break;

								case OffsetVertexPointIndices:
									VertexPointIndices.Resize(count);
									VertexPointIndices.Read(er);
									break;
							}
							break;
						#endregion
						#region TagData
						case (int)geometry_block_resource_type.TagData:
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetRuntimePointData:
									RuntimePointData.Reset(er.ReadBytes(gb.Size));
									break;
							}
							break;
						#endregion
						#region VertexBuffer
						//case (int)geometry_block_resource_type.VertexBuffer:
						#endregion
					}

					index++;
				}
			}

			return true;
		}
Exemplo n.º 35
0
			internal bool Reconstruct(Blam.CacheFile c,
				global_geometry_section_info_struct section,
				geometry_block_info_struct gbi)
			{
				Section.Value.Reconstruct(c, section, gbi);
				PointData.Value.Reconstruct(c, section, gbi);

				int index = 0;
				byte[][] data = gbi.GeometryBlock;

				if (data == null) return false;

				foreach (geometry_block_resource_block gb in gbi.Resources)
				{
					using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
					{
						switch (gb.Type.Value)
						{
							#region TagBlock
							case (int)geometry_block_resource_type.TagBlock:
								int count = gb.GetCount();
								switch (gb.PrimaryLocater.Value)
								{
									case OffsetNodeMap:
										NodeMap.Resize(count);
										NodeMap.Read(er);
										break;
								}
								break;
							#endregion
						}

						index++;
					}
				}

				return true;
			}
Exemplo n.º 36
0
		internal bool Reconstruct(geometry_block_info_struct gbi)
		{
			int index = 0;
			byte[][] data = gbi.GeometryBlock;

			if (data == null) return false;

			foreach (geometry_block_resource_block gb in gbi.Resources)
			{
				using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
				{
					switch (gb.Type.Value)
					{
						#region TagBlock
						case (int)geometry_block_resource_type.TagBlock:
							int count = gb.GetCount();
							switch (gb.PrimaryLocater.Value)
							{
								case OffsetSoundDialogueInfo:
									SoundDialogueInfo.Resize(count);
									SoundDialogueInfo.Read(er);
									break;
							}
							break;
						#endregion
						#region TagData
						case (int)geometry_block_resource_type.TagData:
							if (gb.PrimaryLocater.Value == OffsetEncodedData)
								EncodedData.Reset(er.ReadBytes(gb.Size));
							break;
						#endregion
					}
				}

				index++;
			}

			return true;
		}
Exemplo n.º 37
0
				internal bool Reconstruct(Blam.CacheFile c,
					lightmap_vertex_buffer_bucket_block buffer_bucket,
					geometry_block_info_struct gbi)
				{
					int index = 0;
					int x;
					byte[][] data = gbi.GeometryBlock;

					if (data == null) return false;

					foreach (geometry_block_resource_block gb in gbi.Resources)
					{
						using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
						{
							switch (gb.Type.Value)
							{
								#region TagBlock
								case (int)geometry_block_resource_type.TagBlock:
									int count = gb.GetCount();
									switch (gb.PrimaryLocater.Value)
									{
										case OffsetVertexBuffers:
											VertexBuffers.Resize(count);
											VertexBuffers.Read(er);
											break;
									}
									break;
								#endregion
								#region VertexBuffer
								case (int)geometry_block_resource_type.VertexBuffer:
									var vb_defs = (c.TagIndexManager as InternalCacheTagIndex).kVertexBuffers;

									var stream_readers = new Render.VertexBufferInterface.StreamReader[VertexBuffers.Count];
									for (x = 0; x < VertexBuffers.Count; x++)
										VertexBuffers[x].VertexBuffer.InitializeStreamReader(vb_defs, out stream_readers[x]);

									int vertex_count = gb.Size.Value / VertexBuffers[0].VertexBuffer.StrideSize;
									if(buffer_bucket.RawVertices.Count == 0)
										buffer_bucket.RawVertices.Resize(vertex_count);
									for (x = 0; x < vertex_count; x++)
										buffer_bucket.RawVertices[x].Reconstruct(buffer_bucket, gb,
											er, stream_readers);
									break;
								#endregion
							}
						}

						index++;
					}

					VertexBuffers.DeleteAll();

					return true;
				}
Exemplo n.º 38
0
			void DisallowTags()
			{
				BlamLib.IO.EndianReader input = new BlamLib.IO.EndianReader(output.FileName);
				input.BaseAddress = Program.PeAddressMask;
				input.Seek(AddressOf.TagGroupDefinitions[Platform.Guerilla] - Program.PeAddressMask);

				uint[] offsets = new uint[Constants.StockTagGroupCount];
				for (int x = 0; x < offsets.Length; x++)
					offsets[x] = input.ReadPointer();

				for (int x = 0; x < offsets.Length; x++)
				{
					input.Seek(offsets[x]);
					string name = Program.ReadCString(input.ReadPointer(), input);
					if (IsDisallowedTag(name))
					{
						input.Seek(0x20, System.IO.SeekOrigin.Current);
						output.Seek(input.Position - 2);
						output.Write((short)1);
						output.Seek(input.ReadPointer() + 0x14);
						output.Write(0);
						output.Write(0);
						output.Write(0);
					}
				}
				input.Close();
			}
Exemplo n.º 39
0
		public static List<Entry> ProcessBlamFile(string path)
		{
			List<Entry> entries = null;

			using(IO.EndianReader s = new BlamLib.IO.EndianReader(path, BlamLib.IO.EndianState.Big))
			{
				BLF head = new BLF();
				try { head.Read(s); }
				catch (Debug.ExceptionLog) { return null; }
				entries.Add(head);

				uint group_tag;
				TagInterface.TagGroup tag_group;
				Entry e;

				while((group_tag = unchecked((uint)s.Peek())) != MiscGroups._eof.ID)
				{
					tag_group = Groups.FindTagGroup(group_tag);
					Debug.Assert.If(tag_group, "Unhandled group @0x{0:X} ('{1}')", s.Position, new string(TagInterface.TagGroup.FromUInt(group_tag)));

					Type t = (Type)tag_group.EngineData;

					System.Reflection.ConstructorInfo ci = t.GetConstructor(new Type[0]);
					e = (Entry)ci.Invoke(null);

					e.Read(s);
					entries.Add(e);
				}
			}

			return entries;
		}
Exemplo n.º 40
0
		public CacheFile(string map_name)
		{
			if (!SharableReferenceXbox(map_name) && !SharableReferencePc(map_name))
			{
				InputStream = new BlamLib.IO.EndianReader(map_name, BlamLib.IO.EndianState.Little, this);
				if(!CacheIsReadonly(map_name))
					OutputStream = new BlamLib.IO.EndianWriter(map_name, BlamLib.IO.EndianState.Little, this);
			}

			cacheHeader = new CacheHeader();
			cacheIndex = new CacheIndex();
		}
Exemplo n.º 41
0
		/// <summary>
		/// Postprocess a tag block that has been streamed to a cache block
		/// </summary>
		/// <param name="locator">Offset of the tag block header in the section</param>
		/// <param name="block"></param>
		/// <returns></returns>
		internal bool ReconstructTagBlock(short locator, TagInterface.IBlock block)
		{
			int index = 0;

			if (GeometryBlock == null) return false;

			foreach (geometry_block_resource_block gb in Resources)
			{
				using (IO.EndianReader er = new BlamLib.IO.EndianReader(GeometryBlock[index]))
				{
					switch (gb.Type.Value)
					{
						#region TagBlock
						case (int)geometry_block_resource_type.TagBlock:
							int count = gb.GetCount();
							if (gb.PrimaryLocater.Value == locator)
							{
								block.Resize(count);
								block.Read(er);
							}
							break;
						#endregion
					}

					index++;
				}
			}

			return true;
		}
Exemplo n.º 42
0
		/// <summary>
		/// Postprocess tag data that has been streamed to a cache block
		/// </summary>
		/// <param name="locator">Offset of the tag data header in the section</param>
		/// <param name="data"></param>
		/// <returns></returns>
		internal bool ReconstructTagData(short locator, TagInterface.Data data)
		{
			int index = 0;
			IO.EndianReader er;

			if (GeometryBlock == null) return false;

			foreach (geometry_block_resource_block gb in Resources)
			{
				er = new BlamLib.IO.EndianReader(GeometryBlock[index]);

				switch (gb.Type.Value)
				{
					#region TagData
					case (int)geometry_block_resource_type.TagData:
						if(gb.PrimaryLocater.Value == locator)
								data.Reset(er.ReadBytes(gb.Size));
						break;
					#endregion
				}

				index++;
				er.Close();
				er = null;
			}

			return true;
		}