コード例 #1
0
        public ExtraDropEntry(Stream input)
        {
            Name = new NameChar(128);
            Name.DefaultEncoding = Encoding.GetEncoding("GB18030");
            BinaryReader binaryReader = new BinaryReader(input);
            int          num1         = binaryReader.ReadInt32();

            for (int index = 0; index < num1; ++index)
            {
                this.Monsters.Add(binaryReader.ReadInt32());
            }

            for (int index = 0; index < 256; ++index)
            {
                ExtraDropItem extraDropItem = new ExtraDropItem(input);
                if (extraDropItem.Id > 0U)
                {
                    this.DropItems.Add(extraDropItem);
                }
            }
            this.SetName(binaryReader.ReadBytes(128));
            this.SetType(binaryReader.ReadInt32());
            for (int index = 0; index < 8; ++index)
            {
                float num2 = binaryReader.ReadSingle();
                this._dropNumProbabilities[index] = num2;
            }
        }
コード例 #2
0
        static ForeignPersonRecognition()
        {
            var transEnglish = new NameChar(
                "·-—阿埃艾爱安昂敖奥澳笆芭巴白拜班邦保堡鲍北贝本比毕彼别波玻博勃伯泊卜布才采仓查差柴彻川茨慈次达大戴代丹旦但当道德得登迪狄蒂帝丁东杜敦多额俄厄鄂恩尔伐法范菲芬费佛夫福弗甫噶盖干冈哥戈革葛格各根古瓜哈海罕翰汗汉豪合河赫亨侯呼胡华霍基吉及加贾坚简杰金京久居君喀卡凯坎康考柯科可克肯库奎拉喇莱来兰郎朗劳勒雷累楞黎理李里莉丽历利立力连廉良列烈林隆卢虏鲁路伦仑罗洛玛马买麦迈曼茅茂梅门蒙盟米蜜密敏明摩莫墨默姆木穆那娜纳乃奈南内尼年涅宁纽努诺欧帕潘畔庞培佩彭皮平泼普其契恰强乔切钦沁泉让热荣肉儒瑞若萨塞赛桑瑟森莎沙山善绍舍圣施诗石什史士守斯司丝苏素索塔泰坦汤唐陶特提汀图土吐托陀瓦万王旺威韦维魏温文翁沃乌吾武伍西锡希喜夏相香歇谢辛新牙雅亚彦尧叶依伊衣宜义因音英雍尤于约宰泽增詹珍治中仲朱诸卓孜祖佐伽娅尕腓滕济嘉津赖莲琳律略慕妮聂裴浦奇齐琴茹珊卫欣逊札哲智兹芙汶迦珀琪梵斐胥黛"
                    .ToCharArray());
            var transRussian = new NameChar(
                "·-阿安奥巴比彼波布察茨大德得丁杜尔法夫伏甫盖格哈基加坚捷金卡科可克库拉莱兰勒雷里历利连列卢鲁罗洛马梅蒙米姆娜涅宁诺帕泼普奇齐乔切日萨色山申什斯索塔坦特托娃维文乌西希谢亚耶叶依伊以扎佐柴达登蒂戈果海赫华霍吉季津柯理琳玛曼穆纳尼契钦丘桑沙舍泰图瓦万雅卓兹"
                    .ToCharArray());
            // 注释掉了日本人名.表面上是抵制日货.背地里是处理不好..
            // NameChar trans_japanese = new NameChar(
            // StringUtil
            // .sortCharArray("安奥八白百邦保北倍本比滨博步部彩菜仓昌长朝池赤川船淳次村大代岛稻道德地典渡尔繁饭风福冈高工宫古谷关广桂贵好浩和合河黑横恒宏后户荒绘吉纪佳加见健江介金今进井静敬靖久酒菊俊康可克口梨理里礼栗丽利立凉良林玲铃柳隆鹿麻玛美萌弥敏木纳南男内鸟宁朋片平崎齐千前浅桥琴青清庆秋丘曲泉仁忍日荣若三森纱杉山善上伸神圣石实矢世市室水顺司松泰桃藤天田土万望尾未文武五舞西细夏宪相小孝新星行雄秀雅亚岩杨洋阳遥野也叶一伊衣逸义益樱永由有佑宇羽郁渊元垣原远月悦早造则泽增扎宅章昭沼真政枝知之植智治中忠仲竹助椎子佐阪坂堀荻菅薰浜濑鸠筱"));
            Prlist.Add(transEnglish);
            Prlist.Add(transRussian);
            // PRLIST.add(trans_japanese);

            Inname = new NameChar(
                "-·—丁万丘东丝中丹丽乃久义乌乔买于亚亨京什仑仓代以仲伊伍伏伐伦伯伽但佐佛佩依侯俄保儒克兰其兹内冈凯切列利别力加努劳勃勒北华卓南博卜卡卢卫厄历及古可史叶司各合吉吐君吾呼哈哥哲唐喀善喇喜嘉噶因图土圣坎坚坦埃培基堡塔塞增墨士夏多大夫奇奈奎契奥妮姆威娃娅娜孜季宁守安宜宰密察尔尕尤尧尼居山川差巴布希帕帝干平年库庞康廉弗强当彦彭彻彼律得德恩恰慈慕戈戴才扎托拉拜捷提摩敏敖敦文斐斯新施日旦旺昂明普智曼朗木本札朱李杜来杰林果查柯柴根格桑梅梵森楞次欣欧歇武比毕汀汉汗汤汶沁沃沙河治泉泊法波泰泼泽洛津济浦海涅温滕潘澳烈热爱牙特狄王玛玻珀珊珍班理琪琳琴瑞瑟瓜瓦甫申畔略登白皮盖盟相石祖福科穆立笆简米素索累约纳纽绍维罕罗翁翰考耶聂肉肯胡胥腓舍良色艾芙芬芭苏若英茂范茅茨茹荣莉莎莫莱莲菲萨葛蒂蒙虏蜜衣裴西詹让诗诸诺谢豪贝费贾赖赛赫路辛达迈连迦迪逊道那邦郎鄂采里金钦锡门阿陀陶隆雅雍雷霍革韦音额香马魏鲁鲍麦黎默黛齐"
                    .ToCharArray());

            IsNotFirst.Add('-');
            IsNotFirst.Add('·');
            IsNotFirst.Add('—');
        }
コード例 #3
0
        public void Read(BinaryReader bReader, int Version, bool isClient)
        {
            local_id  = bReader.ReadInt32();
            main_type = bReader.ReadInt32();
            sub_type  = bReader.ReadInt32();
            if (isClient)
            {
                icon = new NameChar(128, bReader, Encoding.GetEncoding("gb2312"));
            }
            else
            {
                icon = new NameChar(128);
                icon.DefaultEncoding = Encoding.GetEncoding("gb2312");
            }
            id  = bReader.ReadUInt32();
            num = bReader.ReadUInt32();
            for (int i = 0; i < 4; i++)
            {
                sale_options[i] = new SaleOption();
                sale_options[i].Read(bReader, Version);
            }
            if (Version <= 7)
            {
                props = bReader.ReadUInt32();
            }
            if (isClient)
            {
                description = new NameChar(1024, bReader);
                name        = new NameChar(64, bReader);
            }
            else
            {
                description = new NameChar(1024);
                name        = new NameChar(64);
                name.Name   = "SVItem " + local_id;
            }
            if (id > 100000)
            {
                throw new Exception("File might be wrong version the name has 0 bytes!");
            }

            if (Version > 7)
            {
                idGift    = bReader.ReadUInt32();
                iGiftNum  = bReader.ReadUInt32();
                iGiftTime = bReader.ReadUInt32();
                iLogPrice = bReader.ReadUInt32();
                if (Version > 123)
                {
                    npc1 = bReader.ReadUInt32();
                    npc2 = bReader.ReadUInt32();
                    npc3 = bReader.ReadUInt32();
                    npc4 = bReader.ReadUInt32();
                    npc5 = bReader.ReadUInt32();
                    npc6 = bReader.ReadUInt32();
                    npc7 = bReader.ReadUInt32();
                    npc8 = bReader.ReadUInt32();
                    if (Version >= 155)
                    {
                        buy_times_limit      = bReader.ReadInt32();
                        buy_times_limit_mode = bReader.ReadInt32();
                        if (Version >= 157)
                        {
                            unk1 = bReader.ReadUInt32();
                        }
                    }
                }
            }
        }
コード例 #4
0
        public int ReWrite()
        {
            string       pathx  = path + ".files\\";
            DialogResult result = DialogResult.No;

            if (Directory.Exists(pathx))
            {
                result = MessageBox.Show("Found files on disk do you want to rewrite from files?", "Question", MessageBoxButtons.YesNo);
            }
            #region AAAAA
            if (result == DialogResult.No)
            {
                LimitedConcurrencyLevelTaskScheduler lcts = new LimitedConcurrencyLevelTaskScheduler(Environment.ProcessorCount / 2);
                List <Task>             tasks             = new List <Task>();
                TaskFactory             factory           = new TaskFactory(lcts);
                CancellationTokenSource cts = new CancellationTokenSource();
                MakeStreams();
                if (path != null && path.Length > 0)
                {
                    PckEntry[] values = table.Values.ToArray();
                    int        count  = values.Length;
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (values[i].bytesCompresed == null)
                        {
                            PckEntry pck  = values[i];
                            byte[]   data = getChunk2("", pck);
                            progress_bar("Reading files ....", i, count);
                            Task t1 = factory.StartNew((o) =>
                            {
                                progress_bar("Compressing files ....", (int)o, count);
                                pck.bytesCompresed = PCKZlib.Compress(data, CompressionLevel);
                            }, i, cts.Token);
                            tasks.Add(t1);
                        }
                    }
                    progress_bar("Please Wait", 0, 0);
                    Task.WaitAll(tasks.ToArray());
                    Thread.Sleep(500);
                    cts.Dispose();
                    initialCount = count;
                    this.Dispose();
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    if (File.Exists(path.Replace(".pck", ".pkx")))
                    {
                        File.Delete(path.Replace(".pck", ".pkx"));
                    }

                    PCKStream stream = new PCKStream(path);
                    stream.WriteInt32(stream.key.FSIG_1);
                    stream.WriteInt32(0);
                    stream.WriteInt32(stream.key.FSIG_2);
                    for (int i = 0; i < values.Length; i++)
                    {
                        PckEntry fte = values[i];
                        fte.setVersion(version);

                        progress_bar("Writing files ....", i, count);
                        fte.fileoffset = (uint)stream.Position;
                        stream.WriteBytes(fte.bytesCompresed);
                    }
                    uint         fileTableOffset_tmp = (uint)stream.Position;
                    MemoryStream FileTable           = new MemoryStream();
                    for (int i = 0; i < values.Length; i++)
                    {
                        PckEntry fte = values[i];
                        fte.setVersion(version);
                        byte[] buffer = fte.Write(CompressionLevel);
                        lock (FileTable)
                        {
                            FileTable.Write(BitConverter.GetBytes(buffer.Length ^ KEY_1), 0, 4);
                            FileTable.Write(BitConverter.GetBytes(buffer.Length ^ KEY_2), 0, 4);
                            FileTable.Write(buffer, 0, buffer.Length);
                        }
                        progress_bar("Writing table...", i, count);
                    }
                    stream.WriteBytes(FileTable.ToArray());
                    FileTable.Flush();
                    FileTable.Dispose();
                    stream.WriteInt32(ASIG_1);
                    stream.WriteInt16(version);
                    stream.WriteInt16(2);
                    stream.WriteUInt32((uint)(fileTableOffset_tmp ^ KEY_1));
                    if (version > 2)
                    {
                        stream.WriteInt32(-1);
                    }
                    stream.WriteInt32(0);
                    NameChar namechar = new NameChar(252);
                    namechar.DefaultEncoding = Encoding.Default;
                    namechar.Name            = "Angelica File Package, writed by JHS Software.";
                    stream.WriteBytes(namechar.EncodedName);
                    stream.WriteInt32(ASIG_2);
                    if (version > 2)
                    {
                        stream.WriteInt32(512);
                    }
                    stream.WriteInt32(table.Count);
                    stream.WriteInt16(version);
                    stream.WriteInt16(2);
                    stream.Seek(4, SeekOrigin.Begin);
                    stream.WriteUInt32((uint)stream.GetLenght());
                    stream.Dispose();
                    progress_bar("Clearing memory...", 0, 0);
                    for (int i = 0; i < values.Length; i++)
                    {
                        PckEntry fte = values[i];
                        table[fte.id].bytes          = null;
                        table[fte.id].bytesCompresed = null;
                        table[fte.id].memory         = null;
                        progress_bar("Clearing memory...", i, count);
                    }
                    GC.Collect();
                    progress_bar("Ready", 0, 0);
                }
            }
            else
            #endregion
            #region FROM DISK
            {
                directoryStructure = null;
                GC.Collect();
                modified           = false;
                directoryStructure = new PackStructureManager(Path.GetFileNameWithoutExtension(path));
                table = new SortedList <int, PckEntry>();
                string[] files = Directory.GetFiles(pathx, "*", SearchOption.AllDirectories);

                int count = files.Length;
                initialCount = count;
                this.Dispose();
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                if (File.Exists(path.Replace(".pck", ".pkx")))
                {
                    File.Delete(path.Replace(".pck", ".pkx"));
                }

                PCKStream stream = new PCKStream(path);
                stream.WriteInt32(stream.key.FSIG_1);
                stream.WriteInt32(0);
                stream.WriteInt32(stream.key.FSIG_2);
                for (int i = 0; i < files.Length; i++)
                {
                    string   file  = files[i].Replace(pathx, "").Replace("/", "\\");
                    string   pathr = Path.Combine(pathx, file);
                    PckEntry data  = new PckEntry(version);
                    data.filePath = file;
                    byte[] datab          = File.ReadAllBytes(pathr);
                    byte[] bytesCompresed = PCKZlib.Compress(datab, CompressionLevel);
                    data.compressedSize   = bytesCompresed.Length;
                    data.decompressedSize = datab.Length;
                    data.id = i;
                    progress_bar("Writing files ....", i, count);
                    data.fileoffset = (uint)stream.Position;
                    stream.WriteBytes(bytesCompresed);
                    table[i] = data;
                    directoryStructure.addfille(table[i]);
                }
                progress_bar("Please Wait", 0, 0);
                Application.DoEvents();
                uint         fileTableOffset_tmp = (uint)stream.Position;
                MemoryStream FileTable           = new MemoryStream();
                progress_bar("Finalizing Pack...", 0, 0);
                for (int i = 0; i < table.Count; i++)
                {
                    PckEntry fte    = table[i];
                    byte[]   buffer = fte.Write(CompressionLevel);
                    lock (FileTable)
                    {
                        FileTable.Write(BitConverter.GetBytes(buffer.Length ^ KEY_1), 0, 4);
                        FileTable.Write(BitConverter.GetBytes(buffer.Length ^ KEY_2), 0, 4);
                        FileTable.Write(buffer, 0, buffer.Length);
                    }
                    progress_bar("Finalizing Pack...", i, count);
                }
                stream.WriteBytes(FileTable.ToArray());
                FileTable.Flush();
                FileTable.Dispose();
                stream.WriteInt32(ASIG_1);
                stream.WriteInt16(version);
                stream.WriteInt16(2);
                stream.WriteUInt32((uint)(fileTableOffset_tmp ^ KEY_1));
                if (version > 2)
                {
                    stream.WriteInt32(-1);
                }
                stream.WriteInt32(0);
                NameChar namechar = new NameChar(252);
                namechar.DefaultEncoding = Encoding.Default;
                namechar.Name            = "Angelica File Package, writed by JHS Software.";
                stream.WriteBytes(namechar.EncodedName);
                stream.WriteInt32(ASIG_2);
                if (version > 2)
                {
                    stream.WriteInt32(512);
                }
                stream.WriteInt32(table.Count);
                stream.WriteInt16(version);
                stream.WriteInt16(2);
                stream.Seek(4, SeekOrigin.Begin);
                stream.WriteUInt32((uint)stream.GetLenght());
                stream.Dispose();
                progress_bar("Clearing memory...", 0, 0);
                for (int i = 0; i < table.Count; i++)
                {
                    table[i].bytes          = null;
                    table[i].bytesCompresed = null;
                    table[i].memory         = null;
                    progress_bar("Clearing memory...", i, count);
                }
                GC.Collect();
                progress_bar("Ready", 0, 0);
            }
            #endregion
            return(0);//SUccess
        }
コード例 #5
0
        /// <summary>
        /// Returns 0 success
        /// </summary>
        /// <returns></returns>
        public int Update()
        {
            if (path != null && path.Length > 0)
            {
                if (initialCount > table.Count)
                {
                    return(ReWrite());
                }
                if (!modified)
                {
                    DialogResult res = JMessageBox.Show(PackView.Instance, "The archive has not been modified do you wish to rewirte it?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (res == DialogResult.Yes)
                    {
                        return(ReWrite());
                    }
                    else
                    {
                        return(0);
                    }
                }
                this.Dispose();
                PCKStream stream = new PCKStream(path);

                if (stream != null)
                {
                    stream.Seek(fileTableOffset, SeekOrigin.Begin);
                    //Write new files
                    PckEntry[] values = table.Values.ToArray();
                    for (int i = 0; i < values.Length; i++)
                    {
                        PckEntry fte = values[i];
                        if (fte.bytesCompresed != null)
                        {
                            fte.fileoffset = (uint)stream.Position;
                            stream.WriteBytes(fte.bytesCompresed);
                        }
                    }
                    uint fileTableOffset_tmp = (uint)stream.Position;
                    //RewriteTable
                    progress_bar("Finalizing Pack...", 0, 0);
                    MemoryStream FileTable = new MemoryStream();
                    for (int i = 0; i < values.Length; i++)
                    {
                        PckEntry fte    = values[i];
                        byte[]   buffer = fte.Write(CompressionLevel);
                        lock (FileTable)
                        {
                            FileTable.Write(BitConverter.GetBytes(buffer.Length ^ KEY_1), 0, 4);
                            FileTable.Write(BitConverter.GetBytes(buffer.Length ^ KEY_2), 0, 4);
                            FileTable.Write(buffer, 0, buffer.Length);
                        }
                        progress_bar("Finalizing Pack...", i, values.Length);
                    }
                    stream.WriteBytes(FileTable.ToArray());
                    FileTable.Flush();
                    FileTable.Dispose();
                    stream.WriteInt32(ASIG_1);
                    stream.WriteInt16(version);
                    stream.WriteInt16(2);
                    stream.WriteUInt32((uint)(fileTableOffset_tmp ^ KEY_1));
                    if (version > 2)
                    {
                        stream.WriteInt32(-1);
                    }
                    stream.WriteInt32(0);
                    NameChar namechar = new NameChar(252);
                    namechar.DefaultEncoding = Encoding.Default;
                    namechar.Name            = "Angelica File Package, writed by JHS Software.";
                    stream.WriteBytes(namechar.EncodedName);
                    stream.WriteInt32(ASIG_2);
                    if (version > 2)
                    {
                        stream.WriteInt32(512);
                    }
                    stream.WriteInt32(table.Count);
                    stream.WriteInt16(version);
                    stream.WriteInt16(2);
                    stream.Seek(4, SeekOrigin.Begin);
                    stream.WriteUInt32((uint)stream.GetLenght());
                    stream.Dispose();
                    progress_bar("Clearing memory...", 0, 0);
                    foreach (PckEntry fte in table.Values)
                    {
                        table[fte.id].bytes          = null;
                        table[fte.id].bytesCompresed = null;
                        table[fte.id].memory         = null;
                    }
                    GC.Collect();
                    return(0);//SUccess
                }
                else
                {
                    return(3);//CANNOT OPEN STREAM;
                }
            }
            else
            {
                if (path == null)
                {
                    return(1); //PATH NULL
                }
                else if (path != null && path.Length == 0)
                {
                    return(1); //PATH NULL
                }
                else
                {
                    return(2);// NOT MODIFIED
                }
            }
        }