Exemplo n.º 1
0
        public void ChangeTextureName(int lumpIndex, string val)
        {
            byte[] newName = CreateTextureName(val);

            //Edit in header
            //Seek to first lump
            fs.Seek(header.LumpOffset + ((lumpIndex + 1) * LumpSize) - 16, SeekOrigin.Begin);
            fs.Write(newName, 0, newName.Length);

            //Edit in texture if type
            if (LumpsInfo[lumpIndex].Type == 0x40 || LumpsInfo[lumpIndex].Type == 0x43)
            {
                fs.Seek(LumpsInfo[lumpIndex].Offset, SeekOrigin.Begin);
                fs.Write(newName, 0, newName.Length);
            }
            fs.Flush();

            WADLump lumpRenamed = new WADLump
            {
                CompressedLength = LumpsInfo[lumpIndex].CompressedLength,
                Compression      = LumpsInfo[lumpIndex].Compression,
                FullLength       = LumpsInfo[lumpIndex].FullLength,
                Name             = val,
                Offset           = LumpsInfo[lumpIndex].Offset,
                Type             = LumpsInfo[lumpIndex].Type
            };

            LumpsInfo[lumpIndex] = lumpRenamed;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load basic lumps data.
        /// </summary>
        private void LoadLumpsInfo()
        {
            //Seek to first lump
            binReader.BaseStream.Seek(header.LumpOffset, SeekOrigin.Begin);

            //Iterate all lumps, insert every lump to array
            for (int i = 0; i < header.LumpCount; i++)
            {
                WADLump lump = new WADLump();
                lump.Offset           = binReader.ReadUInt32();
                lump.CompressedLength = binReader.ReadUInt32();
                lump.FullLength       = binReader.ReadUInt32();
                lump.Type             = binReader.ReadByte();
                lump.Compression      = binReader.ReadByte();
                //Padding, 2-bytes
                binReader.BaseStream.Seek(2, SeekOrigin.Current);
                lump.Name = GetNullTerminatedString(binReader.ReadChars(MaxNameLength));

                LumpsInfo.Add(lump);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load basic lumps data.
        /// </summary>
        private void LoadLumpsInfo()
        {
            //Seek to first lump
            binReader.BaseStream.Seek(header.LumpOffset, SeekOrigin.Begin);

            //Iterate all lumps, insert every lump to array
            for (int i = 0; i < header.LumpCount; i++)
            {
                WADLump lump = new WADLump();
                lump.Offset = binReader.ReadUInt32();
                lump.CompressedLength = binReader.ReadUInt32();
                lump.FullLength = binReader.ReadUInt32();
                lump.Type = binReader.ReadByte();
                lump.Compression = binReader.ReadByte();
                //Padding, 2-bytes
                binReader.BaseStream.Seek(2, SeekOrigin.Current);
                lump.Name = GetNullTerminatedString(binReader.ReadChars(MaxNameLength));

                LumpsInfo.Add(lump);
            }
        }
Exemplo n.º 4
0
        public void ChangeTextureName(int lumpIndex, string val)
        {
            byte[] newName = CreateTextureName(val);

            //Edit in header
            //Seek to first lump
            fs.Seek(header.LumpOffset + ((lumpIndex + 1) * LumpSize) - 16, SeekOrigin.Begin);
            fs.Write(newName, 0, newName.Length);

            //Edit in texture if type
            if (LumpsInfo[lumpIndex].Type == 0x40 || LumpsInfo[lumpIndex].Type == 0x43)
            {
                fs.Seek(LumpsInfo[lumpIndex].Offset, SeekOrigin.Begin);
                fs.Write(newName, 0, newName.Length);
            }
            fs.Flush();

            WADLump lumpRenamed = new WADLump();
            lumpRenamed.CompressedLength = LumpsInfo[lumpIndex].CompressedLength;
            lumpRenamed.Compression = LumpsInfo[lumpIndex].Compression;
            lumpRenamed.FullLength = LumpsInfo[lumpIndex].FullLength;
            lumpRenamed.Name = val;
            lumpRenamed.Offset = LumpsInfo[lumpIndex].Offset;
            lumpRenamed.Type = LumpsInfo[lumpIndex].Type;

            this.LumpsInfo[lumpIndex] = lumpRenamed;
        }