コード例 #1
0
 public WzFile(WzMapleVersion version)
 {
     this.ident     = "";
     this.copyright = "";
     this.name      = "";
     this.wzDir     = new WzLib.WzDirectory();
     this.ident     = "PKG1";
     this.copyright = "Package file v1.0 Copyright 2002 Wizet, ZMS";
     this.type      = version;
 }
コード例 #2
0
        internal string[] GetPathsFromDirectory(WzLib.WzDirectory dir, string curPath)
        {
            List <string> list = new List <string>();

            foreach (WzImage image in dir.WzImages)
            {
                list.Add(curPath + "/" + image.Name);
                list.AddRange(this.GetPathsFromImage(image, curPath + "/" + image.Name));
            }
            foreach (WzLib.WzDirectory directory in dir.WzDirectories)
            {
                list.Add(curPath + "/" + directory.Name);
                list.AddRange(this.GetPathsFromDirectory(directory, curPath + "/" + directory.Name));
            }
            return(list.ToArray());
        }
コード例 #3
0
        public IWzObject[] GetObjectsFromDirectory(WzLib.WzDirectory dir)
        {
            List <IWzObject> list = new List <IWzObject>();

            foreach (WzImage image in dir.WzImages)
            {
                list.Add(image);
                list.AddRange(this.GetObjectsFromImage(image));
            }
            foreach (WzLib.WzDirectory directory in dir.WzDirectories)
            {
                list.Add(directory);
                list.AddRange(this.GetObjectsFromDirectory(directory));
            }
            return(list.ToArray());
        }
コード例 #4
0
        // 解析WZ主目录
        internal void ParseMainWzDirectory()
        {
            WzLib.WzDirectory directory;
            if (this.path == null)
            {
                return;
            }
            BinaryReader fileReader = new BinaryReader(File.Open(this.path, FileMode.Open));

            this.ident = "";
            // 前四个字节,文件标识:PKG1
            for (int i = 0; i < 4; i++)
            {
                this.ident = this.ident + ((char)fileReader.ReadByte());
            }
            this.fsize     = fileReader.ReadUInt64();                      // 8个字节,文件大小
            this.fstart    = fileReader.ReadUInt32();                      // 4个字节,开始位置
            this.copyright = WzTools.ReadNullTerminatedString(fileReader); // 字符串,版本信息:Package file v1.0 Copyright 2002 Wizet, ZMS
            this.version   = fileReader.ReadInt16();                       // 2个字节,文件版本
            // 这个循环用于穷举versionHash值
            for (int j = 0; j < 0xff; j++)
            {
                this.fileVersion = (byte)j;
                if (this.GetVersionHash())
                {
                    long        pos  = fileReader.BaseStream.Position;
                    WzDirectory tdir = null;
                    try
                    {
                        tdir = new WzDirectory(fileReader, fstart, name, versionHash);
                        tdir.ParseDirectory();
                    }
                    catch
                    {
                        fileReader.BaseStream.Position = pos;
                        continue;
                    }
                    WzImage test = null;
                    if (tdir.WzImages.Length != 0)
                    {
                        test = tdir.WzImages[0];
                    }
                    else
                    {
                        test = GetTestImage(tdir.WzDirectories);
                    }
                    try
                    {
                        fileReader.BaseStream.Position = test.Offset;
                        byte check = fileReader.ReadByte();
                        fileReader.BaseStream.Position = pos;
                        tdir.Dispose();
                        if (check == 0x73 || check == 0x1B)
                        {
                            goto Label_00B1;
                        }
                        else
                        {
                            fileReader.BaseStream.Position = pos;
                        }
                    }
                    catch
                    {
                        fileReader.BaseStream.Position = pos;
                        continue;
                    }
                }
            }
            throw new Exception("Error with game version hash : The specified game version is incorrect and WzLib was unable to determine the version itself");
Label_00B1:
            directory = new WzLib.WzDirectory(fileReader, this.fstart, this.name, this.versionHash);
            directory.ParseDirectory();
            this.wzDir = directory;
        }