|
@@ -6,6 +6,8 @@ using System.Xml;
|
|
|
using System.Text;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Security.Cryptography;
|
|
|
+using LitJson;
|
|
|
|
|
|
public class Data
|
|
|
{
|
|
@@ -15,20 +17,20 @@ public class Data
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- if (_PlayerNode == null)
|
|
|
+ if (PlayerNode_ == null)
|
|
|
{
|
|
|
- _PlayerNode = PlayerDoc.SelectSingleNode("PlayerConfig");
|
|
|
+ PlayerNode_ = PlayerDoc.SelectSingleNode("PlayerConfig");
|
|
|
}
|
|
|
|
|
|
- return _PlayerNode;
|
|
|
+ return PlayerNode_;
|
|
|
}
|
|
|
- set { _PlayerNode = value; }
|
|
|
+ set { PlayerNode_ = value; }
|
|
|
}
|
|
|
public static XmlDocument PlayerDoc
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- if (_PlayerDoc == null)
|
|
|
+ if (PlayerDoc_ == null)
|
|
|
{
|
|
|
int version = 0;
|
|
|
int nativeVersion = 0;
|
|
@@ -55,6 +57,22 @@ public class Data
|
|
|
tempDoc1 = new XmlDocument();
|
|
|
tempDoc1.LoadXml(sr.ReadToEnd());
|
|
|
|
|
|
+ byte[] bytes = Encoding.UTF8.GetBytes(tempDoc1.OuterXml);
|
|
|
+
|
|
|
+ MD5 md5 = new MD5CryptoServiceProvider();
|
|
|
+
|
|
|
+ if (PlayerPrefs.GetString("config") != Encoding.UTF8.GetString(md5.ComputeHash(bytes)))
|
|
|
+ {
|
|
|
+ DamageXml = true;
|
|
|
+
|
|
|
+ ManaServer.Load(PlayerPrefs.GetString("id"), RecoveXml);
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Auxiliary.DecryptXml(tempDoc1);
|
|
|
+
|
|
|
+
|
|
|
sr.Close();
|
|
|
|
|
|
TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
|
|
@@ -74,7 +92,7 @@ public class Data
|
|
|
|
|
|
sw.Close();
|
|
|
|
|
|
- _PlayerDoc = tempDoc2;
|
|
|
+ PlayerDoc_ = tempDoc2;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -88,11 +106,11 @@ public class Data
|
|
|
|
|
|
sw.Close();
|
|
|
|
|
|
- _PlayerDoc = tempDoc2;
|
|
|
+ PlayerDoc_ = tempDoc2;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _PlayerDoc = tempDoc1;
|
|
|
+ PlayerDoc_ = tempDoc1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -103,25 +121,21 @@ public class Data
|
|
|
tempDoc2 = new XmlDocument();
|
|
|
tempDoc2.LoadXml(textAsset.text);
|
|
|
|
|
|
- StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
|
|
|
-
|
|
|
- sw.Write(tempDoc2.OuterXml);
|
|
|
-
|
|
|
- sw.Close();
|
|
|
-
|
|
|
- _PlayerDoc = tempDoc2;
|
|
|
+ PlayerDoc_ = tempDoc2;
|
|
|
|
|
|
- _PlayerDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
|
|
|
+ PlayerDoc_.SelectSingleNode("PlayerConfig").SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return _PlayerDoc;
|
|
|
+ return PlayerDoc_;
|
|
|
}
|
|
|
- set { _PlayerDoc = value; }
|
|
|
+ set { PlayerDoc_ = value; }
|
|
|
}
|
|
|
|
|
|
- public static XmlNode _PlayerNode;
|
|
|
- public static XmlDocument _PlayerDoc;
|
|
|
+ public static XmlNode PlayerNode_;
|
|
|
+ public static XmlDocument PlayerDoc_;
|
|
|
+
|
|
|
+ public static bool DamageXml;
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -129,11 +143,41 @@ public class Data
|
|
|
{
|
|
|
if (Initializer.LoadComplete)
|
|
|
{
|
|
|
- StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
|
|
|
+ Auxiliary.EncryptXml(PlayerDoc);
|
|
|
|
|
|
+ StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
|
|
|
+
|
|
|
sw.Write(PlayerDoc.OuterXml);
|
|
|
|
|
|
sw.Close();
|
|
|
+
|
|
|
+
|
|
|
+ byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
|
|
|
+
|
|
|
+ MD5 md5 = new MD5CryptoServiceProvider();
|
|
|
+
|
|
|
+ PlayerPrefs.SetString("id", ManaServer.ID);
|
|
|
+ PlayerPrefs.SetString("config", Encoding.UTF8.GetString(md5.ComputeHash(bytes)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void RecoveXml(JsonData jsonData)
|
|
|
+ {
|
|
|
+ DamageXml = false;
|
|
|
+
|
|
|
+ if (jsonData.Inst_Object.Keys.Contains("l"))
|
|
|
+ {
|
|
|
+ PlayerDoc_ = new XmlDocument();
|
|
|
+
|
|
|
+ PlayerDoc_.LoadXml(jsonData["l"].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
|
|
|
+
|
|
|
+ PlayerDoc_ = new XmlDocument();
|
|
|
+
|
|
|
+ PlayerDoc_.LoadXml(textAsset.text);
|
|
|
}
|
|
|
}
|
|
|
|