project: bringup api - thank you blue!

This commit is contained in:
TheRealNull
2021-01-04 01:25:09 -05:00
parent c0127ef8f6
commit 02b856556c
23 changed files with 188 additions and 85 deletions

View File

@@ -2064,14 +2064,11 @@ public interface Client extends GameShell
List<String> getOutdatedScripts();
//TODO: Implement
void queueChangedVarp(int varp);
//TODO: Implement
VarbitComposition getVarbit(Integer id);
VarbitComposition getVarbit(int id);
Widget getWidget(int param1);
//TODO: Implement
Widget getScriptActiveWidget();
}

View File

@@ -36,5 +36,5 @@ public interface MainBufferProvider extends BufferProvider
*
* @return the loaded image
*/
Image getImage(); //TODO
Image getImage();
}

View File

@@ -56,6 +56,62 @@ public interface SpritePixels
*/
int getHeight();
/**
* Gets the max width of the sprite image in pixels.
*
* @return the width
*/
int getMaxWidth();
/**
* Gets the max height of the sprite image in pixels.
*
* @return the height
*/
int getMaxHeight();
/**
* Gets the x offset of the sprite image in pixels.
*
* @return the offset
*/
int getOffsetX();
/**
* Gets the y offset of the sprite image in pixels.
*
* @return the offset
*/
int getOffsetY();
/**
* Sets the max width of the sprite image in pixels.
*
* @param maxWidth the width
*/
void setMaxWidth(int maxWidth);
/**
* Sets the max height of the sprite image in pixels.
*
* @param maxHeight the height
*/
void setMaxHeight(int maxHeight);
/**
* Sets the x offset of the sprite image in pixels.
*
* @param offsetX the offset
*/
void setOffsetX(int offsetX);
/**
* Sets the y offset of the sprite image in pixels.
*
* @param offsetY the offset
*/
void setOffsetY(int offsetY);
/**
* Gets an array of all pixels data in the sprite.
*
@@ -92,20 +148,4 @@ public interface SpritePixels
* @param color target color
*/
void toBufferedOutline(BufferedImage img, int color);
int getMaxWidth();
void setMaxWidth(int maxWidth);
int getMaxHeight();
void setMaxHeight(int maxHeight);
int getOffsetX();
void setOffsetX(int offsetX);
int getOffsetY();
void setOffsetY(int offsetY);
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020 Abex
* 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.api.events;
import net.runelite.api.Client;
/**
* Posted when the game world the client wants to connect to has changed
* This is posted after the world ID and type have updated, but before a new
* connection is established
*
* @see Client#getWorld()
* @see Client#getWorldType()
*/
public class WorldChanged
{
}

View File

@@ -77,6 +77,7 @@ import net.runelite.api.Skill;
import net.runelite.api.SpritePixels;
import net.runelite.api.Tile;
import net.runelite.api.VarPlayer;
import net.runelite.api.VarbitComposition;
import net.runelite.api.Varbits;
import net.runelite.api.WidgetNode;
import net.runelite.api.WorldType;
@@ -106,6 +107,7 @@ import net.runelite.api.events.UsernameChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.events.VolumeChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.events.WorldChanged;
import net.runelite.api.hooks.Callbacks;
import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.api.mixins.Copy;
@@ -140,6 +142,7 @@ import net.runelite.rs.api.RSTile;
import net.runelite.rs.api.RSTileItem;
import net.runelite.rs.api.RSUsername;
import net.runelite.rs.api.RSWidget;
import net.runelite.rs.api.RSWorld;
import org.slf4j.Logger;
@Mixin(RSClient.class)
@@ -2071,12 +2074,38 @@ public abstract class RSClientMixin implements RSClient
if (!outdatedScripts.contains(outdatedScript))
outdatedScripts.add(outdatedScript);
}
@Inject
@Override
public List<String> getOutdatedScripts()
{
return this.outdatedScripts;
}
@Inject
@MethodHook(value = "changeWorld", end = true)
public static void postChangeWorld(RSWorld world)
{
client.getCallbacks().post(new WorldChanged());
}
@Inject
@Override
public void queueChangedVarp(int varp)
{
assert client.isClientThread() : "queueChangedVarp must be called on client thread";
int[] changedVarps = client.getChangedVarps();
int changedVarpCount = client.getChangedVarpCount();
changedVarps[changedVarpCount & 31] = varp;
client.setChangedVarpCount(changedVarpCount + 1);
}
@Inject
@Override
public VarbitComposition getVarbit(int id)
{
return getVarbitDefinition(id);
}
}

View File

@@ -288,18 +288,10 @@ public abstract class RSPlayerMixin implements RSPlayer
friended = client.getFriendManager().isFriended(getRsName(), false);
}
@Copy("read")
@Replace("read")
@SuppressWarnings("InfiniteRecursion")
public void copy$read(RSBuffer buffer)
@Inject
@MethodHook(value = "read", end = true)
void postRead(RSBuffer var1)
{
final long appearanceHash = getPlayerComposition() == null ? 0 : getPlayerComposition().getHash();
this.copy$read(buffer);
if (client.isComparingAppearance() && getPlayerComposition().getHash() != appearanceHash)
{
client.getCallbacks().post(new PlayerChanged(this));
}
client.getCallbacks().post(new PlayerChanged(this));
}
}

View File

@@ -57,28 +57,19 @@ public abstract class VarbitMixin implements RSClient
@Override
public RSVarbitComposition getVarbitDefinition(int id)
{
assert isClientThread();
assert client.isClientThread() : "getVarbitDefinition must be called on client thread";
RSVarbitComposition varbit;
varbit = varbitCache.getIfPresent(id);
if (varbit != null)
RSVarbitComposition varbit = varbitCache.getIfPresent(id);
if (varbit == null)
{
return varbit;
}
varbit = (RSVarbitComposition) getVarbitCache().get(id);
if (varbit != null && !(varbit.getIndex() == 0 && varbit.getMostSignificantBit() == 0 && varbit.getLeastSignificantBit() == 0))
{
return varbit;
client.getLogger().trace("Cache miss for varbit {}", id);
client.rs$getVarbit(id); // preload varbit
varbit = (RSVarbitComposition) getVarbitCache().get(id);
varbitCache.put(id, varbit);
}
byte[] fileData = getIndexConfig().getConfigData(VARBITS_GROUP, id);
if (fileData == null)
{
return null;
}
varbit = newVarbitDefinition();
varbit.decode(newBuffer(fileData));
return varbit;
return varbit.getIndex() == 0 && varbit.getLeastSignificantBit() == 0 && varbit.getMostSignificantBit() == 0 ? null : varbit;
}
@Inject
@@ -90,7 +81,7 @@ public abstract class VarbitMixin implements RSClient
RSVarbitComposition v = getVarbitDefinition(varbitId);
if (v == null)
{
throw new IndexOutOfBoundsException(String.format("Varbit %d does not exist!", varbitId)); // oob for "backwards compatibility lol"
throw new IndexOutOfBoundsException("Varbit " + varbitId + " does not exist!"); // oob for "backwards compatibility lol"
}
int value = varps[v.getIndex()];

View File

@@ -686,7 +686,7 @@ public interface RSClient extends RSGameShell, Client
RSUsername createName(String name, RSLoginType type);
@Import("getVarbit")
int getVarbit(int varbitId);
int rs$getVarbit(int varbitId);
@Import("VarbitDefinition_cached")
RSEvictingDualNodeHashTable getVarbitCache();
@@ -1314,4 +1314,16 @@ public interface RSClient extends RSGameShell, Client
@Import("viewportColor")
void setViewportColor(int i);
@Import("changedVarps")
int[] getChangedVarps();
@Import("changedVarpCount")
int getChangedVarpCount();
@Import("changedVarpCount")
void setChangedVarpCount(int changedVarpCount);
@Import("scriptActiveWidget")
RSWidget getScriptActiveWidget();
}

View File

@@ -175,7 +175,8 @@ public final class Client extends GameShell implements Usernamed {
@ObfuscatedGetter(
intValue = 1311691811
)
static int field835;
@Export("changedVarpCount")
static int changedVarpCount;
@ObfuscatedName("tc")
static int[] field920;
@ObfuscatedName("tr")
@@ -390,7 +391,8 @@ public final class Client extends GameShell implements Usernamed {
@Export("viewportHeight")
static int viewportHeight;
@ObfuscatedName("nq")
static int[] field834;
@Export("changedVarps")
static int[] changedVarps;
@ObfuscatedName("rh")
@ObfuscatedGetter(
intValue = -1202571805
@@ -1471,8 +1473,8 @@ public final class Client extends GameShell implements Usernamed {
field862 = -1; // L: 509
isDraggingWidget = false; // L: 510
cycleCntr = 1; // L: 515
field834 = new int[32]; // L: 518
field835 = 0; // L: 519
changedVarps = new int[32]; // L: 518
changedVarpCount = 0; // L: 519
changedItemContainers = new int[32]; // L: 520
field837 = 0; // L: 521
changedSkills = new int[32]; // L: 522
@@ -4417,7 +4419,7 @@ public final class Client extends GameShell implements Usernamed {
}
class195.method3681(); // L: 5700
field835 += 32; // L: 5701
changedVarpCount += 32; // L: 5701
var1.serverPacket = null; // L: 5702
return true; // L: 5703
}
@@ -4983,7 +4985,7 @@ public final class Client extends GameShell implements Usernamed {
}
Script.changeGameOptions(var5); // L: 6129
field834[++field835 - 1 & 31] = var5; // L: 6130
changedVarps[++changedVarpCount - 1 & 31] = var5; // L: 6130
var1.serverPacket = null; // L: 6131
return true; // L: 6132
}
@@ -5008,7 +5010,7 @@ public final class Client extends GameShell implements Usernamed {
if (Varps.Varps_main[var16] != Varps.Varps_temp[var16]) { // L: 6144
Varps.Varps_main[var16] = Varps.Varps_temp[var16]; // L: 6145
Script.changeGameOptions(var16); // L: 6146
field834[++field835 - 1 & 31] = var16; // L: 6147
changedVarps[++changedVarpCount - 1 & 31] = var16; // L: 6147
}
}
@@ -5207,7 +5209,7 @@ public final class Client extends GameShell implements Usernamed {
}
Script.changeGameOptions(var5); // L: 6297
field834[++field835 - 1 & 31] = var5; // L: 6298
changedVarps[++changedVarpCount - 1 & 31] = var5; // L: 6298
var1.serverPacket = null; // L: 6299
return true; // L: 6300
}

View File

@@ -96,7 +96,7 @@ public class Frames extends DualNode {
if (var0 != ScriptOpcodes.CC_CALLONRESIZE && var0 != ScriptOpcodes.IF_CALLONRESIZE) { // L: 1145
int var4;
if (var0 == 1928) { // L: 1162
var6 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1163
var6 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1163
var4 = Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]; // L: 1164
if (var4 >= 1 && var4 <= 10) { // L: 1165
class3.widgetDefaultMenuAction(var4, var6.id, var6.childIndex, var6.itemId, ""); // L: 1168
@@ -124,7 +124,7 @@ public class Frames extends DualNode {
if (var0 >= 2000) { // L: 1150
var6 = CollisionMap.getWidget(Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]); // L: 1151
} else {
var6 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1153
var6 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1153
}
if (var6.onResize == null) { // L: 1154

View File

@@ -75,7 +75,7 @@ final class GrandExchangeOfferUnitPriceComparator implements Comparator {
garbageValue = "-613147121"
)
static int method200(int var0, Script var1, boolean var2) {
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1041
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1041
if (var0 == ScriptOpcodes.CC_GETSCROLLX) { // L: 1042
Interpreter.Interpreter_intStack[++VarcInt.Interpreter_intStackSize - 1] = var3.scrollX; // L: 1043
return 1; // L: 1044

View File

@@ -63,7 +63,7 @@ public class Messages {
garbageValue = "-729014462"
)
static int method2283(int var0, Script var1, boolean var2) {
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1012
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1012
if (var0 == ScriptOpcodes.CC_GETX) { // L: 1013
Interpreter.Interpreter_intStack[++VarcInt.Interpreter_intStackSize - 1] = var3.x; // L: 1014
return 1; // L: 1015

View File

@@ -131,7 +131,7 @@ public enum ModeWhere implements Enumerated {
var0 -= 1000; // L: 948
var3 = CollisionMap.getWidget(Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]); // L: 949
} else {
var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 951
var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 951
}
String var4 = Interpreter.Interpreter_stringStack[--Interpreter.Interpreter_stringStackSize]; // L: 952

View File

@@ -608,11 +608,11 @@ public class Players {
ScriptEvent var25;
int var35;
int var36;
if (var9.onVarTransmit != null && Client.field835 > var9.field2645) { // L: 10208
if (var9.varTransmitTriggers != null && Client.field835 - var9.field2645 <= 32) { // L: 10209
if (var9.onVarTransmit != null && Client.changedVarpCount > var9.field2645) { // L: 10208
if (var9.varTransmitTriggers != null && Client.changedVarpCount - var9.field2645 <= 32) { // L: 10209
label777:
for (var36 = var9.field2645; var36 < Client.field835; ++var36) { // L: 10216
var23 = Client.field834[var36 & 31]; // L: 10217
for (var36 = var9.field2645; var36 < Client.changedVarpCount; ++var36) { // L: 10216
var23 = Client.changedVarps[var36 & 31]; // L: 10217
for (var35 = 0; var35 < var9.varTransmitTriggers.length; ++var35) { // L: 10218
if (var23 == var9.varTransmitTriggers[var35]) { // L: 10219
@@ -631,7 +631,7 @@ public class Players {
Client.scriptEvents.addFirst(var22); // L: 10213
}
var9.field2645 = Client.field835; // L: 10229
var9.field2645 = Client.changedVarpCount; // L: 10229
}
if (var9.onInvTransmit != null && Client.field837 > var9.field2721) { // L: 10231

View File

@@ -50,7 +50,7 @@ public class ScriptFrame {
var4 = CollisionMap.getWidget(Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]); // L: 778
var3 = false; // L: 779
} else {
var4 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 781
var4 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 781
}
int var11;

View File

@@ -64,7 +64,7 @@ public class UserComparator9 extends AbstractUserComparator {
var0 -= 1000; // L: 735
var3 = CollisionMap.getWidget(Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]); // L: 736
} else {
var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 738
var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 738
}
CollisionMap.invalidateWidget(var3); // L: 739

View File

@@ -29,7 +29,8 @@ public class VarcInt extends DualNode {
@ObfuscatedSignature(
descriptor = "Lhe;"
)
static Widget field3264;
@Export("scriptActiveWidget")
static Widget scriptActiveWidget;
@ObfuscatedName("x")
@Export("persist")
public boolean persist;

View File

@@ -188,7 +188,7 @@ public class WorldMapData_1 extends AbstractWorldMapData {
var4 = Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]; // L: 553
var3 = CollisionMap.getWidget(var4); // L: 554
} else {
var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 556
var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 556
}
if (var0 == ScriptOpcodes.CC_SETSCROLLPOS) { // L: 557

View File

@@ -119,7 +119,7 @@ public class WorldMapID {
VarcInt.Interpreter_intStackSize -= 2; // L: 1387
var10 = Interpreter.Interpreter_intStack[VarcInt.Interpreter_intStackSize]; // L: 1388
var16 = Interpreter.Interpreter_intStack[VarcInt.Interpreter_intStackSize + 1]; // L: 1389
Widget var13 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1390
Widget var13 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1390
class13.clickWidget(var13, var10, var16); // L: 1391
return 1; // L: 1392
} else if (var0 == ScriptOpcodes.MOUSECAM) {
@@ -256,7 +256,7 @@ public class WorldMapID {
return 1; // L: 1534
} else if (var0 == 3140) {
Client.field810 = 3; // L: 1537
Client.field811 = var2 ? PlayerComposition.field2561.id * -437932207 * 653064625 : VarcInt.field3264.id * -437932207 * 653064625; // L: 1538
Client.field811 = var2 ? PlayerComposition.field2561.id * -437932207 * 653064625 : VarcInt.scriptActiveWidget.id * -437932207 * 653064625; // L: 1538
return 1; // L: 1539
} else {
boolean var11;

View File

@@ -57,7 +57,7 @@ public final class WorldMapRectangle {
garbageValue = "470419605"
)
static int method331(int var0, Script var1, boolean var2) {
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1124
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1124
if (var0 == ScriptOpcodes.CC_GETTARGETMASK) { // L: 1125
Interpreter.Interpreter_intStack[++VarcInt.Interpreter_intStackSize - 1] = ServerPacket.Widget_unpackTargetMask(FaceNormal.getWidgetFlags(var3)); // L: 1126
return 1; // L: 1127

View File

@@ -56,7 +56,7 @@ public class class200 {
var3 = Interpreter.Interpreter_intStack[--VarcInt.Interpreter_intStackSize]; // L: 503
var4 = CollisionMap.getWidget(var3); // L: 504
} else {
var4 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 506
var4 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 506
}
if (var0 == ScriptOpcodes.CC_SETPOSITION) { // L: 507

View File

@@ -159,7 +159,7 @@ public class class231 {
if (var2) { // L: 454
PlayerComposition.field2561 = var12;
} else {
VarcInt.field3264 = var12; // L: 455
VarcInt.scriptActiveWidget = var12; // L: 455
}
CollisionMap.invalidateWidget(var6); // L: 456
@@ -169,7 +169,7 @@ public class class231 {
} else {
Widget var3;
if (var0 == ScriptOpcodes.CC_DELETE) { // L: 459
var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 460
var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 460
Widget var10 = CollisionMap.getWidget(var3.id); // L: 461
var10.children[var3.childIndex] = null; // L: 462
CollisionMap.invalidateWidget(var10); // L: 463
@@ -187,7 +187,7 @@ public class class231 {
if (var2) { // L: 489
PlayerComposition.field2561 = var3;
} else {
VarcInt.field3264 = var3; // L: 490
VarcInt.scriptActiveWidget = var3; // L: 490
}
} else {
Interpreter.Interpreter_intStack[++VarcInt.Interpreter_intStackSize - 1] = 0; // L: 492
@@ -207,7 +207,7 @@ public class class231 {
if (var2) { // L: 479
PlayerComposition.field2561 = var5;
} else {
VarcInt.field3264 = var5; // L: 480
VarcInt.scriptActiveWidget = var5; // L: 480
}
} else {
Interpreter.Interpreter_intStack[++VarcInt.Interpreter_intStackSize - 1] = 0; // L: 482

View File

@@ -10,7 +10,7 @@ public class class277 {
garbageValue = "-1829984749"
)
static int method5005(int var0, Script var1, boolean var2) {
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.field3264; // L: 1106
Widget var3 = var2 ? PlayerComposition.field2561 : VarcInt.scriptActiveWidget; // L: 1106
if (var0 == ScriptOpcodes.CC_GETINVOBJECT) { // L: 1107
Interpreter.Interpreter_intStack[++VarcInt.Interpreter_intStackSize - 1] = var3.itemId; // L: 1108
return 1; // L: 1109