Fixed several object structures and drastically sped up object creation

This commit is contained in:
Obique PSWG
2016-03-25 23:21:16 -05:00
parent 210d6182ac
commit 0fedef77a3
14 changed files with 550 additions and 115 deletions
+82 -8
View File
@@ -1,8 +1,11 @@
package resources.objects.guild;
import java.nio.ByteBuffer;
import network.packets.swg.zone.baselines.Baseline.BaselineType;
import resources.collections.SWGMap;
import resources.collections.SWGSet;
import resources.encodables.Encodable;
import resources.network.BaselineBuilder;
import resources.network.NetBuffer;
import resources.objects.SWGObject;
@@ -14,10 +17,12 @@ public class GuildObject extends SWGObject {
private static final long serialVersionUID = 1L;
private SWGSet<String> abbreviations = new SWGSet<String>(3, 4, StringType.ASCII);
private SWGMap<String, Integer> gcwImperialScorePercentileThisGalaxy = new SWGMap<>(6, 2);
private SWGMap<String, Integer> gcwGroupImperialScorePercentileThisGalaxy = new SWGMap<>(6, 3);
private SWGMap<String, Long> gcwImperialScorePercentileHistoryThisGalaxy = new SWGMap<>(6, 4);
private SWGMap<String, Long> gcwGroupImperialScorePercentileHistoryThisGalaxy = new SWGMap<>(6, 5);
private SWGMap<String, CurrentServerGCWZonePercent> gcwImperialScorePercentileThisGalaxy = new SWGMap<>(6, 2);
private SWGMap<String, CurrentServerGCWZonePercent> gcwGroupImperialScorePercentileThisGalaxy = new SWGMap<>(6, 3);
private SWGMap<String, CurrentServerGCWZoneHistory> gcwImperialScorePercentileHistoryThisGalaxy = new SWGMap<>(6, 4);
private SWGMap<String, CurrentServerGCWZoneHistory> gcwGroupImperialScorePercentileHistoryThisGalaxy = new SWGMap<>(6, 5);
private SWGMap<String, OtherServerGCWZonePercent> gcwImperialScorePercentileOtherGalaxies = new SWGMap<>(6, 6);
private SWGMap<String, OtherServerGCWZonePercent> gcwGroupImperialScorePercentileOtherGalaxies = new SWGMap<>(6, 7);
public GuildObject(long objectId) {
super(objectId, BaselineType.GILD);
@@ -36,6 +41,8 @@ public class GuildObject extends SWGObject {
bb.addObject(gcwGroupImperialScorePercentileThisGalaxy);
bb.addObject(gcwImperialScorePercentileHistoryThisGalaxy);
bb.addObject(gcwGroupImperialScorePercentileHistoryThisGalaxy);
bb.addObject(gcwImperialScorePercentileOtherGalaxies);
bb.addObject(gcwGroupImperialScorePercentileOtherGalaxies);
}
@Override
@@ -47,10 +54,77 @@ public class GuildObject extends SWGObject {
@Override
protected void parseBaseline6(NetBuffer buffer) {
super.parseBaseline6(buffer);
gcwImperialScorePercentileThisGalaxy = buffer.getSwgMap(6, 2, StringType.ASCII, Integer.class, true);
gcwGroupImperialScorePercentileThisGalaxy = buffer.getSwgMap(6, 3, StringType.ASCII, Integer.class, true);
gcwImperialScorePercentileHistoryThisGalaxy = buffer.getSwgMap(6, 4, StringType.ASCII, Long.class, true);
gcwGroupImperialScorePercentileHistoryThisGalaxy = buffer.getSwgMap(6, 5, StringType.ASCII, Long.class, true);
gcwImperialScorePercentileThisGalaxy = buffer.getSwgMap(6, 2, StringType.ASCII, CurrentServerGCWZonePercent.class);
gcwGroupImperialScorePercentileThisGalaxy = buffer.getSwgMap(6, 3, StringType.ASCII, CurrentServerGCWZonePercent.class);
gcwImperialScorePercentileHistoryThisGalaxy = buffer.getSwgMap(6, 4, StringType.ASCII, CurrentServerGCWZoneHistory.class);
gcwGroupImperialScorePercentileHistoryThisGalaxy = buffer.getSwgMap(6, 5, StringType.ASCII, CurrentServerGCWZoneHistory.class);
gcwImperialScorePercentileOtherGalaxies = buffer.getSwgMap(6, 6, StringType.ASCII, OtherServerGCWZonePercent.class);
gcwGroupImperialScorePercentileOtherGalaxies = buffer.getSwgMap(6, 7, StringType.ASCII, OtherServerGCWZonePercent.class);
}
public static class CurrentServerGCWZonePercent implements Encodable {
private int percentage = 0;
public byte [] encode() {
NetBuffer data = NetBuffer.allocate(4);
data.addInt(percentage);
return data.array();
}
public void decode(ByteBuffer data) {
percentage = data.getInt();
}
public String toString() {
return percentage + "%";
}
}
public static class CurrentServerGCWZoneHistory implements Encodable {
private int lastUpdateTime = 0;
private int percentage = 0;
public byte [] encode() {
NetBuffer data = NetBuffer.allocate(8);
data.addInt(lastUpdateTime);
data.addInt(percentage);
return data.array();
}
public void decode(ByteBuffer bb) {
NetBuffer data = NetBuffer.wrap(bb);
lastUpdateTime = data.getInt();
percentage = data.getInt();
}
public String toString() {
return lastUpdateTime + ":" + percentage + "%";
}
}
public static class OtherServerGCWZonePercent implements Encodable {
private String zone = "";
private int percentage = 0;
public byte [] encode() {
NetBuffer data = NetBuffer.allocate(6 + zone.length());
data.addAscii(zone);
data.addInt(percentage);
return data.array();
}
public void decode(ByteBuffer bb) {
NetBuffer data = NetBuffer.wrap(bb);
zone = data.getAscii();
percentage = data.getInt();
}
public String toString() {
return zone + ":" + percentage + "%";
}
}
}