From e43cb51828028d4f4d0d1804d96f6d6a0af6107d Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Thu, 28 May 2020 21:07:26 +0200 Subject: [PATCH] core: Print swf version on startup, and warn when we run into avm2 --- core/src/display_object/movie_clip.rs | 9 ++++++++- core/src/player.rs | 3 ++- swf/src/read.rs | 20 ++++++++++++-------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index fa2102147870..16dd287a9f2a 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -145,7 +145,14 @@ impl<'gc> MovieClip<'gc> { let mut reader = data.read_from(self.0.read().tag_stream_pos); let mut cur_frame = 1; let mut ids = fnv::FnvHashMap::default(); - let tag_callback = |reader: &mut _, tag_code, tag_len| match tag_code { + let tag_callback = |reader: &mut SwfStream<&[u8]>, tag_code, tag_len| match tag_code { + TagCode::FileAttributes => { + let attributes = reader.read_file_attributes()?; + if attributes.is_action_script_3 { + log::warn!("This SWF contains ActionScript 3 which is not yet supported by Ruffle. The movie may not work as intended."); + } + Ok(()) + } TagCode::DefineBits => self .0 .write(context.gc_context) diff --git a/core/src/player.rs b/core/src/player.rs index 9a73aa757504..a6154075cccd 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -154,7 +154,8 @@ impl Player { let movie = Arc::new(movie); info!( - "{}x{}", + "Loaded SWF version {}, with a resolution of {}x{}", + movie.header().version, movie.header().stage_size.x_max, movie.header().stage_size.y_max ); diff --git a/swf/src/read.rs b/swf/src/read.rs index 9627780bf62c..0db4c609077b 100644 --- a/swf/src/read.rs +++ b/swf/src/read.rs @@ -595,14 +595,7 @@ impl Reader { Some(TagCode::ExportAssets) => Tag::ExportAssets(tag_reader.read_export_assets()?), Some(TagCode::FileAttributes) => { - let flags = tag_reader.read_u32()?; - Tag::FileAttributes(FileAttributes { - use_direct_blit: (flags & 0b01000000) != 0, - use_gpu: (flags & 0b00100000) != 0, - has_metadata: (flags & 0b00010000) != 0, - is_action_script_3: (flags & 0b00001000) != 0, - use_network_sandbox: (flags & 0b00000001) != 0, - }) + Tag::FileAttributes(tag_reader.read_file_attributes()?) } Some(TagCode::Protect) => { @@ -2046,6 +2039,17 @@ impl Reader { })) } + pub fn read_file_attributes(&mut self) -> Result { + let flags = self.read_u32()?; + Ok(FileAttributes { + use_direct_blit: (flags & 0b01000000) != 0, + use_gpu: (flags & 0b00100000) != 0, + has_metadata: (flags & 0b00010000) != 0, + is_action_script_3: (flags & 0b00001000) != 0, + use_network_sandbox: (flags & 0b00000001) != 0, + }) + } + pub fn read_export_assets(&mut self) -> Result { let num_exports = self.read_u16()?; let mut exports = Vec::with_capacity(num_exports.into());