refactor: remove unnecessary Client#getSettings(), use Client#getVarps()
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.
This commit is contained in:
@@ -152,8 +152,6 @@ public interface Client extends GameEngine
|
|||||||
|
|
||||||
int[][] getXteaKeys();
|
int[][] getXteaKeys();
|
||||||
|
|
||||||
int[] getSettings();
|
|
||||||
|
|
||||||
int[] getVarps();
|
int[] getVarps();
|
||||||
|
|
||||||
int getSetting(Setting setting);
|
int getSetting(Setting setting);
|
||||||
|
|||||||
@@ -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,32 +43,16 @@ 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.getVarps());
|
||||||
|
|
||||||
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.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)
|
for (int i = 0; i < Math.min(widgetSettings.length, newWidgetSettings.length); ++i)
|
||||||
{
|
{
|
||||||
int before = widgetSettings[i];
|
int before = widgetSettings[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)
|
||||||
|
|||||||
@@ -77,10 +77,6 @@ public interface RSClient extends RSGameEngine, Client
|
|||||||
@Override
|
@Override
|
||||||
byte[][][] getTileSettings();
|
byte[][][] getTileSettings();
|
||||||
|
|
||||||
@Import("serverVarps")
|
|
||||||
@Override
|
|
||||||
int[] getSettings();
|
|
||||||
|
|
||||||
@Import("clientVarps")
|
@Import("clientVarps")
|
||||||
@Override
|
@Override
|
||||||
int[] getVarps();
|
int[] getVarps();
|
||||||
|
|||||||
Reference in New Issue
Block a user