Skip to content

Commit f63164b

Browse files
committed
fix: 日志输出改为英文,修复控制台乱码 (#1)
1 parent 2a2b8cd commit f63164b

20 files changed

Lines changed: 71 additions & 71 deletions

src/d3d9/hook.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ pub fn init(api: &Api) {
4141

4242
let Some(original) = original else {
4343
HOOKED.store(false, Ordering::SeqCst);
44-
api.log_warn("DeviceLostFix 初始化跳过: 未找到 Direct3DCreate9 导入");
44+
api.log_warn("DeviceLostFix skipped: Direct3DCreate9 import not found");
4545
return;
4646
};
4747

4848
ORIGINAL_DIRECT3D_CREATE9.store(original as usize, Ordering::SeqCst);
49-
api.log_info("DeviceLostFix 已安装: Direct3DCreate9 IAT hook");
49+
api.log_info("DeviceLostFix installed: Direct3DCreate9 IAT hook");
5050
}
5151

5252
unsafe extern "system" fn hooked_direct3d_create9(sdk_version: u32) -> *mut c_void {
@@ -109,9 +109,9 @@ fn hook_create_device(d3d: *mut c_void) {
109109
if unsafe { patch_slot(slot, detour) } {
110110
ORIGINAL_CREATE_DEVICE.store(current, Ordering::SeqCst);
111111
CREATE_DEVICE_SLOT.store(slot as usize, Ordering::SeqCst);
112-
log_info("DeviceLostFix 已安装: IDirect3D9::CreateDevice vtable hook");
112+
log_info("DeviceLostFix installed: IDirect3D9::CreateDevice vtable hook");
113113
} else {
114-
log_warn("DeviceLostFix 初始化失败: CreateDevice vtable 写入失败");
114+
log_warn("DeviceLostFix failed: CreateDevice vtable write failed");
115115
}
116116
}
117117

src/d3d9/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ fn init_d3d9_proxy(api: &Api, config: &Config) {
3232

3333
if config.is_enabled("FpsDisplay") {
3434
unsafe { ((*proxy).register_present_callback)(fps_osd::on_end_scene) };
35-
api.log_info("FPS 显示已注册 (d3d9 proxy callback)");
35+
api.log_info("FPS display registered (d3d9 proxy callback)");
3636
}
3737

3838
if config.is_enabled("FrameLock") {
3939
let fps = config.get_int("FrameLock", "fps", 0) as u32;
4040
if fps > 0 {
4141
unsafe { ((*proxy).set_frame_lock)(fps) };
42-
api.log_info(&format!("帧率锁定: {}fps (d3d9 proxy)", fps));
42+
api.log_info(&format!("frame lock: {}fps (d3d9 proxy)", fps));
4343
}
4444
}
4545
}

src/d3d9/recovery.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ unsafe fn recover_device(device: *mut c_void) {
9797
return;
9898
}
9999

100-
log_info("DeviceLostFix 检测到 D3DERR_DEVICELOST,开始等待 Reset");
100+
log_info("DeviceLostFix detected D3DERR_DEVICELOST, waiting for Reset");
101101

102102
for _ in 0..MAX_RECOVERY_ATTEMPTS {
103103
let state = test_cooperative_level()
@@ -110,9 +110,9 @@ unsafe fn recover_device(device: *mut c_void) {
110110
if let Some(reset) = reset() {
111111
let reset_result = reset(device, params);
112112
if reset_result == D3D_OK {
113-
log_info("DeviceLostFix 已通过 Reset 恢复 D3D9 device");
113+
log_info("DeviceLostFix recovered D3D9 device via Reset");
114114
} else {
115-
log_warn("DeviceLostFix 调用 Reset 后仍未恢复");
115+
log_warn("DeviceLostFix Reset called but device not recovered");
116116
}
117117
}
118118
}
@@ -161,9 +161,9 @@ unsafe fn hook_device_slot(
161161
if patch_slot(slot, detour) {
162162
original.store(current, Ordering::SeqCst);
163163
stored_slot.store(slot as usize, Ordering::SeqCst);
164-
log_info(&format!("DeviceLostFix 已安装: IDirect3DDevice9::{name} vtable hook"));
164+
log_info(&format!("DeviceLostFix installed: IDirect3DDevice9::{name} vtable hook"));
165165
} else {
166-
log_warn(&format!("DeviceLostFix 初始化失败: {name} vtable 写入失败"));
166+
log_warn(&format!("DeviceLostFix failed: {name} vtable write failed"));
167167
}
168168
}
169169

src/hooks/autoplay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn init(api: &Api, _config: &Config) {
217217
CreateThread(ptr::null(), 0, Some(demo_write_thread), ptr::null(), 0, ptr::null_mut());
218218
CreateThread(ptr::null(), 0, Some(hotkey_thread), ptr::null(), 0, ptr::null_mut());
219219
}
220-
api.log_info("Autoplay 已启用: Home 键切换,开启时写入 demo/preset flag");
220+
api.log_info("Autoplay enabled: toggle with Home key, writes demo/preset flag when on");
221221
}
222222

223223
pub fn shutdown() {
@@ -230,7 +230,7 @@ pub fn shutdown() {
230230
api.hook_remove(JUDGE_ADDR);
231231
JUDGE_ADDR = 0;
232232
}
233-
api.log_info("Autoplay 已清理");
233+
api.log_info("Autoplay cleaned up");
234234
}
235235
}
236236
}
@@ -361,7 +361,7 @@ unsafe extern "system" fn demo_write_thread(_: *mut c_void) -> u32 {
361361
if enabled {
362362
write_demo_flags();
363363
if !was_enabled {
364-
log_info("Autoplay ON: demo/preset flag 写入中");
364+
log_info("Autoplay ON: writing demo/preset flag");
365365
}
366366
} else if was_enabled {
367367
clear_demo_flag();

src/hooks/smart_upload.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ pub fn init(api: &Api) {
1414

1515
let upsert = find_upsert_function(api, api.text_base(), api.text_size(), api.game_base(), api.game_size());
1616
if upsert == 0 {
17-
api.log_warn("智能成绩屏蔽初始化失败: UpsertUserAll 未找到,autoplay 时成绩可能上传");
17+
api.log_warn("score blocking init failed: UpsertUserAll not found, scores may upload during autoplay");
1818
return;
1919
}
2020

2121
let Some(trampoline) = api.hook_create(upsert, hooked_upsert as *const () as usize) else {
22-
api.log_warn("智能成绩屏蔽初始化失败: UpsertUserAll hook 创建失败");
22+
api.log_warn("score blocking init failed: UpsertUserAll hook creation failed");
2323
return;
2424
};
2525
if !api.hook_enable(upsert) {
26-
api.log_warn("智能成绩屏蔽初始化失败: UpsertUserAll hook 启用失败");
26+
api.log_warn("score blocking init failed: UpsertUserAll hook enable failed");
2727
return;
2828
}
2929

@@ -32,7 +32,7 @@ pub fn init(api: &Api) {
3232
ORIG_UPSERT = trampoline;
3333
}
3434
api.log_info(&format!(
35-
"智能成绩屏蔽已启用: UpsertUserAll @ 0x{upsert:08X},autoplay 开启时成绩不上传"
35+
"score blocking enabled: UpsertUserAll @ 0x{upsert:08X}, scores blocked during autoplay"
3636
));
3737
}
3838

@@ -44,15 +44,15 @@ pub fn shutdown() {
4444
api.hook_remove(UPSERT_ADDR);
4545
UPSERT_ADDR = 0;
4646
}
47-
api.log_info("智能成绩屏蔽已清理");
47+
api.log_info("score blocking cleaned up");
4848
}
4949
}
5050
}
5151

5252
unsafe extern "C" fn hooked_upsert(a: *mut c_void, b: *mut c_void, c: *mut c_void) {
5353
if autoplay::is_enabled() || autoplay::was_used() {
5454
if let Some(api) = API_HANDLE {
55-
api.log_info("成绩屏蔽: 本次游玩使用过 autoplay,已阻止上传");
55+
api.log_info("score blocking: autoplay was used, upload blocked");
5656
}
5757
autoplay::reset_was_used();
5858
return;

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ pub extern "C" fn chumod_init(info: *const ChuModInfo, api: *const ChuModAPI) ->
4545
return -1;
4646
};
4747

48-
api.log_info("AppleChu 初始化中");
48+
api.log_info("AppleChu initializing");
4949
let config = Config::load(&base_dir(info));
5050
patches::apply_all(api, &config);
5151
hooks::init_all(api, &config);
5252
ux::init_all(api, &config);
5353
d3d9::init_all(api, &config);
54-
api.log_info("AppleChu 初始化完成");
54+
api.log_info("AppleChu initialized");
5555
0
5656
}
5757

@@ -79,6 +79,6 @@ fn base_dir(info: *const ChuModInfo) -> String {
7979
pub extern "C" fn chumod_shutdown() {
8080
if let Some(api) = API.get() {
8181
hooks::shutdown_all();
82-
api.log_info("AppleChu 已卸载");
82+
api.log_info("AppleChu unloaded");
8383
}
8484
}

src/patch_engine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ fn find_by_pattern(api: &Api, def: &PatchDef) -> Option<usize> {
4949

5050
fn log_result(api: &Api, def: &PatchDef, result: PatchResult) -> PatchResult {
5151
match result {
52-
PatchResult::Applied => api.log_info(&format!("补丁已应用: {}", def.name)),
53-
PatchResult::AlreadyPatched => api.log_info(&format!("补丁已存在: {}", def.name)),
54-
PatchResult::Mismatch => api.log_warn(&format!("补丁原始字节不匹配: {}", def.name)),
52+
PatchResult::Applied => api.log_info(&format!("patch applied: {}", def.name)),
53+
PatchResult::AlreadyPatched => api.log_info(&format!("patch already applied: {}", def.name)),
54+
PatchResult::Mismatch => api.log_warn(&format!("patch bytes mismatch: {}", def.name)),
5555
}
5656
result
5757
}

src/patches/audio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn apply(api: &Api, config: &Config) {
88
api,
99
config,
1010
&PatchDef {
11-
name: "强制双声道输出",
11+
name: "force 2ch audio",
1212
section: "Force2chAudio",
1313
pattern: Some("83 C4 04 85 C0 75 3F 68 ?? ?? ?? ?? E8 ?? ?? ?? ?? B8 02 00 00 00"),
1414
pattern_offset: 5,
@@ -35,10 +35,10 @@ fn apply_shared_audio(api: &Api, config: &Config) {
3535
if site != 0 {
3636
let zero = [0u8; 1];
3737
if api.mem_write(site + 6, &zero) {
38-
api.log_info("补丁已应用: 强制共享音频");
38+
api.log_info("patch applied: force shared audio");
3939
return;
4040
}
4141
}
4242

43-
api.log_warn("强制共享音频: 未找到目标指令");
43+
api.log_warn("force shared audio: target instruction not found");
4444
}

src/patches/bypass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn apply(api: &Api, config: &Config) {
1919
api,
2020
config,
2121
&PatchDef {
22-
name: "绕过 AppUser 检测",
22+
name: "bypass AppUser check",
2323
section: "BypassAppUser",
2424
pattern: Some("83 7C 24 04 00 75"),
2525
pattern_offset: 5,
@@ -35,7 +35,7 @@ pub fn apply_bypass_120hz(api: &Api, config: &Config) {
3535
api,
3636
config,
3737
&PatchDef {
38-
name: "绕过 120Hz 检测",
38+
name: "bypass 120Hz check",
3939
section: "Bypass120hz",
4040
pattern: Some("85 C0 74 3F ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 81 BC 24 34 02 00 00 80 07 00 00"),
4141
pattern_offset: 0,
@@ -51,7 +51,7 @@ fn apply_bypass_1080p(api: &Api, config: &Config) {
5151
api,
5252
config,
5353
&PatchDef {
54-
name: "绕过 1080P 检测",
54+
name: "bypass 1080p check",
5555
section: "Bypass1080p",
5656
pattern: Some(
5757
"81 BC 24 34 02 00 00 80 07 00 00 75 1F 81 BC 24 38 02 00 00 38 04 00 00 75 12",

src/patches/custom_freeplay.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ pub fn apply(api: &Api, config: &Config) {
1818

1919
let text_bytes = custom_text.as_bytes();
2020
if text_bytes.len() > MAX_CUSTOM_TEXT_LEN {
21-
api.log_warn("自定义 FREE PLAY 文本过长,已跳过");
21+
api.log_warn("custom FREE PLAY text too long, skipped");
2222
return;
2323
}
2424

2525
let text_addr = pattern::scan_bytes(api, b"FREE PLAY\0");
2626
if text_addr == 0 {
27-
api.log_warn("自定义 FREE PLAY 文本: 未找到字符串");
27+
api.log_warn("custom FREE PLAY text: string not found");
2828
return;
2929
}
3030

3131
let length_addr = find_length_addr(api, text_addr);
3232
if length_addr == 0 || !write_value(api, length_addr, text_bytes.len() as u8) {
33-
api.log_warn("补丁写入失败: 自定义 FREE PLAY 文本长度");
33+
api.log_warn("patch write failed: custom FREE PLAY text length");
3434
return;
3535
}
3636

3737
match patch_free_play_text(api, text_addr, text_bytes) {
38-
PatchResult::Applied => api.log_info("补丁已应用: 自定义 FREE PLAY 文本"),
39-
PatchResult::AlreadyPatched => api.log_info("补丁已存在: 自定义 FREE PLAY 文本"),
40-
PatchResult::Mismatch => api.log_warn("补丁原始字节不匹配: 自定义 FREE PLAY 文本"),
38+
PatchResult::Applied => api.log_info("patch applied: custom FREE PLAY text"),
39+
PatchResult::AlreadyPatched => api.log_info("patch already applied: custom FREE PLAY text"),
40+
PatchResult::Mismatch => api.log_warn("patch bytes mismatch: custom FREE PLAY text"),
4141
}
4242
}
4343

0 commit comments

Comments
 (0)