예제 #1
0
        public void BooleanValues(bool expected, byte[] data)
        {
            var packer = new MiniMessagePacker();
            var actual = (bool)packer.Unpack(data);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void NullValue()
        {
            var packer = new MiniMessagePacker();
            var actual = packer.Unpack(new byte[] { 0xc0 });

            Assert.AreEqual(null, actual);
        }
    // Token: 0x06003BB5 RID: 15285 RVA: 0x001393C4 File Offset: 0x001375C4
    public static object MouseHomeMsgPack(byte[] data, byte[] home, byte[] info, bool isCompress = false)
    {
        MiniMessagePacker miniMessagePacker = new MiniMessagePacker();

        byte[] buf = CatAndMouseGame.MouseHomeSub(data, home, info, isCompress);
        return(miniMessagePacker.Unpack(buf));
    }
예제 #4
0
        public void StringValues(string expected, byte[] data, string message)
        {
            var packer = new MiniMessagePacker();
            var actual = packer.Unpack(data);

            Assert.AreEqual(actual.GetType(), typeof(string));
            Assert.AreEqual(expected, actual, message);
        }
예제 #5
0
    public IAVIMMessage Deserialize(string msgStr)
    {
        var spiltStrs  = msgStr.Split(':');
        var serContent = spiltStrs[1];
        var tMessage   = m_MsgPacker.Unpack(System.Convert.FromBase64String(serContent)) as Dictionary <string, object>;

        this.m_SendName = Convert.ToString(tMessage["S"]);
        this.m_Content  = Convert.ToString(tMessage["C"]);

        return(this);
    }
예제 #6
0
        public void MapValues(string[] keys, object[] values, byte[] data, string message)
        {
            var packer = new MiniMessagePacker();
            var actual = (Dictionary <string, object>)packer.Unpack(data);

            Assert.AreEqual(keys.Length, actual.Count, message + ": count");
            for (int i = 0; i < keys.Length; i++)
            {
                Assert.AreEqual(values [i], actual [keys[i]], message + "[" + keys[i] + "]");
            }
        }
예제 #7
0
        public void ArrayValues(object[] expected, byte[] data, string message)
        {
            var packer = new MiniMessagePacker();
            var actual = packer.Unpack(data) as List <object>;

            Assert.AreNotEqual(actual, null, message + ": type");
            Assert.AreEqual(expected.Length, actual.Count, message + ": count");
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected [i], actual [i], message + "[" + i + "]");
            }
        }
예제 #8
0
        protected override void ThreadFunction()
        {
            var    mini = new MiniMessagePacker();
            object message;

            while ((message = mini.Unpack(stream)) != null)
            {
                if (!(message is Dictionary <string, object>))
                {
                    continue;
                }
                Status = MessageSerializer.Serialize((Dictionary <string, object>)message);
            }
        }
        // Adds in a new animation clip from a CreaturePack Anim Data byte stream
        // This means you are using the separately exported CreaturePack Animation Data files
        public void addSplitAnimClip(Stream byteStream, CreaturePackPlayer playerIn)
        {
            var newReader  = new MiniMessagePacker();
            var unpackData = newReader.Unpack(byteStream);
            var readData   = (object[])unpackData;

            // Add in new clip data
            var splitClip = new CreaturePackSplitAnimClip(readData);
            var clipName  = (string)readData[CreatureConsts.SPLIT_CLIP_NAME_IDX];

            animClipMap[clipName]         = splitClip;
            playerIn.runTimeMap[clipName] = splitClip.startTime;

            UnityEngine.Debug.Log("Adding Pack Split Animation: " + clipName);

            // Process clip point data
            var splitProcessObj = new FinalPointsProcessSplitData(this, readData);

            processPerFinalAllPointsSample(splitProcessObj);
        }
예제 #10
0
        public void runDecoder(Stream byteStream)
        {
            var newReader = new MiniMessagePacker();

            fileData = (object[])newReader.Unpack(byteStream);

            headerList          = (object[])fileData[getBaseOffset()];
            animPairsOffsetList = (object[])fileData[getAnimPairsListOffset()];

            // init basic points and topology structure
            indices = new uint[getNumIndices()];
            points  = new float[getNumPoints()];
            uvs     = new float[getNumUvs()];

            updateIndices(getBaseIndicesOffset());
            updatePoints(getBasePointsOffset());
            updateUVs(getBaseUvsOffset());

            // init Animation Clip Map
            for (int i = 0; i < getAnimationNum(); i++)
            {
                var curOffsetPair = getAnimationOffsets(i);

                var animName = (string)(fileData[curOffsetPair.first]);
                var k        = curOffsetPair.first;
                k++;
                var newClip = new CreaturePackAnimClip(k);

                while (k < curOffsetPair.second)
                {
                    int cur_time = (int)(float)(fileData[k]);
                    newClip.addTimeSample(cur_time, (int)k);

                    k += 4;
                }

                newClip.finalTimeSamples();
                animClipMap[animName] = newClip;
            }
        }
예제 #11
0
        public void UnpackExample()
        {
            // it means {"compact":true,"schema":0} in JSON
            var msgpack = new byte[] {
                0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3,
                0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00
            };

            var    packer        = new MiniMessagePacker();
            object unpacked_data = packer.Unpack(msgpack);

            /*
             * unpacked_data = new Dictionary<string, object> {
             *     { "compact", true },
             *     { "schema", 0},
             * };
             */
            var dict = (Dictionary <string, object>)unpacked_data;

            Assert.IsTrue((bool)dict ["compact"]);
            Assert.AreEqual(0, (long)dict ["schema"]);
        }
        public void runDecoder(Stream byteStream, bool loadMultiCore)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var newReader = new MiniMessagePacker();

            fileData = (object[])newReader.Unpack(byteStream);

            stopWatch.Stop();
#if (CREATURE_PACK_DEBUG)
            UnityEngine.Debug.Log("---Data Decode time: " + stopWatch.ElapsedMilliseconds);
#endif
            stopWatch.Reset();

            headerList          = (object[])fileData[getBaseOffset()];
            animPairsOffsetList = (object[])fileData[getAnimPairsListOffset()];

            // init basic points and topology structure
            indices = new uint[getNumIndices()];
            points  = new float[getNumPoints()];
            uvs     = new float[getNumUvs()];

            updateIndices(getBaseIndicesOffset());
            updatePoints(getBasePointsOffset());
            updateUVs(getBaseUvsOffset());

            fillDeformRanges();

            stopWatch.Start();

            if (loadMultiCore)
            {
                finalAllPointSamplesThreaded();
            }
            else
            {
                finalAllPointSamples();
            }

            stopWatch.Stop();
#if (CREATURE_PACK_DEBUG)
            UnityEngine.Debug.Log("---Data Packaging time: " + stopWatch.ElapsedMilliseconds);
#endif

            // init Animation Clip Map
            for (int i = 0; i < getAnimationNum(); i++)
            {
                var curOffsetPair = getAnimationOffsets(i);

                var animName = (string)(fileData[curOffsetPair.first]);
                var k        = curOffsetPair.first;
                k++;
                var newClip = new CreaturePackAnimClip(k, fileData);

                while (k < curOffsetPair.second)
                {
                    int cur_time = (int)(float)(fileData[k]);
                    newClip.addTimeSample(cur_time, (int)k);

                    k += 4;
                }

                newClip.finalTimeSamples();
                animClipMap[animName] = newClip;
            }
        }
예제 #13
0
        private void HttpRequestData()
        {
            listBox1.Items.Clear();
            progressBar1.Value = 0;
            var path     = Directory.GetCurrentDirectory();
            var gamedata = new DirectoryInfo(path + @"\Android\masterdata\");
            var folder   = new DirectoryInfo(path + @"\Android\");

            progressBar1.Value = progressBar1.Value + 250;
            if (!Directory.Exists(folder.FullName))
            {
                listBox1.Items.Add("正在创建Android目录...");
                listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
                Directory.CreateDirectory(folder.FullName);
            }

            listBox1.Items.Add("开始下载/更新游戏数据......");
            progressBar1.Value = progressBar1.Value + 250;
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            var result = HttpRequest.PhttpReq("https://game.fate-go.jp/gamedata/top", "appVer=2.15.0");
            var res    = JObject.Parse(result);

            if (res["response"][0]["fail"]["action"] != null)
            {
                switch (res["response"][0]["fail"]["action"].ToString())
                {
                case "app_version_up":
                {
                    var tmp = res["response"][0]["fail"]["detail"].ToString();
                    tmp = Regex.Replace(tmp, @".*新ver.:(.*)、現.*", "$1", RegexOptions.Singleline);
                    listBox1.Items.Add("当前游戏版本: " + tmp);
                    listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
                    result            = HttpRequest.PhttpReq("https://game.fate-go.jp/gamedata/top", "appVer=" + tmp);
                    res = JObject.Parse(result);
                    break;
                }

                case "maint":
                {
                    var tmp = res["response"][0]["fail"]["detail"].ToString();
                    if (MessageBox.Show(
                            "游戏服务器正在维护,请在维护后下载数据. \r\n以下为服务器公告内容:\r\n\r\n『" +
                            tmp.Replace("[00FFFF]", "").Replace("[url=", "")
                            .Replace("][u]公式サイト お知らせ[/u][/url][-]", "") + "』\r\n\r\n点击\"确定\"可打开公告页面.",
                            "维护中", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        var re = new Regex(@"(?<url>http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?)");
                        var mc = re.Matches(tmp);
                        foreach (Match m in mc)
                        {
                            var url = m.Result("${url}");
                            Process.Start(url);
                        }
                    }

                    Application.ExitThread();
                    Close();
                    return;
                }
                }
            }

            if (File.Exists(gamedata.FullName + "webview") || File.Exists(gamedata.FullName + "raw") ||
                File.Exists(gamedata.FullName + "assetbundle") || File.Exists(gamedata.FullName + "webview") ||
                File.Exists(gamedata.FullName + "master"))
            {
                var fileinfo = folder.GetFileSystemInfos(); //返回目录中所有文件和子目录
                foreach (var i in fileinfo)
                {
                    if (i is DirectoryInfo) //判断是否文件夹
                    {
                        var subdir = new DirectoryInfo(i.FullName);
                        subdir.Delete(true); //删除子目录和文件
                        listBox1.Items.Add("删除: " + subdir);
                        listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
                        continue;
                    }

                    i.Delete();
                    listBox1.Items.Add("删除: " + i);
                    listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
                }
            }

            if (!Directory.Exists(gamedata.FullName))
            {
                Directory.CreateDirectory(gamedata.FullName);
            }
            File.WriteAllText(gamedata.FullName + "raw", result);
            File.WriteAllText(gamedata.FullName + "assetbundle",
                              res["response"][0]["success"]["assetbundle"].ToString());
            listBox1.Items.Add("Writing file to: " + gamedata.FullName + "assetbundle");
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            progressBar1.Value = progressBar1.Value + 40;
            File.WriteAllText(gamedata.FullName + "master", res["response"][0]["success"]["master"].ToString());
            listBox1.Items.Add("Writing file to: " + gamedata.FullName + "master");
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            progressBar1.Value = progressBar1.Value + 40;
            File.WriteAllText(gamedata.FullName + "webview",
                              res["response"][0]["success"]["webview"].ToString());
            listBox1.Items.Add("Writing file to: " + gamedata.FullName + "webview");
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            progressBar1.Value = progressBar1.Value + 40;
            var data = File.ReadAllText(gamedata.FullName + "master");

            if (!Directory.Exists(gamedata.FullName + "decrypted_masterdata"))
            {
                Directory.CreateDirectory(gamedata.FullName + "decrypted_masterdata");
            }
            var masterData =
                (Dictionary <string, byte[]>)MasterDataUnpacker.MouseGame2Unpacker(
                    Convert.FromBase64String(data));
            var job = new JObject();
            var miniMessagePacker = new MiniMessagePacker();

            foreach (var item in masterData)
            {
                var unpackeditem = (List <object>)miniMessagePacker.Unpack(item.Value);
                var json         = JsonConvert.SerializeObject(unpackeditem, Formatting.Indented);
                File.WriteAllText(gamedata.FullName + "decrypted_masterdata/" + item.Key, json);
                listBox1.Items.Add("Writing file to: " + gamedata.FullName + "decrypted_masterdata/" +
                                   item.Key);
                listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
                progressBar1.Value = progressBar1.Value + 40;
            }

            var data2      = File.ReadAllText(gamedata.FullName + "assetbundle");
            var dictionary =
                (Dictionary <string, object>)MasterDataUnpacker.MouseInfoMsgPack(
                    Convert.FromBase64String(data2));
            var str = dictionary.Aggregate <KeyValuePair <string, object>, string>(null,
                                                                                   (current, a) => current + a.Key + ": " + a.Value + "\r\n");

            File.WriteAllText(gamedata.FullName + "assetbundle.txt", str);
            listBox1.Items.Add("folder name: " + dictionary["folderName"]);
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            progressBar1.Value = progressBar1.Value + 40;
            var data3       = File.ReadAllText(gamedata.FullName + "webview");
            var dictionary2 =
                (Dictionary <string, object>)MasterDataUnpacker.MouseGame2MsgPack(
                    Convert.FromBase64String(data3));
            var str2 = "baseURL: " + dictionary2["baseURL"] + "\r\n contactURL: " + dictionary2["contactURL"] +
                       "\r\n";

            listBox1.Items.Add(str2);
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            progressBar1.Value = progressBar1.Value + 40;
            var filePassInfo = (Dictionary <string, object>)dictionary2["filePass"];

            str = filePassInfo.Aggregate(str, (current, a) => current + a.Key + ": " + a.Value + "\r\n");
            File.WriteAllText(gamedata.FullName + "webview.txt", str2);
            listBox1.Items.Add("Writing file to: " + gamedata.FullName + "webview.txt");
            listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            listBox1.Items.Add("下载完成,可以开始解析.");
            listBox1.TopIndex  = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
            progressBar1.Value = progressBar1.Maximum;
            MessageBox.Show("下载完成,可以开始解析.", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Application.ExitThread();
            Close();
        }
        public void DisplayData(byte[] data)
        {
            var str = JsonSerializer.PrettyPrint(JsonSerializer.Serialize <dynamic>(packer.Unpack(data)));

            textBox.Text = str;
        }
예제 #15
0
 private string UnpackString() => (string)_packer.Unpack(_s);
예제 #16
0
 public object MessagePackDecode(byte[] raw)
 {
     return(pakage.Unpack(raw));
 }