1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 02:44:17 +00:00

Fix PLAY_SE hook crash (#602)

This commit is contained in:
GradualSyrup 2023-08-20 14:56:31 -05:00 committed by GitHub
parent a9857bf485
commit 13c87133bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 21 deletions

View file

@ -43,6 +43,10 @@ pub unsafe fn is_buffing(module_accessor: &mut app::BattleObjectModuleAccessor)
IS_BUFFING_PLAYER
}
pub unsafe fn is_buffing_any() -> bool {
IS_BUFFING_CPU || IS_BUFFING_PLAYER
}
pub unsafe fn set_buff_rem(module_accessor: &mut app::BattleObjectModuleAccessor, new_value: i32) {
if is_operation_cpu(module_accessor) {
BUFF_REMAINING_CPU = new_value;

View file

@ -476,7 +476,7 @@ static PLAY_SE_OFFSET: usize = 0x04cf6a0;
// fighters don't use the symbol and go straight through their vtable to this function
#[skyline::hook(offset = PLAY_SE_OFFSET)]
pub unsafe fn handle_fighter_play_se(
module_accessor: &mut app::BattleObjectModuleAccessor,
sound_module: u64, // pointer to fighter's SoundModule
my_hash: Hash40,
bool1: bool,
bool2: bool,
@ -485,22 +485,14 @@ pub unsafe fn handle_fighter_play_se(
se_type: enSEType,
) -> u64 {
if !is_training_mode() {
return original!()(
module_accessor,
my_hash,
bool1,
bool2,
bool3,
bool4,
se_type,
);
return original!()(sound_module, my_hash, bool1, bool2, bool3, bool4, se_type);
}
// Supress Buff Sound Effects while buffing
if buff::is_buffing(module_accessor) {
if buff::is_buffing_any() {
let silent_hash = Hash40::new("se_silent");
return original!()(
module_accessor,
sound_module,
silent_hash,
bool1,
bool2,
@ -509,15 +501,7 @@ pub unsafe fn handle_fighter_play_se(
se_type,
);
}
original!()(
module_accessor,
my_hash,
bool1,
bool2,
bool3,
bool4,
se_type,
)
original!()(sound_module, my_hash, bool1, bool2, bool3, bool4, se_type)
}
static FOLLOW_REQ_OFFSET: usize = 0x044f860;