avm2: Lock old movies (SWFv8 and earlier) to always use AVM1

This commit is contained in:
David Wendt 2020-10-05 22:25:50 -04:00 committed by Mike Welsh
parent 693e56dc67
commit 1a10f1e004
1 changed files with 19 additions and 15 deletions

View File

@ -246,24 +246,28 @@ impl<'gc> Library<'gc> {
if !self.movie_libraries.contains_key(&movie) { if !self.movie_libraries.contains_key(&movie) {
let slice = SwfSlice::from(movie.clone()); let slice = SwfSlice::from(movie.clone());
let mut reader = slice.read_from(0); let mut reader = slice.read_from(0);
let vm_type = match reader.read_tag_code_and_length() { let vm_type = if movie.header().version > 8 {
Ok((tag_code, _tag_len)) match reader.read_tag_code_and_length() {
if TagCode::from_u16(tag_code) == Some(TagCode::FileAttributes) => Ok((tag_code, _tag_len))
{ if TagCode::from_u16(tag_code) == Some(TagCode::FileAttributes) =>
match reader.read_file_attributes() { {
Ok(attributes) if attributes.is_action_script_3 => AvmType::Avm2, match reader.read_file_attributes() {
Ok(_) => AvmType::Avm1, Ok(attributes) if attributes.is_action_script_3 => AvmType::Avm2,
Err(e) => { Ok(_) => AvmType::Avm1,
log::error!("Got {} when reading AS3 flag", e); Err(e) => {
AvmType::Avm1 log::error!("Got {} when reading AS3 flag", e);
AvmType::Avm1
}
} }
} }
Err(e) => {
log::error!("Got {} when looking for AS3 flag", e);
AvmType::Avm1
}
_ => AvmType::Avm1,
} }
Err(e) => { } else {
log::error!("Got {} when looking for AS3 flag", e); AvmType::Avm1
AvmType::Avm1
}
_ => AvmType::Avm1,
}; };
self.movie_libraries self.movie_libraries