Compare commits

...

3 Commits

3 changed files with 52 additions and 10 deletions

View File

@ -1,6 +1,7 @@
using AxibugEmuOnline.Client.Manager; using AxibugEmuOnline.Client.Manager;
using AxibugEmuOnline.Client.Network; using AxibugEmuOnline.Client.Network;
using System.Collections; using System.Collections;
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
@ -31,8 +32,11 @@ namespace AxibugEmuOnline.Client.ClientCore
private static CoroutineRunner coRunner; private static CoroutineRunner coRunner;
#endregion #endregion
#if UNITY_PSP2
public static string PersistentDataPath => "ux0:data/AxibugEmu";
#else
public static string PersistentDataPath => Application.persistentDataPath; public static string PersistentDataPath => Application.persistentDataPath;
#endif
[RuntimeInitializeOnLoadMethod] [RuntimeInitializeOnLoadMethod]
static void Init() static void Init()
@ -56,6 +60,12 @@ namespace AxibugEmuOnline.Client.ClientCore
tickLoop = go.AddComponent<TickLoop>(); tickLoop = go.AddComponent<TickLoop>();
coRunner = go.AddComponent<CoroutineRunner>(); coRunner = go.AddComponent<CoroutineRunner>();
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
{
//PSV 等平台需要手动创建目录
PersistentDataPathDir();
}
var importNode = GameObject.Find("IMPORTENT"); var importNode = GameObject.Find("IMPORTENT");
if (importNode != null) GameObject.DontDestroyOnLoad(importNode); if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
@ -63,6 +73,14 @@ namespace AxibugEmuOnline.Client.ClientCore
RePullNetInfo(); RePullNetInfo();
} }
private static void PersistentDataPathDir()
{
if (!Directory.Exists(PersistentDataPath))
{
Directory.CreateDirectory(PersistentDataPath);
}
}
private static IEnumerator AppTickFlow() private static IEnumerator AppTickFlow()
{ {
while (true) while (true)

View File

@ -1,6 +1,8 @@
using System; using System;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
namespace AxibugEmuOnline.Client.Common namespace AxibugEmuOnline.Client.Common
{ {
@ -42,5 +44,34 @@ namespace AxibugEmuOnline.Client.Common
return resultMemoryStream.ToArray(); return resultMemoryStream.ToArray();
} }
} }
public static string FileMD5Hash(string filePath)
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(filePath))
{
var hash = md5.ComputeHash(stream);
var sb = new StringBuilder(hash.Length * 2);
foreach (var b in hash)
sb.AppendFormat("{0:x2}", b);
return sb.ToString();
}
}
}
public static string FileMD5Hash(byte[] data)
{
using (var md5 = MD5.Create())
{
using (var stream = new MemoryStream(data))
{
var hash = md5.ComputeHash(stream);
var sb = new StringBuilder(hash.Length * 2);
foreach (var b in hash)
sb.AppendFormat("{0:x2}", b);
return sb.ToString();
}
}
}
} }
} }

View File

@ -1,4 +1,5 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -116,15 +117,7 @@ namespace AxibugEmuOnline.Client
public static string CalcHash(byte[] data) public static string CalcHash(byte[] data)
{ {
return string.Empty; //todo : 等待远程仓库敲定hash算法 return Helper.FileMD5Hash(data);
//var hashBytes = MD5.Create().ComputeHash(data);
//StringBuilder sb = new StringBuilder();
//foreach (byte b in hashBytes)
//{
// sb.Append(b.ToString("x2"));
//}
//return sb.ToString();
} }
} }
} }