Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Print swf version on startup, and warn when we run into avm2 #661

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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