mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-14 12:11:45 +07:00
Fix (Parsing swf error: Failed to read past end of stream)
This commit is contained in:
9
Assets/DevTests/Animations/BugTests.meta
Normal file
9
Assets/DevTests/Animations/BugTests.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0af1635387aab4e9cb5b38d8722cecf0
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1511462526
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 78561fafa47094aea89ba0771c70c41b
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1511482664
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5cecc5a6be854444ea6d0ee1bac1925f
|
||||||
|
timeCreated: 1511482664
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 056a3e8eb97b34881be36dd1944cce02
|
||||||
|
timeCreated: 1511482664
|
||||||
|
licenseType: Free
|
||||||
|
TextScriptImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
###### Version 1.3.10
|
###### Version 1.3.10
|
||||||
* Fix (conversion error: 'Error: scaleSelection: Argument number 1 is invalid.')
|
* 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
|
###### Version 1.3.9
|
||||||
* Not save generated meshes in scene
|
* Not save generated meshes in scene
|
||||||
|
|||||||
@@ -198,6 +198,19 @@ namespace FTEditor.Postprocessors {
|
|||||||
self_masks,
|
self_masks,
|
||||||
frame);
|
frame);
|
||||||
break;
|
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:
|
case SwfDisplayInstanceType.Sprite:
|
||||||
AddSpriteInstanceToFrame(
|
AddSpriteInstanceToFrame(
|
||||||
library,
|
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<SwfInstanceData> parent_masks,
|
||||||
|
List<SwfInstanceData> self_masks,
|
||||||
|
SwfFrameData frame)
|
||||||
|
{
|
||||||
|
var bitmap_def = library.FindDefine<SwfLibraryBitmapDefine>(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(
|
static void AddSpriteInstanceToFrame(
|
||||||
SwfLibrary library,
|
SwfLibrary library,
|
||||||
SwfDisplaySpriteInstance inst,
|
SwfDisplaySpriteInstance inst,
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ namespace FTSwfTools {
|
|||||||
|
|
||||||
public enum SwfDisplayInstanceType {
|
public enum SwfDisplayInstanceType {
|
||||||
Shape,
|
Shape,
|
||||||
|
Bitmap,
|
||||||
Sprite
|
Sprite
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +94,12 @@ namespace FTSwfTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SwfDisplayBitmapInstance : SwfDisplayInstance {
|
||||||
|
public override SwfDisplayInstanceType Type {
|
||||||
|
get { return SwfDisplayInstanceType.Bitmap; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SwfDisplaySpriteInstance : SwfDisplayInstance {
|
public class SwfDisplaySpriteInstance : SwfDisplayInstance {
|
||||||
public int CurrentTag = 0;
|
public int CurrentTag = 0;
|
||||||
public SwfDisplayList DisplayList = new SwfDisplayList();
|
public SwfDisplayList DisplayList = new SwfDisplayList();
|
||||||
|
|||||||
@@ -33,10 +33,13 @@ namespace FTSwfTools {
|
|||||||
|
|
||||||
public SwfDisplayList Visit(PlaceObjectTag tag, SwfDisplayList dl) {
|
public SwfDisplayList Visit(PlaceObjectTag tag, SwfDisplayList dl) {
|
||||||
var is_shape = Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
|
var is_shape = Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
|
||||||
|
var is_bitmap = Library.HasDefine<SwfLibraryBitmapDefine>(tag.CharacterId);
|
||||||
var is_sprite = Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
|
var is_sprite = Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
|
||||||
SwfDisplayInstance new_inst = null;
|
SwfDisplayInstance new_inst = null;
|
||||||
if ( is_shape ) {
|
if ( is_shape ) {
|
||||||
new_inst = new SwfDisplayShapeInstance();
|
new_inst = new SwfDisplayShapeInstance();
|
||||||
|
} else if ( is_bitmap ) {
|
||||||
|
new_inst = new SwfDisplayBitmapInstance();
|
||||||
} else if ( is_sprite ) {
|
} else if ( is_sprite ) {
|
||||||
new_inst = new SwfDisplaySpriteInstance();
|
new_inst = new SwfDisplaySpriteInstance();
|
||||||
}
|
}
|
||||||
@@ -56,6 +59,7 @@ namespace FTSwfTools {
|
|||||||
|
|
||||||
public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) {
|
public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) {
|
||||||
var is_shape = tag.HasCharacter && Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
|
var is_shape = tag.HasCharacter && Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
|
||||||
|
var is_bitmap = tag.HasCharacter && Library.HasDefine<SwfLibraryBitmapDefine>(tag.CharacterId);
|
||||||
var is_sprite = tag.HasCharacter && Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
|
var is_sprite = tag.HasCharacter && Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
|
||||||
if ( tag.HasCharacter ) {
|
if ( tag.HasCharacter ) {
|
||||||
SwfDisplayInstance old_inst = null;
|
SwfDisplayInstance old_inst = null;
|
||||||
@@ -68,6 +72,8 @@ namespace FTSwfTools {
|
|||||||
SwfDisplayInstance new_inst = null;
|
SwfDisplayInstance new_inst = null;
|
||||||
if ( is_shape ) {
|
if ( is_shape ) {
|
||||||
new_inst = new SwfDisplayShapeInstance();
|
new_inst = new SwfDisplayShapeInstance();
|
||||||
|
} else if ( is_bitmap ) {
|
||||||
|
new_inst = new SwfDisplayBitmapInstance();
|
||||||
} else if ( is_sprite ) {
|
} else if ( is_sprite ) {
|
||||||
new_inst = new SwfDisplaySpriteInstance();
|
new_inst = new SwfDisplaySpriteInstance();
|
||||||
}
|
}
|
||||||
@@ -101,6 +107,7 @@ namespace FTSwfTools {
|
|||||||
|
|
||||||
public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) {
|
public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) {
|
||||||
var is_shape = tag.HasCharacter && Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
|
var is_shape = tag.HasCharacter && Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
|
||||||
|
var is_bitmap = tag.HasCharacter && Library.HasDefine<SwfLibraryBitmapDefine>(tag.CharacterId);
|
||||||
var is_sprite = tag.HasCharacter && Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
|
var is_sprite = tag.HasCharacter && Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
|
||||||
if ( tag.HasCharacter ) {
|
if ( tag.HasCharacter ) {
|
||||||
SwfDisplayInstance old_inst = null;
|
SwfDisplayInstance old_inst = null;
|
||||||
@@ -113,6 +120,8 @@ namespace FTSwfTools {
|
|||||||
SwfDisplayInstance new_inst = null;
|
SwfDisplayInstance new_inst = null;
|
||||||
if ( is_shape ) {
|
if ( is_shape ) {
|
||||||
new_inst = new SwfDisplayShapeInstance();
|
new_inst = new SwfDisplayShapeInstance();
|
||||||
|
} else if ( is_bitmap ) {
|
||||||
|
new_inst = new SwfDisplayBitmapInstance();
|
||||||
} else if ( is_sprite ) {
|
} else if ( is_sprite ) {
|
||||||
new_inst = new SwfDisplaySpriteInstance();
|
new_inst = new SwfDisplaySpriteInstance();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,15 +32,21 @@ namespace FTSwfTools {
|
|||||||
get { return Position >= Length; }
|
get { return Position >= Length; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Length {
|
public uint Length {
|
||||||
get { return _binaryReader.BaseStream.Length; }
|
get {
|
||||||
|
var longLength = _binaryReader.BaseStream.Length;
|
||||||
|
return longLength < 0 ? 0 : (uint)longLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Position {
|
public uint Position {
|
||||||
get { return _binaryReader.BaseStream.Position; }
|
get {
|
||||||
|
var longPosition = _binaryReader.BaseStream.Position;
|
||||||
|
return longPosition < 0 ? 0 : (uint)longPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long BytesLeft {
|
public uint BytesLeft {
|
||||||
get { return Length - Position; }
|
get { return Length - Position; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +56,7 @@ namespace FTSwfTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] ReadRest() {
|
public byte[] ReadRest() {
|
||||||
return ReadBytes((int)BytesLeft);
|
return ReadBytes(BytesLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ReadBit() {
|
public bool ReadBit() {
|
||||||
@@ -66,20 +72,22 @@ namespace FTSwfTools {
|
|||||||
return _binaryReader.ReadByte();
|
return _binaryReader.ReadByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] ReadBytes(int count) {
|
public byte[] ReadBytes(uint count) {
|
||||||
return count <= 0
|
if ( count > (uint)int.MaxValue ) {
|
||||||
? new byte[0]
|
throw new IOException();
|
||||||
: _binaryReader.ReadBytes(count);
|
}
|
||||||
|
return _binaryReader.ReadBytes((int)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char ReadChar() {
|
public char ReadChar() {
|
||||||
return _binaryReader.ReadChar();
|
return _binaryReader.ReadChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] ReadChars(int count) {
|
public char[] ReadChars(uint count) {
|
||||||
return count <= 0
|
if ( count > (uint)int.MaxValue ) {
|
||||||
? new char[0]
|
throw new IOException();
|
||||||
: _binaryReader.ReadChars(count);
|
}
|
||||||
|
return _binaryReader.ReadChars((int)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public short ReadInt16() {
|
public short ReadInt16() {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace FTSwfTools.SwfTags {
|
|||||||
: (ushort)0;
|
: (ushort)0;
|
||||||
|
|
||||||
tag.Matrix = tag.HasMatrix
|
tag.Matrix = tag.HasMatrix
|
||||||
? SwfMatrix.Read(reader, false)
|
? SwfMatrix.Read(reader)
|
||||||
: SwfMatrix.identity;
|
: SwfMatrix.identity;
|
||||||
|
|
||||||
tag.ColorTransform = tag.HasColorTransform
|
tag.ColorTransform = tag.HasColorTransform
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace FTSwfTools.SwfTags {
|
|||||||
tag.HasFilterList = reader.ReadBit();
|
tag.HasFilterList = reader.ReadBit();
|
||||||
tag.Depth = reader.ReadUInt16();
|
tag.Depth = reader.ReadUInt16();
|
||||||
|
|
||||||
tag.ClassName = (tag.HasClassName || (tag.HasImage && tag.HasCharacter))
|
tag.ClassName = tag.HasClassName
|
||||||
? reader.ReadString()
|
? reader.ReadString()
|
||||||
: string.Empty;
|
: string.Empty;
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ namespace FTSwfTools.SwfTags {
|
|||||||
: (ushort)0;
|
: (ushort)0;
|
||||||
|
|
||||||
tag.Matrix = tag.HasMatrix
|
tag.Matrix = tag.HasMatrix
|
||||||
? SwfMatrix.Read(reader, false)
|
? SwfMatrix.Read(reader)
|
||||||
: SwfMatrix.identity;
|
: SwfMatrix.identity;
|
||||||
|
|
||||||
tag.ColorTransform = tag.HasColorTransform
|
tag.ColorTransform = tag.HasColorTransform
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace FTSwfTools.SwfTags {
|
|||||||
var tag = new PlaceObjectTag();
|
var tag = new PlaceObjectTag();
|
||||||
tag.CharacterId = reader.ReadUInt16();
|
tag.CharacterId = reader.ReadUInt16();
|
||||||
tag.Depth = reader.ReadUInt16();
|
tag.Depth = reader.ReadUInt16();
|
||||||
tag.Matrix = SwfMatrix.Read(reader, false);
|
tag.Matrix = SwfMatrix.Read(reader);
|
||||||
tag.ColorTransform = reader.IsEOF
|
tag.ColorTransform = reader.IsEOF
|
||||||
? SwfColorTransform.identity
|
? SwfColorTransform.identity
|
||||||
: SwfColorTransform.Read(reader, false);
|
: SwfColorTransform.Read(reader, false);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@
|
|||||||
var type_and_size = reader.ReadUInt16();
|
var type_and_size = reader.ReadUInt16();
|
||||||
var tag_id = type_and_size >> 6;
|
var tag_id = type_and_size >> 6;
|
||||||
var short_size = type_and_size & 0x3f;
|
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);
|
var tag_data = reader.ReadBytes(size);
|
||||||
return Create(new SwfTagData{
|
return Create(new SwfTagData{
|
||||||
TagId = tag_id,
|
TagId = tag_id,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SwfMatrix Read(SwfStreamReader reader, bool fill_style) {
|
public static SwfMatrix Read(SwfStreamReader reader) {
|
||||||
var matrix = SwfMatrix.identity;
|
var matrix = SwfMatrix.identity;
|
||||||
var has_scale = reader.ReadBit();
|
var has_scale = reader.ReadBit();
|
||||||
if ( has_scale ) {
|
if ( has_scale ) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace FTSwfTools.SwfTypes {
|
|||||||
SwfColor.Read(reader, with_alpha);
|
SwfColor.Read(reader, with_alpha);
|
||||||
}
|
}
|
||||||
if ( fill_style.Type.IsGradientType ) {
|
if ( fill_style.Type.IsGradientType ) {
|
||||||
SwfMatrix.Read(reader, true); // GradientMatrix
|
SwfMatrix.Read(reader); // GradientMatrix
|
||||||
switch ( fill_style.Type.Value ) {
|
switch ( fill_style.Type.Value ) {
|
||||||
case SwfFillStyleType.Type.LinearGradient:
|
case SwfFillStyleType.Type.LinearGradient:
|
||||||
case SwfFillStyleType.Type.RadialGradient:
|
case SwfFillStyleType.Type.RadialGradient:
|
||||||
@@ -111,7 +111,7 @@ namespace FTSwfTools.SwfTypes {
|
|||||||
}
|
}
|
||||||
if ( fill_style.Type.IsBitmapType ) {
|
if ( fill_style.Type.IsBitmapType ) {
|
||||||
fill_style.BitmapId = reader.ReadUInt16();
|
fill_style.BitmapId = reader.ReadUInt16();
|
||||||
fill_style.BitmapMatrix = SwfMatrix.Read(reader, true);
|
fill_style.BitmapMatrix = SwfMatrix.Read(reader);
|
||||||
} else {
|
} else {
|
||||||
throw new System.Exception(
|
throw new System.Exception(
|
||||||
"Imported .swf file contains vector graphics. " +
|
"Imported .swf file contains vector graphics. " +
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 5.3.7p2
|
m_EditorVersion: 5.3.7f1
|
||||||
m_StandardAssetsVersion: 0
|
m_StandardAssetsVersion: 0
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ https://gist.github.com/talecrafter/111ea3345911bd238f4998b4d5a04bf3
|
|||||||
**** TODO Оптимизации по скейлу не влияют на растр
|
**** TODO Оптимизации по скейлу не влияют на растр
|
||||||
**** TODO Не работает конвертация в batchmod'е
|
**** TODO Не работает конвертация в batchmod'е
|
||||||
**** TODO Площадь для оптимизации вычисляется некорректно при повёрнутых клипах
|
**** 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.'
|
**** DONE conversion error: 'Error: scaleSelection: Argument number 1 is invalid.'
|
||||||
HsiyaoWang/magoichi-test.fla
|
HsiyaoWang/magoichi-test.fla
|
||||||
**** TODO Возможно проблемы с DX9
|
**** TODO Возможно проблемы с DX9
|
||||||
|
|||||||
BIN
ProjectStuff/swf-file-format-spec-19.pdf
Normal file
BIN
ProjectStuff/swf-file-format-spec-19.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user