|
@@ -43,16 +43,28 @@ public class ManaData : Regist
|
|
|
|
|
|
string configPath = Application.persistentDataPath + "/PlayerConfig.xml";
|
|
|
|
|
|
-
|
|
|
if (File.Exists(configPath))
|
|
|
{
|
|
|
- StreamReader sr = new StreamReader(configPath);
|
|
|
-
|
|
|
- nativeDoc.LoadXml(sr.ReadToEnd());
|
|
|
+ try
|
|
|
+ {
|
|
|
+ StreamReader sr = new StreamReader(configPath);
|
|
|
|
|
|
- sr.Close();
|
|
|
-
|
|
|
- Auxiliary.DecryptXml(nativeDoc);
|
|
|
+ nativeDoc.LoadXml(sr.ReadToEnd());
|
|
|
+
|
|
|
+ sr.Close();
|
|
|
+
|
|
|
+ Auxiliary.DecryptXml(nativeDoc);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ Debug.LogWarning("Download Archive : MD5 doesn't match");
|
|
|
+ ManaDebug.Log("Download Archive");
|
|
|
+
|
|
|
+ DamageLock = true;
|
|
|
+ DownloadLock = false;
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
|
|
@@ -79,9 +91,35 @@ public class ManaData : Regist
|
|
|
|
|
|
if (nativeVersion < defaultVersion)
|
|
|
{
|
|
|
- PlayerDoc_ = MergeXML(nativeVersion, nativeDoc, DefaultDoc);
|
|
|
+ byte[] bytes;
|
|
|
+
|
|
|
+ MD5 md5 = new MD5CryptoServiceProvider();
|
|
|
+
|
|
|
+ if (nativeVersion <= 4)
|
|
|
+ {
|
|
|
+ bytes = Encoding.UTF8.GetBytes(nativeDoc.OuterXml);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bytes = File.ReadAllBytes(configPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (PlayerPrefs.GetString("config") != Auxiliary.ToString(md5.ComputeHash(bytes)))
|
|
|
+ {
|
|
|
+ Debug.LogWarning("Download Archive : MD5 doesn't match");
|
|
|
+ ManaDebug.Log("Download Archive");
|
|
|
+
|
|
|
+ DamageLock = true;
|
|
|
+ DownloadLock = false;
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ PlayerDoc_ = MergeXML(nativeVersion, nativeDoc, DefaultDoc);
|
|
|
|
|
|
- ManaServer.Save();
|
|
|
+ ManaServer.Save();
|
|
|
+ }
|
|
|
}
|
|
|
else if (nativeVersion > defaultVersion)
|
|
|
{
|
|
@@ -89,13 +127,13 @@ public class ManaData : Regist
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- byte[] bytes = Encoding.UTF8.GetBytes(nativeDoc.OuterXml);
|
|
|
+ byte[] bytes = File.ReadAllBytes(configPath);
|
|
|
|
|
|
MD5 md5 = new MD5CryptoServiceProvider();
|
|
|
|
|
|
if (PlayerPrefs.GetString("config") != Auxiliary.ToString(md5.ComputeHash(bytes)))
|
|
|
{
|
|
|
- Debug.LogWarning("Download Archive");
|
|
|
+ Debug.LogWarning("Download Archive : MD5 doesn't match");
|
|
|
ManaDebug.Log("Download Archive");
|
|
|
|
|
|
DamageLock = true;
|
|
@@ -103,7 +141,7 @@ public class ManaData : Regist
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
PlayerDoc_ = nativeDoc;
|
|
|
}
|
|
|
}
|
|
@@ -187,14 +225,6 @@ public class ManaData : Regist
|
|
|
{
|
|
|
if (Initializer.Complete)
|
|
|
{
|
|
|
- byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
|
|
|
-
|
|
|
- MD5 md5 = new MD5CryptoServiceProvider();
|
|
|
-
|
|
|
- PlayerPrefs.SetString("id", ManaServer.ID);
|
|
|
- PlayerPrefs.SetString("config", Auxiliary.ToString(md5.ComputeHash(bytes)));
|
|
|
-
|
|
|
-
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
|
doc.LoadXml(PlayerDoc.OuterXml);
|
|
@@ -206,6 +236,13 @@ public class ManaData : Regist
|
|
|
sw.Write(doc.OuterXml);
|
|
|
|
|
|
sw.Close();
|
|
|
+
|
|
|
+ byte[] bytes = File.ReadAllBytes(Application.persistentDataPath + "/PlayerConfig.xml");
|
|
|
+ //byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
|
|
|
+
|
|
|
+ MD5 md5 = new MD5CryptoServiceProvider();
|
|
|
+
|
|
|
+ PlayerPrefs.SetString("config", Auxiliary.ToString(md5.ComputeHash(bytes)));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -231,8 +268,8 @@ public class ManaData : Regist
|
|
|
|
|
|
int nativeVersion = int.Parse(PlayerDoc_.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
|
|
|
int defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
|
|
|
- Debug.Log(nativeVersion + " " + defaultVersion);
|
|
|
- ManaDebug.Log(nativeVersion + " " + defaultVersion);
|
|
|
+ //Debug.Log(nativeVersion + " " + defaultVersion);
|
|
|
+ //ManaDebug.Log(nativeVersion + " " + defaultVersion);
|
|
|
if (nativeVersion < defaultVersion)
|
|
|
{
|
|
|
MergeXML(nativeVersion, PlayerDoc_, DefaultDoc);
|
|
@@ -516,8 +553,6 @@ public class ManaData : Regist
|
|
|
|
|
|
public static void ResetPlayerConfig()
|
|
|
{
|
|
|
- PlayerPrefs.SetString("id", "");
|
|
|
-
|
|
|
PlayerNode.SelectSingleNode("Version").Attributes[0].Value = "10000";
|
|
|
|
|
|
SavePlayerConfig();
|
|
@@ -1024,6 +1059,13 @@ public class ManaData : Regist
|
|
|
To4(nativeDoc, defaultDoc);
|
|
|
}
|
|
|
|
|
|
+ if (nativeVersion < 5)
|
|
|
+ {
|
|
|
+ Debug.LogWarning("UpdateArchive to 5");
|
|
|
+
|
|
|
+ To5(nativeDoc, defaultDoc);
|
|
|
+ }
|
|
|
+
|
|
|
return nativeDoc;
|
|
|
}
|
|
|
|
|
@@ -1140,4 +1182,11 @@ public class ManaData : Regist
|
|
|
|
|
|
return sleeveList;
|
|
|
}
|
|
|
+
|
|
|
+ public static XmlDocument To5(XmlDocument nativeDoc, XmlDocument defaultDoc)
|
|
|
+ {
|
|
|
+ nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 5.ToString();
|
|
|
+
|
|
|
+ return nativeDoc;
|
|
|
+ }
|
|
|
}
|