diff --git a/Assets/DevTests/Animations/BugTests.meta b/Assets/DevTests/Animations/BugTests.meta new file mode 100644 index 0000000..49ed5e9 --- /dev/null +++ b/Assets/DevTests/Animations/BugTests.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0af1635387aab4e9cb5b38d8722cecf0 +folderAsset: yes +timeCreated: 1511462526 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum.meta b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum.meta new file mode 100644 index 0000000..9e883d0 --- /dev/null +++ b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 78561fafa47094aea89ba0771c70c41b +folderAsset: yes +timeCreated: 1511482664 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectStuff/BugReports/Liklain_Unity_Forum/_01_TODO/blockers_tmp_0.fla b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.fla similarity index 100% rename from ProjectStuff/BugReports/Liklain_Unity_Forum/_01_TODO/blockers_tmp_0.fla rename to Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.fla diff --git a/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.fla.meta b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.fla.meta new file mode 100644 index 0000000..e8d824f --- /dev/null +++ b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.fla.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5cecc5a6be854444ea6d0ee1bac1925f +timeCreated: 1511482664 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectStuff/BugReports/Liklain_Unity_Forum/_01_TODO/info.txt b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.txt similarity index 100% rename from ProjectStuff/BugReports/Liklain_Unity_Forum/_01_TODO/info.txt rename to Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.txt diff --git a/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.txt.meta b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.txt.meta new file mode 100644 index 0000000..54adf09 --- /dev/null +++ b/Assets/DevTests/Animations/BugTests/Liklain_Unity_Forum/blockers_tmp_0.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 056a3e8eb97b34881be36dd1944cce02 +timeCreated: 1511482664 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FlashTools/Docs/CHANGELOG.md b/Assets/FlashTools/Docs/CHANGELOG.md index 650230d..9bf42fa 100644 --- a/Assets/FlashTools/Docs/CHANGELOG.md +++ b/Assets/FlashTools/Docs/CHANGELOG.md @@ -1,5 +1,6 @@ ###### Version 1.3.10 * Fix (conversion error: 'Error: scaleSelection: Argument number 1 is invalid.') +* Fix (Parsing swf error: Failed to read past end of stream) ###### Version 1.3.9 * Not save generated meshes in scene diff --git a/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs b/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs index 18992e8..09cb171 100644 --- a/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs +++ b/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs @@ -198,6 +198,19 @@ namespace FTEditor.Postprocessors { self_masks, frame); break; + case SwfDisplayInstanceType.Bitmap: + AddBitmapInstanceToFrame( + library, + inst as SwfDisplayBitmapInstance, + child_matrix, + child_blend_mode, + child_color_transform, + parent_masked, + parent_mask, + parent_masks, + self_masks, + frame); + break; case SwfDisplayInstanceType.Sprite: AddSpriteInstanceToFrame( library, @@ -268,6 +281,47 @@ namespace FTEditor.Postprocessors { } } + static void AddBitmapInstanceToFrame( + SwfLibrary library, + SwfDisplayBitmapInstance inst, + Matrix4x4 inst_matrix, + SwfBlendModeData inst_blend_mode, + SwfColorTransData inst_color_transform, + ushort parent_masked, + ushort parent_mask, + List parent_masks, + List self_masks, + SwfFrameData frame) + { + var bitmap_def = library.FindDefine(inst.Id); + if ( bitmap_def != null ) { + var frame_inst_type = + (parent_mask > 0 || inst.ClipDepth > 0) + ? SwfInstanceData.Types.Mask + : (parent_masked > 0 || self_masks.Count > 0) + ? SwfInstanceData.Types.Masked + : SwfInstanceData.Types.Group; + var frame_inst_clip_depth = + (parent_mask > 0) + ? parent_mask + : (inst.ClipDepth > 0) + ? inst.ClipDepth + : parent_masked + self_masks.Count; + frame.Instances.Add(new SwfInstanceData{ + Type = frame_inst_type, + ClipDepth = (ushort)frame_inst_clip_depth, + Bitmap = inst.Id, + Matrix = SwfMatrixData.FromUMatrix(inst_matrix * Matrix4x4.Scale(new Vector3(20,20,1))), + BlendMode = inst_blend_mode, + ColorTrans = inst_color_transform}); + if ( parent_mask > 0 ) { + parent_masks.Add(frame.Instances[frame.Instances.Count - 1]); + } else if ( inst.ClipDepth > 0 ) { + self_masks.Add(frame.Instances[frame.Instances.Count - 1]); + } + } + } + static void AddSpriteInstanceToFrame( SwfLibrary library, SwfDisplaySpriteInstance inst, diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContext.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContext.cs index 4256900..83a54aa 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContext.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContext.cs @@ -71,6 +71,7 @@ namespace FTSwfTools { public enum SwfDisplayInstanceType { Shape, + Bitmap, Sprite } @@ -93,6 +94,12 @@ namespace FTSwfTools { } } + public class SwfDisplayBitmapInstance : SwfDisplayInstance { + public override SwfDisplayInstanceType Type { + get { return SwfDisplayInstanceType.Bitmap; } + } + } + public class SwfDisplaySpriteInstance : SwfDisplayInstance { public int CurrentTag = 0; public SwfDisplayList DisplayList = new SwfDisplayList(); diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContextExecuter.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContextExecuter.cs index 80c8cd7..f549746 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContextExecuter.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfContextExecuter.cs @@ -33,10 +33,13 @@ namespace FTSwfTools { public SwfDisplayList Visit(PlaceObjectTag tag, SwfDisplayList dl) { var is_shape = Library.HasDefine(tag.CharacterId); + var is_bitmap = Library.HasDefine(tag.CharacterId); var is_sprite = Library.HasDefine(tag.CharacterId); SwfDisplayInstance new_inst = null; if ( is_shape ) { new_inst = new SwfDisplayShapeInstance(); + } else if ( is_bitmap ) { + new_inst = new SwfDisplayBitmapInstance(); } else if ( is_sprite ) { new_inst = new SwfDisplaySpriteInstance(); } @@ -56,6 +59,7 @@ namespace FTSwfTools { public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) { var is_shape = tag.HasCharacter && Library.HasDefine(tag.CharacterId); + var is_bitmap = tag.HasCharacter && Library.HasDefine(tag.CharacterId); var is_sprite = tag.HasCharacter && Library.HasDefine(tag.CharacterId); if ( tag.HasCharacter ) { SwfDisplayInstance old_inst = null; @@ -68,6 +72,8 @@ namespace FTSwfTools { SwfDisplayInstance new_inst = null; if ( is_shape ) { new_inst = new SwfDisplayShapeInstance(); + } else if ( is_bitmap ) { + new_inst = new SwfDisplayBitmapInstance(); } else if ( is_sprite ) { new_inst = new SwfDisplaySpriteInstance(); } @@ -101,6 +107,7 @@ namespace FTSwfTools { public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) { var is_shape = tag.HasCharacter && Library.HasDefine(tag.CharacterId); + var is_bitmap = tag.HasCharacter && Library.HasDefine(tag.CharacterId); var is_sprite = tag.HasCharacter && Library.HasDefine(tag.CharacterId); if ( tag.HasCharacter ) { SwfDisplayInstance old_inst = null; @@ -113,6 +120,8 @@ namespace FTSwfTools { SwfDisplayInstance new_inst = null; if ( is_shape ) { new_inst = new SwfDisplayShapeInstance(); + } else if ( is_bitmap ) { + new_inst = new SwfDisplayBitmapInstance(); } else if ( is_sprite ) { new_inst = new SwfDisplaySpriteInstance(); } diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfStreamReader.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfStreamReader.cs index c4cfe95..d3843b2 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfStreamReader.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfStreamReader.cs @@ -32,15 +32,21 @@ namespace FTSwfTools { get { return Position >= Length; } } - public long Length { - get { return _binaryReader.BaseStream.Length; } + public uint Length { + get { + var longLength = _binaryReader.BaseStream.Length; + return longLength < 0 ? 0 : (uint)longLength; + } } - public long Position { - get { return _binaryReader.BaseStream.Position; } + public uint Position { + get { + var longPosition = _binaryReader.BaseStream.Position; + return longPosition < 0 ? 0 : (uint)longPosition; + } } - public long BytesLeft { + public uint BytesLeft { get { return Length - Position; } } @@ -50,7 +56,7 @@ namespace FTSwfTools { } public byte[] ReadRest() { - return ReadBytes((int)BytesLeft); + return ReadBytes(BytesLeft); } public bool ReadBit() { @@ -66,20 +72,22 @@ namespace FTSwfTools { return _binaryReader.ReadByte(); } - public byte[] ReadBytes(int count) { - return count <= 0 - ? new byte[0] - : _binaryReader.ReadBytes(count); + public byte[] ReadBytes(uint count) { + if ( count > (uint)int.MaxValue ) { + throw new IOException(); + } + return _binaryReader.ReadBytes((int)count); } public char ReadChar() { return _binaryReader.ReadChar(); } - public char[] ReadChars(int count) { - return count <= 0 - ? new char[0] - : _binaryReader.ReadChars(count); + public char[] ReadChars(uint count) { + if ( count > (uint)int.MaxValue ) { + throw new IOException(); + } + return _binaryReader.ReadChars((int)count); } public short ReadInt16() { diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject2Tag.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject2Tag.cs index 3617d6d..fb38914 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject2Tag.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject2Tag.cs @@ -73,7 +73,7 @@ namespace FTSwfTools.SwfTags { : (ushort)0; tag.Matrix = tag.HasMatrix - ? SwfMatrix.Read(reader, false) + ? SwfMatrix.Read(reader) : SwfMatrix.identity; tag.ColorTransform = tag.HasColorTransform diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject3Tag.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject3Tag.cs index a8fa900..33b6342 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject3Tag.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObject3Tag.cs @@ -101,7 +101,7 @@ namespace FTSwfTools.SwfTags { tag.HasFilterList = reader.ReadBit(); tag.Depth = reader.ReadUInt16(); - tag.ClassName = (tag.HasClassName || (tag.HasImage && tag.HasCharacter)) + tag.ClassName = tag.HasClassName ? reader.ReadString() : string.Empty; @@ -110,7 +110,7 @@ namespace FTSwfTools.SwfTags { : (ushort)0; tag.Matrix = tag.HasMatrix - ? SwfMatrix.Read(reader, false) + ? SwfMatrix.Read(reader) : SwfMatrix.identity; tag.ColorTransform = tag.HasColorTransform diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObjectTag.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObjectTag.cs index 40f29fe..1d952ba 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObjectTag.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/PlaceObjectTag.cs @@ -26,7 +26,7 @@ namespace FTSwfTools.SwfTags { var tag = new PlaceObjectTag(); tag.CharacterId = reader.ReadUInt16(); tag.Depth = reader.ReadUInt16(); - tag.Matrix = SwfMatrix.Read(reader, false); + tag.Matrix = SwfMatrix.Read(reader); tag.ColorTransform = reader.IsEOF ? SwfColorTransform.identity : SwfColorTransform.Read(reader, false); diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/SwfTagBase.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/SwfTagBase.cs index 7171904..65decf6 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/SwfTagBase.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTags/SwfTagBase.cs @@ -146,7 +146,7 @@ var type_and_size = reader.ReadUInt16(); var tag_id = type_and_size >> 6; var short_size = type_and_size & 0x3f; - var size = short_size < 0x3f ? short_size : reader.ReadInt32(); + var size = short_size < 0x3f ? (uint)short_size : reader.ReadUInt32(); var tag_data = reader.ReadBytes(size); return Create(new SwfTagData{ TagId = tag_id, diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfMatrix.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfMatrix.cs index 9443a5f..b3a3103 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfMatrix.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfMatrix.cs @@ -19,7 +19,7 @@ } } - public static SwfMatrix Read(SwfStreamReader reader, bool fill_style) { + public static SwfMatrix Read(SwfStreamReader reader) { var matrix = SwfMatrix.identity; var has_scale = reader.ReadBit(); if ( has_scale ) { diff --git a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfShapesWithStyle.cs b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfShapesWithStyle.cs index d52f685..25feca4 100644 --- a/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfShapesWithStyle.cs +++ b/Assets/FlashTools/Scripts/Editor/FTSwfTools/SwfTypes/SwfShapesWithStyle.cs @@ -98,7 +98,7 @@ namespace FTSwfTools.SwfTypes { SwfColor.Read(reader, with_alpha); } if ( fill_style.Type.IsGradientType ) { - SwfMatrix.Read(reader, true); // GradientMatrix + SwfMatrix.Read(reader); // GradientMatrix switch ( fill_style.Type.Value ) { case SwfFillStyleType.Type.LinearGradient: case SwfFillStyleType.Type.RadialGradient: @@ -111,7 +111,7 @@ namespace FTSwfTools.SwfTypes { } if ( fill_style.Type.IsBitmapType ) { fill_style.BitmapId = reader.ReadUInt16(); - fill_style.BitmapMatrix = SwfMatrix.Read(reader, true); + fill_style.BitmapMatrix = SwfMatrix.Read(reader); } else { throw new System.Exception( "Imported .swf file contains vector graphics. " + diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 5cd8a63..4ab6326 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.3.7p2 +m_EditorVersion: 5.3.7f1 m_StandardAssetsVersion: 0 diff --git a/ProjectStuff/FlashTools.org b/ProjectStuff/FlashTools.org index 237b7bb..be13906 100644 --- a/ProjectStuff/FlashTools.org +++ b/ProjectStuff/FlashTools.org @@ -64,6 +64,8 @@ https://gist.github.com/talecrafter/111ea3345911bd238f4998b4d5a04bf3 **** TODO Оптимизации по скейлу не влияют на растр **** TODO Не работает конвертация в batchmod'е **** TODO Площадь для оптимизации вычисляется некорректно при повёрнутых клипах +**** DONE Parsing swf error: Failed to read past end of stream +Из-за помеченых для экспорта битмапов (blockers_tmp_0.fla) **** DONE conversion error: 'Error: scaleSelection: Argument number 1 is invalid.' HsiyaoWang/magoichi-test.fla **** TODO Возможно проблемы с DX9 diff --git a/ProjectStuff/swf-file-format-spec-19.pdf b/ProjectStuff/swf-file-format-spec-19.pdf new file mode 100644 index 0000000..21a2b70 Binary files /dev/null and b/ProjectStuff/swf-file-format-spec-19.pdf differ