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) {
let slice = SwfSlice::from(movie.clone());
let mut reader = slice.read_from(0);
let vm_type = match reader.read_tag_code_and_length() {
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,
Ok(_) => AvmType::Avm1,
Err(e) => {
log::error!("Got {} when reading AS3 flag", e);
AvmType::Avm1
let vm_type = if movie.header().version > 8 {
match reader.read_tag_code_and_length() {
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,
Ok(_) => AvmType::Avm1,
Err(e) => {
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) => {
log::error!("Got {} when looking for AS3 flag", e);
AvmType::Avm1
}
_ => AvmType::Avm1,
} else {
AvmType::Avm1
};
self.movie_libraries