From 0bc339342654aaa562b7a9aba10b25634d9f3d0e Mon Sep 17 00:00:00 2001 From: Naxdy Date: Wed, 21 Feb 2024 10:00:50 +0100 Subject: [PATCH] fix integration with training mode plugin --- Cargo.lock | 20 +++++++++---------- Cargo.toml | 6 ++---- README.md | 20 +++++++++++++++++++ src/lib.rs | 5 +---- src/offsets.rs | 54 -------------------------------------------------- 5 files changed, 32 insertions(+), 73 deletions(-) delete mode 100644 src/offsets.rs diff --git a/Cargo.lock b/Cargo.lock index ceccb36..3174645 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,17 +19,6 @@ dependencies = [ "syn", ] -[[package]] -name = "latency-slider-de" -version = "0.2.0" -dependencies = [ - "lazy_static", - "ninput", - "paste", - "skyline 0.2.1 (git+https://github.com/ultimate-research/skyline-rs.git)", - "skyline_smash", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -177,3 +166,12 @@ name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "zlatency-slider-de" +version = "0.2.1" +dependencies = [ + "ninput", + "skyline 0.2.1 (git+https://github.com/ultimate-research/skyline-rs.git)", + "skyline_smash", +] diff --git a/Cargo.toml b/Cargo.toml index dbe3e77..cd3f5d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "latency-slider-de" -version = "0.2.0" +name = "zlatency-slider-de" +version = "0.2.1" authors = [] edition = "2021" @@ -14,8 +14,6 @@ crate-type = ["cdylib"] ninput = { git = "https://github.com/blu-dev/ninput", version = "0.1.0" } skyline_smash = { git = "https://github.com/jugeeya/skyline-smash.git", branch = "patch-2" } skyline = { git = "https://github.com/ultimate-research/skyline-rs.git" } -paste = "1.0.14" -lazy_static = "1.4.0" [profile.dev] panic = "abort" diff --git a/README.md b/README.md index 74ca447..fcddf1c 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,26 @@ Nix will download and make available all the necessary dev tools for you to buil If there are any Nix enjoyers out there who feel like packaging skyline's rust toolchain so we don't have to rely on `cargo-skyline` anymore and can introduce fully reproducible builds, feel free to submit a pull request! If there are any modding enjoyers out there who want to expand upon this plugin, feel free to do the same! +## FAQ + +#### Am I allowed to modify / redistribute this software? +Yes, so long as you also publish the source code of your modification. View details in the [license](LICENSE). + +#### Will this format my SD Card? +No. But don't take my word for it, the source is available for anyone to see. Feel free to analyze it yourself, or have someone you trust do it for you. Don't use my binary, but compile it yourself (or, again, have someone you trust do it for you). This is one of the benefits of open source, you don't *have* to trust, you can verify. + +#### Will I get banned if I use this mod on qp / in arenas? +The short answer is "I don't know, but probably not". The slightly longer answer is that using any mod (online or offline) carries risks with it. However, I think that the biggest risk when using this mod is other people finding out you have it (e.g. because you publicly posted a screenshot with the latency slider text visible) and proceeding to mass report you to Nintendo. Like the original, the mod doesn't send any extra network packets (arenas or otherwise), so short of Nintendo scanning your SD card, there shouldn't be any way to automatically detect it. + +#### Are you fine with people using this mod to cheat in online tournaments, or on qp? +The short answer is "how people use this mod is up to them". The long answer is this: First, for quickplay, I don't view using this mod as cheating, but rather making the game playable, since there's nothing on the line (if you think GSP holds any meaningful value, I suggest an immediate and thorough psych evaluation), same as in arenas. + +When it comes to online tournaments, for those without prizes my views are the same as those for quickplay. Now, for the others, I am of the opinion that those with significant prizes should have died together with COVID lockdowns. The reason is that online, even without any sort of mods, is inherently random and unfair. Network interference, packet loss, and all the fun things aside, since SSBU determines the input delay on the client side, it is entirely possible that two players play the game with different input delays as is, even without the latency slider. So, if anything, latency slider makes online tournaments *fairer*, but only if both players have it and set it to the same delay, of course. Note that I said *fairer* and not *fair*, because you still have random lag spikes which may impact one player more than the other (e.g. if a huge lag spike happens during Ness' PK thunder recovery, or during a frame-tight combo). + +Additionally, even without latency slider, there are mods (software and hardware) you can use to reduce your input delay when playing with others (both on quickplay and in arenas). `less-delay` just shaves off 1 frame of input delay no matter the game mode (even offline), and there are 3rd party GC adapters that, at best, improve input delay by another frame and, at worst, make the controller input delay much more consistent than the OG. + +The bottom line here is that online tournaments have never been - and will never be - "fair", and if there's a will to cheat, there's a way (even without this mod). Unless you can ensure a 100% stable connection, equal and consistent input delay for both parties, and proctor all players to ensure they aren't using any special hardware to improve their play, this entire discussion is pointless to me. + ## Final Note This fork is published under the original project's AGPL license. Though I pinky promise to never take this repo offline or privatize the source code in any way, I encourage you to fork it and re-share it as much as your heart desires. \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 75dc328..2a48b7f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,9 @@ #![feature(restricted_std)] -use offsets::OFFSET_DRAW; use skyline::hooks::InlineCtx; use skyline::nn::ui2d::{Layout, Pane}; use smash::ui2d::{SmashPane, SmashTextBox}; -mod offsets; - #[skyline::from_offset(0x37a1ef0)] unsafe fn set_text_string(pane: u64, string: *const u8); @@ -86,7 +83,7 @@ unsafe fn non_hdr_update_room_hook(_: &skyline::hooks::InlineCtx) { } } -#[skyline::hook(offset = *OFFSET_DRAW)] +#[skyline::hook(offset = 0x004b620)] unsafe fn handle_draw_hook(layout: *mut Layout, draw_info: u64, cmd_buffer: u64) { // let layout_name = skyline::from_c_str((*layout).layout_name); let root_pane = &mut *(*layout).root_pane; diff --git a/src/offsets.rs b/src/offsets.rs deleted file mode 100644 index 0396c6c..0000000 --- a/src/offsets.rs +++ /dev/null @@ -1,54 +0,0 @@ -use lazy_static::lazy_static; - -// Stolen from Ultimate Training Modpack who stole it from HDR who stole it from Arcropolis -// https://github.com/HDR-Development/HewDraw-Remix/blob/dev/dynamic/src/util.rs -// https://github.com/jugeeya/UltimateTrainingModpack/blob/5b0b5490cc30af4964ed7f8d8d1ed8cfe38f6ff1/src/common/offsets.rs -pub fn byte_search(needle: &[T]) -> Option { - let text = unsafe { - let start = skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *const T; - let end = skyline::hooks::getRegionAddress(skyline::hooks::Region::Rodata) as *const T; - let length = end.offset_from(start) as usize; - std::slice::from_raw_parts(start, length) - }; - - text.windows(needle.len()) - .position(|window| window == needle) -} - -// Wrapper around byte_search() with some additional logging -fn find_offset(name: &str, needle: &[u8]) -> Option { - println!("Searching for {}", name); - let offset_opt = byte_search(needle); - match offset_opt { - Some(offset) => { - println!("Found offset for {} at {:#x}", name, offset); - Some(offset) - } - None => { - println!("ERROR: Cound not find offset for {}", name); - None - } - } -} - -macro_rules! impl_offset { - ($fn_name:ident) => { - paste::paste! { - lazy_static! { - pub static ref []: usize = find_offset(stringify!($fn_name), []).expect(stringify!(Failed to find offset for $fn_name)); - } - } - } -} - -static NEEDLE_DRAW: &[u8] = &[ - 0x08, 0x0c, 0x40, 0xf9, // These comments are to prevent rustfmt from destroying - 0xc8, 0x03, 0x00, 0xb4, // this while still allowing rustfmt in general - 0xff, 0x83, 0x01, 0xd1, // - 0xf5, 0x1b, 0x00, 0xf9, // - 0xf4, 0x4f, 0x04, 0xa9, // - 0xfd, 0x7b, 0x05, 0xa9, // - 0xfd, 0x43, 0x01, 0x91, // - 0xf4, 0x03, 0x00, 0xaa, -]; -impl_offset!(DRAW);