Skip to content

Commit

Permalink
feat: size > 1 support for true tile overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
Pazaz committed Jan 26, 2024
1 parent 3ea75bf commit 79fb9b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
21 changes: 11 additions & 10 deletions client/src/main/java/client.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions client/src/main/java/jagex2/client/ViewBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<init>", descriptor = "(IILclient!a;I)V")
public ViewBox(@OriginalArg(2) GameShell shell, @OriginalArg(3) int width, @OriginalArg(0) int height) {
Expand All @@ -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;
}

Expand Down

0 comments on commit 79fb9b2

Please sign in to comment.