Exemplo n.º 1
0
 private void GetCloudSaveLatestTimestampCallback(Byte[] data, SiliconStudio.Social.ResponseData.Status status)
 {
     if (data != null)
     {
         this.ValidateCloudSaveData(data, delegate(Boolean isValidate)
         {
             if (isValidate)
             {
                 this.RawStorage.RawData = data;
                 this.RawStorage.GetLatestTimestamp(delegate(Boolean isSuccess, Double timestamp)
                 {
                     this.getCloudSaveLatestTimestampFinishDelegate(ISharedDataSerializer.LastErrno, isSuccess, timestamp);
                     this.RawStorage.RawData = null;
                 });
             }
             else
             {
                 ISharedDataSerializer.LastErrno = DataSerializerErrorCode.CloudDataCorruption;
                 ISharedDataLog.LogError("Cloud data is invalid!");
                 this.getCloudSaveLatestTimestampFinishDelegate(ISharedDataSerializer.LastErrno, false, 0.0);
             }
         });
     }
     else
     {
         ISharedDataSerializer.LastErrno = ISharedDataSerializer.ConvertCloudStatusToDataSerializerErrorCode(status);
         this.getCloudSaveLatestTimestampFinishDelegate(ISharedDataSerializer.LastErrno, false, 0.0);
     }
 }
Exemplo n.º 2
0
 private void OnDataLoadSlotFinish(Int32 slotID, List <SharedDataPreviewSlot> data)
 {
     if (ISharedDataSerializer.LastErrno != DataSerializerErrorCode.Success)
     {
         ISharedDataLog.LogWarning("LastErrno is NOT success in OnDataLoadSlotFinish(), return as success!");
         ISharedDataSerializer.LastErrno = DataSerializerErrorCode.Success;
     }
     this.onLoadSlotFinishDelegate(ISharedDataSerializer.LastErrno, slotID, data);
 }
Exemplo n.º 3
0
 private void OnDataSaveFinish(Int32 slotID, Int32 saveID, Boolean isSuccess)
 {
     if (isSuccess)
     {
         this.onSaveFinishDelegate(ISharedDataSerializer.LastErrno, slotID, saveID, true, this.previewSlotCache);
     }
     else
     {
         ISharedDataLog.LogError("Storage.Save() failure!");
         this.onSaveFinishDelegate(ISharedDataSerializer.LastErrno, -1, -1, false, (SharedDataPreviewSlot)null);
     }
 }
Exemplo n.º 4
0
 private void LoadCloudSyncPreviewOnFileExistCallBack(Boolean isExist, SiliconStudio.Social.ResponseData.Status status)
 {
     if (isExist)
     {
         base.StartCoroutine(SiliconStudio.Social.Cloud_Load(this, new Action <Byte[], SiliconStudio.Social.ResponseData.Status>(this.LoadCloudSyncPreviewOnCloudLoadCallBack)));
     }
     else
     {
         ISharedDataLog.LogWarning("Cloud data does not exist!. Return success status.");
         ISharedDataSerializer.LastErrno = DataSerializerErrorCode.CloudFileNotFound;
         this.onSyncCloudSlotFinishDelegate(ISharedDataSerializer.LastErrno, true, this.loadCloudSyncPreviewLocalPreview, (SharedDataPreviewSlot)null);
         this.ClearCloudSyncPreviewCache();
     }
 }
Exemplo n.º 5
0
 private void DownloadFromCloudOnCloudLoadCallBack(Byte[] data, SiliconStudio.Social.ResponseData.Status status)
 {
     if (data != null)
     {
         this.ValidateCloudSaveData(data, delegate(Boolean isValidate)
         {
             if (isValidate)
             {
                 this.RawStorage.RawData = data;
                 this.Storage.SaveRawData(data, delegate(Boolean isSuccess)
                 {
                     this.RawStorage.GetLatestSlotAndSave(delegate(Int32 latestSlotID, Int32 latestSaveID)
                     {
                         this.latestCloudSlotID = latestSlotID;
                         this.latestCloudSaveID = latestSaveID;
                         if (this.latestCloudSlotID != -1 && this.latestCloudSaveID != -1)
                         {
                             this.RawStorage.LoadSlotPreview(this.latestCloudSlotID, delegate(Int32 slotID, List <SharedDataPreviewSlot> previewData)
                             {
                                 this.downloadFromCloudRemoteDataPreviewSlot = previewData[this.latestCloudSaveID];
                                 this.downloadFromCloudLocalDataPreviewSlot  = this.downloadFromCloudRemoteDataPreviewSlot;
                                 this.downloadFromCloudFinishDelegate(ISharedDataSerializer.LastErrno, true, this.downloadFromCloudLocalDataPreviewSlot, this.downloadFromCloudRemoteDataPreviewSlot);
                                 this.ClearCloudSyncPreviewCache();
                                 this.RawStorage.RawData = null;
                             });
                         }
                         else
                         {
                             this.downloadFromCloudFinishDelegate(ISharedDataSerializer.LastErrno, true, this.downloadFromCloudLocalDataPreviewSlot, this.downloadFromCloudRemoteDataPreviewSlot);
                             this.ClearCloudSyncPreviewCache();
                         }
                     });
                 });
             }
             else
             {
                 ISharedDataSerializer.LastErrno = DataSerializerErrorCode.CloudDataCorruption;
                 ISharedDataLog.LogError("Cloud data is invalid!");
                 this.downloadFromCloudFinishDelegate(ISharedDataSerializer.LastErrno, true, this.downloadFromCloudLocalDataPreviewSlot, this.downloadFromCloudRemoteDataPreviewSlot);
                 this.ClearCloudSyncPreviewCache();
             }
         });
     }
     else
     {
         ISharedDataSerializer.LastErrno = ISharedDataSerializer.ConvertCloudStatusToDataSerializerErrorCode(status);
         this.downloadFromCloudFinishDelegate(ISharedDataSerializer.LastErrno, false, (SharedDataPreviewSlot)null, (SharedDataPreviewSlot)null);
         this.ClearCloudSyncPreviewCache();
     }
 }
Exemplo n.º 6
0
 public override void LoadCloudSyncPreview(ISharedDataSerializer.OnSyncCloudSlotStart onStartDelegate, ISharedDataSerializer.OnSyncCloudSlotFinish onFinishDelegate)
 {
     ISharedDataSerializer.LastErrno = DataSerializerErrorCode.Success;
     this.ClearCloudSyncPreviewCache();
     this.onSyncCloudSlotFinishDelegate = onFinishDelegate;
     this.Storage.GetDataSize(delegate(Boolean isSuccess, Int32 dataSize)
     {
         if (isSuccess)
         {
             this.Storage.GetLatestSlotAndSave(delegate(Int32 latestSlot, Int32 latestSave)
             {
                 this.latestSlotID = latestSlot;
                 this.latestSaveID = latestSave;
                 if (onStartDelegate != null)
                 {
                     onStartDelegate(ISharedDataSerializer.LastErrno);
                 }
                 if (this.latestSlotID != -1)
                 {
                     this.LoadSlotPreview(this.latestSlotID, delegate(DataSerializerErrorCode errNo, Int32 slotID, List <SharedDataPreviewSlot> data)
                     {
                         if (data != null)
                         {
                             this.loadCloudSyncPreviewLocalPreview = data[this.latestSaveID];
                             this.StartCoroutine(SiliconStudio.Social.Cloud_IsFileExist(this, new Action <Boolean, SiliconStudio.Social.ResponseData.Status>(this.LoadCloudSyncPreviewOnFileExistCallBack)));
                         }
                         else
                         {
                             ISharedDataLog.LogError("latestSlotID is: " + this.latestSlotID + " but preview data NOT found!");
                             ISharedDataSerializer.LastErrno = DataSerializerErrorCode.DataCorruption;
                             this.onSyncCloudSlotFinishDelegate(ISharedDataSerializer.LastErrno, false, (SharedDataPreviewSlot)null, (SharedDataPreviewSlot)null);
                             this.ClearCloudSyncPreviewCache();
                         }
                     });
                 }
                 else
                 {
                     this.StartCoroutine(SiliconStudio.Social.Cloud_IsFileExist(this, new Action <Boolean, SiliconStudio.Social.ResponseData.Status>(this.LoadCloudSyncPreviewOnFileExistCallBack)));
                 }
             });
         }
         else
         {
             ISharedDataSerializer.LastErrno = DataSerializerErrorCode.DataCorruption;
             ISharedDataLog.LogError("Save data is invalid!");
             this.StartCoroutine(SiliconStudio.Social.Cloud_IsFileExist(this, new Action <Boolean, SiliconStudio.Social.ResponseData.Status>(this.LoadCloudSyncPreviewOnFileExistCallBack)));
         }
     });
 }
Exemplo n.º 7
0
    public override void LoadSlotPreview(Int32 slotID, ISharedDataStorage.OnLoadSlotFinish onFinishDelegate)
    {
        if (this.RawData == null)
        {
            ISharedDataLog.LogWarning("SharedDataRawStorage LoadSlotPreview is being called but RawData is null!");
            onFinishDelegate(slotID, null);
            return;
        }
        base.CreateDataSchema();
        List <SharedDataPreviewSlot> list = new List <SharedDataPreviewSlot>();

        this.cStream           = new MemoryStream(this.RawData);
        this.cReader           = new BinaryReader(this.cStream);
        this.cOnFinishDelegate = onFinishDelegate;
        SlotPreviewReadWriterUtil.Instance.ReadSlotPreview(this.metaData, slotID, this.cStream, this.cReader, this.Encryption, new ISharedDataStorage.OnLoadSlotFinish(this.LoadSlotPreviewDelegate));
    }
Exemplo n.º 8
0
    private void LoadCloudSyncPreviewOnCloudLoadCallBack(Byte[] data, SiliconStudio.Social.ResponseData.Status status)
    {
        global::Debug.Log("in LoadCloudSyncPreviewOnCloudLoadCallBack 1 " + status);
        global::Debug.Log("in LoadCloudSyncPreviewOnCloudLoadCallBack 4");

        if (data != null)
        {
            this.ValidateCloudSaveData(data, delegate(Boolean isSuccess)
            {
                if (isSuccess)
                {
                    this.RawStorage.RawData = data;
                    this.RawStorage.GetLatestSlotAndSave(delegate(Int32 latestCloudSlotID, Int32 latestCloudSaveID)
                    {
                        if (latestCloudSlotID != -1 && latestCloudSaveID != -1)
                        {
                            this.RawStorage.LoadSlotPreview(latestCloudSlotID, delegate(Int32 slotID, List <SharedDataPreviewSlot> previewData)
                            {
                                this.loadCloudSyncPreviewRemotePreview = previewData[latestCloudSaveID];
                                this.onSyncCloudSlotFinishDelegate(ISharedDataSerializer.LastErrno, true, this.loadCloudSyncPreviewLocalPreview, this.loadCloudSyncPreviewRemotePreview);
                                this.ClearCloudSyncPreviewCache();
                                this.RawStorage.RawData = null;
                            });
                        }
                        else
                        {
                            this.onSyncCloudSlotFinishDelegate(ISharedDataSerializer.LastErrno, true, this.loadCloudSyncPreviewLocalPreview, this.loadCloudSyncPreviewRemotePreview);
                            this.ClearCloudSyncPreviewCache();
                        }
                    });
                }
                else
                {
                    ISharedDataSerializer.LastErrno = DataSerializerErrorCode.CloudDataCorruption;
                    ISharedDataLog.LogError("Cloud data is invalid!");
                    this.onSyncCloudSlotFinishDelegate(ISharedDataSerializer.LastErrno, true, this.loadCloudSyncPreviewLocalPreview, this.loadCloudSyncPreviewRemotePreview);
                }
            });
        }
        else
        {
            ISharedDataLog.LogWarning("Cloud data is null!");
            ISharedDataSerializer.LastErrno = ISharedDataSerializer.ConvertCloudStatusToDataSerializerErrorCode(status);
            this.onSyncCloudSlotFinishDelegate(ISharedDataSerializer.LastErrno, true, this.loadCloudSyncPreviewLocalPreview, this.loadCloudSyncPreviewRemotePreview);
            this.ClearCloudSyncPreviewCache();
        }
    }
Exemplo n.º 9
0
 public override void GetLatestTimestamp(ISharedDataStorage.OnGetLatestSaveTimestamp onFinishDelegate)
 {
     if (this.RawData == null)
     {
         ISharedDataLog.LogWarning("SharedDataRawStorage GetLatestTimestamp is being called but RawData is null!");
         onFinishDelegate(false, 0.0);
         return;
     }
     base.CreateDataSchema();
     using (MemoryStream memoryStream = new MemoryStream(this.RawData))
     {
         using (BinaryReader binaryReader = new BinaryReader(memoryStream))
         {
             this.metaData.Read(memoryStream, binaryReader, this.Encryption);
         }
     }
     onFinishDelegate(true, this.metaData.LatestTimestamp);
 }
Exemplo n.º 10
0
 public static void WillAutosave()
 {
     try
     {
         if (FF9Snd.HasJustChangedBetweenWorldAndField)
         {
             FF9StateSystem.Sound.auto_save_bgm_id = -1;
         }
         else
         {
             FF9StateSystem.Sound.auto_save_bgm_id = FF9Snd.GetCurrentMusicId();
         }
         FF9Snd.HasJustChangedBetweenWorldAndField = false;
     }
     catch (Exception arg)
     {
         ISharedDataLog.LogWarning("GetCurrentMusicId: Exception: " + arg);
     }
 }
Exemplo n.º 11
0
 public override void Load(Int32 slotID, Int32 saveID, ISharedDataStorage.OnLoadFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 12
0
 public override void LoadRawData(ISharedDataStorage.OnLoadRawDataFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 13
0
 public override void HasAutoload(ISharedDataStorage.OnHasAutoloadFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 14
0
 public override void SaveRawData(Byte[] rawData, ISharedDataStorage.OnSaveRawDataFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 15
0
 public override void ClearAllData()
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 16
0
 public override void SaveSlotPreview(Int32 slotID, Int32 saveID, ISharedDataStorage.OnSaveSlotFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 17
0
    public void WriteSlotPreview(SharedDataPreviewSlot previewSlot, SharedDataBytesStorage.MetaData metaData, Int32 saveID, Int32 slotID, Stream stream, BinaryReader reader, BinaryWriter writer, ISharedDataEncryption encryption, ISharedDataStorage.OnSaveSlotFinish onFinishDelegate)
    {
        stream.Seek((Int64)(320 - (Int32)stream.Position), SeekOrigin.Current);
        Int32 num = slotID * 1024 * 15 + saveID * 1024;

        ISharedDataLog.Log("Seek to: " + num);
        stream.Seek((Int64)num, SeekOrigin.Current);
        Int32 num2       = (Int32)stream.Position;
        Int32 cipherSize = encryption.GetCipherSize(965);

        Byte[] buffer = new Byte[cipherSize];
        Byte[] array  = null;
        using (MemoryStream memoryStream = new MemoryStream())
        {
            using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
            {
                binaryWriter.Write('P');
                binaryWriter.Write('R');
                binaryWriter.Write('E');
                binaryWriter.Write('V');
                previewSlot.HasData = true;
                binaryWriter.Write(previewSlot.HasData);
                binaryWriter.Write(previewSlot.Gil);
                binaryWriter.Write(previewSlot.PlayDuration);
                binaryWriter.Write(previewSlot.win_type);
                Byte[] array2 = new Byte[128];
                Byte[] bytes  = Encoding.UTF8.GetBytes(previewSlot.Location);
                Buffer.BlockCopy(bytes, 0, array2, 0, (Int32)bytes.Length);
                binaryWriter.Write(array2, 0, (Int32)array2.Length);
                Byte[] array3 = new Byte[136];
                for (Int32 i = 0; i < 4; i++)
                {
                    if (previewSlot.CharacterInfoList[i] == null)
                    {
                        Int32 value  = -1;
                        Int32 value2 = -1;
                        binaryWriter.Write(value);
                        binaryWriter.Write(value2);
                        Byte[] array4 = new Byte[128];
                        binaryWriter.Write(array4, 0, (Int32)array4.Length);
                    }
                    else
                    {
                        binaryWriter.Write(previewSlot.CharacterInfoList[i].SerialID);
                        binaryWriter.Write(previewSlot.CharacterInfoList[i].Level);
                        Byte[] array5 = new Byte[128];
                        Byte[] bytes2 = Encoding.UTF8.GetBytes(previewSlot.CharacterInfoList[i].Name);
                        Buffer.BlockCopy(bytes2, 0, array5, 0, (Int32)bytes2.Length);
                        binaryWriter.Write(array5, 0, (Int32)array5.Length);
                    }
                }
                Double totalSeconds = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
                previewSlot.Timestamp = totalSeconds;
                binaryWriter.Write(previewSlot.Timestamp);
                Byte[] array6 = new Byte[256];
                binaryWriter.Write(array6, 0, (Int32)array6.Length);
                array = memoryStream.ToArray();
                if ((Int32)array.Length != 965)
                {
                    ISharedDataLog.LogError("previewPlainText has incorrect size: " + (Int32)array.Length);
                }
            }
        }
        buffer = encryption.Encrypt(array);
        stream.Seek((Int64)num2, SeekOrigin.Begin);
        writer.Write(buffer, 0, cipherSize);
        onFinishDelegate(slotID, saveID, previewSlot);
    }
Exemplo n.º 18
0
 public override void Autosave(JSONClass rootNode, ISharedDataStorage.OnAutosaveFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }
Exemplo n.º 19
0
    private IEnumerator ReadSlotPreviewInCoroutine(SharedDataBytesStorage.MetaData metaData, Int32 slotID, Stream stream, BinaryReader reader, ISharedDataEncryption encryption, ISharedDataStorage.OnLoadSlotFinish onFinishDelegate)
    {
        List <SharedDataPreviewSlot> list = new List <SharedDataPreviewSlot>();

        metaData.Read(stream, reader, encryption);
        stream.Seek((Int64)(320 - (Int32)stream.Position), SeekOrigin.Current);
        Int32 seekTo = slotID * 1024 * 15;

        ISharedDataLog.Log("Seek to: " + seekTo);
        stream.Seek((Int64)seekTo, SeekOrigin.Current);
        Int32 previewCipherSize = encryption.GetCipherSize(965);
        Int32 i = 0;

        while (i < 15)
        {
            yield return(onFinishDelegate);

            Int32  prevPosition = (Int32)stream.Position;
            Int32  seekSize     = 0;
            Byte[] cipherText   = new Byte[previewCipherSize];
            reader.Read(cipherText, 0, (Int32)cipherText.Length);
            Byte[] plainText = null;
            try
            {
                plainText = encryption.Decrypt(cipherText);
            }
            catch (Exception ex2)
            {
                Exception ex = ex2;
                list.Add(new SharedDataPreviewSlot
                {
                    IsPreviewCorrupted = true
                });
                ISharedDataLog.LogError(ex);
                ISharedDataSerializer.LastErrno = DataSerializerErrorCode.DataCorruption;
                seekSize = 1024 - ((Int32)stream.Position - prevPosition);
                stream.Seek((Int64)seekSize, SeekOrigin.Current);
                goto IL_597;
            }
            goto IL_1CC;
IL_597:
            i++;
            continue;
IL_1CC:
            Boolean isValidPreview = false;
            SharedDataPreviewSlot preview = new SharedDataPreviewSlot();
            using (MemoryStream memStram = new MemoryStream(plainText))
            {
                using (BinaryReader memReader = new BinaryReader(memStram))
                {
                    Char[] chs = memReader.ReadChars(4);
                    if (chs[0] == 'N' && chs[1] == 'O' && chs[2] == 'N' && chs[3] == 'E')
                    {
                        list.Add((SharedDataPreviewSlot)null);
                        seekSize = 1024 - ((Int32)stream.Position - prevPosition);
                        stream.Seek((Int64)seekSize, SeekOrigin.Current);
                        goto IL_597;
                    }
                    if (chs[0] != 'P' || chs[1] != 'R' || chs[2] != 'E' || chs[3] != 'V')
                    {
                        list.Add(new SharedDataPreviewSlot
                        {
                            IsPreviewCorrupted = true
                        });
                        ISharedDataLog.LogError("Error! seek to NOT preview position");
                        seekSize = 1024 - ((Int32)stream.Position - prevPosition);
                        stream.Seek((Int64)seekSize, SeekOrigin.Current);
                        goto IL_597;
                    }
                    preview.CharacterInfoList = new List <SharedDataPreviewCharacterInfo>();
                    preview.HasData           = memReader.ReadBoolean();
                    preview.Gil          = memReader.ReadInt64();
                    preview.PlayDuration = memReader.ReadUInt64();
                    preview.win_type     = memReader.ReadUInt64();
                    preview.Location     = Encoding.UTF8.GetString(memReader.ReadBytes(128), 0, 128);
                    preview.Location     = preview.Location.Trim(new Char[1]);
                    if (preview.HasData)
                    {
                        isValidPreview = true;
                    }
                    for (Int32 j = 0; j < 4; j++)
                    {
                        SharedDataPreviewCharacterInfo cInfo = new SharedDataPreviewCharacterInfo();
                        cInfo.SerialID = memReader.ReadInt32();
                        cInfo.Level    = memReader.ReadInt32();
                        cInfo.Name     = Encoding.UTF8.GetString(memReader.ReadBytes(128), 0, 128);
                        cInfo.Name     = cInfo.Name.Trim(new Char[1]);
                        if (cInfo.SerialID == -1)
                        {
                            preview.CharacterInfoList.Add((SharedDataPreviewCharacterInfo)null);
                        }
                        else
                        {
                            preview.CharacterInfoList.Add(cInfo);
                        }
                    }
                    preview.Timestamp = memReader.ReadDouble();
                }
            }
            if (isValidPreview)
            {
                list.Add(preview);
            }
            else
            {
                list.Add((SharedDataPreviewSlot)null);
            }
            seekSize = 1024 - ((Int32)stream.Position - prevPosition);
            stream.Seek((Int64)seekSize, SeekOrigin.Current);
            goto IL_597;
        }
        onFinishDelegate(slotID, list);
        yield break;
    }
Exemplo n.º 20
0
 public override void Save(Int32 slotID, Int32 saveID, JSONClass rootNode, ISharedDataStorage.OnSaveFinish onFinishDelegate)
 {
     ISharedDataLog.LogWarning("No need implementation");
 }