Beispiel #1
0
        public override void ReadData(BinaryReader reader)
        {
            bool isOld  = ModdedSaveData.LATEST_READ_VERSION < 4;
            int  number = reader.ReadInt32();

            if (number >= 3)
            {
                isOld = false;
            }

            if (number >= 3)
            {
                number -= 3;
            }
            idType = (IdentifierType)number;
            if (!isOld)
            {
                Version = reader.ReadInt32();
            }
            longIdentifier   = reader.ReadInt64();
            stringIdentifier = isOld ? "" : reader.ReadString();
            dataPiece        = DataPiece.Deserialize(reader) as CompoundDataPiece;
            if (dataPiece == null)
            {
                throw new Exception("Invalid top level datapiece!");
            }
        }
Beispiel #2
0
 public void Read(BinaryReader reader)
 {
     idType     = (IdentifierType)reader.ReadInt32();
     identifier = reader.ReadInt64();
     dataPiece  = DataPiece.Deserialize(reader) as CompoundDataPiece;
     if (dataPiece == null)
     {
         throw new Exception("Invalid top level data piece!");
     }
 }
Beispiel #3
0
        public void Read(BinaryReader reader)
        {
            data.Clear();
            var count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                bool shouldbenull = reader.ReadBoolean();
                if (shouldbenull)
                {
                    data.Add(null);
                }
                else
                {
                    var piece = DataPiece.Deserialize(reader) as CompoundDataPiece;
                    ExtendedData.CullMissingModsFromData(piece);
                    if (piece.DataList.Count == 0)
                    {
                        piece = null;
                    }
                    data.Add(piece);
                }
            }
        }
Beispiel #4
0
        public void Read(BinaryReader reader)
        {
            version    = reader.ReadInt32();
            modid      = reader.ReadString();
            byteLength = reader.ReadInt64();
            if (!(SRModLoader.GetMod(modid) is SRMod mod))
            {
                throw new Exception($"Unrecognized mod id: {modid}");
            }
            var saveInfo = SaveRegistry.GetSaveInfo(mod);

            identifiableData.Clear();
            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var e = new IdentifiedData();
                e.Read(reader, saveInfo);
                identifiableData.Add(e);
            }

            extendedData.Clear();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var e = new ExtendedDataTree();
                e.Read(reader);
                extendedData.Add(e);
            }

            if (version >= 1)
            {
                playerData.Read(reader);
                pediaData.Read(reader);
                BinaryUtils.ReadDictionary(reader, customAmmo, (x) => AmmoIdentifier.Read(x), (x) =>
                {
                    var list      = new List <VanillaAmmoData>();
                    int ammoCount = x.ReadInt32();
                    for (int i = 0; i < ammoCount; i++)
                    {
                        if (x.ReadBoolean())
                        {
                            var newData = new VanillaAmmoData();
                            newData.Load(x.BaseStream);
                            list.Add(newData);
                        }
                        else
                        {
                            list.Add(null);
                        }
                    }

                    return(list);
                });
                if (version < 2)
                {
                    return;
                }
                extendedWorldData = (CompoundDataPiece)DataPiece.Deserialize(reader);
                if (version < 3)
                {
                    return;
                }
                worldData.Read(reader);
            }
            else
            {
                identifiableData.Clear(); // with the new enum translator system we need to make sure old id's are gone
            }
        }