Merge pull request #1036 from Joshua-F/refactor/rename-vars

Rename widgetSettings and settings
This commit is contained in:
Adam
2018-03-22 08:49:16 -04:00
committed by GitHub
7 changed files with 16 additions and 40 deletions

View File

@@ -36,8 +36,8 @@ public class Instructions
public void init() public void init()
{ {
add(LOAD_INT, "load_int", 0, 1); add(LOAD_INT, "load_int", 0, 1);
add(GET_SETTINGS, "get_settings", 0, 1); add(GET_VARP, "get_varp", 0, 1);
add(PUT_SETTINGS, "put_settings", 0, 1); add(PUT_VARP, "put_varp", 0, 1);
add(LOAD_STRING, "load_string", 0, 0, 0, 1); add(LOAD_STRING, "load_string", 0, 0, 0, 1);
add(JUMP, "jump", 0, 0); add(JUMP, "jump", 0, 0);
add(IF_ICMPNE, "if_icmpne", 2, 0); add(IF_ICMPNE, "if_icmpne", 2, 0);

View File

@@ -27,8 +27,8 @@ package net.runelite.cache.script;
public class Opcodes public class Opcodes
{ {
public static final int LOAD_INT = 0; public static final int LOAD_INT = 0;
public static final int GET_SETTINGS = 1; public static final int GET_VARP = 1;
public static final int PUT_SETTINGS = 2; public static final int PUT_VARP = 2;
public static final int LOAD_STRING = 3; public static final int LOAD_STRING = 3;
public static final int JUMP = 6; public static final int JUMP = 6;
public static final int IF_ICMPNE = 7; public static final int IF_ICMPNE = 7;

View File

@@ -152,9 +152,7 @@ public interface Client extends GameEngine
int[][] getXteaKeys(); int[][] getXteaKeys();
int[] getSettings(); int[] getVarps();
int[] getWidgetSettings();
int getSetting(Setting setting); int getSetting(Setting setting);

View File

@@ -34,7 +34,6 @@ public class SettingsTracker
{ {
private final Client client; private final Client client;
private int[] clientSettings;
private int[] widgetSettings; private int[] widgetSettings;
public SettingsTracker(Client client) public SettingsTracker(Client client)
@@ -44,31 +43,15 @@ public class SettingsTracker
public void snapshot(ActionEvent e) public void snapshot(ActionEvent e)
{ {
if (clientSettings == null || widgetSettings == null) if (widgetSettings == null)
{ {
clientSettings = copy(client.getSettings()); widgetSettings = copy(client.getVarps());
widgetSettings = copy(client.getWidgetSettings());
log.info("Snapshotted client and widget settings"); log.info("Snapshotted client and widget settings");
return; return;
} }
int[] newClientSettings = client.getSettings(); int[] newWidgetSettings = client.getVarps();
int[] newWidgetSettings = client.getWidgetSettings();
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) for (int i = 0; i < Math.min(widgetSettings.length, newWidgetSettings.length); ++i)
{ {
@@ -84,13 +67,12 @@ public class SettingsTracker
i, before, after, prettyPrintInt(before), prettyPrintInt(after)); i, before, after, prettyPrintInt(before), prettyPrintInt(after));
} }
clientSettings = copy(newClientSettings);
widgetSettings = copy(newWidgetSettings); widgetSettings = copy(newWidgetSettings);
} }
public void clear(ActionEvent e) public void clear(ActionEvent e)
{ {
clientSettings = widgetSettings = null; widgetSettings = null;
} }
private static int[] copy(int[] array) private static int[] copy(int[] array)

View File

@@ -233,8 +233,8 @@ public abstract class RSClientMixin implements RSClient
@Override @Override
public int getSetting(Setting setting) public int getSetting(Setting setting)
{ {
int[] settings = getSettings(); int[] varps = getVarps();
return settings[setting.getId()]; return varps[setting.getId()];
} }
@Inject @Inject
@@ -634,7 +634,7 @@ public abstract class RSClientMixin implements RSClient
eventBus.post(offerChangedEvent); eventBus.post(offerChangedEvent);
} }
@FieldHook("settings") @FieldHook("clientVarps")
@Inject @Inject
public static void settingsChanged(int idx) public static void settingsChanged(int idx)
{ {

View File

@@ -64,8 +64,8 @@ public abstract class VarbitMixin implements RSClient
varbitCache.put(varbitId, v); varbitCache.put(varbitId, v);
} }
int[] settings = getSettings(); int[] varps = getVarps();
int value = settings[v.getIndex()]; int value = varps[v.getIndex()];
int lsb = v.getLeastSignificantBit(); int lsb = v.getLeastSignificantBit();
int msb = v.getMostSignificantBit(); int msb = v.getMostSignificantBit();
int mask = (1 << ((msb - lsb) + 1)) - 1; int mask = (1 << ((msb - lsb) + 1)) - 1;

View File

@@ -77,13 +77,9 @@ public interface RSClient extends RSGameEngine, Client
@Override @Override
byte[][][] getTileSettings(); byte[][][] getTileSettings();
@Import("settings") @Import("clientVarps")
@Override @Override
int[] getSettings(); int[] getVarps();
@Import("widgetSettings")
@Override
int[] getWidgetSettings();
@Import("energy") @Import("energy")
@Override @Override