Make script dumper test use an easier to read script format
This commit is contained in:
@@ -36,7 +36,7 @@ public class ScriptDefinition
|
||||
private int anInt2269;
|
||||
private int[] instructions;
|
||||
private int[] intOperands;
|
||||
private String[] aStringArray2272;
|
||||
private String[] stringOperands;
|
||||
private int localStringCount;
|
||||
private int anInt2276;
|
||||
private int localIntCount;
|
||||
@@ -81,14 +81,14 @@ public class ScriptDefinition
|
||||
this.intOperands = intOperands;
|
||||
}
|
||||
|
||||
public String[] getaStringArray2272()
|
||||
public String[] getStringOperands()
|
||||
{
|
||||
return aStringArray2272;
|
||||
return stringOperands;
|
||||
}
|
||||
|
||||
public void setaStringArray2272(String[] aStringArray2272)
|
||||
public void setStringOperands(String[] stringOperands)
|
||||
{
|
||||
this.aStringArray2272 = aStringArray2272;
|
||||
this.stringOperands = stringOperands;
|
||||
}
|
||||
|
||||
public int getLocalStringCount()
|
||||
|
||||
@@ -56,11 +56,11 @@ public class ScriptLoader
|
||||
|
||||
int[] instructions = new int[paramCount];
|
||||
int[] intOperands = new int[paramCount];
|
||||
String[] aStringArray2272 = new String[paramCount];
|
||||
String[] stringOperands = new String[paramCount];
|
||||
|
||||
def.setInstructions(instructions);
|
||||
def.setIntOperands(intOperands);
|
||||
def.setaStringArray2272(aStringArray2272);
|
||||
def.setStringOperands(stringOperands);
|
||||
|
||||
int var3;
|
||||
for (int var6 = 0; in.getOffset() < in.getLength() - 12; instructions[var6++] = var3)
|
||||
@@ -68,7 +68,7 @@ public class ScriptLoader
|
||||
var3 = in.readUnsignedShort();
|
||||
if (var3 == 3)
|
||||
{
|
||||
aStringArray2272[var6] = in.readString();
|
||||
stringOperands[var6] = in.readString();
|
||||
}
|
||||
else if (var3 < 100 && 21 != var3 && 38 != var3 && 39 != var3)
|
||||
{
|
||||
|
||||
@@ -27,14 +27,13 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.cache;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import net.runelite.cache.definitions.ScriptDefinition;
|
||||
import net.runelite.cache.definitions.loaders.ScriptLoader;
|
||||
import net.runelite.cache.fs.Archive;
|
||||
@@ -78,12 +77,38 @@ public class ScriptDumperTest
|
||||
|
||||
ScriptDefinition script = loader.load(file.getFileId(), contents);
|
||||
|
||||
String str = gson.toJson(script);
|
||||
Files.write(str, new java.io.File(outDir, archive.getArchiveId() + ".script"), Charset.defaultCharset());
|
||||
java.io.File outFile = new java.io.File(outDir, archive.getArchiveId() + ".rs");
|
||||
writeScript(outFile, script);
|
||||
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Dumped {} scripts to {}", count, outDir);
|
||||
}
|
||||
|
||||
private void writeScript(java.io.File file, ScriptDefinition script) throws IOException
|
||||
{
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file)))
|
||||
{
|
||||
int length = script.getInstructions().length;
|
||||
|
||||
assert script.getIntOperands().length == length;
|
||||
assert script.getStringOperands().length == length;
|
||||
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
int opcode = script.getInstructions()[i];
|
||||
int iop = script.getInstructions()[i];
|
||||
String sop = script.getStringOperands()[i];
|
||||
|
||||
writer.write(String.format("0x%03x", opcode));
|
||||
if (iop != 0 || sop != null)
|
||||
writer.write(" " + iop);
|
||||
if (sop != null)
|
||||
writer.write(" " + sop);
|
||||
writer.write("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user