diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..b8b641c --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +match_block_trailing_comma = true +struct_lit_width = 50 +use_field_init_shorthand = true \ No newline at end of file diff --git a/src/build.rs b/src/build.rs index 92c9626..398eee4 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,3 +1,3 @@ fn main() { // this only exists so I can use option_env!("OUT_DIR") elsewhere -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 314ffa3..ae58232 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,11 +16,7 @@ use windows::Win32::System::SystemServices::DLL_PROCESS_ATTACH; #[allow(clippy::missing_safety_doc)] #[no_mangle] -pub unsafe extern "stdcall" fn DllMain( - hmodule: HINSTANCE, - reason: u32, - _: *mut std::ffi::c_void, -) { +pub unsafe extern "stdcall" fn DllMain(hmodule: HINSTANCE, reason: u32, _: *mut std::ffi::c_void) { if reason == DLL_PROCESS_ATTACH { trace!("DllMain()"); std::thread::spawn(move || { @@ -59,7 +55,11 @@ struct MainHud { impl MainHud { fn new() -> Self { let mut this = Self { - version_string: format!("swQolSuite v{}{}", env!("CARGO_PKG_VERSION"), option_env!("SHA").map_or_else(|| "".to_string(), |sha| format!(" ({sha})"))), + version_string: format!( + "swQolSuite v{}{}", + env!("CARGO_PKG_VERSION"), + option_env!("SHA").map_or_else(|| "".to_string(), |sha| format!(" ({sha})")) + ), show: true, tweaks: vec![], errors: vec![], @@ -79,7 +79,7 @@ impl MainHud { this } - fn add_tweak(&mut self, tw: anyhow::Result){ + fn add_tweak(&mut self, tw: anyhow::Result) { match tw { Ok(tw) => self.tweaks.push(Box::new(tw)), Err(e) => self.errors.push(e), @@ -128,7 +128,10 @@ impl ImguiRenderLoop for MainHud { .position_pivot([1., 1.]) .position(ui.io().display_size, Condition::Always) .build(|| { - let text_color = ui.push_style_color(StyleColor::Text, [0.8, 0.8, 0.8, if self.show { 0.9 } else { 0.4 }]); + let text_color = ui.push_style_color( + StyleColor::Text, + [0.8, 0.8, 0.8, if self.show { 0.9 } else { 0.4 }], + ); if self.show { ui.text(format!("{} [~]", self.version_string)); } else { diff --git a/src/main.rs b/src/main.rs index 1b3375e..2016633 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,8 @@ fn main() { let dll_path = cur_exe.canonicalize().unwrap(); println!("Injecting DLL @ {dll_path:?}"); - Process::by_name("stormworks64.exe").expect("Failed to find stormworks64.exe") - .inject(dll_path).expect("Failed to inject DLL"); -} \ No newline at end of file + Process::by_name("stormworks64.exe") + .expect("Failed to find stormworks64.exe") + .inject(dll_path) + .expect("Failed to inject DLL"); +} diff --git a/src/tweaks/editor_camera_speed.rs b/src/tweaks/editor_camera_speed.rs index 578cde4..3c8652b 100644 --- a/src/tweaks/editor_camera_speed.rs +++ b/src/tweaks/editor_camera_speed.rs @@ -3,7 +3,13 @@ use std::{arch::asm, sync::atomic::Ordering}; use anyhow::Context; use atomic_float::AtomicF32; use hudhook::imgui::TreeNodeFlags; -use memory_rs::{generate_aob_pattern, internal::{injections::{Inject, Injection}, memory_region::MemoryRegion}}; +use memory_rs::{ + generate_aob_pattern, + internal::{ + injections::{Inject, Injection}, + memory_region::MemoryRegion, + }, +}; use super::{MemoryRegionExt, Tweak}; @@ -21,7 +27,8 @@ const DEFAULT_WHEEL_MULTIPLIER: f32 = 1.1; static SPEED: AtomicF32 = AtomicF32::new(1.0); -#[no_mangle] static mut jmp_back_addr: usize = 0x0; +#[no_mangle] +static mut jmp_back_addr: usize = 0x0; pub struct EditorCameraSpeedTweak { base_speed: f32, @@ -38,14 +45,18 @@ impl EditorCameraSpeedTweak { pub fn new(region: &MemoryRegion) -> anyhow::Result { // `xmm5 = param_1->shift_down ? 0.2 : 1.0` let memory_pattern = generate_aob_pattern![ - 0x80, 0xb9, 0x1a, 0x0e, 0x00, 0x00, 0x00, // CMP byte ptr [RCX + param_1->shift_down],0x0 - 0x74, 0x0a, // JZ +0xA - 0xf3, 0x0f, 0x10, 0x2d, _, _, _, _, // MOVSS XMM5,dword ptr [FLOAT_XXX] = 0.2 - 0xeb, 0x08, // JMP +0x8 - 0xf3, 0x0f, 0x10, 0x2d, _, _, _, _ // MOVSS XMM5,dword ptr [FLOAT_XXX] = 1.0 + 0x80, 0xb9, 0x1a, 0x0e, 0x00, 0x00, + 0x00, // CMP byte ptr [RCX + param_1->shift_down],0x0 + 0x74, 0x0a, // JZ +0xA + 0xf3, 0x0f, 0x10, 0x2d, _, _, _, + _, // MOVSS XMM5,dword ptr [FLOAT_XXX] = 0.2 + 0xeb, 0x08, // JMP +0x8 + 0xf3, 0x0f, 0x10, 0x2d, _, _, _, + _ // MOVSS XMM5,dword ptr [FLOAT_XXX] = 1.0 ]; let speed_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context("Error finding editor camera speed addr")? }; @@ -63,7 +74,7 @@ impl EditorCameraSpeedTweak { shift_multiplier: DEFAULT_SHIFT_MULTIPLIER, control_multiplier: DEFAULT_CONTROL_MULTIPLIER, wheel_multiplier: DEFAULT_WHEEL_MULTIPLIER, - + current_wheel_multiplier: 1.0, current_speed: DEFAULT_BASE_SPEED, _speed_inject: speed_inject, @@ -81,13 +92,17 @@ impl Tweak for EditorCameraSpeedTweak { ui.set_next_item_width(100.0); ui.slider("Base Speed", 0.1, 4.0, &mut self.base_speed); if ui.is_item_hovered() { - ui.tooltip_text(format!("(default: {DEFAULT_BASE_SPEED}, vanilla: {VANILLA_BASE_SPEED})")); + ui.tooltip_text(format!( + "(default: {DEFAULT_BASE_SPEED}, vanilla: {VANILLA_BASE_SPEED})" + )); } ui.set_next_item_width(100.0); ui.slider("Shift Multiplier", 0.1, 4.0, &mut self.shift_multiplier); if ui.is_item_hovered() { - ui.tooltip_text(format!("(default: {DEFAULT_SHIFT_MULTIPLIER}, vanilla: {VANILLA_SHIFT_MULTIPLIER})")); + ui.tooltip_text(format!( + "(default: {DEFAULT_SHIFT_MULTIPLIER}, vanilla: {VANILLA_SHIFT_MULTIPLIER})" + )); } ui.set_next_item_width(100.0); @@ -101,7 +116,7 @@ impl Tweak for EditorCameraSpeedTweak { // if ui.is_item_hovered() { // ui.tooltip_text(format!("(default: {DEFAULT_WHEEL_MULTIPLIER}, vanilla: {VANILLA_WHEEL_MULTIPLIER})")); // } - + // ui.text(format!("{}", self.current_speed)); // ui.text(format!("{}", self.current_wheel_multiplier)); } @@ -114,11 +129,15 @@ impl Tweak for EditorCameraSpeedTweak { self.current_speed = self.base_speed * self.current_wheel_multiplier; - if ui.is_key_down(hudhook::imgui::Key::LeftShift) || ui.is_key_down(hudhook::imgui::Key::RightShift) { + if ui.is_key_down(hudhook::imgui::Key::LeftShift) + || ui.is_key_down(hudhook::imgui::Key::RightShift) + { self.current_speed *= self.shift_multiplier; } - if ui.is_key_down(hudhook::imgui::Key::LeftCtrl) || ui.is_key_down(hudhook::imgui::Key::RightCtrl) { + if ui.is_key_down(hudhook::imgui::Key::LeftCtrl) + || ui.is_key_down(hudhook::imgui::Key::RightCtrl) + { self.current_speed *= self.control_multiplier; } @@ -150,4 +169,4 @@ extern "stdcall" fn custom_speed() { options(nostack), ); } -} \ No newline at end of file +} diff --git a/src/tweaks/editor_placement.rs b/src/tweaks/editor_placement.rs index 4328596..42f3070 100644 --- a/src/tweaks/editor_placement.rs +++ b/src/tweaks/editor_placement.rs @@ -1,9 +1,14 @@ use anyhow::Context; -use memory_rs::{generate_aob_pattern, internal::{injections::{Inject, Injection}, memory_region::MemoryRegion}}; +use memory_rs::{ + generate_aob_pattern, + internal::{ + injections::{Inject, Injection}, + memory_region::MemoryRegion, + }, +}; use super::{MemoryRegionExt, Tweak}; - const VANILLA_SUPPORT_CHECK: bool = true; const DEFAULT_SUPPORT_CHECK: bool = false; @@ -23,25 +28,26 @@ impl EditorPlacementTweak { // The start of the function that determines if a component placement has support let memory_pattern = generate_aob_pattern![ - 0x4c, 0x8b, 0xdc, // MOV R11,RSP - 0x49, 0x89, 0x5b, 0x10, // MOV qword ptr [R11 + local_res10],RBX - 0x49, 0x89, 0x6b, 0x18, // MOV qword ptr [R11 + local_res18],RBP - 0x56, // PUSH RSI - 0x57, // PUSH RDI - 0x41, 0x54, // PUSH R12 - 0x41, 0x56, // PUSH R14 - 0x41, 0x57, // PUSH R15 - 0x48, 0x81, 0xec, 0xb0, 0x00, 0x00, 0x00 // SUB RSP,0xb0 + 0x4c, 0x8b, 0xdc, // MOV R11,RSP + 0x49, 0x89, 0x5b, 0x10, // MOV qword ptr [R11 + local_res10],RBX + 0x49, 0x89, 0x6b, 0x18, // MOV qword ptr [R11 + local_res18],RBP + 0x56, // PUSH RSI + 0x57, // PUSH RDI + 0x41, 0x54, // PUSH R12 + 0x41, 0x56, // PUSH R14 + 0x41, 0x57, // PUSH R15 + 0x48, 0x81, 0xec, 0xb0, 0x00, 0x00, 0x00 // SUB RSP,0xb0 ]; let support_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context("Error finding placement support check function")? }; // basically just early exit `return true` let inject = vec![ 0xB0, 0x01, // MOV al,01 - 0xC3, // RET + 0xC3, // RET ]; let mut disable_support_check_inject = Injection::new(support_addr, inject); @@ -54,25 +60,26 @@ impl EditorPlacementTweak { // The start of the function that determines if a merge is valid let memory_pattern = generate_aob_pattern![ - 0x48, 0x8b, 0xc4, // MOV RAX,RSP - 0x4c, 0x89, 0x40, 0x18, // MOV qword ptr [RAX + local_res18],R8 - 0x48, 0x89, 0x50, 0x10, // MOV qword ptr [RAX + local_res10],RDX - 0x48, 0x89, 0x48, 0x08, // MOV qword ptr [RAX + local_res8],RCX - 0x55, // PUSH RBP - 0x56, // PUSH RSI - 0x57, // PUSH RDI - 0x41, 0x54, // PUSH R12 - 0x48, 0x81, 0xec, 0xf8, 0x00, 0x00, 0x00 // SUB RSP,0xf8 + 0x48, 0x8b, 0xc4, // MOV RAX,RSP + 0x4c, 0x89, 0x40, 0x18, // MOV qword ptr [RAX + local_res18],R8 + 0x48, 0x89, 0x50, 0x10, // MOV qword ptr [RAX + local_res10],RDX + 0x48, 0x89, 0x48, 0x08, // MOV qword ptr [RAX + local_res8],RCX + 0x55, // PUSH RBP + 0x56, // PUSH RSI + 0x57, // PUSH RDI + 0x41, 0x54, // PUSH R12 + 0x48, 0x81, 0xec, 0xf8, 0x00, 0x00, 0x00 // SUB RSP,0xf8 ]; let merge_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context("Error finding merge check function")? }; // basically just early exit `return true` let inject = vec![ 0xB0, 0x01, // MOV al,01 - 0xC3, // RET + 0xC3, // RET ]; let mut disable_merge_check_inject = Injection::new(merge_addr, inject); @@ -116,7 +123,10 @@ impl Tweak for EditorPlacementTweak { } fn render(&mut self, ui: &hudhook::imgui::Ui) { - if ui.checkbox("Disable Placement Support Check", &mut self.disable_support_check) { + if ui.checkbox( + "Disable Placement Support Check", + &mut self.disable_support_check, + ) { self.set_support_check(!self.disable_support_check); } if ui.is_item_hovered() { @@ -140,4 +150,4 @@ impl Tweak for EditorPlacementTweak { self.set_support_check(VANILLA_SUPPORT_CHECK); self.set_merge_check(VANILLA_MERGE_CHECK); } -} \ No newline at end of file +} diff --git a/src/tweaks/editor_show_hidden.rs b/src/tweaks/editor_show_hidden.rs index 77711f4..35d813a 100644 --- a/src/tweaks/editor_show_hidden.rs +++ b/src/tweaks/editor_show_hidden.rs @@ -1,5 +1,11 @@ use anyhow::{anyhow, Context}; -use memory_rs::{generate_aob_pattern, internal::{injections::{Inject, Injection}, memory_region::MemoryRegion}}; +use memory_rs::{ + generate_aob_pattern, + internal::{ + injections::{Inject, Injection}, + memory_region::MemoryRegion, + }, +}; use super::{MemoryRegionExt, Tweak}; @@ -18,18 +24,21 @@ impl ShowHiddenComponents { // check for hidden flag let memory_pattern = generate_aob_pattern![ - 0xf7, 0x86, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, // TEST dword ptr [RSI + 0x2a0],0x20000000 - 0x77, 0x67 // JA LAB_140444479 + 0xf7, 0x86, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, // TEST dword ptr [RSI + 0x2a0],0x20000000 + 0x77, 0x67 // JA LAB_140444479 ]; let check_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context(anyhow!("Error finding menu fade addr"))? }; // NOP the JA let inject = vec![0x90; 2]; - let mut injection_1 = Injection::new(check_addr + memory_pattern.size - inject.len(), inject); + let mut injection_1 = + Injection::new(check_addr + memory_pattern.size - inject.len(), inject); if DEFAULT_SHOW_HIDDEN_COMPONENTS { injection_1.inject(); @@ -40,18 +49,20 @@ impl ShowHiddenComponents { // check for hidden flag let memory_pattern = generate_aob_pattern![ 0x8b, 0x86, 0xa0, 0x02, 0x00, 0x00, // MOV EAX,dword ptr [RSI + 0x2a0] - 0xa9, 0x00, 0x00, 0x00, 0x20, // TEST EAX,0x20000000 - 0x0f, 0x87, 0x14, 0x01, 0x00, 0x00 // JA LAB_1405ce8a6 + 0xa9, 0x00, 0x00, 0x00, 0x20, // TEST EAX,0x20000000 + 0x0f, 0x87, 0x14, 0x01, 0x00, 0x00 // JA LAB_1405ce8a6 ]; let check_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context(anyhow!("Error finding menu fade addr"))? }; // NOP the JA let inject = vec![0x90; 6]; - let mut injection_2 = Injection::new(check_addr + memory_pattern.size - inject.len(), inject); + let mut injection_2 = + Injection::new(check_addr + memory_pattern.size - inject.len(), inject); if DEFAULT_SHOW_HIDDEN_COMPONENTS { injection_2.inject(); @@ -81,20 +92,23 @@ impl Tweak for ShowHiddenComponents { fn uninit(&mut self) -> anyhow::Result<()> { Ok(()) } - + fn render(&mut self, ui: &hudhook::imgui::Ui) { - if ui.checkbox("Show Hidden Components (reload save)", &mut self.show_hidden_components) { + if ui.checkbox( + "Show Hidden Components (reload save)", + &mut self.show_hidden_components, + ) { self.set_show_hidden_components(self.show_hidden_components); } if ui.is_item_hovered() { ui.tooltip_text(format!("Forces editor to show components flagged as hidden.\nChanging this setting requires reloading your save to apply.\n(default: {DEFAULT_SHOW_HIDDEN_COMPONENTS}, vanilla: {VANILLA_SHOW_HIDDEN_COMPONENTS})")); } } - + fn reset_to_default(&mut self) { self.set_show_hidden_components(DEFAULT_SHOW_HIDDEN_COMPONENTS); } - + fn reset_to_vanilla(&mut self) { self.set_show_hidden_components(VANILLA_SHOW_HIDDEN_COMPONENTS); } diff --git a/src/tweaks/loading.rs b/src/tweaks/loading.rs index f61cb15..228f1fb 100644 --- a/src/tweaks/loading.rs +++ b/src/tweaks/loading.rs @@ -1,7 +1,13 @@ use std::arch::asm; use anyhow::{anyhow, Context}; -use memory_rs::{generate_aob_pattern, internal::{injections::{Inject, Injection}, memory_region::MemoryRegion}}; +use memory_rs::{ + generate_aob_pattern, + internal::{ + injections::{Inject, Injection}, + memory_region::MemoryRegion, + }, +}; use super::{MemoryRegionExt, Tweak}; @@ -27,13 +33,14 @@ impl LoadingTweak { // menu_state.fade_cur++; // ``` let memory_pattern = generate_aob_pattern![ - 0x49, 0x8B, 0xD4, // MOV RDX,R12 - 0xff, 0x90, 0xf0, 0x00, 0x00, 0x00, // CALL qword ptr [RAX + 0xf0] - 0x41, 0xff, 0x86, 0x80, 0xdb, 0x0b, 0x00 // INC dword ptr [R14 + 0xbdb80] + 0x49, 0x8B, 0xD4, // MOV RDX,R12 + 0xff, 0x90, 0xf0, 0x00, 0x00, 0x00, // CALL qword ptr [RAX + 0xf0] + 0x41, 0xff, 0x86, 0x80, 0xdb, 0x0b, 0x00 // INC dword ptr [R14 + 0xbdb80] ]; let menu_fade_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context(anyhow!("Error finding menu fade addr"))? }; @@ -53,17 +60,21 @@ impl LoadingTweak { // `&& (visual_progress == 1.0)` let memory_pattern = generate_aob_pattern![ - 0x0f, 0x2e, 0xc6, // UCOMISS XMM0,XMM6 - 0x7a, 0x41, // JP +41 - 0x75, 0x3f // JNZ +3f + 0x0f, 0x2e, 0xc6, // UCOMISS XMM0,XMM6 + 0x7a, 0x41, // JP +41 + 0x75, 0x3f // JNZ +3f ]; let skip_load_finish_addr = { - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context(anyhow!("Error finding skip load finish addr"))? }; - let mut skip_load_finish_injection = Injection::new(skip_load_finish_addr + memory_pattern.size - 2, vec![0x90, 0x90]); + let mut skip_load_finish_injection = Injection::new( + skip_load_finish_addr + memory_pattern.size - 2, + vec![0x90, 0x90], + ); if DEFAULT_SKIP_LOAD_FINISH { skip_load_finish_injection.inject(); @@ -102,7 +113,7 @@ impl Tweak for LoadingTweak { fn uninit(&mut self) -> anyhow::Result<()> { Ok(()) } - + fn render(&mut self, ui: &hudhook::imgui::Ui) { if ui.checkbox("Fast Main Menu Fade", &mut self.fast_menu_fade) { self.set_fast_menu_fade(self.fast_menu_fade); @@ -118,12 +129,12 @@ impl Tweak for LoadingTweak { ui.tooltip_text(format!("Skips the animation of the progress bar going to 100%\n(default: {DEFAULT_SKIP_LOAD_FINISH}, vanilla: {VANILLA_SKIP_LOAD_FINISH})")); } } - + fn reset_to_default(&mut self) { self.set_fast_menu_fade(DEFAULT_FAST_MENU_FADE); self.set_skip_load_finish(DEFAULT_SKIP_LOAD_FINISH); } - + fn reset_to_vanilla(&mut self) { self.set_fast_menu_fade(VANILLA_FAST_MENU_FADE); self.set_skip_load_finish(VANILLA_SKIP_LOAD_FINISH); @@ -134,10 +145,10 @@ impl Tweak for LoadingTweak { extern "stdcall" fn custom_fade() { unsafe { asm!( - "mov rdx,r12", // original code - "call [rax + 0xf0]", // original code + "mov rdx,r12", // original code + "call [rax + 0xf0]", // original code "add dword ptr [r14 + 0xbdb80],15", // inc by 15 instead of 1 options(nostack), ); } -} \ No newline at end of file +} diff --git a/src/tweaks/map_lag.rs b/src/tweaks/map_lag.rs index 94972ca..572d29c 100644 --- a/src/tweaks/map_lag.rs +++ b/src/tweaks/map_lag.rs @@ -1,5 +1,11 @@ use anyhow::{anyhow, Context}; -use memory_rs::{generate_aob_pattern, internal::{injections::{Inject, Injection}, memory_region::MemoryRegion}}; +use memory_rs::{ + generate_aob_pattern, + internal::{ + injections::{Inject, Injection}, + memory_region::MemoryRegion, + }, +}; use super::{MemoryRegionExt, Tweak}; @@ -16,21 +22,28 @@ impl MapLagTweak { let sleep_addr = { // `Sleep(10)` let memory_pattern = generate_aob_pattern![ - 0xB9, VANILLA_SLEEP, 0x00, 0x00, 0x00, // - 0xFF, 0x15, _, _, _, _, // CALL Sleep + 0xB9, + VANILLA_SLEEP, + 0x00, + 0x00, + 0x00, // + 0xFF, + 0x15, + _, + _, + _, + _, // CALL Sleep 0x48 ]; - region.scan_aob_single(&memory_pattern) + region + .scan_aob_single(&memory_pattern) .context(anyhow!("Error finding Sleep(10) addr"))? }; let mut sleep_injection = Injection::new(sleep_addr + 1, vec![DEFAULT_SLEEP]); sleep_injection.inject(); - Ok(Self { - sleep: DEFAULT_SLEEP, - sleep_injection, - }) + Ok(Self { sleep: DEFAULT_SLEEP, sleep_injection }) } } @@ -38,7 +51,7 @@ impl Tweak for MapLagTweak { fn uninit(&mut self) -> anyhow::Result<()> { Ok(()) } - + fn render(&mut self, ui: &hudhook::imgui::Ui) { ui.set_next_item_width(100.0); if ui.slider("Map Sleep (ms)", 0, VANILLA_SLEEP * 2, &mut self.sleep) { @@ -49,13 +62,13 @@ impl Tweak for MapLagTweak { ui.tooltip_text(format!("Change the artificial delay in the map screen rendering\n(default: {DEFAULT_SLEEP}, vanilla: {VANILLA_SLEEP})")); } } - + fn reset_to_default(&mut self) { self.sleep = DEFAULT_SLEEP; self.sleep_injection.f_new = vec![self.sleep]; self.sleep_injection.inject(); } - + fn reset_to_vanilla(&mut self) { self.sleep = VANILLA_SLEEP; self.sleep_injection.f_new = vec![self.sleep]; diff --git a/src/tweaks/mod.rs b/src/tweaks/mod.rs index 162aa41..9321a1a 100644 --- a/src/tweaks/mod.rs +++ b/src/tweaks/mod.rs @@ -1,20 +1,17 @@ use memory_rs::internal::memory_region::MemoryRegion; - -pub mod map_lag; pub mod editor_camera_speed; pub mod editor_placement; -pub mod loading; pub mod editor_show_hidden; +pub mod loading; +pub mod map_lag; pub trait Tweak { fn uninit(&mut self) -> anyhow::Result<()>; fn render(&mut self, ui: &hudhook::imgui::Ui); - fn constant_render(&mut self, _ui: &hudhook::imgui::Ui) { - - } + fn constant_render(&mut self, _ui: &hudhook::imgui::Ui) {} fn reset_to_default(&mut self); fn reset_to_vanilla(&mut self); @@ -28,17 +25,23 @@ pub enum ScanAOBSingleError { } pub trait MemoryRegionExt { - fn scan_aob_single(&self, pat: &memory_rs::internal::memory::MemoryPattern) -> anyhow::Result; + fn scan_aob_single( + &self, + pat: &memory_rs::internal::memory::MemoryPattern, + ) -> anyhow::Result; } impl MemoryRegionExt for MemoryRegion { - fn scan_aob_single(&self, pat: &memory_rs::internal::memory::MemoryPattern) -> anyhow::Result { + fn scan_aob_single( + &self, + pat: &memory_rs::internal::memory::MemoryPattern, + ) -> anyhow::Result { let matches = self.scan_aob_all_matches(pat)?; - + match matches.len() { 0 => anyhow::bail!("No Matches"), 1 => Ok(matches[0]), _ => anyhow::bail!("Multiple Matches"), } } -} \ No newline at end of file +}