Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-01-23 12:57:53 +01:00
19 changed files with 1390 additions and 131 deletions

View File

@@ -43,6 +43,7 @@ public enum ConfigType
VARCLIENT(19),
VARCLIENTSTRING(15),
VARPLAYER(16),
HITSPLAT(32),
STRUCT(34),
AREA(35);

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2020, Hexagon <hexagon@fking.work>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (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.definitions;
import lombok.Data;
@Data
public class HitSplatDefinition
{
private String stringFormat = "";
private int varbitID = -1;
private int leftSprite = -1;
private int leftSprite2 = -1;
private int rightSpriteId = -1;
private int fontType = -1;
private int backgroundSprite = -1;
private int varpID = -1;
private int useDamage = -1;
private int textColor = 0xFFFFFF;
private int displayCycles = 70;
private int[] multihitsplats;
private int scrollToOffsetX = 0;
private int fadeStartCycle = -1;
private int scrollToOffsetY = 0;
private int textOffsetY = 0;
}

View File

@@ -46,7 +46,7 @@ public class InterfaceDefinition
public int scrollWidth;
public int scrollHeight;
public boolean noClickThrough;
public int spriteId;
public int spriteId = -1;
public int textureId;
public boolean spriteTiling;
public int opacity;
@@ -54,34 +54,34 @@ public class InterfaceDefinition
public int shadowColor;
public boolean flippedVertically;
public boolean flippedHorizontally;
public int modelType;
public int modelId;
public int modelType = 1;
public int modelId = -1;
public int offsetX2d;
public int offsetY2d;
public int rotationX;
public int rotationY;
public int rotationZ;
public int modelZoom;
public int animation;
public int modelZoom = 100;
public int animation = -1;
public boolean orthogonal;
public int modelHeightOverride;
public int fontId;
public String text;
public int fontId = -1;
public String text = "";
public int lineHeight;
public int xTextAlignment;
public int yTextAlignment;
public boolean textShadowed;
public int textColor;
public boolean filled;
public int lineWidth;
public int lineWidth = 1;
public boolean lineDirection;
public int clickMask;
public String name;
public String name = "";
public String[] actions;
public int dragDeadZone;
public int dragDeadTime;
public boolean dragRenderBehavior;
public String targetVerb;
public String targetVerb = "";
public Object[] onLoadListener;
public Object[] onMouseOverListener;
public Object[] onMouseLeaveListener;
@@ -119,13 +119,13 @@ public class InterfaceDefinition
public int[] yOffsets;
public int[] sprites;
public String[] configActions;
public String alternateText;
public String alternateText = "";
public int alternateTextColor;
public int hoveredTextColor;
public int alternateHoveredTextColor;
public int alternateSpriteId;
public int alternateModelId;
public int alternateAnimation;
public String spellName;
public String tooltip;
public int alternateSpriteId = -1;
public int alternateModelId = -1;
public int alternateAnimation = -1;
public String spellName = "";
public String tooltip = "Ok";
}

View File

@@ -33,13 +33,13 @@ public class WorldMapDefinition
{
public String name;
public int field450;
public int field451;
public int defaultZoom;
public int fileId;
public int field453;
public int field454;
public int field456;
public boolean field457;
public List field458;
public boolean isSurface;
public List regionList;
public String safeName;
public Position position;
public int field463;

View File

@@ -29,14 +29,14 @@ import lombok.Data;
@Data
public class WorldMapType0 implements WorldMapTypeBase
{
public int field600;
public int field601;
public int field602;
public int field603;
public int field604;
public int field605;
public int field606;
public int field607;
public int field608;
public int field609;
public int chunk_xHigh;
public int xLow;
public int chunk_xLow;
public int yLow;
public int xHigh;
public int numberOfPlanes;
public int plane;
public int chunk_yLow;
public int yHigh;
public int chunk_yHigh;
}

View File

@@ -29,14 +29,14 @@ import lombok.Data;
@Data
public class WorldMapType1 implements WorldMapTypeBase
{
public int field424;
public int field425;
public int field426;
public int field427;
public int field428;
public int field429;
public int field431;
public int field433;
public int field434;
public int field435;
public int numberOfPlanes;
public int xLowerLeft;
public int yLowerLeft;
public int xLowerRight;
public int yLowerRight;
public int xUpperLeft;
public int yUpperLeft;
public int xUpperRight;
public int plane;
public int yUpperRight;
}

View File

@@ -29,10 +29,10 @@ import lombok.Data;
@Data
public class WorldMapType2 implements WorldMapTypeBase
{
public int field510;
public int field511;
public int field512;
public int field514;
public int field515;
public int field519;
public int xLow;
public int numberOfPlanes;
public int yLow;
public int xHigh;
public int yHigh;
public int plane;
}

View File

@@ -29,18 +29,18 @@ import lombok.Data;
@Data
public class WorldMapType3 implements WorldMapTypeBase
{
public int field376;
public int field377;
public int field378;
public int field379;
public int field380;
public int field381;
public int field382;
public int field383;
public int field384;
public int field385;
public int field386;
public int field387;
public int field388;
public int field389;
public int chunk_oldXHigh;
public int numberOfPlanes;
public int oldX;
public int chunk_oldYHigh;
public int newX;
public int newY;
public int chunk_oldXLow;
public int oldY;
public int chunk_newYLow;
public int chunk_oldYLow;
public int chunk_newXLow;
public int oldPlane;
public int chunk_newXHigh;
public int chunk_newYHigh;
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2020, Hexagon <hexagon@fking.work>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (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.definitions.loaders;
import net.runelite.cache.definitions.HitSplatDefinition;
import net.runelite.cache.io.InputStream;
public class HitSplatLoader
{
public HitSplatDefinition load(byte[] data)
{
HitSplatDefinition def = new HitSplatDefinition();
InputStream stream = new InputStream(data);
for (; ; )
{
int opcode = stream.readUnsignedByte();
switch (opcode)
{
case 0:
return def;
case 1:
def.setFontType(stream.readBigSmart2());
break;
case 2:
def.setTextColor(stream.read24BitInt());
break;
case 3:
def.setLeftSprite(stream.readBigSmart2());
break;
case 4:
def.setLeftSprite2(stream.readBigSmart2());
break;
case 5:
def.setBackgroundSprite(stream.readBigSmart2());
break;
case 6:
def.setRightSpriteId(stream.readBigSmart2());
break;
case 7:
def.setScrollToOffsetX(stream.readShort());
break;
case 8:
def.setStringFormat(stream.readString2());
break;
case 9:
def.setDisplayCycles(stream.readUnsignedShort());
break;
case 10:
def.setScrollToOffsetY(stream.readShort());
break;
case 11:
def.setFadeStartCycle(0);
break;
case 12:
def.setUseDamage(stream.readUnsignedByte());
break;
case 13:
def.setTextOffsetY(stream.readShort());
break;
case 14:
def.setFadeStartCycle(stream.readUnsignedShort());
break;
case 17:
case 18:
int varbitId = stream.readUnsignedShort();
if (varbitId == 0xFFFF)
{
varbitId = -1;
}
def.setVarbitID(varbitId);
int varp = stream.readUnsignedShort();
if (varp == 0xFFFF)
{
varp = -1;
}
def.setVarpID(varp);
int id = -1;
if (opcode == 18)
{
id = stream.readUnsignedShort();
if (id == 0xFFFF)
{
id = -1;
}
}
int length = stream.readUnsignedByte();
int[] multihitsplats = new int[length + 2];
for (int i = 0; i <= length; i++)
{
multihitsplats[i] = stream.readUnsignedShort();
if (multihitsplats[i] == 0xFFFF)
{
multihitsplats[i] = -1;
}
}
multihitsplats[length + 1] = id;
def.setMultihitsplats(multihitsplats);
break;
}
}
}
}

View File

@@ -61,14 +61,14 @@ public class WorldMapLoader
def.field450 = in.readInt();
in.readUnsignedByte();
def.field457 = in.readUnsignedByte() == 1;
def.field451 = in.readUnsignedByte();
def.isSurface = in.readUnsignedByte() == 1;
def.defaultZoom = in.readUnsignedByte();
int var3 = in.readUnsignedByte();
def.field458 = new LinkedList();
def.regionList = new LinkedList();
for (int var4 = 0; var4 < var3; ++var4)
{
def.field458.add(this.loadType(in));
def.regionList.add(this.loadType(in));
}
return def;
@@ -110,16 +110,16 @@ public class WorldMapLoader
{
WorldMapType0 wm = new WorldMapType0();
wm.field606 = in.readUnsignedByte();
wm.field605 = in.readUnsignedByte();
wm.field601 = in.readUnsignedShort();
wm.field602 = in.readUnsignedByte();
wm.field603 = in.readUnsignedShort();
wm.field607 = in.readUnsignedByte();
wm.field604 = in.readUnsignedShort();
wm.field600 = in.readUnsignedByte();
wm.field608 = in.readUnsignedShort();
wm.field609 = in.readUnsignedByte();
wm.plane = in.readUnsignedByte();
wm.numberOfPlanes = in.readUnsignedByte();
wm.xLow = in.readUnsignedShort();
wm.chunk_xLow = in.readUnsignedByte();
wm.yLow = in.readUnsignedShort();
wm.chunk_yLow = in.readUnsignedByte();
wm.xHigh = in.readUnsignedShort();
wm.chunk_xHigh = in.readUnsignedByte();
wm.yHigh = in.readUnsignedShort();
wm.chunk_yHigh = in.readUnsignedByte();
return wm;
}
@@ -128,16 +128,16 @@ public class WorldMapLoader
{
WorldMapType1 wm = new WorldMapType1();
wm.field434 = in.readUnsignedByte();
wm.field424 = in.readUnsignedByte();
wm.field425 = in.readUnsignedShort();
wm.field426 = in.readUnsignedShort();
wm.field427 = in.readUnsignedShort();
wm.field431 = in.readUnsignedShort();
wm.field429 = in.readUnsignedShort();
wm.field428 = in.readUnsignedShort();
wm.field433 = in.readUnsignedShort();
wm.field435 = in.readUnsignedShort();
wm.plane = in.readUnsignedByte();
wm.numberOfPlanes = in.readUnsignedByte();
wm.xLowerLeft = in.readUnsignedShort();
wm.yLowerLeft = in.readUnsignedShort();
wm.xLowerRight = in.readUnsignedShort();
wm.yUpperLeft = in.readUnsignedShort();
wm.xUpperLeft = in.readUnsignedShort();
wm.yLowerRight = in.readUnsignedShort();
wm.xUpperRight = in.readUnsignedShort();
wm.yUpperRight = in.readUnsignedShort();
return wm;
}
@@ -146,12 +146,12 @@ public class WorldMapLoader
{
WorldMapType2 wm = new WorldMapType2();
wm.field519 = in.readUnsignedByte();
wm.field511 = in.readUnsignedByte();
wm.field510 = in.readUnsignedShort();
wm.field512 = in.readUnsignedShort();
wm.field514 = in.readUnsignedShort();
wm.field515 = in.readUnsignedShort();
wm.plane = in.readUnsignedByte();
wm.numberOfPlanes = in.readUnsignedByte();
wm.xLow = in.readUnsignedShort();
wm.yLow = in.readUnsignedShort();
wm.xHigh = in.readUnsignedShort();
wm.yHigh = in.readUnsignedShort();
return wm;
}
@@ -160,20 +160,20 @@ public class WorldMapLoader
{
WorldMapType3 wm = new WorldMapType3();
wm.field387 = in.readUnsignedByte();
wm.field377 = in.readUnsignedByte();
wm.field378 = in.readUnsignedShort();
wm.field382 = in.readUnsignedByte();
wm.field376 = in.readUnsignedByte();
wm.field383 = in.readUnsignedShort();
wm.field385 = in.readUnsignedByte();
wm.field379 = in.readUnsignedByte();
wm.field380 = in.readUnsignedShort();
wm.field386 = in.readUnsignedByte();
wm.field388 = in.readUnsignedByte();
wm.field381 = in.readUnsignedShort();
wm.field384 = in.readUnsignedByte();
wm.field389 = in.readUnsignedByte();
wm.oldPlane = in.readUnsignedByte();
wm.numberOfPlanes = in.readUnsignedByte();
wm.oldX = in.readUnsignedShort();
wm.chunk_oldXLow = in.readUnsignedByte();
wm.chunk_oldXHigh = in.readUnsignedByte();
wm.oldY = in.readUnsignedShort();
wm.chunk_oldYLow = in.readUnsignedByte();
wm.chunk_oldYHigh = in.readUnsignedByte();
wm.newX = in.readUnsignedShort();
wm.chunk_newXLow = in.readUnsignedByte();
wm.chunk_newXHigh = in.readUnsignedByte();
wm.newY = in.readUnsignedShort();
wm.chunk_newYLow = in.readUnsignedByte();
wm.chunk_newYHigh = in.readUnsignedByte();
return wm;
}

View File

@@ -200,6 +200,18 @@ public class InputStream extends java.io.InputStream
return sb.toString();
}
public String readString2()
{
if (this.readByte() != 0)
{
throw new IllegalStateException("Invalid jstr2");
}
else
{
return readString();
}
}
public String readStringOrNull()
{
if (this.peek() != 0)

View File

@@ -0,0 +1,88 @@
/*
* Copyright (c) 2020, Hexagon <hexagon@fking.work>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (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.File;
import java.io.IOException;
import java.nio.charset.Charset;
import lombok.extern.slf4j.Slf4j;
import net.runelite.cache.definitions.HitSplatDefinition;
import net.runelite.cache.definitions.loaders.HitSplatLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@Slf4j
public class HitSplatDumper
{
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
@Rule
public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test
@Ignore
public void test() throws IOException
{
File dumpDir = folder.newFolder();
int count = 0;
try (Store store = new Store(StoreLocation.LOCATION))
{
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.HITSPLAT.getId());
HitSplatLoader loader = new HitSplatLoader();
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
byte[] b = file.getContents();
HitSplatDefinition def = loader.load(b);
Files.asCharSink(new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(def));
++count;
}
}
log.info("Dumped {} hitsplats to {}", count, dumpDir);
}
}