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()
{
add(LOAD_INT, "load_int", 0, 1);
add(GET_SETTINGS, "get_settings", 0, 1);
add(PUT_SETTINGS, "put_settings", 0, 1);
add(GET_VARP, "get_varp", 0, 1);
add(PUT_VARP, "put_varp", 0, 1);
add(LOAD_STRING, "load_string", 0, 0, 0, 1);
add(JUMP, "jump", 0, 0);
add(IF_ICMPNE, "if_icmpne", 2, 0);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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