コード例 #1
0
ファイル: WZDirectory.cs プロジェクト: smolson4/wzmapeditor
 public WZDirectory(string Name, WZFile file, int baseOffset, WZDirectory parent, int Size)
 {
     this.Name = Name;
     this.baseOffset = baseOffset;
     this.file = file;
     this.Size = Size;
     this.parent = parent;
 }
コード例 #2
0
 public WZDirectory(string Name, WZFile file, int baseOffset, WZDirectory parent, int Size)
 {
     this.Name       = Name;
     this.baseOffset = baseOffset;
     this.file       = file;
     this.Size       = Size;
     this.parent     = parent;
 }
コード例 #3
0
ファイル: IMGFile.cs プロジェクト: phantomeis/wzmapeditor
 public IMGFile(string Name, File file, int baseOffset, WZDirectory parent, int Size, int checksum)
 {
     loaded          = false;
     this.Name       = Name;
     this.baseOffset = baseOffset;
     this.file       = file;
     this.Size       = Size;
     this.Directory  = parent;
     this.Checksum   = checksum;
 }
コード例 #4
0
ファイル: IMGFile.cs プロジェクト: smolson4/wzmapeditor
 public IMGFile(string Name, File file, int baseOffset, WZDirectory parent, int Size, int checksum)
 {
     loaded = false;
     this.Name = Name;
     this.baseOffset = baseOffset;
     this.file = file;
     this.Size = Size;
     this.Directory = parent;
     this.Checksum = checksum;
 }
コード例 #5
0
        public void Open(WZDirectory other, List <WZPatchOperation> operations, string Base)
        {
            int count = file.ReadValue();

            List <string> names = new List <string>();

            for (int i = 0; i < count; i++)
            {
                string Name = "";
                int    size, checksum, offset;
                byte   type = file.ReadByte();

                switch (type)
                {
                case 0x02: Name = file.ReadStringAt(true); break;

                case 0x03:
                case 0x04: Name = file.ReadString(); break;
                }

                size     = file.ReadValue();
                checksum = file.ReadValue();
                offset   = file.ReadOffset();

                switch (type)
                {
                case 0x02:
                case 0x04:
                {
                    IMGFile img = other.GetIMG(Base + ((Base == "") ? "" : "/") + Name);
                    if (img == null || img.Checksum != checksum)
                    {
                        operations.Add(new Add(file, offset + file.FileStart, size));
                    }
                    else
                    {
                        operations.Add(new Copy(other.file, img.baseOffset + other.file.FileStart, img.Size));
                    }
                    break;
                }

                case 0x03:
                {
                    names.Add(Name);
                    break;
                }
                }
            }
            foreach (string name in names)
            {
                Open(other, operations, Base + ((Base == "") ? "" : "/") + name);
            }
        }
コード例 #6
0
        public void WriteIMGs(BinaryWriter file)
        {
            foreach (DictionaryEntry entry in IMGs)
            {
                IMGFile img = (IMGFile)entry.Value;
                img.Write(file);
            }


            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                directory.WriteIMGs(file);
            }
        }
コード例 #7
0
        private int CalculateIMGsSize()
        {
            int size = 0;

            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                size += directory.CalculateIMGsSize();
            }
            foreach (DictionaryEntry entry in IMGs)
            {
                IMGFile img = (IMGFile)entry.Value;
                size += img.Size;
            }
            return(size);
        }
コード例 #8
0
 public void CreateTempIMGs()
 {
     foreach (DictionaryEntry entry in Directories)
     {
         WZDirectory directory = (WZDirectory)entry.Value;
         directory.CreateTempIMGs();
     }
     foreach (DictionaryEntry entry in IMGs)
     {
         IMGFile img = (IMGFile)entry.Value;
         if (img.ToSave)
         {
             img.CreateTemp();
         }
     }
 }
コード例 #9
0
        public void Open(WZDirectory other, List <WZPatchOperation> operations)
        {
            long soffset = file.file.BaseStream.Position;

            List <WZPatchOperation> ops = new List <WZPatchOperation>();

            file.file.BaseStream.Seek(baseOffset + file.FileStart, SeekOrigin.Begin);

            Open(other, ops, "");

            int size = (int)file.file.BaseStream.Position;

            operations.Add(new Add(file, 0, size));

            operations.AddRange(ops);

            file.file.BaseStream.Seek(soffset, SeekOrigin.Begin);
        }
コード例 #10
0
        public override void Write(BinaryWriter file)
        {
            if (dirOffsets.Contains(this))
            {
                WriteOffsetAt(file, (int)dirOffsets[this], (int)file.BaseStream.Position);
            }

            WritePackedInt(file, Directories.Count + IMGs.Count);

            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                WriteString(file, directory.Name, 3, 1, true);
                WritePackedInt(file, directory.CalculateIMGsSize());
                WritePackedInt(file, 0); // checksum
                dirOffsets[directory] = (int)file.BaseStream.Position;
                file.Write((int)0);      // keep place for the offset
            }

            foreach (DictionaryEntry entry in IMGs)
            {
                IMGFile img = (IMGFile)entry.Value;
                img.CalculateChecksum();
                WriteString(file, img.Name, 4, 2, true);
                WritePackedInt(file, img.Size);
                WritePackedInt(file, img.Checksum);
                imgOffsets[img] = (int)file.BaseStream.Position;
                file.Write((int)0); // keep place for the offset
            }

            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                directory.Write(file);
            }

            /*foreach (DictionaryEntry entry in IMGs)
             * {
             *  IMGFile img = (IMGFile)entry.Value;
             *  img.Write(file);
             * }*/
        }
コード例 #11
0
        public void Open()
        {
            if (!loaded)
            {
                file.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);

                Header    = ReadString(4);
                FileSize  = ReadLong();
                FileStart = ReadInt();
                Copyright = ReadString(FileStart - (int)Position());
                byte EncodedVersion = ReadByte();
                if (EncodeVersion() != EncodedVersion)
                {
                    throw new Exception("Incorrect version error");
                }
                ReadByte(); // null

                Directory = new WZDirectory(Name, this, 2);

                loaded = true;
            }
        }
コード例 #12
0
 private static void Clean(WZDirectory directory, object locker)
 {
     foreach(IMGFile img in directory.IMGs.Values)
     {
         lock (img)
         {
             if (img.IsLoaded())
             {
                 if (!img.ToSave && !imgs.Contains(img))
                 {
                     lock(locker)
                         img.Close();
                 }
             }
         }
     }
     foreach (WZDirectory dir in directory.Directories.Values)
     {
         Clean(dir, locker);
     }
 }
コード例 #13
0
ファイル: WZDirectory.cs プロジェクト: smolson4/wzmapeditor
        public void Open(WZDirectory other, List<WZPatchOperation> operations, string Base)
        {
            int count = file.ReadValue();

            List<string> names = new List<string>();

            for (int i = 0; i < count; i++)
            {
                string Name = "";
                int size, checksum, offset;
                byte type = file.ReadByte();

                switch (type)
                {
                    case 0x02: Name = file.ReadStringAt(true); break;
                    case 0x03:
                    case 0x04: Name = file.ReadString(); break;
                }

                size = file.ReadValue();
                checksum = file.ReadValue();
                offset = file.ReadOffset();

                switch (type)
                {
                    case 0x02:
                    case 0x04:
                        {
                            IMGFile img = other.GetIMG(Base + ((Base == "") ? "" : "/") + Name);
                            if (img == null || img.Checksum != checksum)
                            {
                                operations.Add(new Add(file, offset + file.FileStart, size));
                            }
                            else
                            {
                                operations.Add(new Copy(other.file, img.baseOffset + other.file.FileStart, img.Size));
                            }
                            break;
                        }
                    case 0x03:
                        {
                            names.Add(Name);
                            break;
                        }
                }
            }
            foreach (string name in names)
            {
                Open(other, operations, Base + ((Base == "") ? "" : "/") + name);
            }
        }
コード例 #14
0
ファイル: WZDirectory.cs プロジェクト: smolson4/wzmapeditor
        public void Open(WZDirectory other, List<WZPatchOperation> operations)
        {
            long soffset = file.file.BaseStream.Position;

            List<WZPatchOperation> ops = new List<WZPatchOperation>();
            file.file.BaseStream.Seek(baseOffset + file.FileStart, SeekOrigin.Begin);

            Open(other, ops, "");

            int size = (int)file.file.BaseStream.Position;

            operations.Add(new Add(file, 0, size));

            operations.AddRange(ops);

            file.file.BaseStream.Seek(soffset, SeekOrigin.Begin);
        }
コード例 #15
0
ファイル: MapEditor.cs プロジェクト: smolson4/wzmapeditor
 private void LoadNames(WZDirectory dir, IMGFile strings, Hashtable names)
 {
     foreach (IMGFile life in dir.IMGs.Values)
     {
         string id = int.Parse(life.Name.Substring(0, 7)).ToString();
         names.Add(id, strings.GetString(id + "/name"));
     }
 }
コード例 #16
0
ファイル: WZFile.cs プロジェクト: smolson4/wzmapeditor
        public void Open()
        {
            if (!loaded)
            {
                file.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);

                Header = ReadString(4);
                FileSize = ReadLong();
                FileStart = ReadInt();
                Copyright = ReadString(FileStart - (int)Position());
                byte EncodedVersion = ReadByte();
                if (EncodeVersion() != EncodedVersion) throw new Exception("Incorrect version error");
                ReadByte(); // null

                Directory = new WZDirectory(Name, this, 2);

                loaded = true;
            }
        }