예제 #1
0
        public BoolProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            dataFilePosition = ms.position;
            this.data        = ms.ReadByte() != 0;
        }
예제 #2
0
        public IntProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            dataFilePosition = ms.position;
            this.data        = ms.ReadInt();
        }
예제 #3
0
        public TextProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            dataFilePosition = ms.position;
            this.data        = Convert.ToBase64String(ms.ReadBytes(length));
        }
예제 #4
0
        public void DebugReadArkClassnameStep(DotArkDeserializer ds)
        {
            long start = ms.Position;

            DebugReadArkClassname(ds);
            ms.Position = start + 4;
        }
예제 #5
0
        public NameProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            dataFilePosition = ms.position;
            this.data        = ms.ReadArkClassname(d);
        }
예제 #6
0
        public byte byteValue;         //Use ONLY if the above boolean is true

        public ByteProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            //Read in the enum name
            enumName = ms.ReadArkClassname(d);

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

            isNormalByte = enumName.IsNone();

            //If that type is a None, this is not an enum. If it is, this is an enum. Read the name.
            dataFilePosition = ms.position;
            if (isNormalByte)
            {
                byteValue = ms.ReadByte();
            }
            else
            {
                enumValue = ms.ReadArkClassname(d);
            }
        }
        public static DotArkIntroMysteryFlags ReadFromFile(DotArkDeserializer ds)
        {
            DotArkIntroMysteryFlags mf = new DotArkIntroMysteryFlags();

            mf.flags       = ds.ms.ReadInt();
            mf.objectCount = ds.ms.ReadInt();
            mf.nameString  = ds.ms.ReadUEString();
            return(mf);
        }
예제 #8
0
        public StructProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            //Read the struct type
            structType = ms.ReadArkClassname(d);

            //Read in the struct
            dataFilePosition = ms.position;
            structData       = DotArkStruct.ReadFromFile(d, structType);
            data             = structData;
        }
예제 #9
0
        public static DotArkStruct ReadFromFile(DotArkDeserializer d, ArkClassName structType)
        {
            //Based on the type, open it.
            string typeName = structType.classname;

            DotArkStruct st;

            //First, we check known types for the struct property list. There could be other data, but it could fail.
            if (typeName == "ItemNetID" || typeName == "ItemNetInfo" || typeName == "Transform" || typeName == "PrimalPlayerDataStruct" || typeName == "PrimalPlayerCharacterConfigStruct" || typeName == "PrimalPersistentCharacterStatsStruct" || typeName == "TribeData" || typeName == "TribeGovernment" || typeName == "TerrainInfo" || typeName == "ArkInventoryData" || typeName == "DinoOrderGroup" || typeName == "ARKDinoData")
            {
                //Open this as a struct property list.
                st = new ArkStructProps(d, structType);
            }
            else if (typeName == "Vector" || typeName == "Rotator")
            {
                //3d vector or rotor
                st = new ArkStructVector3(d.ms, structType);
            }
            else if (typeName == "Vector2D")
            {
                //2d vector
                st = new ArkStructVector2(d.ms, structType);
            }
            else if (typeName == "Quat")
            {
                //Quat
                st = new ArkStructQuat(d.ms, structType);
            }
            else if (typeName == "Color")
            {
                //Color
                st = new ArkStructColor(d.ms, structType);
            }
            else if (typeName == "LinearColor")
            {
                //Linear color
                st = new ArkStructLinearColor(d.ms, structType);
            }
            else if (typeName == "UniqueNetIdRepl")
            {
                //Some net stuff
                st = new ArkStructUniqueNetId(d.ms, structType);
            }
            else
            {
                //Interpet this as a struct property list. Maybe raise a warning later?
                //Console.WriteLine($"Unknown struct type '{typeName}'. Interpeting as struct property list.");
                st = new ArkStructProps(d, structType);
            }

            return(st);
        }
예제 #10
0
        private static DotArkProperty ReadStructProperty(DotArkDeserializer d, int index, int length, ArkClassName type)
        {
            //Open
            List <DotArkStruct> data = new List <DotArkStruct>();
            int arraySize            = d.ms.ReadInt();

            //Determine the type
            ArkClassName structType;

            if (arraySize * 4 + 4 == length)
            {
                structType = ArkClassName.Create("Color");
            }
            else if (arraySize * 12 + 4 == length)
            {
                structType = ArkClassName.Create("Vector");
            }
            else if (arraySize * 16 + 4 == length)
            {
                structType = ArkClassName.Create("LinearColor");
            }
            else
            {
                structType = null;
            }

            //Read
            if (structType != null)
            {
                for (int i = 0; i < arraySize; i++)
                {
                    data.Add(DotArkStruct.ReadFromFile(d, structType));
                }
            }
            else
            {
                for (int i = 0; i < arraySize; i++)
                {
                    data.Add(new ArkStructProps(d, structType));
                }
            }

            //Create
            return(new ArrayProperty <DotArkStruct>
            {
                arrayType = type,
                index = index,
                items = data,
                size = length
            });
        }
예제 #11
0
        public static DotArkProperty ReadArray(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            //First, read the type of the array.
            ArkClassName arrayType = ms.ReadArkClassname(d);

            //Read through each of the values in the array.
            //ms.ms.Position += length;

            //Switch depending on the type
            DotArkProperty r;

            switch (arrayType.classname)
            {
            case "ObjectProperty": r = ReadObjectProperty(d, index, length, arrayType); break;

            case "StructProperty": r = ReadStructProperty(d, index, length, arrayType); break;

            case "UInt32Property": r = ReadUInt32Property(d, index, length, arrayType); break;

            case "IntProperty": r = ReadIntProperty(d, index, length, arrayType); break;

            case "UInt16Property": r = ReadUInt16Property(d, index, length, arrayType); break;

            case "Int16Property": r = ReadInt16Property(d, index, length, arrayType); break;

            case "ByteProperty": r = ReadByteProperty(d, index, length, arrayType); break;

            case "Int8Property": r = ReadInt8Property(d, index, length, arrayType); break;

            case "StrProperty": r = ReadStrProperty(d, index, length, arrayType); break;

            case "UInt64Property": r = ReadUInt64Property(d, index, length, arrayType); break;

            case "BoolProperty": r = ReadBoolProperty(d, index, length, arrayType); break;

            case "FloatProperty": r = ReadFloatProperty(d, index, length, arrayType); break;

            case "DoubleProperty": r = ReadDoubleProperty(d, index, length, arrayType); break;

            case "NameProperty": r = ReadNameProperty(d, index, length, arrayType); break;

            default:
                throw new Exception($"Unknown ARK array type '{arrayType.classname}'.");
            }

            return(r);
        }
예제 #12
0
        public static DotArkLocationData ReadLocationData(DotArkDeserializer da)
        {
            var stream           = da.ms;
            DotArkLocationData l = new DotArkLocationData();

            l.x = stream.ReadFloat();
            l.y = stream.ReadFloat();
            l.z = stream.ReadFloat();

            l.pitch = stream.ReadFloat();
            l.yaw   = stream.ReadFloat();
            l.roll  = stream.ReadFloat();

            return(l);
        }
예제 #13
0
        public void DebugReadArkClassname(DotArkDeserializer ds)
        {
            long start = ms.Position;
            int  u1    = ReadInt();
            int  u2    = ReadInt();

            ms.Position = start;
            try
            {
                var e = ArkClassName.ReadFromFile(ds);
                Console.WriteLine($"[Classname Debug] Name={e.classname}, Index={e.index} ({u1}, {u2})");
            } catch
            {
                Console.WriteLine($"[Classname Debug] Failed ({u1}, {u2})");
            }
        }
예제 #14
0
        public DotArkGameObject gameObjectRef; //Only exists if the above is ObjectPropertyType.TypeID

        public ObjectProperty(DotArkDeserializer d, int index, int length)
        {
            var ms = d.ms;

            //If the length is four (only seems to happen on version 5), this is an integer.
            if (length == 4)
            {
                objectRefType    = ObjectPropertyType.TypeID;
                dataFilePosition = ms.position;
                objectId         = ms.ReadInt();
            }
            else if (length >= 8)
            {
                //Read type
                int type = ms.ReadInt();
                if (type > 1 || type < 0)
                {
                    throw new Exception($"Unknown ref type! Expected 0 or 1, but got {type} instead!");
                }
                //Convert this to our enum
                objectRefType    = (ObjectPropertyType)type;
                dataFilePosition = ms.position;
                //Depending on the type, read it in.
                if (objectRefType == ObjectPropertyType.TypeID)
                {
                    objectId = ms.ReadInt();
                }
                if (objectRefType == ObjectPropertyType.TypePath)
                {
                    className = ms.ReadArkClassname(d);
                }
            }
            else
            {
                dataFilePosition = ms.position;
                throw new Exception($"Unknown object ref length! Expected 4 or >= 8, but got {length} instead.");
            }
            //If this is a type ID, I **THINK** this is a refrence to a GameObject
            if (objectRefType == ObjectPropertyType.TypeID)
            {
                if (objectId != -1)
                {
                    gameObjectRef = d.gameObjects[objectId];
                }
            }
        }
        public void ReadPropsFromFile(DotArkDeserializer ds)
        {
            //First, let's jump to the location of this data.
            long position = (long)propDataOffset + (long)ds.propertiesBlockOffset; //Add the offset we got to the properties block offset
            var  ms       = ds.ms;

            ms.ms.Position = position;
            //Now, keep reading properties until we run out. For some reason, Wildcard didn't include a count.
            DotArkProperty prop = DotArkProperty.ReadPropertyFromDisk(ds);

            props = new List <DotArkProperty>();
            while (prop != null)
            {
                //Add this to the properties.
                props.Add(prop);
                //Continue and read next property.
                prop = DotArkProperty.ReadPropertyFromDisk(ds);
            }
        }
예제 #16
0
        private static DotArkProperty ReadObjectProperty(DotArkDeserializer d, int index, int length, ArkClassName type)
        {
            //Open
            int arraySize = d.ms.ReadInt();

            List <ObjectProperty> data = new List <ObjectProperty>();

            for (int i = 0; i < arraySize; i++)
            {
                data.Add(new ObjectProperty(d, index, length));
            }

            //Create
            return(new ArrayProperty <ObjectProperty>
            {
                arrayType = type,
                index = index,
                items = data,
                size = length
            });
        }
        public static DotArkGameObject ReadBaseFromFile(DotArkDeserializer ds)
        {
            //Read from the initial ArkGameObject table.
            DotArkGameObject go = new DotArkGameObject();
            var ms = ds.ms;

            go.guid      = new Guid(ms.ReadBytes(16));
            go.classname = ms.ReadArkClassname(ds);
            go.isItem    = ms.ReadIntBool();
            //Read the name array. Start by reading the integer length.
            int nameArrayLength = ms.ReadInt();

            go.names = new List <ArkClassName>();
            for (int i = 0; i < nameArrayLength; i++)
            {
                go.names.Add(ms.ReadArkClassname(ds));
            }
            //Read some unknown data
            go.unknownData1 = ms.ReadIntBool();
            go.unknownData2 = ms.ReadInt();
            //Read location data boolean
            bool locationDataExists = ms.ReadIntBool();

            if (locationDataExists)
            {
                go.locationData = ms.ReadLocationData(ds);
            }
            else
            {
                go.locationData = null;
            }
            //Read the offset to the property data
            go.propDataOffset = ms.ReadInt();
            //Read some last unknown data
            go.unknownData3 = ms.ReadInt();

            return(go);
        }
예제 #18
0
        public ArkStructProps(DotArkDeserializer d, ArkClassName structType)
        {
            var ms = d.ms;

            //This file has more custom data.
            //Create the dictoanry where we will store data.
            props        = new Dictionary <ArkClassName, DotArkProperty>();
            props_string = new Dictionary <string, DotArkProperty>();
            //Read through all of the properties in a similar matter to the standard way.
            DotArkProperty prop = DotArkProperty.ReadPropertyFromDisk(d);

            while (prop != null)
            {
                //Add this to the properties.
                props.Add(prop.name, prop);
                if (!props_string.ContainsKey(prop.name.classname))
                {
                    props_string.Add(prop.name.classname, prop);
                }
                //Continue and read next property.
                prop = DotArkProperty.ReadPropertyFromDisk(d);
            }
        }
예제 #19
0
        public static ArkClassName ReadFromFile(DotArkDeserializer ark)
        {
            ArkClassName cn = new ArkClassName();

            //Before a certain version, this is just a string. If we've read ark.binaryNameTable, use the index method.
            if (ark.binaryNameTable == null)
            {
                //Read classname from the file.
                cn.classname = ark.ms.ReadUEString();
            }
            else
            {
                //Read the index here and jump to it.
                int index = ark.ms.ReadInt() - 1; //Subtract one because Ark uses a base-one method
                if (index < 0 || index > ark.binaryNameTable.Length)
                {
                    throw new Exception($"Failed to read Ark class name; {index} is out of range.");
                }
                cn.classname = ark.binaryNameTable[index];
            }
            //Read the unique index
            cn.index = ark.ms.ReadInt();
            return(cn);
        }
예제 #20
0
        public static DotArkProperty ReadPropertyFromDisk(DotArkDeserializer d)
        {
            var ms = d.ms;

            //First, read a name and open it.
            ArkClassName name = ms.ReadArkClassname(d);

            //If this name is null, we've done something wrong.
            if (name == null)
            {
                throw new Exception("A property reading error occurred and got an unexpected NULL value; do not save");
            }

            //If the name is None, we've read to the final property and we can stop.
            if (name.IsNone())
            {
                return(null);
            }

            //Now, read the type
            ArkClassName type = ms.ReadArkClassname(d);

            //If the type is None or unreadable, something has gone wrong.
            if (type == null)
            {
                throw new Exception($"A property name was identified as {name.classname}, but the type failed to read.");
            }

            //Read in the index and size
            int size  = ms.ReadInt();
            int index = ms.ReadInt();

            //Based on the type, deserialize this.
            DotArkProperty prop;

            switch (type.classname)
            {
            case "IntProperty":
                prop = new IntProperty(d, index, size);
                break;

            case "UInt32Property":
                prop = new UInt32Property(d, index, size);
                break;

            case "Int8Property":
                prop = new Int8Property(d, index, size);
                break;

            case "Int16Property":
                prop = new Int16Property(d, index, size);
                break;

            case "UInt16Property":
                prop = new UInt16Property(d, index, size);
                break;

            case "UInt64Property":
                prop = new UInt64Property(d, index, size);
                break;

            case "BoolProperty":
                prop = new BoolProperty(d, index, size);
                break;

            case "ByteProperty":
                prop = new ByteProperty(d, index, size);
                break;

            case "FloatProperty":
                prop = new FloatProperty(d, index, size);
                break;

            case "DoubleProperty":
                prop = new DoubleProperty(d, index, size);
                break;

            case "NameProperty":
                prop = new NameProperty(d, index, size);
                break;

            case "ObjectProperty":
                prop = new ObjectProperty(d, index, size);
                break;

            case "StrProperty":
                prop = new StrProperty(d, index, size);
                break;

            case "StructProperty":
                prop = new StructProperty(d, index, size);
                break;

            case "ArrayProperty":
                prop = DotArkArray.ReadArray(d, index, size);     //UNFINISHED
                break;

            case "TextProperty":
                prop = new TextProperty(d, index, size);
                break;

            default:
                //Unknown
                throw new Exception($"Type {type.classname} was not a valid property type. Something failed to read.");
            }
            //Set additional values in the property and return it.
            prop.type  = type;
            prop.name  = name;
            prop.index = index;
            prop.size  = size;

            return(prop);
        }
예제 #21
0
 public ArkClassName ReadArkClassname(DotArkDeserializer ds)
 {
     return(ArkClassName.ReadFromFile(ds));
 }
예제 #22
0
 public DotArkLocationData ReadLocationData(DotArkDeserializer ds)
 {
     return(DotArkLocationData.ReadLocationData(ds));
 }