Beispiel #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);
        }
Beispiel #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)));
        }
Beispiel #3
0
 public override int SetString(Span <byte> destBuffer, ReadOnlySpan <char> value, int maxLength, StringConverterOption option) => StringConverter8.SetString(destBuffer, value, maxLength, option);
Beispiel #4
0
 public override string GetString(ReadOnlySpan <byte> data) => StringConverter8.GetString(data);