Skip to content

Commit

Permalink
core: Print swf version on startup, and warn when we run into avm2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed May 29, 2020
1 parent e7971f2 commit e43cb51
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
9 changes: 8 additions & 1 deletion core/src/display_object/movie_clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion core/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
20 changes: 12 additions & 8 deletions swf/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,7 @@ impl<R: Read> Reader<R> {
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) => {
Expand Down Expand Up @@ -2046,6 +2039,17 @@ impl<R: Read> Reader<R> {
}))
}

pub fn read_file_attributes(&mut self) -> Result<FileAttributes> {
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<ExportAssets> {
let num_exports = self.read_u16()?;
let mut exports = Vec::with_capacity(num_exports.into());
Expand Down

0 comments on commit e43cb51

Please sign in to comment.