Skip to content

Commit

Permalink
refactor: remove unnecessary Client#getSettings(), use Client#getVarps()
Browse files Browse the repository at this point in the history
These two methods would return the same values for a majority (if not all) of the time. The backing
arrays for both of these are synchronized when the server sends the packet to set a varp value.
  • Loading branch information
Joshua-F committed Mar 21, 2018
1 parent 8c7beff commit 8ee3de2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
2 changes: 0 additions & 2 deletions runelite-api/src/main/java/net/runelite/api/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ public interface Client extends GameEngine

int[][] getXteaKeys();

int[] getSettings();

int[] getVarps();

int getSetting(Setting setting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class SettingsTracker
{
private final Client client;

private int[] clientSettings;
private int[] widgetSettings;

public SettingsTracker(Client client)
Expand All @@ -44,32 +43,16 @@ public SettingsTracker(Client client)

public void snapshot(ActionEvent e)
{
if (clientSettings == null || widgetSettings == null)
if (widgetSettings == null)
{
clientSettings = copy(client.getSettings());
widgetSettings = copy(client.getVarps());

log.info("Snapshotted client and widget settings");
return;
}

int[] newClientSettings = client.getSettings();
int[] newWidgetSettings = client.getVarps();

for (int i = 0; i < Math.min(clientSettings.length, newClientSettings.length); ++i)
{
int before = clientSettings[i];
int after = newClientSettings[i];

if (before == after)
{
continue;
}

log.info("Client setting index {} has changed from {} to {}: {} -> {}",
i, before, after, prettyPrintInt(before), prettyPrintInt(after));
}

for (int i = 0; i < Math.min(widgetSettings.length, newWidgetSettings.length); ++i)
{
int before = widgetSettings[i];
Expand All @@ -84,13 +67,12 @@ public void snapshot(ActionEvent e)
i, before, after, prettyPrintInt(before), prettyPrintInt(after));
}

clientSettings = copy(newClientSettings);
widgetSettings = copy(newWidgetSettings);
}

public void clear(ActionEvent e)
{
clientSettings = widgetSettings = null;
widgetSettings = null;
}

private static int[] copy(int[] array)
Expand Down
4 changes: 0 additions & 4 deletions runescape-api/src/main/java/net/runelite/rs/api/RSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ public interface RSClient extends RSGameEngine, Client
@Override
byte[][][] getTileSettings();

@Import("serverVarps")
@Override
int[] getSettings();

@Import("clientVarps")
@Override
int[] getVarps();
Expand Down

0 comments on commit 8ee3de2

Please sign in to comment.