diff --git a/src/engine_constants/mod.rs b/src/engine_constants/mod.rs index 0e16c8c..1850d8f 100644 --- a/src/engine_constants/mod.rs +++ b/src/engine_constants/mod.rs @@ -67,7 +67,7 @@ pub struct GameConsts { pub tile_offset_x: i32, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct CaretConsts { pub offsets: [(i32, i32); 18], pub bubble_left_rects: Vec>, @@ -97,34 +97,6 @@ pub struct TextureSizeTable { sizes: HashMap, } -impl Clone for CaretConsts { - fn clone(&self) -> Self { - Self { - offsets: self.offsets, - bubble_left_rects: self.bubble_left_rects.clone(), - bubble_right_rects: self.bubble_right_rects.clone(), - projectile_dissipation_left_rects: self.projectile_dissipation_left_rects.clone(), - projectile_dissipation_right_rects: self.projectile_dissipation_right_rects.clone(), - projectile_dissipation_up_rects: self.projectile_dissipation_up_rects.clone(), - shoot_rects: self.shoot_rects.clone(), - zzz_rects: self.zzz_rects.clone(), - drowned_quote_left_rect: self.drowned_quote_left_rect, - drowned_quote_right_rect: self.drowned_quote_right_rect, - level_up_rects: self.level_up_rects.clone(), - level_down_rects: self.level_down_rects.clone(), - hurt_particles_rects: self.hurt_particles_rects.clone(), - explosion_rects: self.explosion_rects.clone(), - little_particles_rects: self.little_particles_rects.clone(), - exhaust_rects: self.exhaust_rects.clone(), - question_left_rect: self.question_left_rect, - question_right_rect: self.question_right_rect, - small_projectile_dissipation: self.small_projectile_dissipation.clone(), - empty_text: self.empty_text.clone(), - push_jump_key: self.push_jump_key.clone(), - } - } -} - #[derive(Debug, Copy, Clone)] pub struct BulletData { pub damage: u8, @@ -175,23 +147,13 @@ pub struct BulletRects { pub b042_spur_trail_l3: [Rect; 6], } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct WeaponConsts { pub bullet_table: Vec, pub bullet_rects: BulletRects, pub level_table: [[u16; 3]; 14], } -impl Clone for WeaponConsts { - fn clone(&self) -> WeaponConsts { - WeaponConsts { - bullet_table: self.bullet_table.clone(), - bullet_rects: self.bullet_rects, - level_table: self.level_table, - } - } -} - #[derive(Debug, Copy, Clone)] pub struct WorldConsts { pub snack_rect: Rect, @@ -245,7 +207,7 @@ pub struct TextScriptConsts { pub fade_ticks: i8, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct TitleConsts { pub intro_text: String, pub logo_rect: Rect, @@ -266,42 +228,12 @@ pub struct TitleConsts { pub cursor_sue: [Rect; 4], } -impl Clone for TitleConsts { - fn clone(&self) -> TitleConsts { - TitleConsts { - intro_text: self.intro_text.clone(), - logo_rect: self.logo_rect, - logo_splash_rect: self.logo_splash_rect, - menu_left_top: self.menu_left_top, - menu_right_top: self.menu_right_top, - menu_left_bottom: self.menu_left_bottom, - menu_right_bottom: self.menu_right_bottom, - menu_top: self.menu_top, - menu_bottom: self.menu_bottom, - menu_middle: self.menu_middle, - menu_left: self.menu_left, - menu_right: self.menu_right, - cursor_quote: self.cursor_quote, - cursor_curly: self.cursor_curly, - cursor_toroko: self.cursor_toroko, - cursor_king: self.cursor_king, - cursor_sue: self.cursor_sue, - } - } -} - -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct GamepadConsts { pub button_rects: HashMap; 4]>, pub axis_rects: HashMap; 4]>, } -impl Clone for GamepadConsts { - fn clone(&self) -> GamepadConsts { - GamepadConsts { button_rects: self.button_rects.clone(), axis_rects: self.axis_rects.clone() } - } -} - impl GamepadConsts { fn rects(base: Rect) -> [Rect; 4] { [ @@ -313,7 +245,7 @@ impl GamepadConsts { } } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct EngineConstants { pub base_paths: Vec, pub is_cs_plus: bool, @@ -347,43 +279,6 @@ pub struct EngineConstants { pub gamepad: GamepadConsts, } -impl Clone for EngineConstants { - fn clone(&self) -> EngineConstants { - EngineConstants { - base_paths: self.base_paths.clone(), - is_cs_plus: self.is_cs_plus, - is_switch: self.is_switch, - is_demo: self.is_demo, - supports_og_textures: self.supports_og_textures, - has_difficulty_menu: self.has_difficulty_menu, - supports_two_player: self.supports_two_player, - game: self.game, - player: self.player, - booster: self.booster, - caret: self.caret.clone(), - world: self.world, - npc: self.npc, - weapon: self.weapon.clone(), - tex_sizes: self.tex_sizes.clone(), - textscript: self.textscript, - title: self.title.clone(), - inventory_dim_color: self.inventory_dim_color, - font_path: self.font_path.clone(), - font_space_offset: self.font_space_offset, - soundtracks: self.soundtracks.clone(), - music_table: self.music_table.clone(), - organya_paths: self.organya_paths.clone(), - credit_illustration_paths: self.credit_illustration_paths.clone(), - player_skin_paths: self.player_skin_paths.clone(), - animated_face_table: self.animated_face_table.clone(), - string_table: self.string_table.clone(), - missile_flags: self.missile_flags.clone(), - locales: self.locales.clone(), - gamepad: self.gamepad.clone(), - } - } -} - impl EngineConstants { pub fn defaults() -> Self { EngineConstants { diff --git a/src/game/scripting/tsc/text_script.rs b/src/game/scripting/tsc/text_script.rs index 354c9eb..1f3b0e2 100644 --- a/src/game/scripting/tsc/text_script.rs +++ b/src/game/scripting/tsc/text_script.rs @@ -1874,16 +1874,11 @@ impl TextScriptVM { } } +#[derive(Clone)] pub struct TextScript { pub(crate) event_map: HashMap>, } -impl Clone for TextScript { - fn clone(&self) -> Self { - Self { event_map: self.event_map.clone() } - } -} - impl Default for TextScript { fn default() -> Self { TextScript::new() diff --git a/src/game/stage.rs b/src/game/stage.rs index 3c30845..5a6f50f 100644 --- a/src/game/stage.rs +++ b/src/game/stage.rs @@ -15,17 +15,11 @@ use crate::game::map::{Map, NPCData}; use crate::game::scripting::tsc::text_script::TextScript; use crate::util::encoding::read_cur_shift_jis; -#[derive(Debug, PartialEq, Eq, Hash)] +#[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct NpcType { name: String, } -impl Clone for NpcType { - fn clone(&self) -> Self { - Self { name: self.name.clone() } - } -} - impl NpcType { pub fn new(name: &str) -> Self { Self { name: name.to_owned() } @@ -36,17 +30,11 @@ impl NpcType { } } -#[derive(Debug, PartialEq, Eq, Hash)] +#[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct Tileset { pub(crate) name: String, } -impl Clone for Tileset { - fn clone(&self) -> Self { - Self { name: self.name.clone() } - } -} - impl Tileset { pub fn new(name: &str) -> Self { Self { name: name.to_owned() } @@ -66,17 +54,11 @@ impl Tileset { } } -#[derive(Debug, PartialEq, Eq, Hash)] +#[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct Background { name: String, } -impl Clone for Background { - fn clone(&self) -> Self { - Self { name: self.name.clone() } - } -} - impl Background { pub fn new(name: &str) -> Self { Self { name: name.to_owned() } @@ -195,7 +177,7 @@ pub struct PxPackStageData { pub offset_bg: u32, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct StageData { pub name: String, pub name_jp: String, @@ -210,24 +192,6 @@ pub struct StageData { pub npc2: NpcType, } -impl Clone for StageData { - fn clone(&self) -> Self { - StageData { - name: self.name.clone(), - name_jp: self.name_jp.clone(), - map: self.map.clone(), - boss_no: self.boss_no, - tileset: self.tileset.clone(), - pxpack_data: self.pxpack_data.clone(), - background: self.background.clone(), - background_type: self.background_type, - background_color: self.background_color, - npc1: self.npc1.clone(), - npc2: self.npc2.clone(), - } - } -} - const NXENGINE_BACKDROPS: [&str; 15] = [ "bk0", "bkBlue", diff --git a/src/sound/org_playback.rs b/src/sound/org_playback.rs index cb165a9..0ace0b3 100644 --- a/src/sound/org_playback.rs +++ b/src/sound/org_playback.rs @@ -50,17 +50,12 @@ pub(crate) struct OrgPlaybackEngine { pub interpolation: InterpolationMode, } +#[derive(Clone)] pub struct SavedOrganyaPlaybackState { song: Organya, play_pos: i32, } -impl Clone for SavedOrganyaPlaybackState { - fn clone(&self) -> SavedOrganyaPlaybackState { - SavedOrganyaPlaybackState { song: self.song.clone(), play_pos: self.play_pos } - } -} - impl OrgPlaybackEngine { pub fn new() -> Self { let mut buffers: [MaybeUninit; 136] = unsafe { MaybeUninit::uninit().assume_init() }; diff --git a/src/sound/organya.rs b/src/sound/organya.rs index 86fcd1f..81eb9fa 100644 --- a/src/sound/organya.rs +++ b/src/sound/organya.rs @@ -44,20 +44,12 @@ pub struct Instrument { pub notes: u16, } +#[derive(Clone)] pub struct Track { pub inst: Instrument, pub notes: Vec, } -impl Clone for Track { - fn clone(&self) -> Track { - Track { - inst: self.inst, - notes: self.notes.clone(), - } - } -} - impl std::fmt::Debug for Track { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { self.inst.fmt(f) @@ -74,23 +66,13 @@ pub struct Note { pub pan: u8, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Song { pub version: Version, pub time: Timing, pub tracks: [Track; 16], } -impl Clone for Song { - fn clone(&self) -> Song { - Song { - version: self.version, - time: self.time, - tracks: self.tracks.clone(), - } - } -} - impl Song { pub fn empty() -> Song { Song {