Skip to content

Commit 4c1ce6d

Browse files
DinnerboneHerschel
authored andcommitted
core: Print swf version on startup, and warn when we run into avm2
1 parent c0593ce commit 4c1ce6d

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

core/src/display_object/movie_clip.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,14 @@ impl<'gc> MovieClip<'gc> {
145145
let mut reader = data.read_from(self.0.read().tag_stream_pos);
146146
let mut cur_frame = 1;
147147
let mut ids = fnv::FnvHashMap::default();
148-
let tag_callback = |reader: &mut _, tag_code, tag_len| match tag_code {
148+
let tag_callback = |reader: &mut SwfStream<&[u8]>, tag_code, tag_len| match tag_code {
149+
TagCode::FileAttributes => {
150+
let attributes = reader.read_file_attributes()?;
151+
if attributes.is_action_script_3 {
152+
log::warn!("This SWF contains ActionScript 3 which is not yet supported by Ruffle. The movie may not work as intended.");
153+
}
154+
Ok(())
155+
}
149156
TagCode::DefineBits => self
150157
.0
151158
.write(context.gc_context)

core/src/player.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ impl Player {
154154
let movie = Arc::new(movie);
155155

156156
info!(
157-
"{}x{}",
157+
"Loaded SWF version {}, with a resolution of {}x{}",
158+
movie.header().version,
158159
movie.header().stage_size.x_max,
159160
movie.header().stage_size.y_max
160161
);

swf/src/read.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -595,14 +595,7 @@ impl<R: Read> Reader<R> {
595595
Some(TagCode::ExportAssets) => Tag::ExportAssets(tag_reader.read_export_assets()?),
596596

597597
Some(TagCode::FileAttributes) => {
598-
let flags = tag_reader.read_u32()?;
599-
Tag::FileAttributes(FileAttributes {
600-
use_direct_blit: (flags & 0b01000000) != 0,
601-
use_gpu: (flags & 0b00100000) != 0,
602-
has_metadata: (flags & 0b00010000) != 0,
603-
is_action_script_3: (flags & 0b00001000) != 0,
604-
use_network_sandbox: (flags & 0b00000001) != 0,
605-
})
598+
Tag::FileAttributes(tag_reader.read_file_attributes()?)
606599
}
607600

608601
Some(TagCode::Protect) => {
@@ -2046,6 +2039,17 @@ impl<R: Read> Reader<R> {
20462039
}))
20472040
}
20482041

2042+
pub fn read_file_attributes(&mut self) -> Result<FileAttributes> {
2043+
let flags = self.read_u32()?;
2044+
Ok(FileAttributes {
2045+
use_direct_blit: (flags & 0b01000000) != 0,
2046+
use_gpu: (flags & 0b00100000) != 0,
2047+
has_metadata: (flags & 0b00010000) != 0,
2048+
is_action_script_3: (flags & 0b00001000) != 0,
2049+
use_network_sandbox: (flags & 0b00000001) != 0,
2050+
})
2051+
}
2052+
20492053
pub fn read_export_assets(&mut self) -> Result<ExportAssets> {
20502054
let num_exports = self.read_u16()?;
20512055
let mut exports = Vec::with_capacity(num_exports.into());

0 commit comments

Comments
 (0)