From 5a42865f2e65aba79670c6d057d2408f6976a51a Mon Sep 17 00:00:00 2001 From: Corey Date: Sat, 13 Aug 2022 17:15:42 +0100 Subject: [PATCH] feat: #206 support Yoinked from https://github.com/Displee/cs2-editor/pull/13 --- .../editor/controller/MainController.kt | 10 +++++++--- .../java/dawn/cs2/FlowBlocksGenerator.java | 2 +- src/main/java/dawn/cs2/ast/GlobalVariable.java | 2 +- .../java/dawn/cs2/instructions/Opcodes.java | 1 + .../resources/cs2/opcode/database/osrs.ini | 2 ++ .../resources/cs2/opcode/unscramble/179.txt | 18 +++++++++++++++++- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/displee/editor/controller/MainController.kt b/src/main/java/com/displee/editor/controller/MainController.kt index a0e2192..6ca3751 100644 --- a/src/main/java/com/displee/editor/controller/MainController.kt +++ b/src/main/java/com/displee/editor/controller/MainController.kt @@ -348,9 +348,13 @@ class MainController : Initializable { try { CS2Reader.readCS2ScriptNewFormat(data, id, config.unscrambled, config.disableSwitches, config.disableLongs) } catch(e: Throwable) { - error++ - if (error >= 2) { - break +// error++ +// if (error >= 2) { +// break +// } + if (config.version == 179) { + println(e) + println("id $id") } } } diff --git a/src/main/java/dawn/cs2/FlowBlocksGenerator.java b/src/main/java/dawn/cs2/FlowBlocksGenerator.java index 7cf926e..55bf753 100644 --- a/src/main/java/dawn/cs2/FlowBlocksGenerator.java +++ b/src/main/java/dawn/cs2/FlowBlocksGenerator.java @@ -262,7 +262,7 @@ private void processFlowBlock(FlowBlock block) { ExpressionNode value = stack.pop(); ExpressionNode index = CS2Type.cast(stack.pop(), CS2Type.INT); block.write(new PopableNode(new ArrayStoreNode(intInstr.getConstant(), index, value))); - } else if (opcode == 47) { + } else if (opcode == 47 || opcode == 49) { stack.push(new VariableLoadNode(GlobalVariable.VARC_STRING(intInstr.getConstant()))); } else if (opcode == 106) { stack.push(new VariableLoadNode(GlobalVariable.find("CLAN", intInstr.getConstant(), CS2Type.INT))); diff --git a/src/main/java/dawn/cs2/ast/GlobalVariable.java b/src/main/java/dawn/cs2/ast/GlobalVariable.java index 7628940..13a9176 100644 --- a/src/main/java/dawn/cs2/ast/GlobalVariable.java +++ b/src/main/java/dawn/cs2/ast/GlobalVariable.java @@ -102,7 +102,7 @@ public AbstractInstruction generateLoadInstruction() { op = Opcodes.LOAD_VARC; break; case "STRING": - op = Opcodes.LOAD_VARCSTR; + op = Opcodes.LOAD_VARCSTR_NEW; break; //These are READONLY, some are not even used case "CLANDEF_STRING115": diff --git a/src/main/java/dawn/cs2/instructions/Opcodes.java b/src/main/java/dawn/cs2/instructions/Opcodes.java index 866c992..73a19e6 100644 --- a/src/main/java/dawn/cs2/instructions/Opcodes.java +++ b/src/main/java/dawn/cs2/instructions/Opcodes.java @@ -25,6 +25,7 @@ public class Opcodes { public static final int STORE_VARP = 2; public static final int LOAD_VARC = 42; public static final int LOAD_VARCSTR = 47; + public static final int LOAD_VARCSTR_NEW = 49; public static final int STORE_VARC = 43; public static final int LOAD_VARPBIT = 25; public static final int SWITCH = 51; diff --git a/src/main/resources/cs2/opcode/database/osrs.ini b/src/main/resources/cs2/opcode/database/osrs.ini index f286671..c4c7818 100644 --- a/src/main/resources/cs2/opcode/database/osrs.ini +++ b/src/main/resources/cs2/opcode/database/osrs.ini @@ -1972,6 +1972,8 @@ 7006 cs2method7006 void +10034 cs2Method10034 string int arg0 int arg1 string string2 string string3 +10035 cs2Method10035 int arg0 # OSRS 21000 setPosition void int x int y diff --git a/src/main/resources/cs2/opcode/unscramble/179.txt b/src/main/resources/cs2/opcode/unscramble/179.txt index 69fc855..f17c776 100644 --- a/src/main/resources/cs2/opcode/unscramble/179.txt +++ b/src/main/resources/cs2/opcode/unscramble/179.txt @@ -182,6 +182,19 @@ 1117 1117 1118 1118 1119 1119 +1130 1130 +1434 1434 +6231 6231 +3178 3178 +3500 3500 +1707 1707 +4213 4213 +6232 6232 +1928 1928 + +1131 1131 +3212 3212 +3214 3214 1120 1120 1200 1200 1201 1201 @@ -407,6 +420,8 @@ 3207 3207 3208 3208 3209 3209 +3213 3213 +3215 3215 3300 3300 3301 3301 3302 3302 @@ -830,6 +845,7 @@ 6304 6304 6305 6305 6306 6306 +6307 6307 6405 6405 6406 6406 6500 6500 @@ -1084,4 +1100,4 @@ 7454 7454 7455 7455 7456 7456 -7460 7460 +7460 7460 \ No newline at end of file