🐛 修复成就数据读取异常

This commit is contained in:
BTMuli
2025-12-03 18:40:25 +08:00
parent 676ef8e8ee
commit 46cf40734f
6 changed files with 18 additions and 57 deletions

View File

@@ -1,43 +0,0 @@
syntax = "proto3";
message AchievementProtoFieldInfo {
uint32 id = 1;
uint32 status = 2;
uint32 total_progress = 3;
uint32 current_progress = 4;
uint32 finish_timestamp = 5;
}
message AchievementItem {
uint32 pre = 1;
uint32 group = 2;
string name = 3;
string description = 4;
}
message MethodRvaConfig {
uint32 do_cmd = 1;
uint32 update_normal_prop = 3;
uint32 new_string = 4;
uint32 find_game_object = 5;
uint32 event_system_update = 6;
uint32 simulate_pointer_click = 7;
uint32 to_int32 = 8;
uint32 tcp_state_ptr = 9;
uint32 shared_info_ptr = 10;
uint32 decompress = 11;
}
message NativeLibConfig {
uint32 store_cmd_id = 1;
uint32 achievement_cmd_id = 2;
map<uint32, MethodRvaConfig> method_rva = 10;
}
message AchievementInfo {
string version = 1;
map<uint32, string> group = 2;
map<uint32, AchievementItem> items = 3;
AchievementProtoFieldInfo pb_info = 4;
NativeLibConfig native_config = 5;
}

View File

@@ -154,7 +154,7 @@ pub fn run_with_admin() -> Result<(), String> {
return Err(format!("executable not found: {}", exe_path.display()));
}
let elevated_arg = "--elevated-action=post_install";
let elevated_arg = "--elevated";
// /C start "" "<full_path>" --elevated-action=post_install
let params = format!("/C start \"\" \"{}\" {}", exe_path.display(), elevated_arg);

View File

@@ -15,13 +15,7 @@ pub fn build_si_plugin<R: Runtime>() -> TauriPlugin<R> {
let args: Vec<String> = argv.iter().map(|s| s.to_string()).collect();
// 如果包含提升约定参数,发出专门事件并短路退出
if args.iter().any(|a| a.starts_with("--elevated-action"))
|| args.iter().any(|a| a == "--elevated")
{
if let Err(e) = app.emit("elevated_launch", args.clone()) {
// 记录错误但不要 panic
eprintln!("emit elevated_launch failed: {}", e);
}
if args.iter().any(|a| a == "--elevated") {
// 提升实例通常只负责传参或执行一次性任务,退出避免与主实例冲突
std::process::exit(0);
}

View File

@@ -23,7 +23,7 @@ fn read_rva(key: &str) -> i32 {
}
// 读取配置文件
fn read_conf(path: &str) -> i32 {
pub fn read_conf(path: &str) -> i32 {
// 编译时嵌入 JSON 文件值都是32位整数
let data = include_str!("../../lib/conf.json");
let json: Value = serde_json::from_str(data).expect("Invalid JSON");

View File

@@ -1,7 +1,8 @@
//! Yae 成就信息的 Protobuf 定义
//! @since Beta v0.8.7
//! @since Beta v0.7.9
#![cfg(target_os = "windows")]
use crate::yae::read_conf;
use prost::encoding::{decode_key, WireType};
use prost::DecodeError;
use prost::Message;
@@ -140,6 +141,8 @@ pub fn parse_achi_list(bytes: &[u8]) -> Result<Vec<UiafAchiItem>, DecodeError> {
let value = prost::encoding::decode_varint(&mut inner)? as u32;
dict.insert(tag, value);
}
// 输出 dict
println!("{:?}", dict);
// dict 至少需要两个 key
if dict.len() > 2 {
dicts.push(dict)
@@ -147,14 +150,20 @@ pub fn parse_achi_list(bytes: &[u8]) -> Result<Vec<UiafAchiItem>, DecodeError> {
}
}
let _id = read_conf("id") as u32;
let _status = read_conf("status") as u32;
let _cur = read_conf("currentProgress") as u32;
let _ts = read_conf("finishTimestamp") as u32;
let achievements = dicts
.into_iter()
.map(|d| UiafAchiItem {
id: d.get(&15).copied().unwrap_or(0),
status: d.get(&11).copied().unwrap_or(0),
current: d.get(&13).copied().unwrap_or(0),
timestamp: d.get(&7).copied().unwrap_or(0),
id: d.get(&_id).copied().unwrap_or(0),
status: d.get(&_status).copied().unwrap_or(0),
current: d.get(&_cur).copied().unwrap_or(0),
timestamp: d.get(&_ts).copied().unwrap_or(0),
})
.filter(|a| a.status != 0)
.collect();
Ok(achievements)

View File

@@ -350,6 +350,7 @@ async function toYae(): Promise<void> {
}
async function tryParseYaeAchi(payload: TGApp.Plugins.Yae.AchiListRes): Promise<void> {
console.log(payload);
if (payload.length === 0) {
showSnackbar.warn(`未从Yae获取到成就数据`);
return;