Beispiel #1
0
        /// <summary>
        /// Saves track as SOL at location
        /// </summary>
        public SOL(string location, Track export)
        {
            BigEndianWriter bw = new BigEndianWriter();

            bw.WriteShort(0x00BF);     //sol version
            bw.WriteInt(0);            //length, placeholder
            bw.WriteString("TCSO");
            bw.WriteBytes(new byte[] { 0, 4, 0, 0, 0, 0 });
            bw.WriteMapleString("savedLines");
            bw.WriteInt(0);            //padding
            Amf0Object rootobj = new Amf0Object();

            rootobj.name = "trackList";
            rootobj.type = Amf0Object.Amf0Type.AMF0_ECMA_ARRAY;
            var tracks = new List <Amf0Object>();

            rootobj.data = tracks;
            WriteTrack(tracks, export);
            Amf0 amf = new Amf0(bw);

            amf.WriteAmf0Object(rootobj);
            bw.WriteByte(0);
            bw.Reset(2);
            bw.WriteInt(bw.Length - 6);
            File.WriteAllBytes(location, bw.ToArray());
        }
Beispiel #2
0
        public SOL(string location)
        {
            var             bytes = File.ReadAllBytes(location);
            BigEndianReader br    = new BigEndianReader(bytes);

            ///HEADER///
            br.ReadInt16();                   //sol_version
            br.ReadInt32();                   //file lengthh
            if (br.ReadInt32() != 0x5443534F) //TCSO
            {
                throw new Exception("Invalid magic number, maybe this isn't an SOL file?");
            }
            br.ReadBytes(6);                                                          //padding
            RootObject.name = Encoding.ASCII.GetString(br.ReadBytes(br.ReadInt16())); //shared object name
            if (RootObject.name != "savedLines")
            {
                throw new Exception("invalid root object");
            }
            if (br.ReadInt32() != 0)
            {
                throw new Exception("Invalid AMF version");                //amf version, we only support 0o
            }
            ///items///
            Amf0 amf = new Amf0(br);

            RootObject.data = amf.ReadAmf0(true);
        }