コード例 #1
0
ファイル: s2parse.cs プロジェクト: Mnuzz/dsmm_web
        public static s2replay GetDetails(string replay_file, dynamic details_dec)
        {
            string id = Path.GetFileNameWithoutExtension(replay_file);

            //var json = JsonConvert.SerializeObject(details_dec, Formatting.Indented);
            var json = JsonSerializer.Serialize(details_dec, jOptions);

            File.WriteAllText(Program.workdir + "/bab/analyzes/" + id + "_details.json", json);


            string reppath        = Path.GetDirectoryName(replay_file);
            var    plainTextBytes = System.Text.Encoding.UTF8.GetBytes(reppath);
            MD5    md5            = new MD5CryptoServiceProvider();
            string reppath_md5    = System.BitConverter.ToString(md5.ComputeHash(plainTextBytes));
            string repid          = reppath_md5 + "/" + id;

            s2replay replay = new s2replay();

            replay.REPLAY = repid;
            Program.Log("Replay id: " + repid);
            int failsafe_pos = 0;

            foreach (var player in details_dec["m_playerList"])
            {
                failsafe_pos++;
                string name = "";
                IronPython.Runtime.Bytes bab = null;
                try
                {
                    bab = player["m_name"];
                }
                catch { }

                if (bab != null)
                {
                    name = Encoding.UTF8.GetString(bab.ToByteArray());
                }
                else
                {
                    name = player["m_name"].ToString();
                }

                if (name.Length == 0)
                {
                    continue;
                }
                Match m2 = rx_subname.Match(name);
                if (m2.Success)
                {
                    name = m2.Groups[1].Value;
                }
                Program.Log("Replay playername: " + name);

                s2player pl = new s2player();
                if (s2players.ContainsKey(repid))
                {
                    pl = s2players[repid][failsafe_pos - 1];
                }

                pl.NAME   = name;
                pl.RACE   = player["m_race"].ToString();
                pl.RESULT = int.Parse(player["m_result"].ToString());
                pl.TEAM   = int.Parse(player["m_teamId"].ToString());
                try
                {
                    pl.POS = int.Parse(player["m_workingSetSlotId"].ToString()) + 1;
                }
                catch
                {
                    pl.POS = failsafe_pos;
                }
                replay.PLAYERS.Add(pl);
            }

            long offset  = long.Parse(details_dec["m_timeLocalOffset"].ToString());
            long timeutc = long.Parse(details_dec["m_timeUTC"].ToString());

            long     georgian = timeutc + offset;
            DateTime gametime = DateTime.FromFileTime(georgian);

            replay.GAMETIME = double.Parse(gametime.ToString("yyyyMMddhhmmss"));


            return(replay);
        }
コード例 #2
0
ファイル: MemoryView.cs プロジェクト: tinyg/ironpython2
 public MemoryView(string @object) : this(Bytes.Make(@object.MakeByteArray()))
 {
 }
コード例 #3
0
ファイル: Bytes.cs プロジェクト: slozier/ironpython3
 public Bytes([NotNone] Bytes bytes)
 {
     _bytes = bytes._bytes;
 }
コード例 #4
0
ファイル: Bytes.cs プロジェクト: jameslan/ironpython3
 public Bytes([NotNull] Bytes bytes)
 {
     _bytes = bytes._bytes;
 }