客户端rsa,冗余清理,bug修复,安卓build问题
This commit is contained in:
@@ -10,6 +10,7 @@ public class PlayerProgressBackupBundle
|
||||
public int version = 1;
|
||||
public long savedUtcTicks;
|
||||
public PlayerEconomyPayload economy;
|
||||
public bool hasPlayerExperience;
|
||||
public int playerExperience;
|
||||
public float bestOverallRks;
|
||||
public PlayerSkillSaveData playerSkill;
|
||||
@@ -27,6 +28,62 @@ public static class PlayerProgressBackupService
|
||||
private static bool s_cacheLoaded;
|
||||
private static bool s_isWriting;
|
||||
|
||||
public static bool HasExistingBackupFile()
|
||||
{
|
||||
IReadOnlyList<string> candidates = SaveIdentityUtility.GetPersistentRootVariants();
|
||||
for (int i = 0; i < candidates.Count; i++)
|
||||
{
|
||||
string root = candidates[i];
|
||||
if (string.IsNullOrWhiteSpace(root))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (File.Exists(Path.Combine(root, BackupFileName)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HasEconomyBackup()
|
||||
{
|
||||
PlayerProgressBackupBundle bundle;
|
||||
return TryLoadBundle(out bundle) && bundle != null && bundle.economy != null;
|
||||
}
|
||||
|
||||
public static bool HasPlayerExperienceBackup()
|
||||
{
|
||||
PlayerProgressBackupBundle bundle;
|
||||
return TryLoadBundle(out bundle) && bundle != null && (bundle.hasPlayerExperience || bundle.playerExperience > 0);
|
||||
}
|
||||
|
||||
public static bool HasAllyHeroDeployBackup()
|
||||
{
|
||||
PlayerProgressBackupBundle bundle;
|
||||
return TryLoadBundle(out bundle) && bundle != null && bundle.allyHeroDeploy != null;
|
||||
}
|
||||
|
||||
public static bool HasExpBottleBackup()
|
||||
{
|
||||
PlayerProgressBackupBundle bundle;
|
||||
return TryLoadBundle(out bundle) && bundle != null && bundle.expBottle != null;
|
||||
}
|
||||
|
||||
public static bool HasDushMaterialBackup()
|
||||
{
|
||||
PlayerProgressBackupBundle bundle;
|
||||
return TryLoadBundle(out bundle) && bundle != null && bundle.dushMaterial != null;
|
||||
}
|
||||
|
||||
public static bool HasStoreOwnershipBackup()
|
||||
{
|
||||
PlayerProgressBackupBundle bundle;
|
||||
return TryLoadBundle(out bundle) && bundle != null && bundle.storeOwnership != null;
|
||||
}
|
||||
|
||||
public static bool TryRestoreEconomy(out PlayerEconomyPayload payload)
|
||||
{
|
||||
payload = null;
|
||||
@@ -59,7 +116,7 @@ public static class PlayerProgressBackupService
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bundle.playerExperience <= 0)
|
||||
if (!bundle.hasPlayerExperience && bundle.playerExperience <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -70,7 +127,11 @@ public static class PlayerProgressBackupService
|
||||
|
||||
public static void SavePlayerExperience(int experience)
|
||||
{
|
||||
UpdateBundle(bundle => bundle.playerExperience = Mathf.Max(0, experience));
|
||||
UpdateBundle(bundle =>
|
||||
{
|
||||
bundle.hasPlayerExperience = true;
|
||||
bundle.playerExperience = Mathf.Max(0, experience);
|
||||
});
|
||||
}
|
||||
|
||||
public static bool TryRestoreRks(out float rks)
|
||||
@@ -229,6 +290,59 @@ public static class PlayerProgressBackupService
|
||||
UpdateBundle(bundle => bundle.storeOwnership = CloneStoreOwnership(payload));
|
||||
}
|
||||
|
||||
public static void ClearPlayerExperienceBackup()
|
||||
{
|
||||
UpdateBundle(bundle =>
|
||||
{
|
||||
bundle.hasPlayerExperience = false;
|
||||
bundle.playerExperience = 0;
|
||||
});
|
||||
}
|
||||
|
||||
public static void ClearRksBackup()
|
||||
{
|
||||
UpdateBundle(bundle => bundle.bestOverallRks = 0f);
|
||||
}
|
||||
|
||||
public static void ClearPlayerSkillBackup()
|
||||
{
|
||||
UpdateBundle(bundle => bundle.playerSkill = null);
|
||||
}
|
||||
|
||||
public static void ClearStoreOwnershipBackup()
|
||||
{
|
||||
UpdateBundle(bundle => bundle.storeOwnership = null);
|
||||
}
|
||||
|
||||
public static void ClearAllBackupData()
|
||||
{
|
||||
s_cachedBundle = null;
|
||||
s_cacheLoaded = true;
|
||||
|
||||
IReadOnlyList<string> candidates = SaveIdentityUtility.GetPersistentRootVariants();
|
||||
for (int i = 0; i < candidates.Count; i++)
|
||||
{
|
||||
string root = candidates[i];
|
||||
if (string.IsNullOrWhiteSpace(root))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string path = Path.Combine(root, BackupFileName);
|
||||
try
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning("[PlayerProgressBackup] Failed to delete backup '" + path + "': " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateBundle(Action<PlayerProgressBackupBundle> mutator)
|
||||
{
|
||||
if (mutator == null || s_isWriting)
|
||||
|
||||
Reference in New Issue
Block a user