Fixed: Flash viewer- cyclic DefineSprite usage

This commit is contained in:
Jindra Petřík
2021-03-03 18:00:55 +01:00
parent af7f30cd53
commit ec0d890fd2
2 changed files with 32 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file.
- Copying to clipboard does not support transparency
- #1634 AS3 slot/const editor loses focus on edit button press
- #1636 Exception after search - traitslist with not properly set abc, other ui exception
- Flash viewer- cyclic DefineSprite usage
### Removed
- #1631 ActiveX Flash component download in windows installer

View File

@@ -306,6 +306,13 @@ public class Timeline {
if (characterId != -1) {
fl.characterId = characterId;
}
CharacterTag character = swf.getCharacter(characterId);
if (character instanceof DefineSpriteTag) {
Stack<Integer> cyStack = new Stack<>();
if (isCyclic(timelined, cyStack)) {
fl.characterId = -1;
}
}
if (po.flagMove()) {
MATRIX matrix2 = po.getMatrix();
if (matrix2 != null) {
@@ -1215,4 +1222,28 @@ public class Timeline {
return false;
}
private boolean isCyclic(Timelined tim, Stack<Integer> walked) {
for (Tag t : tim.getTags()) {
if (t instanceof PlaceObjectTypeTag) {
PlaceObjectTypeTag p = (PlaceObjectTypeTag) t;
int chid = p.getCharacterId();
if (chid != -1) {
if (walked.contains(chid)) {
return true;
}
CharacterTag character = swf.getCharacter(chid);
if (character instanceof DefineSpriteTag) {
walked.push(chid);
if (isCyclic((DefineSpriteTag) character, walked)) {
walked.pop();
return true;
}
walked.pop();
}
}
}
}
return false;
}
}