public ArkStructColor(IOMemoryStream ms, ArkClassName structType)
 {
     b = ms.ReadByte();
     g = ms.ReadByte();
     r = ms.ReadByte();
     a = ms.ReadByte();
 }
示例#2
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     x = ms.ReadFloat();
     y = ms.ReadFloat();
     z = ms.ReadFloat();
     w = ms.ReadFloat();
 }
示例#3
0
 public ArkStructQuat(IOMemoryStream ms, ArkClassName structType)
 {
     x = ms.ReadFloat();
     y = ms.ReadFloat();
     z = ms.ReadFloat();
     w = ms.ReadFloat();
 }
示例#4
0
        public DotArkFile OpenArkFile(IOMemoryStream ms)
        {
            this.ms = ms;
            //Initialize our variables
            ark = new DotArkFile();
            //Open the header data.
            ReadHeader();
            //Read in the binary data names, such as "Extinction", "C1_Far", "C2_Far"
            binaryDataNames = ReadStringArray(ms);
            //Read the embeded binary data.
            ReadArkEmbededBinaryData();
            //Finally, read the mystery flags
            ReadMysteryFlags();
            //Save our position and read the class name block.
            gameObjectBlockStartOffset = ms.ms.Position;             //Save location
            ms.ms.Position             = nameTableOffset;            //Jump to the table
            binaryNameTable            = ReadStringArray(ms);        //Read in the data
            ms.ms.Position             = gameObjectBlockStartOffset; //Jump back to continue reading the file.
            //Read the GameObject table.
            ReadGameObjectTable();
            //Get the property data
            ReadPropertiesForGameObjects();
            //Finish by setting values
            ark.gameObjects = gameObjects;
            ark.meta        = this;

            return(ark);
        }
示例#5
0
        public static FObjectExport ReadEntry(IOMemoryStream ms, UassetFile f)
        {
            //Read in
            FObjectExport g = new FObjectExport();

            g.entryLocation = ms.position;
            g.id            = ms.ReadInt();
            g.unknown1      = ms.ReadInt();
            g.unknown2      = ms.ReadInt();
            g.unknown3      = ms.ReadInt();
            g.type          = ms.ReadNameTableEntry(f);
            g.unknown4      = ms.ReadInt();
            g.unknown5      = ms.ReadInt();
            g.dataLength    = ms.ReadInt();
            g.dataLocation  = ms.ReadInt();
            g.unknown6      = ms.ReadInt();
            g.unknown7      = ms.ReadInt();
            g.unknown8      = ms.ReadInt();
            g.unknown9      = ms.ReadInt();
            g.unknown10     = ms.ReadInt();
            g.unknown11     = ms.ReadInt();
            g.unknown12     = ms.ReadInt();
            g.unknown13     = ms.ReadInt();
            g.unknown14     = ms.ReadInt();
            g.uassetFile    = f;

            return(g);
        }
示例#6
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     ms.ReadInt();
     ms.ReadInt();
     ms.ReadInt();
     ms.ReadInt();
 }
示例#7
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     b = ms.ReadByte();
     g = ms.ReadByte();
     r = ms.ReadByte();
     a = ms.ReadByte();
 }
示例#8
0
        public override void Read(IOMemoryStream ms)
        {
            if (length != 8)
            {
                throw new Exception("Unexpected ObjectProperty length: " + length);
            }

            //Check type
            int linkType = ms.ReadInt();

            if (linkType != 0 && linkType != 1)
            {
                throw new Exception("Unexepcted link type: " + linkType);
            }

            //Read
            isLocalLink = linkType == 0;
            if (isLocalLink)
            {
                localLinkIndex = ms.ReadInt();
            }
            else
            {
                gameLinkIndex = ms.ReadUEString(); //Not tested
            }
        }
        public static void WriteDotArk(IOMemoryStream ms, DotArkFile f)
        {
            //Create instance
            DotArkSerializerInstance inst = new DotArkSerializerInstance();

            //Write the game object bodies into their own temporary stream for later
            IOMemoryStream gameObjectBodyStream = new IOMemoryStream(true);

            long[] gameObjectPropertyOffsets = GameObjectBodyWriter.WriteGameObjectBodies(gameObjectBodyStream, f, inst);

            //Now, write the GameObject heads into their own temporary stream for later.
            IOMemoryStream gameObjectHeadStream = new IOMemoryStream(true);

            GameObjectHeadWriter.WriteGameObjectHeads(gameObjectHeadStream, f, inst, gameObjectPropertyOffsets);

            //Create the binary data names, the map parts.
            IOMemoryStream binaryDataNames = SmallArkDataWriter.WriteBinaryDataNames(f, inst);

            //Create the embedded binary data
            IOMemoryStream embeddedBinaryData = SmallArkDataWriter.WriteEmbeddedBinaryDataArray(f, inst);

            //Create flag data
            IOMemoryStream unknownFlagData = SmallArkDataWriter.WriteArkUnknownFlags(f, inst);

            //Finally, generate the name table. THIS STEP MUST COME LAST!
            IOMemoryStream nameTable = SmallArkDataWriter.WriteNameTable(f, inst);

            //Build the file
            BuildArkFile(nameTable, binaryDataNames, embeddedBinaryData, unknownFlagData, gameObjectHeadStream, gameObjectBodyStream, f.meta.unknownData1, f.gameTime, f.meta.saveCount).CopyFromBeginningTo(ms);
        }
示例#10
0
        public static IOMemoryStream BuildArkFile(IOMemoryStream nameTable, IOMemoryStream binaryDataNames, IOMemoryStream embeddedBinaryData, IOMemoryStream unknownFlagData, IOMemoryStream gameObjectHeadStream, IOMemoryStream gameObjectBodyStream, int headerUnknownData1, float headerGameTime, int headerSaveCount)
        {
            //Create MemoryStream
            IOMemoryStream ms = new IOMemoryStream(true);

            //Now that we have all of that data generated, we need to get offsets.
            long binaryDataNameOffset       = HEADER_SIZE_BYTES;                                    //Offset to map names
            long embeddedBinaryDataOffset   = binaryDataNameOffset + binaryDataNames.length;        //Offset to embedded binary data
            long unknownFlagsOffset         = embeddedBinaryDataOffset + embeddedBinaryData.length; //Offset to the unknown flags
            long gameObjectHeadOffset       = unknownFlagsOffset + unknownFlagData.length;          //Offset to the game object heads
            long binaryNameTableOffset      = gameObjectHeadOffset + gameObjectHeadStream.length;   //Offset to name table
            long gameObjectPropertiesOffset = binaryNameTableOffset + nameTable.length;             //Offset to the game object props

            //Now that we have all of our data, it's time to actually put it into the file. We're going to start generating the header
            //Use version 9, the latest
            ms.WriteShort(9);                             //0
            ms.WriteInt((int)binaryDataNameOffset);       // 2
            ms.WriteInt(headerUnknownData1);              //Unknown header data. Appears to be 0 commonly. Index 6
            ms.WriteInt((int)binaryNameTableOffset);      //10
            ms.WriteInt((int)gameObjectPropertiesOffset); //14
            ms.WriteFloat(headerGameTime);                //18
            ms.WriteInt(headerSaveCount);                 //22

            //Now, it's time to copy all of the data into the file.
            binaryDataNames.CopyFromBeginningTo(ms);
            embeddedBinaryData.CopyFromBeginningTo(ms);
            unknownFlagData.CopyFromBeginningTo(ms);
            gameObjectHeadStream.CopyFromBeginningTo(ms);
            nameTable.CopyFromBeginningTo(ms);
            gameObjectBodyStream.CopyFromBeginningTo(ms);

            return(ms);
        }
 public ArkStructLinearColor(IOMemoryStream ms, ArkClassName structType)
 {
     r = ms.ReadFloat();
     g = ms.ReadFloat();
     b = ms.ReadFloat();
     a = ms.ReadFloat();
 }
示例#12
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     r = ms.ReadFloat();
     g = ms.ReadFloat();
     b = ms.ReadFloat();
     a = ms.ReadFloat();
 }
示例#13
0
        static void WriteHead(IOMemoryStream ms, DotArkFile f, DotArkSerializerInstance si, DotArkGameObject go, long propertyOffset)
        {
            //Write data according to https://us-central.assets-static-2.romanport.com/ark/#gameobject+base_header
            ms.WriteBytes(go.guid.ToByteArray());   //Write the GUID
            ms.WriteArkClassname(go.classname, si); //Write classname
            ms.WriteIntBool(go.isItem);

            //Write classname array
            ms.WriteInt(go.names.Count);
            foreach (var n in go.names)
            {
                ms.WriteArkClassname(n, si);
            }

            //Write unknowns
            ms.WriteIntBool(go.unknownData1);
            ms.WriteInt(go.unknownData2);

            //Write position data if it exists.
            ms.WriteIntBool(go.locationData != null);
            if (go.locationData != null)
            {
                ms.WriteLocationData(go.locationData);
            }

            //Write the offset to the properties data
            ms.WriteInt((int)propertyOffset);

            //Write last unknown data
            ms.WriteInt(go.unknownData3);
        }
示例#14
0
        public static ArkClassName ReadFromFile(IOMemoryStream ms)
        {
            ArkClassName cn = new ArkClassName();

            cn.classname = ms.ReadUEString();
            cn.index     = ms.ReadInt();
            return(cn);
        }
示例#15
0
        public static ArkClassName ReadFromFileInline(IOMemoryStream ms)
        {
            ArkClassName cn = new ArkClassName();

            //Read classname from the file.
            cn.classname = ms.ReadUEString();
            return(cn);
        }
示例#16
0
        public SoftEditSession(IOMemoryStream ms)
        {
            //Load ARK save
            underlyingFile = new DotArkDeserializer().OpenArkFile(ms);

            //Copy name table to here
            nameTable = underlyingFile.meta.binaryNameTable.ToList();
        }
 public InlineProperty(IOMemoryStream ms)
 {
     startPos = ms.position;
     name     = ms.ReadInlineArkClassname();
     type     = ms.ReadInlineArkClassname();
     length   = ms.ReadInt();
     index    = ms.ReadInt();
 }
示例#18
0
        public override void Read(IOMemoryStream ms)
        {
            //Read type
            structType = ms.ReadUEString();

            //Skip
            ms.position += length;
        }
示例#19
0
        public MemoryStream Commit()
        {
            //First, we're going to rebuild the name table
            IOMemoryStream nameTableData = new IOMemoryStream(true);

            DotArkWriter.WriteStringArray(nameTableData, nameTable.ToArray());

            return(null);
        }
示例#20
0
        public void WriteToDotArkFile(DotArkSerializerInstance ark, IOMemoryStream ms)
        {
            //Get name table index.
            int nameTableIndex = ark.GetNameTableEntry(classname);

            //Write nameTableIndex and the index
            ms.WriteInt(nameTableIndex);
            ms.WriteInt(index);
        }
        public override void Read(IOMemoryStream ms)
        {
            //We don't care much about arrays, so we'll skip them.

            //Read the type of the array
            arrayType = ms.ReadUEString();

            //Skip
            ms.position += length;
        }
示例#22
0
        public void WriteLocationData(IOMemoryStream ms)
        {
            ms.WriteFloat(x);
            ms.WriteFloat(y);
            ms.WriteFloat(z);

            ms.WriteFloat(pitch);
            ms.WriteFloat(yaw);
            ms.WriteFloat(roll);
        }
示例#23
0
        public static void WriteStringArray(IOMemoryStream ms, string[] s)
        {
            //Write the length first
            ms.WriteInt(s.Length);

            //Write each string
            for (int i = 0; i < s.Length; i++)
            {
                ms.WriteUEString(s[i]);
            }
        }
        public static IOMemoryStream WriteNameTable(DotArkFile f, DotArkSerializerInstance si)
        {
            //name table for props. Spec is here: https://us-central.assets-static-2.romanport.com/ark/#binary+class+name+table_header

            //Create stream
            IOMemoryStream ms = new IOMemoryStream(true);

            //Write into it
            DotArkWriter.WriteStringArray(ms, si.nameTable.ToArray());
            return(ms);
        }
        public static IOMemoryStream WriteBinaryDataNames(DotArkFile f, DotArkSerializerInstance si)
        {
            //Binary data names are showing map parts. Spec is here: https://us-central.assets-static-2.romanport.com/ark/#binary+data+names_header

            //Create stream
            IOMemoryStream ms = new IOMemoryStream(true);

            //Write into it
            DotArkWriter.WriteStringArray(ms, f.meta.binaryDataNames);
            return(ms);
        }
示例#26
0
 public override void Read(IOMemoryStream ms, UAssetFile f)
 {
     if (length == 0 || length == 8)
     {
         data    = ms.ReadNameTableEntry(f);
         unknown = ms.ReadInt();
     }
     else
     {
         data = ms.ReadNameTableEntry(f);
     }
 }
示例#27
0
            public ArkStructInlineProps(IOMemoryStream ms)
            {
                props = new List <InlineProperty>();
                InlineProperty p = InlineProperty.ReadProperty(ms);

                while (p != null)
                {
                    props.Add(p);
                    //Console.WriteLine($"STRUCT > {p.name.classname} ({p.type.classname})");
                    p = InlineProperty.ReadProperty(ms);
                }
            }
示例#28
0
        public static void WriteGameObjectHeads(IOMemoryStream ms, DotArkFile f, DotArkSerializerInstance si, long[] propertyOffsets)
        {
            //Write all of the GameObject headers
            //First, write the number of GameObjects
            ms.WriteInt(f.gameObjects.Count);

            //Loop through gameObjects and write their heads
            for (int i = 0; i < f.gameObjects.Count; i++)
            {
                WriteHead(ms, f, si, f.gameObjects[i], propertyOffsets[i]);
            }
        }
示例#29
0
        public static string[] ReadStringArray(IOMemoryStream ms)
        {
            //Read a standard array. First, read the Int32 of the length
            int length = ms.ReadInt();

            //Create an array and read in strings
            string[] array = new string[length];
            for (int i = 0; i < length; i++)
            {
                array[i] = ms.ReadUEString();
            }
            return(array);
        }
示例#30
0
        public byte byteValue;   //Use ONLY if the above boolean is true

        public override void Read(IOMemoryStream ms, UAssetFile f)
        {
            if (length == 1)
            {
                //Read in the enum name
                enumName = ms.ReadNameTableEntry(f);

                //That can be None, but cannot be null.
                if (enumName == null)
                {
                    throw new Exception("Tried to read enum type, but got null!");
                }

                isNormalByte = enumName == "None";

                //If that type is a None, this is not an enum. If it is, this is an enum. Read the name.
                if (isNormalByte)
                {
                    byteValue = ms.ReadByte();
                    ms.ReadInt();
                }
                else
                {
                    enumValue = ms.ReadNameTableEntry(f);
                }
            }
            else if (length == 8)
            {
                //If the length is 8, this is an enum. It seems to follow like this...
                //Enum name
                //Int, usually 0
                //Enum value
                //Int, usually 0
                enumType     = ms.ReadNameTableEntry(f);
                ms.position += 4;
                enumValue    = ms.ReadNameTableEntry(f);
                ms.position += 4;
            }
            else if (length == 0)
            {
                //Just skip.
                throw new NotImplementedException();
                ms.position += 4;
            }
            else
            {
                throw new Exception($"Warning: Unknown ByteProperty length '{length}'.");
            }
        }