From 79fb9b22fedf9e539ec105787e590306ea909095 Mon Sep 17 00:00:00 2001 From: Pazaz Date: Fri, 26 Jan 2024 16:35:07 -0500 Subject: [PATCH] feat: size > 1 support for true tile overlay --- client/src/main/java/client.java | 21 ++++++++++--------- .../src/main/java/jagex2/client/ViewBox.java | 6 ++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/client/src/main/java/client.java b/client/src/main/java/client.java index 7d45b7b5..6a835d6e 100644 --- a/client/src/main/java/client.java +++ b/client/src/main/java/client.java @@ -1362,11 +1362,12 @@ private void draw2DEntityElements() { if (this.showDebug) { // true tile overlay if (entity.pathLength > 0 || entity.forceMoveEndCycle >= loopCycle || entity.forceMoveStartCycle > loopCycle) { - this.drawTileOverlay(entity.pathTileX[0] * 128 + 64, entity.pathTileZ[0] * 128 + 64, this.currentLevel, 0x666666, true); + int halfUnit = 64 * entity.size; + this.drawTileOverlay(entity.pathTileX[0] * 128 + halfUnit, entity.pathTileZ[0] * 128 + halfUnit, this.currentLevel, entity.size, 0x666666, true); } // local tile overlay - this.drawTileOverlay(entity.x, entity.z, this.currentLevel, 0x444444, false); + this.drawTileOverlay(entity.x, entity.z, this.currentLevel, entity.size, 0x444444, false); int offsetY = 0; this.projectFromGround(entity, entity.height + 30); @@ -2875,8 +2876,8 @@ private void pushPlayers() { @OriginalMember(owner = "client!client", name = "a", descriptor = "(IIBI)I") private int getHeightmapY(@OriginalArg(0) int level, @OriginalArg(1) int sceneX, @OriginalArg(3) int sceneZ) { - @Pc(11) int tileX = sceneX >> 7; - @Pc(15) int tileZ = sceneZ >> 7; + @Pc(11) int tileX = Math.min(sceneX >> 7, 103); + @Pc(15) int tileZ = Math.min(sceneZ >> 7, 103); @Pc(17) int realLevel = level; if (level < 3 && (this.levelTileFlags[1][tileX][tileZ] & 0x2) == 2) { realLevel = level + 1; @@ -6895,24 +6896,24 @@ private void drawInfoOverlay() { } } - private void drawTileOverlay(int x, int z, int level, int color, boolean crossed) { + private void drawTileOverlay(int x, int z, int level, int size, int color, boolean crossed) { int height = this.getHeightmapY(level, x, z); int x0, y0; int x1, y1; int x2, y2; int x3, y3; - // x/z should be the center of a tile which is 128 client-units large, so +/- 64 puts us at the edges - this.project(x - 64, height, z - 64); + int halfUnit = 64 * size; + this.project(x - halfUnit, height, z - halfUnit); x0 = this.projectX; y0 = this.projectY; - this.project(x + 64, height, z - 64); + this.project(x + halfUnit, height, z - halfUnit); x1 = this.projectX; y1 = this.projectY; - this.project(x - 64, height, z + 64); + this.project(x - halfUnit, height, z + halfUnit); x2 = this.projectX; y2 = this.projectY; - this.project(x + 64, height, z + 64); + this.project(x + halfUnit, height, z + halfUnit); x3 = this.projectX; y3 = this.projectY; diff --git a/client/src/main/java/jagex2/client/ViewBox.java b/client/src/main/java/jagex2/client/ViewBox.java index 8e6c4672..4892b33c 100644 --- a/client/src/main/java/jagex2/client/ViewBox.java +++ b/client/src/main/java/jagex2/client/ViewBox.java @@ -13,7 +13,7 @@ public class ViewBox extends Frame { @OriginalMember(owner = "client!b", name = "b", descriptor = "Lclient!a;") private final GameShell shell; - public final Insets insets; + public Insets insets; @OriginalMember(owner = "client!b", name = "", descriptor = "(IILclient!a;I)V") public ViewBox(@OriginalArg(2) GameShell shell, @OriginalArg(3) int width, @OriginalArg(0) int height) { @@ -30,7 +30,9 @@ public ViewBox(@OriginalArg(2) GameShell shell, @OriginalArg(3) int width, @Orig @Override public Graphics getGraphics() { @Pc(2) Graphics g = super.getGraphics(); - g.translate(this.insets.left, this.insets.top); + if (this.insets != null) { + g.translate(this.insets.left, this.insets.top); + } return g; }