示例#1
0
        public TradePartnerLA(byte[] TIDSID, byte[] trainerNameObject)
        {
            Debug.Assert(TIDSID.Length == 4);
            var tidsid = BitConverter.ToUInt32(TIDSID, 0);

            TID7 = $"{tidsid % 1_000_000:000000}";
            SID7 = $"{tidsid / 1_000_000:0000}";

            TrainerName = StringConverter8.GetString(trainerNameObject);
        }
示例#2
0
        public static string ReadStringFromRAMObject(byte[] obj)
        {
            // 0x10 typeinfo/monitor, 0x4 len, char[len]
            const int ofs_len   = 0x10;
            const int ofs_chars = 0x14;

            Debug.Assert(obj.Length >= ofs_chars);

            // Detect string length, but be cautious about its correctness (protect against bad data)
            int maxCharCount = (obj.Length - ofs_chars) / 2;
            int length       = BitConverter.ToInt32(obj, ofs_len);

            if (length < 0 || length > maxCharCount)
            {
                length = maxCharCount;
            }

            return(StringConverter8.GetString(obj.AsSpan(ofs_chars, length * 2)));
        }
示例#3
0
 public override string GetString(ReadOnlySpan <byte> data) => StringConverter8.GetString(data);