Example #1
0
        /// <summary>
        /// The halo ce container.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void HaloCEContainer(Map map)
        {
            map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[0] + 1444;
            bspcount = map.BR.ReadInt32();
            int tempr = map.BR.ReadInt32() - map.PrimaryMagic;

            sbsp = new BSPInfo[bspcount];
            for (int x = 0; x < bspcount; x++)
            {
                sbsp[x] = new BSPInfo();
                sbsp[x].pointerOffset      = tempr + (x * 32) - map.MetaInfo.Offset[0];
                map.BR.BaseStream.Position = tempr + (x * 32);
                sbsp[x].offset             = map.BR.ReadInt32();
                sbsp[x].size  = map.BR.ReadInt32();
                sbsp[x].magic = map.BR.ReadInt32() - sbsp[x].offset;
                map.BR.BaseStream.Position = tempr + (x * 32) + 28;
                sbsp[x].ident    = map.BR.ReadInt32();
                sbsp[x].TagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].ident);
                map.MetaInfo.Offset[sbsp[x].TagIndex] = sbsp[x].offset;
                map.MetaInfo.Size[sbsp[x].TagIndex]   = sbsp[x].size;
                map.BR.BaseStream.Position            = sbsp[x].offset + 4;
                sbsp[x].Halo1VerticeCount             = map.BR.ReadInt32();

                sbsp[x].lightmapoffset     = 24;
                map.BR.BaseStream.Position = sbsp[x].lightmapoffset + 12;

                sbsp[x].lightmapident    = map.BR.ReadInt32();
                sbsp[x].lightmapTagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].ident);
            }

            map.CloseMap();
        }
Example #2
0
        /// <summary>
        /// The halo ce container.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void HaloCEContainer(Map map)
        {
            map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[0] + 1444;
            bspcount = map.BR.ReadInt32();
            int tempr = map.BR.ReadInt32() - map.PrimaryMagic;
            sbsp = new BSPInfo[bspcount];
            for (int x = 0; x < bspcount; x++)
            {
                sbsp[x] = new BSPInfo();
                sbsp[x].pointerOffset = tempr + (x * 32) - map.MetaInfo.Offset[0];
                map.BR.BaseStream.Position = tempr + (x * 32);
                sbsp[x].offset = map.BR.ReadInt32();
                sbsp[x].size = map.BR.ReadInt32();
                sbsp[x].magic = map.BR.ReadInt32() - sbsp[x].offset;
                map.BR.BaseStream.Position = tempr + (x * 32) + 28;
                sbsp[x].ident = map.BR.ReadInt32();
                sbsp[x].TagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].ident);
                map.MetaInfo.Offset[sbsp[x].TagIndex] = sbsp[x].offset;
                map.MetaInfo.Size[sbsp[x].TagIndex] = sbsp[x].size;
                map.BR.BaseStream.Position = sbsp[x].offset + 4;
                sbsp[x].Halo1VerticeCount = map.BR.ReadInt32();

                sbsp[x].lightmapoffset = 24;
                map.BR.BaseStream.Position = sbsp[x].lightmapoffset + 12;

                sbsp[x].lightmapident = map.BR.ReadInt32();
                sbsp[x].lightmapTagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].ident);
            }

            map.CloseMap();
        }
Example #3
0
        /// <summary>
        /// The halo 2 bsp container.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void Halo2BSPContainer(Map map)
        {
            map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 528;
            bspcount = map.BR.ReadInt32();
            int tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            sbsp = new BSPInfo[bspcount];
            for (int x = 0; x < bspcount; x++)
            {
                sbsp[x] = new BSPInfo();
                sbsp[x].pointerOffset = tempr + (x * 68) - map.MetaInfo.Offset[3];
                map.BR.BaseStream.Position = tempr + (x * 68);
                sbsp[x].offset = map.BR.ReadInt32();
                map.Functions.ParsePointer(ref sbsp[x].offset, ref sbsp[x].location);
                sbsp[x].size = map.BR.ReadInt32();
                sbsp[x].magic = map.BR.ReadInt32() - sbsp[x].offset;
                map.BR.BaseStream.Position = tempr + (x * 68) + 20;
                sbsp[x].ident = map.BR.ReadInt32();

                // 	MessageBox.Show(sbsp[x].ident.ToString("X"));
                sbsp[x].TagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].ident);
                map.MetaInfo.Offset[sbsp[x].TagIndex] = sbsp[x].offset;
                map.MetaInfo.Size[sbsp[x].TagIndex] = sbsp[x].size;
                map.BR.BaseStream.Position = tempr + (x * 68) + 28;
                sbsp[x].lightmapident = map.BR.ReadInt32();
                sbsp[x].lightmapTagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].lightmapident);
                if (sbsp[x].lightmapTagIndex == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = sbsp[x].offset + 8;
                sbsp[x].lightmapoffset = map.BR.ReadInt32();
                if (sbsp[x].lightmapoffset == 0)
                {
                    sbsp[x].lightmapident = -1;
                    sbsp[x].lightmapTagIndex = -1;
                    if (
                        MessageBox.Show(
                            "There is no lightmap for this bsp and the scenario is currently linked to a broken ID.\n Would you like Entity to fix it?",
                            "Error",
                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        map.BW.BaseStream.Position = tempr + (x * 68) + 28;
                        map.BW.Write(int.Parse("FFFFFFFF", NumberStyles.HexNumber));
                    }

                    continue;
                }

                sbsp[x].lightmapoffset += -sbsp[x].magic;
                sbsp[x].lightmapsize = sbsp[x].size + sbsp[x].offset - sbsp[x].lightmapoffset;

                map.MetaInfo.Offset[sbsp[x].lightmapTagIndex] = sbsp[x].lightmapoffset;
                map.MetaInfo.Size[sbsp[x].lightmapTagIndex] = sbsp[x].lightmapsize;

                // light map bitmap
                map.BR.BaseStream.Position = sbsp[x].lightmapoffset + 128;
                int tempc = map.BR.ReadInt32();
                int temprx = map.BR.ReadInt32() - sbsp[x].magic;
                map.BR.BaseStream.Position = temprx + 28;
                sbsp[x].LightMap_TagNumber = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                ///light map palettes
                map.BR.BaseStream.Position = temprx + 8;
                int tempc2 = map.BR.ReadInt32();
                int tempr2 = map.BR.ReadInt32() - sbsp[x].magic;
                sbsp[x].palettesoffset = tempr2;
                for (int y = 0; y < tempc2; y++)
                {
                    map.BR.BaseStream.Position = tempr2 + (y * 1024);
                    Palette_Color[] pc = new Palette_Color[256];
                    for (int z = 0; z < 256; z++)
                    {
                        pc[z] = new Palette_Color();
                        pc[z].r = map.BR.ReadByte();
                        pc[z].g = map.BR.ReadByte();
                        pc[z].b = map.BR.ReadByte();
                        pc[z].a = map.BR.ReadByte();
                    }

                    sbsp[x].LightMap_Palettes.Add(pc);
                }

                map.BR.BaseStream.Position = temprx + 40;
                tempc2 = map.BR.ReadInt32();
                tempr2 = map.BR.ReadInt32() - sbsp[x].magic;
                sbsp[x].VisualChunk_Bitmap_Index = new int[tempc2];
                sbsp[x].VisualChunk_LightMap_Index = new int[tempc2];

                if (tempc2 != 0)
                {
                    map.BR.BaseStream.Position = tempr2;
                    for (int y = 0; y < tempc2; y++)
                    {
                        sbsp[x].VisualChunk_Bitmap_Index[y] = map.BR.ReadInt16();
                        sbsp[x].VisualChunk_LightMap_Index[y] = map.BR.ReadInt16();
                    }
                }

                map.BR.BaseStream.Position = temprx + 72;
                tempc2 = map.BR.ReadInt32();
                tempr2 = map.BR.ReadInt32() - sbsp[x].magic;
                sbsp[x].SceneryChunk_Bitmap_Index = new int[tempc2];
                sbsp[x].SceneryChunk_LightMap_Index = new int[tempc2];

                if (tempc2 > 0)
                {
                    map.BR.BaseStream.Position = tempr2;
                    for (int y = 0; y < tempc2; y++)
                    {
                        sbsp[x].SceneryChunk_Bitmap_Index[y] = map.BR.ReadInt16();
                        sbsp[x].SceneryChunk_LightMap_Index[y] = map.BR.ReadInt16();
                    }
                }
            }

            map.CloseMap();
        }
Example #4
0
        /// <summary>
        /// The halo 2 bsp container.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void Halo2BSPContainer(Map map)
        {
            map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 528;
            bspcount = map.BR.ReadInt32();
            int tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            sbsp = new BSPInfo[bspcount];
            for (int x = 0; x < bspcount; x++)
            {
                sbsp[x] = new BSPInfo();
                sbsp[x].pointerOffset      = tempr + (x * 68) - map.MetaInfo.Offset[3];
                map.BR.BaseStream.Position = tempr + (x * 68);
                sbsp[x].offset             = map.BR.ReadInt32();
                map.Functions.ParsePointer(ref sbsp[x].offset, ref sbsp[x].location);
                sbsp[x].size  = map.BR.ReadInt32();
                sbsp[x].magic = map.BR.ReadInt32() - sbsp[x].offset;
                map.BR.BaseStream.Position = tempr + (x * 68) + 20;
                sbsp[x].ident = map.BR.ReadInt32();

                //  MessageBox.Show(sbsp[x].ident.ToString("X"));
                sbsp[x].TagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].ident);
                map.MetaInfo.Offset[sbsp[x].TagIndex] = sbsp[x].offset;
                map.MetaInfo.Size[sbsp[x].TagIndex]   = sbsp[x].size;
                map.BR.BaseStream.Position            = tempr + (x * 68) + 28;
                sbsp[x].lightmapident    = map.BR.ReadInt32();
                sbsp[x].lightmapTagIndex = map.Functions.ForMeta.FindMetaByID(sbsp[x].lightmapident);
                if (sbsp[x].lightmapTagIndex == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = sbsp[x].offset + 8;
                sbsp[x].lightmapoffset     = map.BR.ReadInt32();
                if (sbsp[x].lightmapoffset == 0)
                {
                    sbsp[x].lightmapident    = -1;
                    sbsp[x].lightmapTagIndex = -1;
                    if (
                        MessageBox.Show(
                            "There is no lightmap for this bsp and the scenario is currently linked to a broken ID.\n Would you like Entity to fix it?",
                            "Error",
                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        map.BW.BaseStream.Position = tempr + (x * 68) + 28;
                        map.BW.Write(int.Parse("FFFFFFFF", NumberStyles.HexNumber));
                    }

                    continue;
                }

                sbsp[x].lightmapoffset += -sbsp[x].magic;
                sbsp[x].lightmapsize    = sbsp[x].size + sbsp[x].offset - sbsp[x].lightmapoffset;

                map.MetaInfo.Offset[sbsp[x].lightmapTagIndex] = sbsp[x].lightmapoffset;
                map.MetaInfo.Size[sbsp[x].lightmapTagIndex]   = sbsp[x].lightmapsize;

                // light map bitmap
                map.BR.BaseStream.Position = sbsp[x].lightmapoffset + 128;
                int tempc  = map.BR.ReadInt32();
                int temprx = map.BR.ReadInt32() - sbsp[x].magic;
                map.BR.BaseStream.Position = temprx + 28;
                sbsp[x].LightMap_TagNumber = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                ///light map palettes
                map.BR.BaseStream.Position = temprx + 8;
                int tempc2 = map.BR.ReadInt32();
                int tempr2 = map.BR.ReadInt32() - sbsp[x].magic;
                sbsp[x].palettesoffset = tempr2;
                for (int y = 0; y < tempc2; y++)
                {
                    map.BR.BaseStream.Position = tempr2 + (y * 1024);
                    Palette_Color[] pc = new Palette_Color[256];
                    for (int z = 0; z < 256; z++)
                    {
                        pc[z]   = new Palette_Color();
                        pc[z].r = map.BR.ReadByte();
                        pc[z].g = map.BR.ReadByte();
                        pc[z].b = map.BR.ReadByte();
                        pc[z].a = map.BR.ReadByte();
                    }

                    sbsp[x].LightMap_Palettes.Add(pc);
                }

                map.BR.BaseStream.Position = temprx + 40;
                tempc2 = map.BR.ReadInt32();
                tempr2 = map.BR.ReadInt32() - sbsp[x].magic;
                sbsp[x].VisualChunk_Bitmap_Index   = new int[tempc2];
                sbsp[x].VisualChunk_LightMap_Index = new int[tempc2];

                if (tempc2 != 0)
                {
                    map.BR.BaseStream.Position = tempr2;
                    for (int y = 0; y < tempc2; y++)
                    {
                        sbsp[x].VisualChunk_Bitmap_Index[y]   = map.BR.ReadInt16();
                        sbsp[x].VisualChunk_LightMap_Index[y] = map.BR.ReadInt16();
                    }
                }

                map.BR.BaseStream.Position = temprx + 72;
                tempc2 = map.BR.ReadInt32();
                tempr2 = map.BR.ReadInt32() - sbsp[x].magic;
                sbsp[x].SceneryChunk_Bitmap_Index   = new int[tempc2];
                sbsp[x].SceneryChunk_LightMap_Index = new int[tempc2];

                if (tempc2 > 0)
                {
                    map.BR.BaseStream.Position = tempr2;
                    for (int y = 0; y < tempc2; y++)
                    {
                        sbsp[x].SceneryChunk_Bitmap_Index[y]   = map.BR.ReadInt16();
                        sbsp[x].SceneryChunk_LightMap_Index[y] = map.BR.ReadInt16();
                    }
                }
            }

            map.CloseMap();
        }