Ejemplo n.º 1
0
        public DummyFlatLookup(Wad wad)
        {
            var firstFlat = wad.GetLumpNumber("F_START") + 1;
            var lastFlat  = wad.GetLumpNumber("F_END") - 1;
            var count     = lastFlat - firstFlat + 1;

            flats = new Flat[count];

            nameToFlat   = new Dictionary <string, Flat>();
            nameToNumber = new Dictionary <string, int>();

            for (var lump = firstFlat; lump <= lastFlat; lump++)
            {
                if (wad.GetLumpSize(lump) != 4096)
                {
                    continue;
                }

                var number = lump - firstFlat;
                var name   = wad.LumpInfos[lump].Name;
                var flat   = name != "F_SKY1" ? DummyData.GetFlat() : DummyData.GetSkyFlat();

                flats[number]      = flat;
                nameToFlat[name]   = flat;
                nameToNumber[name] = number;
            }

            skyFlatNumber = nameToNumber["F_SKY1"];
            skyFlat       = nameToFlat["F_SKY1"];
        }
Ejemplo n.º 2
0
        public static Flat GetSkyFlat()
        {
            if (dummySkyFlat != null)
            {
                return(dummySkyFlat);
            }
            else
            {
                dummySkyFlat = new Flat("DUMMY", GetFlat().Data);

                return(dummySkyFlat);
            }
        }
Ejemplo n.º 3
0
        private void InitStandard(Wad wad)
        {
            try
            {
                Console.Write("Load flats: ");

                var firstFlat = wad.GetLumpNumber("F_START") + 1;
                var lastFlat  = wad.GetLumpNumber("F_END") - 1;
                var count     = lastFlat - firstFlat + 1;

                flats = new Flat[count];

                nameToFlat   = new Dictionary <string, Flat>();
                nameToNumber = new Dictionary <string, int>();

                for (var lump = firstFlat; lump <= lastFlat; lump++)
                {
                    if (wad.GetLumpSize(lump) != 4096)
                    {
                        continue;
                    }

                    var number = lump - firstFlat;
                    var name   = wad.LumpInfos[lump].Name;
                    var flat   = new Flat(name, wad.ReadLump(lump));

                    flats[number]      = flat;
                    nameToFlat[name]   = flat;
                    nameToNumber[name] = number;
                }

                skyFlatNumber = nameToNumber["F_SKY1"];
                skyFlat       = nameToFlat["F_SKY1"];

                Console.WriteLine("OK (" + nameToFlat.Count + " flats)");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                ExceptionDispatchInfo.Throw(e);
            }
        }
Ejemplo n.º 4
0
        public static Flat GetFlat()
        {
            if (dummyFlat != null)
            {
                return(dummyFlat);
            }
            else
            {
                var data = new byte[64 * 64];
                var spot = 0;
                for (var y = 0; y < 64; y++)
                {
                    for (var x = 0; x < 64; x++)
                    {
                        data[spot] = ((x / 32) ^ (y / 32)) == 0 ? (byte)80 : (byte)96;
                        spot++;
                    }
                }

                dummyFlat = new Flat("DUMMY", data);

                return(dummyFlat);
            }
        }
Ejemplo n.º 5
0
        private void InitDeuTexMerge(Wad wad)
        {
            try
            {
                Console.Write("Load flats: ");

                var allFlats = new List <int>();
                var flatZone = false;
                for (var lump = 0; lump < wad.LumpInfos.Count; lump++)
                {
                    var name = wad.LumpInfos[lump].Name;
                    if (flatZone)
                    {
                        if (name == "F_END" || name == "FF_END")
                        {
                            flatZone = false;
                        }
                        else
                        {
                            allFlats.Add(lump);
                        }
                    }
                    else
                    {
                        if (name == "F_START" || name == "FF_START")
                        {
                            flatZone = true;
                        }
                    }
                }
                allFlats.Reverse();

                var dupCheck      = new HashSet <string>();
                var distinctFlats = new List <int>();
                foreach (var lump in allFlats)
                {
                    if (!dupCheck.Contains(wad.LumpInfos[lump].Name))
                    {
                        distinctFlats.Add(lump);
                        dupCheck.Add(wad.LumpInfos[lump].Name);
                    }
                }
                distinctFlats.Reverse();

                flats = new Flat[distinctFlats.Count];

                nameToFlat   = new Dictionary <string, Flat>();
                nameToNumber = new Dictionary <string, int>();

                for (var number = 0; number < flats.Length; number++)
                {
                    var lump = distinctFlats[number];

                    if (wad.GetLumpSize(lump) != 4096)
                    {
                        continue;
                    }

                    var name = wad.LumpInfos[lump].Name;
                    var flat = new Flat(name, wad.ReadLump(lump));

                    flats[number]      = flat;
                    nameToFlat[name]   = flat;
                    nameToNumber[name] = number;
                }

                skyFlatNumber = nameToNumber["F_SKY1"];
                skyFlat       = nameToFlat["F_SKY1"];

                Console.WriteLine("OK (" + nameToFlat.Count + " flats)");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                ExceptionDispatchInfo.Throw(e);
            }
        }