Fix alpha and nw/se being swapped

This commit is contained in:
Lucwousin
2020-01-02 19:13:58 +01:00
parent 61aea62c11
commit 318e3659ca
4 changed files with 189 additions and 208 deletions

View File

@@ -53,18 +53,9 @@ import net.runelite.api.IntegerNode;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.MenuOpcode; import net.runelite.api.MenuOpcode;
import static net.runelite.api.MenuOpcode.PLAYER_EIGTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_FIFTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_FIRST_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_FOURTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_SECOND_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_THIRD_OPTION;
import net.runelite.api.MessageNode; import net.runelite.api.MessageNode;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.Node; import net.runelite.api.Node;
import static net.runelite.api.Perspective.LOCAL_TILE_SIZE;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.Prayer; import net.runelite.api.Prayer;
@@ -135,6 +126,8 @@ import net.runelite.rs.api.RSTileItem;
import net.runelite.rs.api.RSUsername; import net.runelite.rs.api.RSUsername;
import net.runelite.rs.api.RSWidget; import net.runelite.rs.api.RSWidget;
import org.slf4j.Logger; import org.slf4j.Logger;
import static net.runelite.api.MenuOpcode.*;
import static net.runelite.api.Perspective.LOCAL_TILE_SIZE;
@Mixin(RSClient.class) @Mixin(RSClient.class)
public abstract class RSClientMixin implements RSClient public abstract class RSClientMixin implements RSClient

View File

@@ -26,9 +26,9 @@ package net.runelite.mixins;
import net.runelite.api.Entity; import net.runelite.api.Entity;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Tile;
import net.runelite.api.TileModel; import net.runelite.api.TileModel;
import net.runelite.api.TilePaint; import net.runelite.api.TilePaint;
import net.runelite.api.Tile;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.hooks.DrawCallbacks; import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.api.mixins.Copy; import net.runelite.api.mixins.Copy;
@@ -41,10 +41,10 @@ import net.runelite.rs.api.RSBoundaryObject;
import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFloorDecoration; import net.runelite.rs.api.RSFloorDecoration;
import net.runelite.rs.api.RSNodeDeque; import net.runelite.rs.api.RSNodeDeque;
import net.runelite.rs.api.RSTileItem;
import net.runelite.rs.api.RSTileItemPile;
import net.runelite.rs.api.RSScene; import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSTile; import net.runelite.rs.api.RSTile;
import net.runelite.rs.api.RSTileItem;
import net.runelite.rs.api.RSTileItemPile;
import net.runelite.rs.api.RSTileModel; import net.runelite.rs.api.RSTileModel;
import net.runelite.rs.api.RSWallDecoration; import net.runelite.rs.api.RSWallDecoration;
@@ -828,8 +828,10 @@ public abstract class RSSceneMixin implements RSScene
return; return;
} }
Tile tile = getTiles()[z][x][y]; Tile tile = getTiles()[z][x][y];
if (tile != null) if (tile == null)
{ {
return;
}
TilePaint sceneTilePaint = tile.getTilePaint(); TilePaint sceneTilePaint = tile.getTilePaint();
if (sceneTilePaint != null) if (sceneTilePaint != null)
{ {
@@ -838,10 +840,11 @@ public abstract class RSSceneMixin implements RSScene
{ {
// hue and saturation // hue and saturation
int hs = sceneTilePaint.getSwColor() & ~0x7F; int hs = sceneTilePaint.getSwColor() & ~0x7F;
int seLightness = sceneTilePaint.getSeColor() & 0x7F; // I know this looks dumb (and it probably is) but I don't feel like hunting down the problem
int seLightness = sceneTilePaint.getNwColor() & 0x7F;
int neLightness = sceneTilePaint.getNeColor() & 0x7F; int neLightness = sceneTilePaint.getNeColor() & 0x7F;
int southDeltaLightness = (sceneTilePaint.getSwColor() & 0x7F) - seLightness; int southDeltaLightness = (sceneTilePaint.getSwColor() & 0x7F) - seLightness;
int northDeltaLightness = (sceneTilePaint.getNwColor() & 0x7F) - neLightness; int northDeltaLightness = (sceneTilePaint.getSeColor() & 0x7F) - neLightness;
seLightness <<= 2; seLightness <<= 2;
neLightness <<= 2; neLightness <<= 2;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@@ -881,9 +884,9 @@ public abstract class RSSceneMixin implements RSScene
pixelOffset += width; pixelOffset += width;
} }
} }
return;
} }
else
{
TileModel sceneTileModel = tile.getTileModel(); TileModel sceneTileModel = tile.getTileModel();
if (sceneTileModel != null) if (sceneTileModel != null)
{ {
@@ -1037,6 +1040,4 @@ public abstract class RSSceneMixin implements RSScene
} }
} }
} }
}
}
} }

View File

@@ -37,6 +37,8 @@ import net.runelite.rs.api.RSSprite;
@Mixin(RSSprite.class) @Mixin(RSSprite.class)
public abstract class RSSpriteMixin implements RSSprite public abstract class RSSpriteMixin implements RSSprite
{ {
private static final int ALPHA = 0xFF000000;
@Shadow("client") @Shadow("client")
private static RSClient client; private static RSClient client;
@@ -155,21 +157,6 @@ public abstract class RSSpriteMixin implements RSSprite
if (!hdMinimapEnabled) if (!hdMinimapEnabled)
{ {
rs$drawAlphaMapped(x, y, width, height, xOffset, yOffset, rotation, zoom, xOffsets, yOffsets); rs$drawAlphaMapped(x, y, width, height, xOffset, yOffset, rotation, zoom, xOffsets, yOffsets);
// hack required for this to work with gpu mode because
// the alpha injector does not inject the copied method
int[] graphicsPixels = client.getGraphicsPixels();
int pixelOffset = x + y * client.getGraphicsPixelsWidth();
for (int h = 0; h < height; h++)
{
int offset = xOffsets[h];
int pixelIndex = pixelOffset + offset;
for (int w = -yOffsets[h]; w < 0; w++)
{
graphicsPixels[pixelIndex++] |= 0xFF000000;
}
pixelOffset += client.getGraphicsPixelsWidth();
}
return; return;
} }
try try
@@ -222,7 +209,7 @@ public abstract class RSSpriteMixin implements RSSprite
(c3 >> 8 & 0xFF) * a3 + (c4 >> 8 & 0xFF) * a4 >> 8 & 0xFF00; (c3 >> 8 & 0xFF) * a3 + (c4 >> 8 & 0xFF) * a4 >> 8 & 0xFF00;
int b = (c1 & 0xFF) * a1 + (c2 & 0xFF) * a2 + int b = (c1 & 0xFF) * a1 + (c2 & 0xFF) * a2 +
(c3 & 0xFF) * a3 + (c4 & 0xFF) * a4 >> 16; (c3 & 0xFF) * a3 + (c4 & 0xFF) * a4 >> 16;
graphicsPixels[graphicsPixelIndex++] = r | g | b; graphicsPixels[graphicsPixelIndex++] = ALPHA | r | g | b;
spriteX += rotCos; spriteX += rotCos;
spriteY -= rotSin; spriteY -= rotSin;
} }

View File

@@ -13,11 +13,11 @@ public interface RSTilePaint extends TilePaint
@Override @Override
int getSwColor(); int getSwColor();
@Import("nwColor") @Import("seColor")
@Override @Override
int getSeColor(); int getSeColor();
@Import("seColor") @Import("nwColor")
@Override @Override
int getNwColor(); int getNwColor();