mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-11 15:41:53 +00:00
fix: fix tellTarget handling on old AS version
This commit is contained in:
@@ -355,8 +355,8 @@ public class ActionGraph extends Graph {
|
||||
SetTargetActionItem st = (SetTargetActionItem) it;
|
||||
if (st.target.isEmpty()) {
|
||||
if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
break;
|
||||
targetEnd = t;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
target = new DirectValueActionItem(null, null, 0, st.target, new ArrayList<>());
|
||||
@@ -378,8 +378,8 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
if ((st.target instanceof DirectValueActionItem) && st.target.getResult().equals("")) {
|
||||
if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
break;
|
||||
targetEnd = t;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
targetStart = t;
|
||||
@@ -433,6 +433,8 @@ public class ActionGraph extends Graph {
|
||||
targetStartItem = st;
|
||||
target = new DirectValueActionItem(null, null, 0, st.target, new ArrayList<>());
|
||||
}
|
||||
} else if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
}
|
||||
}
|
||||
if (it instanceof SetTarget2ActionItem) {
|
||||
@@ -445,8 +447,14 @@ public class ActionGraph extends Graph {
|
||||
targetStartItem = st;
|
||||
target = st.target;
|
||||
}
|
||||
} else if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
}
|
||||
}
|
||||
|
||||
if (it instanceof TellTargetActionItem && targetStart > -1) {
|
||||
targetEnd = t;
|
||||
}
|
||||
|
||||
if (targetStart > -1 && targetEnd > -1) {
|
||||
List<GraphTargetItem> newlist = new ArrayList<>();
|
||||
@@ -459,7 +467,7 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
newlist.add(new TellTargetActionItem(targetStartItem.getSrc(), targetStartItem.getLineStartItem(), target, tellist));
|
||||
//TODO: maybe set nested flag
|
||||
for (int i = targetEnd + 1; i < list.size(); i++) {
|
||||
for (int i = targetEnd + (it instanceof TellTargetActionItem ? 0 : 1); i < list.size(); i++) {
|
||||
newlist.add(list.get(i));
|
||||
}
|
||||
list.clear();
|
||||
@@ -467,7 +475,7 @@ public class ActionGraph extends Graph {
|
||||
targetStart = -1;
|
||||
targetEnd = -1;
|
||||
target = null;
|
||||
t = 0;
|
||||
t = -1;
|
||||
}
|
||||
}
|
||||
for (int t = 1/*not first*/; t < list.size(); t++) {
|
||||
|
||||
@@ -627,4 +627,23 @@ public class ActionScript2AssemblerTest extends ActionScript2TestBase {
|
||||
assertEquals(res, "c += 1;");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTellTarget() {
|
||||
String res = decompilePcode("SetTarget \"\"\n"
|
||||
+ "GotoFrame 1\n"
|
||||
+ "SetTarget \"../test\"\n"
|
||||
+ "GoToLabel \"MyLabel\"\n"
|
||||
+ "Play");
|
||||
res = cleanPCode(res);
|
||||
assertEquals(res, "tellTarget(\"\")\n"
|
||||
+ "{\n"
|
||||
+ "gotoAndStop(2);\n"
|
||||
+ "}\n"
|
||||
+ "tellTarget(\"../test\")\n"
|
||||
+ "{\n"
|
||||
+ "gotoAndStop(\"MyLabel\");\n"
|
||||
+ "play();\n"
|
||||
+ "}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user