rs-client: refactoring (#1344)

* Rename some things to be more consistent everywhere

* rs-client: refactoring

* MenuAction -> MenuOpcode merge
This commit is contained in:
Lucwousin
2019-08-20 22:24:51 +02:00
committed by GitHub
parent 0f46656e9d
commit db705f5dd5
297 changed files with 13734 additions and 14043 deletions

View File

@@ -95,12 +95,12 @@ public abstract class EntityHiderMixin implements RSScene
private static boolean hideDeadNPCs;
@Copy("newGameObject")
abstract boolean addEntityMarker(int var1, int var2, int var3, int var4, int var5, int x, int y, int var8, RSEntity renderable, int var10, boolean var11, long var12, int var13);
abstract boolean addEntityMarker(int var1, int var2, int var3, int var4, int var5, int x, int y, int var8, RSEntity entity, int var10, boolean var11, long var12, int var13);
@Replace("newGameObject")
boolean rl$addEntityMarker(int var1, int var2, int var3, int var4, int var5, int x, int y, int var8, RSEntity renderable, int var10, boolean var11, long var12, int var13)
boolean rl$addEntityMarker(int var1, int var2, int var3, int var4, int var5, int x, int y, int var8, RSEntity entity, int var10, boolean var11, long var12, int var13)
{
final boolean shouldDraw = shouldDraw(renderable, false);
final boolean shouldDraw = shouldDraw(entity, false);
if (!shouldDraw)
{
@@ -113,7 +113,7 @@ public abstract class EntityHiderMixin implements RSScene
client.getOccupiedTilesTick()[tileX][tileY] = -1;
}
return shouldDraw && addEntityMarker(var1, var2, var3, var4, var5, x, y, var8, renderable, var10, var11, var12, var13);
return shouldDraw && addEntityMarker(var1, var2, var3, var4, var5, x, y, var8, entity, var10, var11, var12, var13);
}
@Copy("drawActor2d")
@@ -132,22 +132,22 @@ public abstract class EntityHiderMixin implements RSScene
}
@Inject
private static boolean shouldDraw(Object renderable, boolean drawingUI)
private static boolean shouldDraw(Object entity, boolean drawingUI)
{
if (!isHidingEntities)
{
return true;
}
if (renderable instanceof RSPlayer)
if (entity instanceof RSPlayer)
{
boolean local = drawingUI ? hideLocalPlayer2D : hideLocalPlayer;
boolean other = drawingUI ? hidePlayers2D : hidePlayers;
boolean isLocalPlayer = renderable == client.getLocalPlayer();
boolean isLocalPlayer = entity == client.getLocalPlayer();
if (isLocalPlayer ? local : other)
{
RSPlayer player = (RSPlayer) renderable;
RSPlayer player = (RSPlayer) entity;
if (!hideAttackers)
{
@@ -166,9 +166,9 @@ public abstract class EntityHiderMixin implements RSScene
return (!hideFriends && player.isFriend()) || (!isLocalPlayer && !hideClanMates && player.isClanMember());
}
}
else if (renderable instanceof RSNPC)
else if (entity instanceof RSNPC)
{
RSNPC npc = (RSNPC) renderable;
RSNPC npc = (RSNPC) entity;
if (!hideAttackers)
{
@@ -207,7 +207,7 @@ public abstract class EntityHiderMixin implements RSScene
return drawingUI ? !hideNPCs2D : !hideNPCs;
}
else if (renderable instanceof RSProjectile)
else if (entity instanceof RSProjectile)
{
return !hideProjectiles;
}

View File

@@ -115,12 +115,12 @@ public abstract class MenuMixin implements RSClient
public void sortMenuEntries()
{
int count = getMenuOptionCount() - 1;
int[] menuOpcodes = getMenuTypes();
int[] menuOpcodes = getMenuOpcodes();
String[] menuTargetNames = getMenuTargets();
String[] menuActions = getMenuOptions();
int[] menuArguments0 = getMenuIdentifiers();
int[] menuArguments1 = getMenuActionParams0();
int[] menuArguments2 = getMenuActionParams1();
int[] menuArguments1 = getMenuArguments1();
int[] menuArguments2 = getMenuArguments2();
boolean[] menuShiftClick = getMenuForceLeftClick();
int tmp;

View File

@@ -36,7 +36,7 @@ public abstract class ProcessClientErrorMixin implements RSClient
@Shadow("client")
private static RSClient client;
@Replace("sendStackTrace")
@Replace("RunException_sendStackTrace")
static void rl$processClientError(String string, Throwable throwable)
{
if (throwable != null)

View File

@@ -36,7 +36,7 @@ public abstract class RSBoundaryObjectMixin implements RSBoundaryObject
@Inject
public Model getModelA()
{
Entity entity = getRenderable1();
Entity entity = getEntity1();
if (entity == null)
{
return null;
@@ -55,7 +55,7 @@ public abstract class RSBoundaryObjectMixin implements RSBoundaryObject
@Inject
public Model getModelB()
{
Entity entity = getRenderable2();
Entity entity = getEntity2();
if (entity == null)
{
return null;

View File

@@ -50,15 +50,15 @@ import net.runelite.api.Ignore;
import net.runelite.api.IndexDataBase;
import net.runelite.api.IndexedSprite;
import net.runelite.api.InventoryID;
import net.runelite.api.MenuAction;
import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FOURTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SECOND_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
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.MenuEntry;
import net.runelite.api.MessageNode;
import net.runelite.api.NPC;
@@ -654,9 +654,9 @@ public abstract class RSClientMixin implements RSClient
String[] menuOptions = getMenuOptions();
String[] menuTargets = getMenuTargets();
int[] menuIdentifiers = getMenuIdentifiers();
int[] menuTypes = getMenuTypes();
int[] params0 = getMenuActionParams0();
int[] params1 = getMenuActionParams1();
int[] menuTypes = getMenuOpcodes();
int[] params0 = getMenuArguments1();
int[] params1 = getMenuArguments2();
boolean[] leftClick = getMenuForceLeftClick();
MenuEntry[] entries = new MenuEntry[count];
@@ -666,7 +666,7 @@ public abstract class RSClientMixin implements RSClient
entry.setOption(menuOptions[i]);
entry.setTarget(menuTargets[i]);
entry.setIdentifier(menuIdentifiers[i]);
entry.setType(menuTypes[i]);
entry.setOpcode(menuTypes[i]);
entry.setParam0(params0[i]);
entry.setParam1(params1[i]);
entry.setForceLeftClick(leftClick[i]);
@@ -682,9 +682,9 @@ public abstract class RSClientMixin implements RSClient
String[] menuOptions = getMenuOptions();
String[] menuTargets = getMenuTargets();
int[] menuIdentifiers = getMenuIdentifiers();
int[] menuTypes = getMenuTypes();
int[] params0 = getMenuActionParams0();
int[] params1 = getMenuActionParams1();
int[] menuTypes = getMenuOpcodes();
int[] params0 = getMenuArguments1();
int[] params1 = getMenuArguments2();
boolean[] leftClick = getMenuForceLeftClick();
for (MenuEntry entry : entries)
@@ -697,7 +697,7 @@ public abstract class RSClientMixin implements RSClient
menuOptions[count] = entry.getOption();
menuTargets[count] = entry.getTarget();
menuIdentifiers[count] = entry.getIdentifier();
menuTypes[count] = entry.getType();
menuTypes[count] = entry.getOpcode();
params0[count] = entry.getParam0();
params1[count] = entry.getParam1();
leftClick[count] = entry.isForceLeftClick();
@@ -724,9 +724,9 @@ public abstract class RSClientMixin implements RSClient
client.getMenuOptions()[oldCount],
client.getMenuTargets()[oldCount],
client.getMenuIdentifiers()[oldCount],
client.getMenuTypes()[oldCount],
client.getMenuActionParams0()[oldCount],
client.getMenuActionParams1()[oldCount],
client.getMenuOpcodes()[oldCount],
client.getMenuArguments1()[oldCount],
client.getMenuArguments2()[oldCount],
client.getMenuForceLeftClick()[oldCount]
)
);
@@ -1041,12 +1041,12 @@ public abstract class RSClientMixin implements RSClient
@Inject
public static void playerOptionsChanged(int idx)
{
// Reset the menu type
MenuAction[] playerActions = {PLAYER_FIRST_OPTION, PLAYER_SECOND_OPTION, PLAYER_THIRD_OPTION, PLAYER_FOURTH_OPTION,
// Reset the menu opcode
MenuOpcode[] playerActions = {PLAYER_FIRST_OPTION, PLAYER_SECOND_OPTION, PLAYER_THIRD_OPTION, PLAYER_FOURTH_OPTION,
PLAYER_FIFTH_OPTION, PLAYER_SIXTH_OPTION, PLAYER_SEVENTH_OPTION, PLAYER_EIGTH_OPTION};
if (idx >= 0 && idx < playerActions.length)
{
MenuAction playerAction = playerActions[idx];
MenuOpcode playerAction = playerActions[idx];
client.getPlayerMenuTypes()[idx] = playerAction.getId();
}
@@ -1346,7 +1346,7 @@ public abstract class RSClientMixin implements RSClient
return;
}
rs$menuAction(menuOptionClicked.getActionParam0(), menuOptionClicked.getActionParam1(), menuOptionClicked.getType(),
rs$menuAction(menuOptionClicked.getActionParam0(), menuOptionClicked.getActionParam1(), menuOptionClicked.getOpcode(),
menuOptionClicked.getIdentifier(), menuOptionClicked.getOption(), menuOptionClicked.getTarget(), var6, var7);
}
@@ -1642,8 +1642,8 @@ public abstract class RSClientMixin implements RSClient
int len = getMenuOptionCount();
if (len > 0)
{
int type = getMenuTypes()[len - 1];
return type == MenuAction.RUNELITE_OVERLAY.getId();
int type = getMenuOpcodes()[len - 1];
return type == MenuOpcode.RUNELITE_OVERLAY.getId();
}
return false;

View File

@@ -37,7 +37,7 @@ public abstract class RSFloorDecorationMixin implements RSFloorDecoration
@Override
public Model getModel()
{
Entity entity = getRenderable();
Entity entity = getEntity();
if (entity == null)
{
return null;

View File

@@ -62,7 +62,7 @@ public abstract class RSGameObjectMixin implements RSGameObject
@Override
public RSModel getModel()
{
RSEntity renderable = getRenderable();
RSEntity renderable = getEntity();
if (renderable == null)
{
return null;

View File

@@ -398,13 +398,13 @@ public abstract class RSTileMixin implements RSTile
boolean currentInvalid = false, prevInvalid = false;
if (current != null)
{
RSEntity renderable = current.getRenderable();
RSEntity renderable = current.getEntity();
currentInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject;
}
if (previous != null)
{
RSEntity renderable = previous.getRenderable();
RSEntity renderable = previous.getEntity();
prevInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject;
}

View File

@@ -40,7 +40,7 @@ public abstract class RSWallDecorationMixin implements RSWallDecoration
@Override
public RSModel getModel1()
{
RSEntity renderable = getRenderable();
RSEntity renderable = getEntity1();
if (renderable == null)
{
return null;
@@ -64,7 +64,7 @@ public abstract class RSWallDecorationMixin implements RSWallDecoration
@Override
public RSModel getModel2()
{
RSEntity renderable = getRenderable2();
RSEntity renderable = getEntity2();
if (renderable == null)
{
return null;

View File

@@ -1,6 +1,6 @@
package net.runelite.mixins;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuOpcode;
import net.runelite.api.World;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.mixins.Inject;
@@ -15,7 +15,7 @@ public abstract class WorldHoppingMixin implements RSClient
public void openWorldHopper()
{
// The clicked x & y coordinates (the last arguments) are not processed in the game or sent to Jagex, so they don't have to be real.
invokeMenuAction(-1, WidgetInfo.WORLD_SWITCHER_BUTTON.getId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "World Switcher", "", 658, 384);
invokeMenuAction(-1, WidgetInfo.WORLD_SWITCHER_BUTTON.getId(), MenuOpcode.WIDGET_DEFAULT.getId(), 1, "World Switcher", "", 658, 384);
}
@Inject
@@ -23,6 +23,6 @@ public abstract class WorldHoppingMixin implements RSClient
public void hopToWorld(World world)
{
final int worldId = world.getId();
invokeMenuAction(worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "Switch", "<col=ff9040>" + (worldId - 300) + "</col>", 683, 244);
invokeMenuAction(worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId(), MenuOpcode.WIDGET_DEFAULT.getId(), 1, "Switch", "<col=ff9040>" + (worldId - 300) + "</col>", 683, 244);
}
}