예제 #1
0
 internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
 {
     //int index = BitmapGroup.Value & 0xFFFF;
     //if (index != -1) System.Diagnostics.Debug.WriteLine(string.Format(
     //	 "BitmapGroup: {0} {1}", index, c.Index.Tags[index].FileName));
     return(true);
 }
 internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
 {
     dead_sphere_shapes.DeleteAll();
     pill_shapes.DeleteAll();
     sphere_shapes.DeleteAll();
     return(true);
 }
예제 #3
0
 /// <summary>
 /// Process the reference data to the cache file
 /// </summary>
 /// <param name="c">Cache file</param>
 public override void WriteHeader(BlamLib.Blam.CacheFile c)
 {
     if ((c.EngineVersion & BlamVersion.Halo1) != 0 || (c.EngineVersion & BlamVersion.Stubbs) != 0)
     {
         c.OutputStream.Write(elements.Count);
         headerOffset = c.OutputStream.PositionUnsigned;
         c.OutputStream.Write(0);
         c.OutputStream.Write(0);
     }
     else if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon)
     {
         c.OutputStream.Write(elements.Count);
         headerOffset = c.OutputStream.PositionUnsigned;
         c.OutputStream.Write(0);
         c.OutputStream.Write(0);
     }
     else if ((c.EngineVersion & BlamVersion.Halo2) != 0)
     {
         c.OutputStream.Write(elements.Count);
         headerOffset = c.OutputStream.PositionUnsigned;
         c.OutputStream.Write(0);
     }
     else if ((c.EngineVersion & BlamVersion.Halo3) != 0 || (c.EngineVersion & BlamVersion.HaloOdst) != 0 ||
              (c.EngineVersion & BlamVersion.HaloReach) != 0 || (c.EngineVersion & BlamVersion.Halo4) != 0)
     {
         c.OutputStream.Write(elements.Count);
         headerOffset = c.OutputStream.PositionUnsigned;
         c.OutputStream.Write(0);
         c.OutputStream.Write(0);
     }
 }
 internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
 {
     Invert_Value(ref acceleration_range.I);
     Invert_Value(ref acceleration_range.J);
     Invert_Value(ref acceleration_range.K);
     return(true);
 }
예제 #5
0
 // TODO: I believe useless pad was added after alpha halo, so we should check for that and read\write if in a cache\tag
 #region Cache
 /// <summary>
 /// Seek the stream ahead however many bytes the size of this pad is
 /// </summary>
 /// <param name="c"></param>
 public override void Read(BlamLib.Blam.CacheFile c)
 {
     if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon)
     {
         c.InputStream.Seek(Value, System.IO.SeekOrigin.Current);
     }
 }
        /// <summary>
        /// Process the struct field from a cache file
        /// </summary>
        /// <param name="c">Cache file</param>
        /// <param name="iop">Processing method</param>
        public void Read(BlamLib.Blam.CacheFile c, IOProcess iop)
        {
            VersionCtorAttribute upgrade_parameters;

            if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon || c.EngineVersion == BlamVersion.Halo3_Beta)
            {
                if ((upgrade_parameters = kState.VersionForEngine(c.EngineVersion)) != null)
                {
                    // It is ASSUMED that the group tag won't ever be needed for version construction
                    Value          = (T)kState.NewInstance(this, upgrade_parameters.Major, upgrade_parameters.Minor);
                    NeedsUpgrading = true;
                }
                else
                {
                    NeedsUpgrading = false;
                }
            }

            Value.Read(c, iop);

            if (NeedsUpgrading)
#if DEBUG
            { Debug.Assert.If(Value.Upgrade(), "Failed to upgrade struct. {0} {1}", typeof(T).Name, Value.ToVersionString()); }
#else
            { Value.Upgrade(); }
#endif
        }
예제 #7
0
        /// <summary>
        /// Process the reference data from the cache file
        /// </summary>
        /// <param name="c">Cache file</param>
        public override void ReadHeader(BlamLib.Blam.CacheFile c)
        {
#if DEBUG
            relativeOffset = c.InputStream.PositionUnsigned;
#endif
            VersionCtorAttribute upgrade_parameters;
            if ((c.EngineVersion & BlamVersion.Halo1) != 0 || (c.EngineVersion & BlamVersion.Stubbs) != 0)
            {
                Resize(c.InputStream.ReadInt32());                 // element count
                relativeOffset = c.InputStream.ReadPointer();
                c.InputStream.ReadUInt32();
            }
            #region Halo 2 Betas
            else if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon)
            {
                if ((upgrade_parameters = kState.VersionForEngine(c.EngineVersion)) != null)
                {
                    NeedsUpgrading = true;
                    Resize(c.InputStream.ReadInt32(), upgrade_parameters.Major, upgrade_parameters.Minor);
                }
                else
                {
                    NeedsUpgrading = false;
                    Resize(c.InputStream.ReadInt32());                     // element count
                }
                relativeOffset = c.InputStream.ReadPointer();
                c.InputStream.ReadUInt32();
            }
            #endregion
            else if ((c.EngineVersion & BlamVersion.Halo2) != 0)
            {
                Resize(c.InputStream.ReadInt32());                 // element count
                relativeOffset = c.InputStream.ReadPointer();
            }
            #region Halo 3 Betas
            else if (c.EngineVersion == BlamVersion.Halo3_Beta)
            {
                if ((upgrade_parameters = kState.VersionForEngine(c.EngineVersion)) != null)
                {
                    NeedsUpgrading = true;
                    Resize(c.InputStream.ReadInt32(), upgrade_parameters.Major, upgrade_parameters.Minor);
                }
                else
                {
                    NeedsUpgrading = false;
                    Resize(c.InputStream.ReadInt32());                     // element count
                }
                relativeOffset = c.InputStream.ReadPointer();
                c.InputStream.ReadUInt32();
            }
            #endregion
            else if ((c.EngineVersion & BlamVersion.Halo3) != 0 || (c.EngineVersion & BlamVersion.HaloOdst) != 0 ||
                     (c.EngineVersion & BlamVersion.HaloReach) != 0 || (c.EngineVersion & BlamVersion.Halo4) != 0)
            {
                Resize(c.InputStream.ReadInt32());                 // element count
                relativeOffset = c.InputStream.ReadPointer();
                c.InputStream.ReadUInt32();
            }
        }
예제 #8
0
        /// <summary>
        /// Stream the field to a cache
        /// </summary>
        /// <param name="c"></param>
        public override void WriteHeader(BlamLib.Blam.CacheFile c)
        {
            if (c.EngineVersion == BlamVersion.Halo2_Alpha)             // old string id
            {
                c.OutputStream.Write(NullPreviewString);
            }

            Handle.Write(c.OutputStream);
        }
예제 #9
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            //ReconstructRigidBodyShapeData();
            int Object_Count = Spheres.Count + MultiSpheres.Count + Pills.Count + Boxes.Count + Triangles.Count + Polyhedra.Count;

            MassDistributions.Resize(Object_Count);            //TODO: Find a proper way to generate values for this. This fix will only go so far.

            return(true);
        }
예제 #10
0
        /// <summary>
        /// Stream the field from a buffer
        /// </summary>
        /// <param name="c"></param>
        public override void ReadHeader(BlamLib.Blam.CacheFile c)
        {
            OwnerId = c.TagIndexManager.IndexId;

            if (c.EngineVersion == BlamVersion.Halo2_Alpha)             // old string id
            {
                c.InputStream.Seek(28, System.IO.SeekOrigin.Current);   // preview string
            }
            Handle.Read(c.InputStream, c.StringIds.Definition.Description);
        }
예제 #11
0
        /// <summary>Ran whenever the UI says it's time to close the cache</summary>
        void OnCacheClosed()
        {
            PopulateTagInstanceProperties(null);
            m_cache = null;

            ToggleUserInterfaceForCacheState(false);
            SetCacheViewerPath("No File Loaded");
            PopulateCacheProperties();
            TagTreeViewClear();
        }
예제 #12
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            //PredictedResources.DeleteAll();
            //EditorScenarioData.Delete();
            LevelData.DeleteAll();
            //SharedReferences.DeleteAll();
            //SimulationDefinitionTable.DeleteAll();

            return(true);
        }
 internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
 {
     Invert_Value(ref power_transition_time.Value);
     Invert_Value(ref power_acceleration_time.Value);
     Invert_Value(ref position_transition_time.Value);
     Invert_Value(ref position_acceleration_time.Value);
     Invert_Value(ref depowered_position_transition_time.Value);
     Invert_Value(ref depowered_position_acceleration_time.Value);
     PredictedResources.DeleteAll();
     return(true);
 }
예제 #14
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            bool result = true;

            if (RawPcaData.Count == 0)
            {
                result = ReconstructRawPcaData(c, GeometryBlockInfo.Value);
            }

            GeometryBlockInfo.Value.ClearPostReconstruction();

            return(result);
        }
예제 #15
0
		public CacheView(BlamLib.BlamVersion engine)
		{
			InitializeComponent();

			MainMenu.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;
			MenuTagInstance.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;

			m_tagTreeEditorMode = TagTreeEditorMode.TagExtraction;
			m_engine = engine;
			m_cache = null;

			bool tag_extraction_supported = (engine & kAllowedPlatforms) != 0;
			ViewUpdateExtractionSupportedState(tag_extraction_supported, false);
		}
예제 #16
0
        /// <summary>
        /// Process the block from the cache file
        /// </summary>
        /// <param name="c">Cache file</param>
        public override void Read(BlamLib.Blam.CacheFile c)
        {
            if (relativeOffset == 0)
            {
                return;
            }

            c.InputStream.Seek(relativeOffset, System.IO.SeekOrigin.Begin);
            elements.Read(c);

            if (NeedsUpgrading)
            {
                elements.Upgrade();
            }
        }
예제 #17
0
        public CacheView(BlamLib.BlamVersion engine)
        {
            InitializeComponent();

            MainMenu.Renderer        = MainForm.kOpenSauceIDEToolStripRenderer;
            MenuTagInstance.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;

            m_tagTreeEditorMode = TagTreeEditorMode.TagExtraction;
            m_engine            = engine;
            m_cache             = null;

            bool tag_extraction_supported = (engine & kAllowedPlatforms) != 0;

            ViewUpdateExtractionSupportedState(tag_extraction_supported, false);
        }
예제 #18
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            bool result = true;

            if (EncodedPermutationSection.Count != 1)
            {
                sound_encoded_dialogue_section_block section;
                EncodedPermutationSection.Add(out section);

                result = section.Reconstruct(GeometryBlockInfo.Value);
            }

            GeometryBlockInfo.Value.ClearPostReconstruction();

            return(result);
        }
예제 #19
0
            internal byte[] CacheRead(BlamLib.Blam.CacheFile c)
            {
                // read the cache block...
                byte[] bytes;
                if (!CacheRead(c, out bytes))
                {
                    return(null);
                }

                if (c.EngineVersion == BlamVersion.Halo2_PC)                 // ...and perform zlib decompression
                {
                    bytes = Util.ZLibBufferFromBytes(bytes, 0, GetPixelDataSize(c.EngineVersion));
                }

                return(bytes);
            }
예제 #20
0
            internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
            {
                bool result = true;

                if (ParticleSystemData.Count != 1)
                {
                    particle_system_lite_data_block data;
                    ParticleSystemData.Add(out data);

                    result = data.Reconstruct(GeometryBlockInfo.Value);
                }

                GeometryBlockInfo.Value.ClearPostReconstruction();

                return(result);
            }
예제 #21
0
            internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
            {
                bool result = true;

                if (CacheData.Count != 1)
                {
                    lightmap_geometry_section_cache_data_block cache_data;
                    CacheData.Add(out cache_data);

                    result = cache_data.Reconstruct(c, GeometryInfo.Value, GeometryBlockInfo.Value);
                }

                GeometryBlockInfo.Value.ClearPostReconstruction();

                return(result);
            }
예제 #22
0
            internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
            {
                bool result = true;

                // recreate the section data
                if (Section.Count != 1)
                {
                    water_geometry_section_block section;
                    Section.Add(out section);

                    result = section.Section.Value.Reconstruct(c, null, GeometryBlockInfo.Value);
                }

                GeometryBlockInfo.Value.ClearPostReconstruction();

                return(result);
            }
예제 #23
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            bool result = true;

            // recreate the section data
            if (CacheBlockData.Count != 1)
            {
                decorator_cache_block_data_block cdata;
                CacheBlockData.Add(out cdata);

                result = cdata.Reconstruct(GeometryBlockInfo.Value);
            }

            GeometryBlockInfo.Value.ClearPostReconstruction();

            return(result);
        }
예제 #24
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            bool result = true;

            // recreate the section data
            if (RenderData.Count != 1)
            {
                structure_bsp_cluster_data_block_new cdata;
                RenderData.Add(out cdata);

                result = cdata.Section.Value.Reconstruct(c, SectionInfo.Value, GeometryBlockInfo.Value);
            }

            GeometryBlockInfo.Value.ClearPostReconstruction();

            return(result);
        }
예제 #25
0
        internal override Item AddFeignItem(BlamLib.Blam.CacheFile cf, string tag_name, BlamLib.TagInterface.TagGroup group_tag)
        {
            var       last_item = items[items.Length - 1];
            CacheItem item      = new CacheItem();

            item.InitializeForFeigning(last_item.Datum, group_tag);

            // We don't use the optimized version
            item.ReferenceName = cf.References.Add(group_tag, tag_name);
            if (item.ReferenceName == DatumIndex.Null)
            {
                throw new Debug.ExceptionLog("Unable to create feign item's name reference!");
            }

            Array.Resize(ref items, items.Length + 1);

            return(items[items.Length - 1] = item);
        }
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            PredictedResources.DeleteAll();
            EditorScenarioData.Delete();
            LevelData.DeleteAll();
            SharedReferences.DeleteAll();
            SimulationDefinitionTable.DeleteAll();

            DeleteCompiledScripts();

            if (ScenarioResources.Count >= 1)
            {
                var scenario_resources = ScenarioResources[0];
                scenario_resources.references.DeleteAll();
                scenario_resources.ai_resources.DeleteAll();
            }

            return(true);
        }
예제 #27
0
            internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
            {
                if (c.EngineVersion.IsXbox1())
                {
                    var rsrc_ptr   = GetOffset();
                    var rsrc_cache = Program.Halo2.FromLocation(c as Halo2.CacheFile, rsrc_ptr);

                    // the shared cache isn't loaded, break
                    if (rsrc_cache == null)
                    {
                        return(false);
                    }

                    c.InputStream.Seek(rsrc_ptr.Offset);
                    Data = c.InputStream.ReadBytes(GetSizeOf());

                    Stream = new System.IO.MemoryStream(Data, false);
                }
                return(true);
            }
예제 #28
0
        /// <summary>
        /// Process the block to the cache file
        /// </summary>
        /// <param name="c">Cache file</param>
        public override void Write(BlamLib.Blam.CacheFile c)
        {
            relativeOffset = c.OutputStream.PositionUnsigned;                // store offset
            c.OutputStream.Seek(headerOffset, System.IO.SeekOrigin.Begin);   // go to the reflexive header
            c.OutputStream.WritePointer(relativeOffset);                     // write offset
            c.OutputStream.Seek(relativeOffset, System.IO.SeekOrigin.Begin); // go back to where we were

            if ((c.EngineVersion & BlamVersion.Halo1) != 0 || (c.EngineVersion & BlamVersion.Stubbs) != 0)
            {
                elements.Write(c);
            }
            else if ((c.EngineVersion & BlamVersion.Halo2) != 0)
            {
                elements.Write(c);
            }
            else if ((c.EngineVersion & BlamVersion.Halo3) != 0 || (c.EngineVersion & BlamVersion.HaloOdst) != 0 ||
                     (c.EngineVersion & BlamVersion.HaloReach) != 0)
            {
                elements.Write(c);
            }
        }
예제 #29
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            var clpi = c.TagIndexManager as ICacheLanguagePackContainer;

            if (clpi != null)
            {
                var h2_cache = c as Halo2.CacheFile;

                var interop = new s_language_cache_interop[(int)LanguageType.kMax];
                int total_string_buffer_size = 0;

                // For each language, get the string data referenced by this tag
                for (LanguageType lang = LanguageType.English; lang < LanguageType.kMax; lang++)
                {
                    total_string_buffer_size = interop[(int)lang].Initialize(clpi.LanguagePackGet(lang),
                                                                             total_string_buffer_size, LanguageHandles[(int)lang]);
                }

                // Resize the string data container to have enough memory for all of our language strings
                this.StringData.Value = new byte[total_string_buffer_size];

                // For each language, copy the string data and initialize the reference blocks
                for (LanguageType lang = LanguageType.English; lang < LanguageType.kMax; lang++)
                {
                    interop[(int)lang].ReconstructTagData(this, lang);
                }

                // Null the handles for the extracted tag
                foreach (var handle in LanguageHandles)
                {
                    handle.Value = 0;
                }

                return(true);
            }

            return(false);
        }
예제 #30
0
        internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
        {
            bool result = true;

            if (c.EngineVersion.IsXbox1())
            {
                animation_graph_cache_block cache;
                byte[] temp;
                foreach (animation_graph_resources_struct.animation_pool_block anim
                         in Resources.Value.Animations)
                {
                    cache = CacheBlocks[anim.ParentGraphBlockIndex];
                    temp  = new byte[anim.GetTotalSize()];

                    if (cache.Stream == null)
                    {
                        result = false;
                    }

                    cache.Stream.Position = anim.ParentGraphBlockOffset.Value;
                    cache.Stream.Read(temp, 0, temp.Length);
                    anim.AnimationData.Reset(temp);

                    temp  = null;
                    cache = null;
                }

                foreach (animation_graph_cache_block cb in CacheBlocks)
                {
                    cb.Close();                                                                     // clean up resources
                }
                //CacheBlocks.DeleteAll();
                //CacheUnknown.DeleteAll();
            }

            return(result);
        }
예제 #31
0
            bool CacheRead(BlamLib.Blam.CacheFile c, out byte[] data)
            {
                data = null;

                ResourcePtr offset = GetOffset(0);
                int         size   = GetSize(0);

                var rsrc_cache = Program.Halo2.FromLocation(c as Halo2.CacheFile, offset);

                // the shared cache isn't loaded, break
                if (rsrc_cache == null)
                {
                    return(false);
                }

                // get the input stream we need
                IO.EndianReader er = rsrc_cache.InputStream;

                // read the bitmap
                er.Seek(offset.Offset);
                data = er.ReadBytes(size);

                return(true);
            }
예제 #32
0
		/// <summary>Ran whenever the UI says it's time to close the cache</summary>
		void OnCacheClosed()
		{
			PopulateTagInstanceProperties(null);
			m_cache = null;

			ToggleUserInterfaceForCacheState(false);
			SetCacheViewerPath("No File Loaded");
			PopulateCacheProperties();
			TagTreeViewClear();
		}