From 26097235a7ed6805798073ec0a898cdefe10cb87 Mon Sep 17 00:00:00 2001 From: toasterparty Date: Thu, 1 Aug 2024 09:23:17 -0700 Subject: [PATCH] schema fixes / formatting --- schema/randomprime.schema.json | 10 ++-- src/add_modify_obj_patches.rs | 76 +++++++++++++++++---------- src/patch_config.rs | 36 ++++++++----- src/patches.rs | 71 ++++++++++--------------- structs/src/scly_props/camera_hint.rs | 2 +- structs/src/scly_props/water.rs | 2 +- 6 files changed, 107 insertions(+), 90 deletions(-) diff --git a/schema/randomprime.schema.json b/schema/randomprime.schema.json index a7fdd54e..27eebd13 100644 --- a/schema/randomprime.schema.json +++ b/schema/randomprime.schema.json @@ -276,6 +276,11 @@ "type": "boolean", "default": true }, + "noHud": { + "description": "If true, removes many hud elements", + "type": "boolean", + "default": false + }, "trilogyDiscPath": { "description": "The filepath to a Trilogy ISO to restore the intended Flaahgra music.", "type": "string" @@ -925,11 +930,6 @@ "type": "string", "default": null }, - "noHud": { - "description": "If true, removes many hud elements", - "type": "boolean", - "default": false - }, "artifactHints": { "description": "The hint provided to the player when scanning the respective Artifact's totem in Artifact Temple. Supports color modification with &push and &pop delimiters. If left unspecified, defaults to humorous hints which include the room name of the corresponding artifact.", "type": "object", diff --git a/src/add_modify_obj_patches.rs b/src/add_modify_obj_patches.rs index 96358173..1558b605 100644 --- a/src/add_modify_obj_patches.rs +++ b/src/add_modify_obj_patches.rs @@ -9,11 +9,12 @@ use crate::{ mlvl_wrapper, patch_config::{ ActorKeyFrameConfig, ActorRotateConfig, BlockConfig, BombSlotConfig, CameraConfig, - CameraHintTriggerConfig, CameraFilterKeyframeConfig, CameraWaypointConfig, ControllerActionConfig, - CounterConfig, DamageType, FogConfig, GenericTexture, HudmemoConfig, LockOnPoint, NewCameraHintConfig, - PlatformConfig, PlatformType, PlayerActorConfig, PlayerHintConfig, RelayConfig, SpawnPointConfig, - SpecialFunctionConfig, StreamedAudioConfig, SwitchConfig, TimerConfig, TriggerConfig, - WaterConfig, WaypointConfig, WorldLightFaderConfig, + CameraFilterKeyframeConfig, CameraHintTriggerConfig, CameraWaypointConfig, + ControllerActionConfig, CounterConfig, DamageType, FogConfig, GenericTexture, + HudmemoConfig, LockOnPoint, NewCameraHintConfig, PlatformConfig, PlatformType, + PlayerActorConfig, PlayerHintConfig, RelayConfig, SpawnPointConfig, SpecialFunctionConfig, + StreamedAudioConfig, SwitchConfig, TimerConfig, TriggerConfig, WaterConfig, WaypointConfig, + WorldLightFaderConfig, }, patcher::PatcherState, patches::{string_to_cstr, WaterType}, @@ -1938,15 +1939,20 @@ pub fn patch_add_new_camera_hint( hint_distance_selection: config.hint_distance_selection.unwrap_or(false) as u8, hint_distance_self_pos: config.hint_distance_self_pos.unwrap_or(false) as u8, control_interpolation: config.control_interpolation.unwrap_or(false) as u8, - sinusoidal_interpolation: config.sinusoidal_interpolation.unwrap_or(false) as u8, - sinusoidal_interpolation_hintless: config.sinusoidal_interpolation_hintless.unwrap_or(false) as u8, + sinusoidal_interpolation: config.sinusoidal_interpolation.unwrap_or(false) + as u8, + sinusoidal_interpolation_hintless: config + .sinusoidal_interpolation_hintless + .unwrap_or(false) as u8, clamp_velocity: config.clamp_velocity.unwrap_or(false) as u8, skip_cinematic: config.skip_cinematic.unwrap_or(false) as u8, no_elevation_interp: config.no_elevation_interp.unwrap_or(false) as u8, direct_elevation: config.direct_elevation.unwrap_or(false) as u8, override_look_dir: config.override_look_dir.unwrap_or(false) as u8, no_elevation_vel_clamp: config.no_elevation_vel_clamp.unwrap_or(false) as u8, - calculate_transform_from_prev_cam: config.calculate_transform_from_prev_cam.unwrap_or(false) as u8, + calculate_transform_from_prev_cam: config + .calculate_transform_from_prev_cam + .unwrap_or(false) as u8, no_spline: config.no_spline.unwrap_or(false) as u8, unknown21: config.unknown1.unwrap_or(false) as u8, unknown22: config.unknown2.unwrap_or(false) as u8, @@ -1976,7 +1982,10 @@ pub fn patch_add_new_camera_hint( .into(), chase_look_at_offset: structs::scly_props::structs::BoolVec3 { override_flags: config.override_chase_look_at_offset.unwrap_or(false) as u8, - value: config.chase_look_at_offset.unwrap_or([0.0, 0.0, 0.0]).into(), + value: config + .chase_look_at_offset + .unwrap_or([0.0, 0.0, 0.0]) + .into(), } .into(), @@ -2062,19 +2071,26 @@ pub fn patch_add_new_camera_hint( property_data.camera_hint_params.look_at_ball = look_at_ball as u8 } if let Some(hint_distance_selection) = config.hint_distance_selection { - property_data.camera_hint_params.hint_distance_selection = hint_distance_selection as u8 + property_data.camera_hint_params.hint_distance_selection = + hint_distance_selection as u8 } if let Some(hint_distance_self_pos) = config.hint_distance_self_pos { - property_data.camera_hint_params.hint_distance_self_pos = hint_distance_self_pos as u8 + property_data.camera_hint_params.hint_distance_self_pos = + hint_distance_self_pos as u8 } if let Some(control_interpolation) = config.control_interpolation { property_data.camera_hint_params.control_interpolation = control_interpolation as u8 } if let Some(sinusoidal_interpolation) = config.sinusoidal_interpolation { - property_data.camera_hint_params.sinusoidal_interpolation = sinusoidal_interpolation as u8 + property_data.camera_hint_params.sinusoidal_interpolation = + sinusoidal_interpolation as u8 } - if let Some(sinusoidal_interpolation_hintless) = config.sinusoidal_interpolation_hintless { - property_data.camera_hint_params.sinusoidal_interpolation_hintless = sinusoidal_interpolation_hintless as u8 + if let Some(sinusoidal_interpolation_hintless) = + config.sinusoidal_interpolation_hintless + { + property_data + .camera_hint_params + .sinusoidal_interpolation_hintless = sinusoidal_interpolation_hintless as u8 } if let Some(clamp_velocity) = config.clamp_velocity { property_data.camera_hint_params.clamp_velocity = clamp_velocity as u8 @@ -2092,10 +2108,15 @@ pub fn patch_add_new_camera_hint( property_data.camera_hint_params.override_look_dir = override_look_dir as u8 } if let Some(no_elevation_vel_clamp) = config.no_elevation_vel_clamp { - property_data.camera_hint_params.no_elevation_vel_clamp = no_elevation_vel_clamp as u8 + property_data.camera_hint_params.no_elevation_vel_clamp = + no_elevation_vel_clamp as u8 } - if let Some(calculate_transform_from_prev_cam) = config.calculate_transform_from_prev_cam { - property_data.camera_hint_params.calculate_transform_from_prev_cam = calculate_transform_from_prev_cam as u8 + if let Some(calculate_transform_from_prev_cam) = + config.calculate_transform_from_prev_cam + { + property_data + .camera_hint_params + .calculate_transform_from_prev_cam = calculate_transform_from_prev_cam as u8 } if let Some(no_spline) = config.no_spline { property_data.camera_hint_params.no_spline = no_spline as u8 @@ -2131,7 +2152,8 @@ pub fn patch_add_new_camera_hint( property_data.look_at_offset.value = look_at_offset.into() } if let Some(override_chase_look_at_offset) = config.override_chase_look_at_offset { - property_data.chase_look_at_offset.override_flags = override_chase_look_at_offset as u8 + property_data.chase_look_at_offset.override_flags = + override_chase_look_at_offset as u8 } if let Some(chase_look_at_offset) = config.chase_look_at_offset { property_data.chase_look_at_offset.value = chase_look_at_offset.into() @@ -2187,14 +2209,7 @@ pub fn patch_add_new_camera_hint( }; } - add_edit_obj_helper!( - area, - Some(config.id), - config.layer, - CameraHint, - new, - update - ); + add_edit_obj_helper!(area, Some(config.id), config.layer, CameraHint, new, update); } pub fn patch_add_camera_hint_trigger( @@ -2241,7 +2256,14 @@ pub fn patch_add_camera_hint_trigger( }; } - add_edit_obj_helper!(area, config.id, config.layer, CameraHintTrigger, new, update); + add_edit_obj_helper!( + area, + config.id, + config.layer, + CameraHintTrigger, + new, + update + ); } pub fn patch_add_platform<'r>( diff --git a/src/patch_config.rs b/src/patch_config.rs index a04186ac..08e762ed 100644 --- a/src/patch_config.rs +++ b/src/patch_config.rs @@ -838,7 +838,7 @@ pub enum EBallCameraBehaviour { HintFixedTransform, PathCameraDesiredPos, // Unused PathCamera, - SpindleCamera + SpindleCamera, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -914,7 +914,6 @@ pub struct CameraHintTriggerConfig { pub deactivate_on_exit: Option, } - #[allow(non_camel_case_types)] #[derive(Debug, Serialize, Deserialize, Copy, Clone, Eq, PartialEq)] #[repr(u32)] @@ -2534,13 +2533,9 @@ impl PatchConfigPrivate { }; let spring_ball_item = { - match self - .game_config - .spring_ball_item - .as_deref() - { + match self.game_config.spring_ball_item.as_deref() { Some(s) => PickupType::from_str(s), - None => PickupType::MorphBallBomb + None => PickupType::MorphBallBomb, } }; @@ -2575,10 +2570,22 @@ impl PatchConfigPrivate { .game_config .phazon_elite_without_dynamo .unwrap_or(!force_vanilla_layout), - main_plaza_door: self.game_config.main_plaza_door.unwrap_or(!force_vanilla_layout), - backwards_labs: self.game_config.backwards_labs.unwrap_or(!force_vanilla_layout), - backwards_frigate: self.game_config.backwards_frigate.unwrap_or(!force_vanilla_layout), - backwards_upper_mines: self.game_config.backwards_upper_mines.unwrap_or(!force_vanilla_layout), + main_plaza_door: self + .game_config + .main_plaza_door + .unwrap_or(!force_vanilla_layout), + backwards_labs: self + .game_config + .backwards_labs + .unwrap_or(!force_vanilla_layout), + backwards_frigate: self + .game_config + .backwards_frigate + .unwrap_or(!force_vanilla_layout), + backwards_upper_mines: self + .game_config + .backwards_upper_mines + .unwrap_or(!force_vanilla_layout), backwards_lower_mines: self.game_config.backwards_lower_mines.unwrap_or(false), patch_power_conduits: self.game_config.patch_power_conduits.unwrap_or(false), remove_mine_security_station_locks: self @@ -2598,7 +2605,10 @@ impl PatchConfigPrivate { .hall_of_the_elders_bomb_slot_covers, automatic_crash_screen: self.preferences.automatic_crash_screen.unwrap_or(true), visible_bounding_box: self.preferences.visible_bounding_box.unwrap_or(false), - door_destination_scans: self.preferences.door_destination_scans.unwrap_or(!force_vanilla_layout), + door_destination_scans: self + .preferences + .door_destination_scans + .unwrap_or(!force_vanilla_layout), no_hud: self.preferences.no_hud.unwrap_or(false), artifact_hint_behavior, flaahgra_music_files, diff --git a/src/patches.rs b/src/patches.rs index 7cd8c26b..7f88967a 100644 --- a/src/patches.rs +++ b/src/patches.rs @@ -44,7 +44,7 @@ use crate::{ CtwkConfig, CutsceneMode, DifficultyBehavior, DoorConfig, DoorOpenMode, FogConfig, GameBanner, GenericTexture, HallOfTheEldersBombSlotCoversConfig, IsoFormat, LevelConfig, PatchConfig, PhazonDamageModifier, PickupConfig, PlatformConfig, PlatformType, RoomConfig, - RunMode, SpecialFunctionType, SuitDamageReduction, Version, Visor, TimerConfig + RunMode, SpecialFunctionType, SuitDamageReduction, TimerConfig, Version, Visor, }, patcher::{PatcherState, PrimePatcher}, pickup_meta::{ @@ -11211,11 +11211,11 @@ fn patch_dol( _spring_ball_item_condition_patch.encoded_bytes() } else { let _spring_ball_item_condition_patch = ppcasm!(new_text_section_end, { - nop; - nop; - nop; - nop; - nop; + nop; + nop; + nop; + nop; + nop; }); _spring_ball_item_condition_patch.encoded_bytes() }; @@ -16314,30 +16314,22 @@ fn build_and_run_patches<'r>( start_immediately: Some(true), layer: None, - max_random_add: None, + max_random_add: None, }; - - patcher.add_scly_patch( - res.into(), - move |ps, area| { - patch_add_timer(ps, area, timer_config.clone()) - }, - ); - - let connections = vec![ - ConnectionConfig { - sender_id: timer_id, - state: ConnectionState::ZERO, - target_id: dock_id, - message: ConnectionMsg::INCREMENT, - } - ]; - patcher.add_scly_patch( - res.into(), - move |ps, area| { - patch_add_connections(ps, area, &connections) - }, - ); + + patcher.add_scly_patch(res.into(), move |ps, area| { + patch_add_timer(ps, area, timer_config.clone()) + }); + + let connections = vec![ConnectionConfig { + sender_id: timer_id, + state: ConnectionState::ZERO, + target_id: dock_id, + message: ConnectionMsg::INCREMENT, + }]; + patcher.add_scly_patch(res.into(), move |ps, area| { + patch_add_connections(ps, area, &connections) + }); } } } @@ -16389,7 +16381,7 @@ fn build_and_run_patches<'r>( // this is a hack because something is getting messed up with the MREA objects if this patch never gets used let remove_otrs = config.qol_cosmetic && !(config.shuffle_pickup_position - && room_info.room_id.to_u32() == 0x40C548E9); + && room_info.room_id.to_u32() == 0x40C548E9); patcher.add_scly_patch( (pak_name.as_bytes(), room_info.room_id.to_u32()), @@ -16687,7 +16679,8 @@ fn build_and_run_patches<'r>( } } - if let Some(camera_filter_keyframes) = room.camera_filter_keyframes.as_ref() { + if let Some(camera_filter_keyframes) = room.camera_filter_keyframes.as_ref() + { for config in camera_filter_keyframes { patcher.add_scly_patch( (pak_name.as_bytes(), room_info.room_id.to_u32()), @@ -16720,7 +16713,6 @@ fn build_and_run_patches<'r>( } } - if room.streamed_audios.is_some() { for config in room.streamed_audios.as_ref().unwrap() { patcher.add_scly_patch( @@ -17210,7 +17202,7 @@ fn build_and_run_patches<'r>( scan.position, scan.rotation.unwrap_or(0.0), scan.layer, - scan.actor_id + scan.actor_id, ) }, ); @@ -17710,17 +17702,10 @@ fn build_and_run_patches<'r>( }); if config.no_hud { - for res in vec![ - resource_info!("FRME_CombatHud.FRME"), + for res in [resource_info!("FRME_CombatHud.FRME"), resource_info!("FRME_BallHud.FRME"), - resource_info!("FRME_ScanHud.FRME"), - // resource_info!("FRME_Helmet.FRME"), - // resource_info!("FRME_BaseHud.FRME"), - ] { - patcher.add_resource_patch( - res.into(), - patch_no_hud, - ); + resource_info!("FRME_ScanHud.FRME")] { + patcher.add_resource_patch(res.into(), patch_no_hud); } } diff --git a/structs/src/scly_props/camera_hint.rs b/structs/src/scly_props/camera_hint.rs index 2ff80c40..231c9c4a 100644 --- a/structs/src/scly_props/camera_hint.rs +++ b/structs/src/scly_props/camera_hint.rs @@ -2,7 +2,7 @@ use auto_struct_macros::auto_struct; use reader_writer::{generic_array::GenericArray, typenum::U3, CStr}; use crate::{ - scly_props::structs::{CameraHintParameters, BoolFloat, BoolVec3}, + scly_props::structs::{BoolFloat, BoolVec3, CameraHintParameters}, SclyPropertyData, }; diff --git a/structs/src/scly_props/water.rs b/structs/src/scly_props/water.rs index fa94c0ef..577af8d4 100644 --- a/structs/src/scly_props/water.rs +++ b/structs/src/scly_props/water.rs @@ -108,4 +108,4 @@ impl<'r> SclyPropertyData for Water<'r> { fn impl_set_damage_infos(&mut self, x: Vec) { self.damage_info = x[0]; } -} \ No newline at end of file +}