Ejemplo n.º 1
0
        internal protected override IGameResource PrecacheResource(Game owner, string resource_name, string r_path, string r_name)
        {
            IGameResource gr     = null;
            bool          result = false;

            switch (resource_name)
            {
            case Managers.BlamDefinition.ResourceScripts:
                gr     = new Scripting.XmlInterface();
                result = gr.Load(r_path, r_name);
                break;

            case Managers.BlamDefinition.ResourceStringIds:
                gr     = new Managers.StringIdStaticCollection();
                result = gr.Load(r_path, r_name);
                break;

            case Managers.BlamDefinition.ResourceVertexBuffers:
                gr     = new Render.VertexBufferInterface.VertexBuffersGen2();
                result = gr.Load(r_path, r_name);
                break;
            }

            if (!result && gr != null)
            {
                gr.Close();
                gr = null;
            }

            return(gr);
        }
Ejemplo n.º 2
0
        public override void ExtractionDispose()
        {
            cacheLanguagePackContainer = null;

            if (globals_handle != DatumIndex.Null)
            {
                Unload(globals_handle);
                globals_handle = DatumIndex.Null;
            }
            if (sound_gestalt_handle != DatumIndex.Null)
            {
                Unload(sound_gestalt_handle);
                sound_gestalt_handle = DatumIndex.Null;
            }

            if (kVertexBuffers != null)
            {
                kVertexBuffers = null;
                Program.Halo2.Manager.VertexBufferCacheClose(cacheFile.EngineVersion);
            }

            base.ExtractionDispose();
        }
Ejemplo n.º 3
0
		public override void ExtractionDispose()
		{
			cacheLanguagePackContainer = null;

			if (globals_handle != DatumIndex.Null)
			{
				Unload(globals_handle);
				globals_handle = DatumIndex.Null;
			}
			if (sound_gestalt_handle != DatumIndex.Null)
			{
				Unload(sound_gestalt_handle);
				sound_gestalt_handle = DatumIndex.Null;
			}

			if (kVertexBuffers != null)
			{
				kVertexBuffers = null;
				Program.Halo2.Manager.VertexBufferCacheClose(cacheFile.EngineVersion);
			}

			base.ExtractionDispose();
		}
Ejemplo n.º 4
0
		public override void ExtractionInitialize()
		{
			// If we have kVertexBuffers initialized, then that means we've already ran extract init.
			if (kVertexBuffers != null) return;

			base.ExtractionInitialize();

			var h2cf = base.cacheFile as CacheFile;

			Program.Halo2.Manager.VertexBufferCacheOpen(Engine);
			kVertexBuffers = Program.Halo2.Manager.FindGame(Engine).GetResource
				<Render.VertexBufferInterface.VertexBuffersGen2>
				(Managers.BlamDefinition.ResourceVertexBuffers);

			// We only need the globals tag for language pack headers. If this is a PC multiplayer map, then 
			// the headers are stored elsewhere in the cache so we don't have to exception when there is no globals tag
			if ((globals_handle = base.Open(@"globals\globals", TagGroups.matg)) == DatumIndex.Null
				&& Engine != BlamVersion.Halo2_PC)
				throw new Debug.ExceptionLog("ExtractionInitialize: couldn't open the globals tag!");

			#region Initialze the cache language pack interface
			if (globals_handle != DatumIndex.Null)
			{
				var globals = (base[globals_handle].TagDefinition as Tags.globals_group);
				globals.LanguagePacksReadFromCache(h2cf);

				cacheLanguagePackContainer = globals;
			}
			// either this map's globals tag is f****d up or it's a MP map for PC and thus doesn't have a local copy)
			else if (h2cf.HeaderHalo2.PcFields.UsesCustomLanguagePack)
			{
				var pc_fields = h2cf.HeaderHalo2.PcFields;
				pc_fields.LanguagePackHeadersReadFromCache(h2cf);
				pc_fields.LanguagePacksReadFromCache(h2cf);

				cacheLanguagePackContainer = pc_fields;
			}
			#endregion

			// TODO: we may want to use the tag_index found in global's sound_block instead...
			if ((sound_gestalt_handle = base.Open(@"i've got a lovely bunch of coconuts", TagGroups.ugh_)) == DatumIndex.Null)
			{
				if (h2cf.HeaderHalo2.PcFields.UsesCustomSoundGestalt)
					sound_gestalt_handle = base.Open(h2cf.HeaderHalo2.PcFields.SecondarySoundGestalt);

				if(sound_gestalt_handle == DatumIndex.Null
					&& Engine != BlamVersion.Halo2_PC) // TODO: tag sharing logic
					throw new Debug.ExceptionLog("ExtractionInitialize: couldn't open the sound gestalt!");
			}

			#region Initialize the feign invalid-shader tag
			const string invalid_handle_shader_name = @"shaders\invalid";

			Blam.CacheIndex.Item i;
			if (h2cf.TryAndFind(invalid_handle_shader_name, TagGroups.shad, out i))
				invalid_handle_shader = i.Datum;
			else
				invalid_handle_shader = h2cf.AddFeignTagInstance(invalid_handle_shader_name, TagGroups.shad).Datum;
			#endregion
		}
Ejemplo n.º 5
0
		internal protected override IGameResource PrecacheResource(Game owner, string resource_name, string r_path, string r_name)
		{
			IGameResource gr = null;
			bool result = false;

			switch (resource_name)
			{
				case Managers.BlamDefinition.ResourceScripts:
					gr = new Scripting.XmlInterface();
					result = gr.Load(r_path, r_name);
					break;

				case Managers.BlamDefinition.ResourceStringIds:
					gr = new Managers.StringIdStaticCollection();
					result = gr.Load(r_path, r_name);
					break;

				case Managers.BlamDefinition.ResourceVertexBuffers:
					gr = new Render.VertexBufferInterface.VertexBuffersGen2();
					result = gr.Load(r_path, r_name);
					break;
			}

			if (!result && gr != null)
			{
				gr.Close();
				gr = null;
			}

			return gr;
		}
Ejemplo n.º 6
0
        public override void ExtractionInitialize()
        {
            // If we have kVertexBuffers initialized, then that means we've already ran extract init.
            if (kVertexBuffers != null)
            {
                return;
            }

            base.ExtractionInitialize();

            var h2cf = base.cacheFile as CacheFile;

            Program.Halo2.Manager.VertexBufferCacheOpen(Engine);
            kVertexBuffers = Program.Halo2.Manager.FindGame(Engine).GetResource
                             <Render.VertexBufferInterface.VertexBuffersGen2>
                                 (Managers.BlamDefinition.ResourceVertexBuffers);

            // We only need the globals tag for language pack headers. If this is a PC multiplayer map, then
            // the headers are stored elsewhere in the cache so we don't have to exception when there is no globals tag
            if ((globals_handle = base.Open(@"globals\globals", TagGroups.matg)) == DatumIndex.Null &&
                Engine != BlamVersion.Halo2_PC)
            {
                throw new Debug.ExceptionLog("ExtractionInitialize: couldn't open the globals tag!");
            }

            #region Initialze the cache language pack interface
            if (globals_handle != DatumIndex.Null)
            {
                var globals = (base[globals_handle].TagDefinition as Tags.globals_group);
                globals.LanguagePacksReadFromCache(h2cf);

                cacheLanguagePackContainer = globals;
            }
            // either this map's globals tag is f****d up or it's a MP map for PC and thus doesn't have a local copy)
            else if (h2cf.HeaderHalo2.PcFields.UsesCustomLanguagePack)
            {
                var pc_fields = h2cf.HeaderHalo2.PcFields;
                pc_fields.LanguagePackHeadersReadFromCache(h2cf);
                pc_fields.LanguagePacksReadFromCache(h2cf);

                cacheLanguagePackContainer = pc_fields;
            }
            #endregion

            // TODO: we may want to use the tag_index found in global's sound_block instead...
            if ((sound_gestalt_handle = base.Open(@"i've got a lovely bunch of coconuts", TagGroups.ugh_)) == DatumIndex.Null)
            {
                if (h2cf.HeaderHalo2.PcFields.UsesCustomSoundGestalt)
                {
                    sound_gestalt_handle = base.Open(h2cf.HeaderHalo2.PcFields.SecondarySoundGestalt);
                }

                if (sound_gestalt_handle == DatumIndex.Null &&
                    Engine != BlamVersion.Halo2_PC)                        // TODO: tag sharing logic
                {
                    throw new Debug.ExceptionLog("ExtractionInitialize: couldn't open the sound gestalt!");
                }
            }

            #region Initialize the feign invalid-shader tag
            const string invalid_handle_shader_name = @"shaders\invalid";

            Blam.CacheIndex.Item i;
            if (h2cf.TryAndFind(invalid_handle_shader_name, TagGroups.shad, out i))
            {
                invalid_handle_shader = i.Datum;
            }
            else
            {
                invalid_handle_shader = h2cf.AddFeignTagInstance(invalid_handle_shader_name, TagGroups.shad).Datum;
            }
            #endregion
        }