Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions ModPcGUI/src/ModPcGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@
<!-- PclStyles.xaml 已改为运行时 XamlReader.Parse 加载(其程序集名带空格,
无法通过 WPF 编译期的 clr-namespace URI 校验),从 Page 自动包含里排除 -->
<Page Remove="PclStyles.xaml" />
<!-- SDK 默认的 None 通配项也会拾到它,先摘掉再按自定义 TargetPath 加回来,避免重复项 -->
<None Remove="PclStyles.xaml" />
<!-- 运行时从 BaseDirectory\pcl\PclStyles.xaml 读取(PclMainWindow.LoadPclStyles),
所以按同样的相对路径拷到输出目录;不要打包进程序集当 Page——里面引用了
`clr-namespace:PCL;assembly=Plain Craft Launcher 2`,编译期解析不了。
注意:目标路径与 pcl\ 下已有的同名文件会互相覆盖,以本文件为准。 -->
<None Include="PclStyles.xaml">
<Link>pcl\PclStyles.xaml</Link>
<TargetPath>pcl\PclStyles.xaml</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -65,7 +54,6 @@
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System.Web" />
Expand Down
523 changes: 0 additions & 523 deletions ModPcGUI/src/PclStyles.xaml

This file was deleted.

60 changes: 0 additions & 60 deletions ModPcGUI/src/UI/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public static void Init()

Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

// 运行时数据自愈:先保证 config.json 与 user\ 存在,再做任何依赖它们的事。
// 官方发行包自带这两样,但从源码编译出来的 bin\Debug\net48 里没有 ——
// 缺了会让 CoreNative.CanLaunch 拿到 null 配置直接 NRE,账号列表也永远是空的
// (点「登录」只会弹「还没有账号」)。
try { EnsureRuntimeData(); }
catch (Exception ex) { Term.WriteLine("[init] 运行时数据自愈失败:" + ex.Message); }

try
{
string fpd;
Expand All @@ -66,35 +59,6 @@ public static void Init()
}
}

/// <summary>
/// 补齐跑起来必需、但发行包里才有的运行时数据。
/// 只补「缺了就直接白屏 / 功能全废」的两样,不动已有文件:
/// user\ —— 账号 json 的存放目录,缺了账号下拉永远是空的
/// config.json —— 版本号 / 服务器地址 / 游戏路径,缺了 app.Temp 为 null
/// 默认值取网易正式包的当前值,只作为兜底,用户改过就永不覆盖。
/// </summary>
private static void EnsureRuntimeData()
{
string baseDir = AppDomain.CurrentDomain.BaseDirectory;

string userDir = Path.Combine(baseDir, "user");
if (!Directory.Exists(userDir)) Directory.CreateDirectory(userDir);

string cfgPath = Path.Combine(baseDir, "config.json");
if (File.Exists(cfgPath)) return;

var def = new Login.temp
{
Version = "1.21.130",
url = "https://x19obtcore.nie.netease.com:8443",
PE_url = "https://g79obtcore.nie.netease.com:8443",
engineVersion = "3.4.5.272725",
connect_log = true
};
File.WriteAllText(cfgPath, JsonConvert.SerializeObject(def));
Term.WriteLine("[init] 未找到 config.json,已生成默认配置(服务器 " + def.url + ")\r\n");
}

public static string UserDir
{
get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "user"); }
Expand All @@ -114,29 +78,6 @@ public static List<string> ListAccounts()
return list;
}

/// <summary>
/// 账号文件自检。返回 null 表示看起来正常,否则返回人话描述的毛病。
/// 典型坏法:手工粘贴 sauth 时内层引号没转义,外层 JSON 直接不成立 ——
/// 这种文件选中后点登录会一路静默失败(错误只写进设置页的日志框),
/// 表现就是「登录按钮点了没反应」,所以要在点之前就拦住。
/// </summary>
public static string CheckAccount(string path)
{
try
{
if (!File.Exists(path)) return "文件不存在";
string raw = File.ReadAllText(path).Trim();
if (raw.Length == 0) return "文件是空的";
if (raw.StartsWith("ey") || raw.StartsWith("SDK4399")) return null; // 纯 sauth JWT,无需解析
Newtonsoft.Json.Linq.JObject.Parse(raw);
return null;
}
catch (Exception ex)
{
return "不是合法 JSON(" + ex.Message + ")";
}
}

public static void AddAccount(string name, string cookie)
{
string dir = UserDir;
Expand All @@ -160,7 +101,6 @@ public static void Login(string accountFile, string mode)
{
if (LoggingIn || Started) return;
LoggingIn = true;
LastError = "";
Notify();

try
Expand Down
45 changes: 1 addition & 44 deletions ModPcGUI/src/UI/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,7 @@ private static void Main(string[] args)
// 一旦触发就是整进程闪退;这里记入 crash.log 并继续运行
wpf.DispatcherUnhandledException += (s, e) =>
{
try
{
var ex = e.Exception;
if (IsKnownPclNoise(ex))
{
// 同一签名 60 秒内只记首次:这类异常由 DispatcherTimer 每秒重试,
// 全量记录会把 crash.log 刷到几 MB,反而盖住真正的新问题
string key = (ex.StackTrace ?? "").Split('\n')[0].Trim();
DateTime last;
_noiseStamp.TryGetValue(key, out last);
if ((DateTime.Now - last).TotalSeconds < 60)
{
e.Handled = true;
return;
}
_noiseStamp[key] = DateTime.Now;
Log("Dispatcher", ex.ToString());
e.Handled = true;
return;
}
Log("Dispatcher", ex.ToString());
}
catch { }
Log("Dispatcher", e.Exception.ToString());
e.Handled = true;
};
wpf.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
Expand Down Expand Up @@ -265,27 +243,6 @@ private static void Log(string tag, string msg)
catch { }
}

/// <summary>已知噪音签名 -> 上次记录时间(用于 crash.log 去重)</summary>
private static readonly System.Collections.Generic.Dictionary<string, DateTime> _noiseStamp
= new System.Collections.Generic.Dictionary<string, DateTime>();

/// <summary>
/// 判断是否为「PCL 控件与宿主环境不兼容」导致的已知噪音异常。
/// 只认两个确切签名,其余异常一律照常记录,避免掩盖新问题:
/// 1) Popup.OnWindowResize —— WPF(.NET Framework) 在弹层销毁期间重排时的 NRE;
/// 2) MyScrollViewer_IsVisibleChanged —— PCL 该回调未判空直接读 FrmMain(宿主无此单例)。
/// 第 2 类已在 PclStyles.xaml 里通过改用原生 ScrollViewer 消除,
/// 这里只是兜底:万一别处又冒出同类异常,也不至于被每秒重试刷爆日志。
/// </summary>
private static bool IsKnownPclNoise(Exception ex)
{
if (!(ex is NullReferenceException)) return false;
string st = ex.StackTrace;
if (string.IsNullOrEmpty(st)) return false;
return st.IndexOf("Popup.OnWindowResize", StringComparison.Ordinal) >= 0
|| st.IndexOf("MyScrollViewer_IsVisibleChanged", StringComparison.Ordinal) >= 0;
}

private static void SelfTest()
{
var sb = new System.Text.StringBuilder();
Expand Down
Loading
Loading