From e0ef313297a1c3c0bf19c1f647be8ba5b5c05823 Mon Sep 17 00:00:00 2001 From: jugeeya Date: Tue, 11 Jul 2023 09:10:56 -0700 Subject: [PATCH] Keep Mii hats and Luma on save state load; Fix Github Actions (#532) * Exclude Mii hats and Luma * Use allowlist to fix clippy * More clippy * More clippy * Unnecessary cast * Unnecessary vec! * Spacing * Import ordering * Use a different action for test --------- Co-authored-by: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com> --- .github/workflows/rust.yml | 6 +++--- src/common/mod.rs | 3 +-- src/training/combo.rs | 2 +- src/training/save_states.rs | 25 ++++++++++++++++++++++--- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 63f706e..b3cbf0d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,10 +50,10 @@ jobs: command: clippy args: --all-targets --all-features --target=x86_64-unknown-linux-gnu -- -D warnings - name: TUI Test - uses: actions-rs/cargo@v1 - continue-on-error: false + uses: ClementTsang/cargo-action@v0.0.3 with: - working-directory: training_mod_tui + command: test + directory: training_mod_tui plugin: name: Plugin NRO runs-on: ubuntu-latest diff --git a/src/common/mod.rs b/src/common/mod.rs index 42b62e2..499410e 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -70,8 +70,7 @@ pub fn is_operation_cpu(module_accessor: &mut app::BattleObjectModuleAccessor) - let entry_id = app::FighterEntryID(entry_id_int); let mgr = *(FIGHTER_MANAGER_ADDR as *mut *mut app::FighterManager); - let fighter_information = - FighterManager::get_fighter_information(mgr, entry_id) as *mut app::FighterInformation; + let fighter_information = FighterManager::get_fighter_information(mgr, entry_id); FighterInformation::is_operation_cpu(fighter_information) } diff --git a/src/training/combo.rs b/src/training/combo.rs index 921b107..5578d00 100644 --- a/src/training/combo.rs +++ b/src/training/combo.rs @@ -32,7 +32,7 @@ unsafe fn was_in_shieldstun(module_accessor: *mut app::BattleObjectModuleAccesso macro_rules! actionable_statuses { () => { - vec![ + [ FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_AIR, FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_AIR, FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON, diff --git a/src/training/save_states.rs b/src/training/save_states.rs index 2fed8c8..8a51970 100644 --- a/src/training/save_states.rs +++ b/src/training/save_states.rs @@ -4,6 +4,7 @@ use log::info; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use smash::app::{self, lua_bind::*, Item}; +use smash::cpp::l2c_value::LuaConst; use smash::hash40; use smash::lib::lua_const::*; use smash::phx::{Hash40, Vector3f}; @@ -29,6 +30,24 @@ use crate::training::reset; use crate::training::ui::notifications; use crate::{is_ptrainer, ITEM_MANAGER_ADDR}; +// Don't remove Mii hats, or Luma, or crafting table +const ARTICLE_ALLOWLIST: [(LuaConst, LuaConst); 5] = [ + ( + FIGHTER_KIND_MIIFIGHTER, + FIGHTER_MIIFIGHTER_GENERATE_ARTICLE_HAT, + ), + ( + FIGHTER_KIND_MIISWORDSMAN, + FIGHTER_MIISWORDSMAN_GENERATE_ARTICLE_HAT, + ), + ( + FIGHTER_KIND_MIIGUNNER, + FIGHTER_MIIGUNNER_GENERATE_ARTICLE_HAT, + ), + (FIGHTER_KIND_ROSETTA, FIGHTER_ROSETTA_GENERATE_ARTICLE_TICO), + (FIGHTER_KIND_PICKEL, FIGHTER_PICKEL_GENERATE_ARTICLE_TABLE), +]; + extern "C" { #[link_name = "\u{1}_ZN3app14sv_information8stage_idEv"] pub fn stage_id() -> i32; @@ -296,10 +315,10 @@ unsafe fn on_death(fighter_kind: i32, module_accessor: &mut app::BattleObjectMod // All articles have ID <= 0x25 (0..=0x25) - // Don't remove crafting table .filter(|article_idx| { - !(fighter_kind == *FIGHTER_KIND_PICKEL - && *article_idx == *FIGHTER_PICKEL_GENERATE_ARTICLE_TABLE) + !ARTICLE_ALLOWLIST.iter().any(|article_allowed| { + article_allowed.0 == fighter_kind && article_allowed.1 == *article_idx + }) }) .for_each(|article_idx| { if ArticleModule::is_exist(module_accessor, article_idx) {