Skip to content

Commit

Permalink
Fix Clippy (#673)
Browse files Browse the repository at this point in the history
* Fix

* Fix formatting

---------

Co-authored-by: Joshua Sambasivam <[email protected]>
  • Loading branch information
jugeeya and jsambasivam-sc authored Mar 8, 2024
1 parent 5b0b549 commit 7d15768
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 35 deletions.
6 changes: 2 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/docker-from-docker
{
"name": "Cargo Skyline",
"image": "jugeeya/cargo-skyline:3.2.0-no-dkp",
"mounts": [
"source=ultimatetrainingmodpack-bashhistory,target=/commandhistory,type=volume"
],
"image": "rust:1.73",
"mounts": [],
// // Use this environment variable if you need to bind mount your local source code into a new container.
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
Expand Down
1 change: 0 additions & 1 deletion src/common/dev_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::fs;
use lazy_static::lazy_static;
use parking_lot::Mutex;
use serde::Deserialize;
use toml;

use crate::common::input::*;
use crate::consts::DEV_TOML_PATH;
Expand Down
12 changes: 6 additions & 6 deletions src/common/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::fs;
use std::io::BufReader;
use std::ptr::addr_of;

use lazy_static::lazy_static;
use parking_lot::Mutex;
use skyline::nn::hid::GetNpadStyleSet;
use training_mod_consts::{create_app, MenuJsonStruct};
use training_mod_tui::AppPage;

use crate::common::button_config::button_mapping;
use crate::common::*;
use crate::consts::MENU_OPTIONS_PATH;
use crate::events::{Event, EVENT_QUEUE};
use crate::input::*;
use crate::logging::*;
Expand Down Expand Up @@ -53,9 +51,11 @@ pub fn load_from_file() {
info!("Setting initial menu selections...");
unsafe {
let mut app = QUICK_MENU_APP.lock();
app.serialized_default_settings =
serde_json::to_string(&DEFAULTS_MENU).expect("Could not serialize DEFAULTS_MENU");
app.update_all_from_json(&serde_json::to_string(&MENU).expect("Could not serialize MENU"));
app.serialized_default_settings = serde_json::to_string(&*addr_of!(DEFAULTS_MENU))
.expect("Could not serialize DEFAULTS_MENU");
app.update_all_from_json(
&serde_json::to_string(&*addr_of!(MENU)).expect("Could not serialize MENU"),
);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/common/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::common::dialog;
use crate::consts::*;
use crate::logging::*;
use crate::MENU;
use anyhow::{anyhow, Result};
use lazy_static::lazy_static;
use parking_lot::Mutex;
Expand Down
2 changes: 1 addition & 1 deletion src/training/air_dodge_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> Op

STICK_DIRECTION = MENU.air_dodge_dir.get_random();
STICK_DIRECTION.into_angle().map(|angle| {
if !should_reverse_angle(&STICK_DIRECTION) {
if !should_reverse_angle(STICK_DIRECTION) {
// Direction is LEFT/RIGHT, so don't perform any adjustment
angle
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/training/combo.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use skyline::nn::ui2d::ResColor;
use smash::app::BattleObjectModuleAccessor;
use training_mod_consts::OnOff;

use crate::common::consts::FighterId;
use crate::common::*;
use crate::training::*;

Expand Down
6 changes: 3 additions & 3 deletions src/training/directional_influence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ unsafe fn mod_handle_di(fighter: &L2CFighterCommon, _arg1: L2CValue) {
roll_di_case();

let angle_tuple = DI_CASE.into_angle().map_or((0.0, 0.0), |angle| {
let a = if should_reverse_angle(&DI_CASE) {
let a = if should_reverse_angle(DI_CASE) {
PI - angle
} else {
angle
Expand All @@ -70,12 +70,12 @@ unsafe fn mod_handle_di(fighter: &L2CFighterCommon, _arg1: L2CValue) {
set_x_y(module_accessor, angle_tuple.0 as f32, angle_tuple.1 as f32);
}

pub fn should_reverse_angle(direction: &Direction) -> bool {
pub fn should_reverse_angle(direction: Direction) -> bool {
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
let player_module_accessor = get_module_accessor(FighterId::Player);
unsafe {
PostureModule::pos_x(player_module_accessor) > PostureModule::pos_x(cpu_module_accessor)
&& ![Direction::LEFT, Direction::RIGHT].contains(direction)
&& ![Direction::LEFT, Direction::RIGHT].contains(&direction)
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/training/full_hop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub fn roll_full_hop() {
}
}

/**
*/
pub unsafe fn check_button_on(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
Expand All @@ -29,8 +27,6 @@ pub unsafe fn check_button_on(
Some(true)
}

/**
*/
pub unsafe fn check_button_off(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
Expand Down
8 changes: 5 additions & 3 deletions src/training/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ptr::addr_of_mut;

use crate::common::button_config;
use crate::common::consts::{BuffOption, FighterId, MENU};
use crate::common::offsets::*;
Expand Down Expand Up @@ -836,21 +838,21 @@ pub fn training_mods() {

unsafe {
LookupSymbol(
&mut FIGHTER_MANAGER_ADDR,
addr_of_mut!(FIGHTER_MANAGER_ADDR),
"_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E\u{0}"
.as_bytes()
.as_ptr(),
);

LookupSymbol(
&mut STAGE_MANAGER_ADDR,
addr_of_mut!(STAGE_MANAGER_ADDR),
"_ZN3lib9SingletonIN3app12StageManagerEE9instance_E\u{0}"
.as_bytes()
.as_ptr(),
);

LookupSymbol(
&mut ITEM_MANAGER_ADDR,
addr_of_mut!(ITEM_MANAGER_ADDR),
"_ZN3lib9SingletonIN3app11ItemManagerEE9instance_E\0"
.as_bytes()
.as_ptr(),
Expand Down
2 changes: 1 addition & 1 deletion src/training/sdi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn roll_direction() {

unsafe fn get_sdi_direction() -> Option<f64> {
DIRECTION.into_angle().map(|angle| {
if directional_influence::should_reverse_angle(&DIRECTION) {
if directional_influence::should_reverse_angle(DIRECTION) {
PI - angle
} else {
angle
Expand Down
8 changes: 5 additions & 3 deletions src/training/ui/display.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ptr::addr_of_mut;

use skyline::nn::ui2d::*;
use smash::ui2d::{SmashPane, SmashTextBox};

Expand All @@ -24,8 +26,8 @@ macro_rules! display_txt_fmt {
pub unsafe fn draw(root_pane: &Pane) {
let notification_idx = 0;

let queue = &mut ui::notifications::QUEUE;
let notification = queue.first_mut();
let queue = addr_of_mut!(ui::notifications::QUEUE);
let notification = (*queue).first_mut();

root_pane
.find_pane_by_name_recursive(display_parent_fmt!(notification_idx))
Expand Down Expand Up @@ -58,6 +60,6 @@ pub unsafe fn draw(root_pane: &Pane) {

let has_completed = notification.check_completed();
if has_completed {
queue.remove(0);
(*queue).remove(0);
}
}
14 changes: 8 additions & 6 deletions src/training/ui/notifications.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ptr::addr_of_mut;

use skyline::nn::ui2d::ResColor;

pub static mut QUEUE: Vec<Notification> = vec![];
Expand Down Expand Up @@ -45,8 +47,8 @@ impl Notification {

pub fn notification(header: String, message: String, len: u32) {
unsafe {
let queue = &mut QUEUE;
queue.push(Notification::new(
let queue = addr_of_mut!(QUEUE);
(*queue).push(Notification::new(
header,
message,
len,
Expand All @@ -62,14 +64,14 @@ pub fn notification(header: String, message: String, len: u32) {

pub fn color_notification(header: String, message: String, len: u32, color: ResColor) {
unsafe {
let queue = &mut QUEUE;
queue.push(Notification::new(header, message, len, color));
let queue = addr_of_mut!(QUEUE);
(*queue).push(Notification::new(header, message, len, color));
}
}

pub fn clear_notifications(header: &'static str) {
unsafe {
let queue = &mut QUEUE;
queue.retain(|notif| notif.header != header);
let queue = addr_of_mut!(QUEUE);
(*queue).retain(|notif| notif.header != header);
}
}

0 comments on commit 7d15768

Please sign in to comment.