Publish verified live restoration source snapshot and known limits

This commit is contained in:
0xcjy
2026-10-01 19:42:22 +08:00
parent 0dd0d3bdaa
commit d70a65c7ce
896 changed files with 105420 additions and 12745 deletions
+13 -1
View File
@@ -10,7 +10,19 @@ using UnityEngine;
public static class Sqlite3MC
{
// ---- DLL name: change if you use different file name / arch ----
private const string DLL = "sqlite3mc_x64"; // ensure sqlite3mc_x64.dll is available for x64 build
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
private const string DLL = "sqlite3mc_x64"; // sqlite3mc_x64.dll
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
private const string DLL = "sqlite3mc_mac"; // libsqlite3mc_mac.dylib
#elif UNITY_ANDROID
private const string DLL = "sqlite3mcandroid"; // libsqlite3mcandroid.so
#elif (UNITY_IOS || UNITY_IPHONE) && !UNITY_EDITOR
private const string DLL = "__Internal"; // libsqlite3mc_static.a
#else
private const string DLL = "sqlite3mc";
#endif
// ---- Common SQLite constants ----
public const int SQLITE_OK = 0;
+29 -8
View File
@@ -43,15 +43,43 @@ public class FaceTypeData
[System.Serializable]
public class CharaEntry
{
/// master.mdb 中读取到的原始日文名。
public string Name;
/// <summary>
/// 从在线更新、持久缓存或 LocalizeEn.cs 内置表读取的英文名。
/// </summary>
public string EnName;
public Sprite Icon;
public int Id;
public string ThemeColor;
public bool IsMob;
public string GetName()
{
return string.IsNullOrEmpty(EnName) ? Name : EnName;
switch (Config.Instance.Language)
{
case Language.En:
if (!string.IsNullOrEmpty(EnName))
return EnName;
return IsMob
? LocalizeEn.GetMobName(Id, Name)
: LocalizeEn.GetCharaName(Id, Name);
case Language.Cn:
Localize.CurrentRegion = Localize.Region.CN;
return IsMob
? Localize.GetMobName(Id, Name)
: Localize.GetCharaName(Id, Name);
case Language.Jp:
default:
Localize.CurrentRegion = Localize.Region.JP;
return Name ?? string.Empty;
}
}
}
@@ -184,10 +212,3 @@ public enum UmaFileType
jobs,
manualdownloadatlas,
}
public enum TranslationTables
{
Costumes = 5,
UmaNames = 6,
MobNames = 59,
}
@@ -45,6 +45,9 @@ public class UmaDatabaseController
public List<DataRow> LiveData;
public List<DataRow> DressData;
//从master里面取点歌机歌曲目录
public Gallop.MasterJukeboxMusicData JukeboxMusicData;
//修改(载入通用服装ColorSet相关)
public List<DataRow> CharaDressColor;
@@ -64,6 +67,20 @@ public class UmaDatabaseController
{
dbKey = Config.Instance.GlobalDBKey;
}
#if UNITY_ANDROID || UNITY_IOS || UNITY_IPHONE
EnsureMobileDatabaseFiles();
var mobileMetaPath = Path.Combine(Config.Instance.MainPath, "meta");
var mobileMasterPath = Path.Combine(Config.Instance.MainPath, "master", "master.mdb");
if (!File.Exists(mobileMetaPath)) throw new FileNotFoundException("Mobile meta database not found", mobileMetaPath);
if (!File.Exists(mobileMasterPath)) throw new FileNotFoundException("Mobile master database not found", mobileMasterPath);
var encryptedDbKey = GenFinalKey((byte[])dbKey.Clone());
MetaEntries = ReadMetaFromEncryptedDb(mobileMetaPath, encryptedDbKey, 3);
masterDb = new SqliteConnection($@"Data Source={mobileMasterPath};");
#else
if (Config.Instance.WorkMode == WorkMode.Standalone)
{
if (!File.Exists($@"{Config.Instance.MainPath}/meta_umaviewer")) throw new Exception();
@@ -82,12 +99,12 @@ public class UmaDatabaseController
metaDb.Open();
MetaEntries = ReadMeta(metaDb);
}
catch (Exception e)
catch (Exception)
{
try
{
var dbPath = $@"{Config.Instance.MainPath}/meta";
var key = GenFinalKey(dbKey);
var key = GenFinalKey((byte[])dbKey.Clone());
MetaEntries = ReadMetaFromEncryptedDb(dbPath, key, 3);
}
catch (Exception)
@@ -95,6 +112,7 @@ public class UmaDatabaseController
throw;
}
}
#endif
masterDb.Open();
@@ -103,6 +121,7 @@ public class UmaDatabaseController
FaceTypeData = ReadFaceTypeData(masterDb);
LiveData = ReadAllLiveData(masterDb);
DressData = ReadAllDressData(masterDb);
JukeboxMusicData = new Gallop.MasterJukeboxMusicData(masterDb);
//修改(载入通用服装ColorSet相关)
@@ -116,9 +135,14 @@ public class UmaDatabaseController
}
#endif
}
catch
catch (Exception ex)
{
Debug.LogError("Database initialization failed: " + ex);
CloseAllConnection();
#if UNITY_ANDROID || UNITY_IOS || UNITY_IPHONE
var msg = $"Mobile database initialization failed at: {Config.Instance.MainPath}\n{ex.GetType().Name}: {ex.Message}";
WriteMobileDatabaseErrorLog(ex);
#else
var msg = $"Database not found at: {Config.Instance.MainPath}";
if (Config.Instance.WorkMode == WorkMode.Standalone)
{
@@ -135,10 +159,84 @@ public class UmaDatabaseController
{
msg += "\nPlease make sure the game client is installed and follow the instructions on GitHub.";
}
#endif
UmaViewerUI.Instance.ShowMessage(msg, UIMessageType.Error);
}
}
private static void WriteMobileDatabaseErrorLog(Exception ex)
{
#if UNITY_ANDROID || UNITY_IOS || UNITY_IPHONE
try
{
var logPath = Path.Combine(Config.Instance.MainPath, "MobileDatabaseInitError.txt");
File.WriteAllText(logPath, ex.ToString());
}
catch
{
}
#endif
}
private static void EnsureMobileDatabaseFiles()
{
Directory.CreateDirectory(Config.Instance.MainPath);
CopyBuiltinDatabaseToFile("Database/meta", Path.Combine(Config.Instance.MainPath, "meta"));
CopyBuiltinDatabaseToFile("Database/master.mdb", Path.Combine(Config.Instance.MainPath, "master", "master.mdb"));
}
private static void CopyBuiltinDatabaseToFile(string resourcePath, string targetPath)
{
var asset = UnityEngine.Resources.Load<UnityEngine.TextAsset>(resourcePath);
if (asset == null)
{
throw new FileNotFoundException($"Built-in database resource not found: Resources/{resourcePath}.bytes");
}
try
{
var bytes = asset.bytes;
var target = new FileInfo(targetPath);
if (target.Exists && target.Length == bytes.LongLength)
{
MarkNoBackup(targetPath);
return;
}
var directory = Path.GetDirectoryName(targetPath);
if (!string.IsNullOrEmpty(directory))
{
Directory.CreateDirectory(directory);
MarkNoBackup(directory);
}
var tempPath = targetPath + ".tmp";
if (File.Exists(tempPath))
{
File.Delete(tempPath);
}
File.WriteAllBytes(tempPath, bytes);
if (File.Exists(targetPath))
{
File.Delete(targetPath);
}
File.Move(tempPath, targetPath);
MarkNoBackup(targetPath);
}
finally
{
UnityEngine.Resources.UnloadAsset(asset);
}
}
private static void MarkNoBackup(string path)
{
#if UNITY_IOS || UNITY_IPHONE
UnityEngine.iOS.Device.SetNoBackupFlag(path);
#endif
}
//修改(载入通用服装ColorSet相关)
@@ -474,6 +572,8 @@ public class UmaDatabaseController
public void CloseAllConnection()
{
JukeboxMusicData?.Unload();
JukeboxMusicData = null;
masterDb?.Close();
metaDb?.Close();
masterDb?.Dispose();
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -81,15 +81,19 @@ public class UmaDatabaseEntry
public T Get<T>(bool withDependencies = true)
{
Object asset = UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies)
.LoadAllAssets().FirstOrDefault(a=>a.GetType() == typeof(T));
Object[] loaded = UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies).LoadAllAssets();
Object asset = loaded.FirstOrDefault(a => a.GetType() == typeof(T));
if (Gallop.Live.LiveRuntimeDiagnostics.Enabled)
Gallop.Live.LiveRuntimeDiagnostics.RecordAssetLoad(Name, "Get", typeof(T), loaded, asset);
return (T)System.Convert.ChangeType(asset, typeof(T));
}
public IEnumerable<T> GetAll<T>(bool withDependencies = true)
{
IEnumerable<Object> assets = UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies)
.LoadAllAssets().Where(a => a.GetType() == typeof(T));
Object[] loaded = UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies).LoadAllAssets();
if (Gallop.Live.LiveRuntimeDiagnostics.Enabled)
Gallop.Live.LiveRuntimeDiagnostics.RecordAssetLoad(Name, "GetAll", typeof(T), loaded);
IEnumerable<Object> assets = loaded.Where(a => a.GetType() == typeof(T));
return assets.Select(asset => (T)System.Convert.ChangeType(asset, typeof(T)));
}