diff --git a/src/resources/objects/CurrentServerGCWZoneInfo.java b/src/resources/objects/CurrentServerGCWZoneInfo.java new file mode 100644 index 00000000..ad523078 --- /dev/null +++ b/src/resources/objects/CurrentServerGCWZoneInfo.java @@ -0,0 +1,53 @@ +package resources.objects; + +public class CurrentServerGCWZoneInfo { + + private byte unknown1 = 0; + private String zone = ""; + private int unknown2 = 0x0D05EA4E; + private int percent = 50; + + public CurrentServerGCWZoneInfo(byte unknown1, String zone, int unknown2, int percent) { + this.unknown1 = unknown1; + this.zone = zone; + this.unknown2 = unknown2; + this.percent = percent; + } + + public CurrentServerGCWZoneInfo() { + + } + + public byte getUnknown1() { + return unknown1; + } + + public void setUnknown1(byte unknown1) { + this.unknown1 = unknown1; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public int getUnknown2() { + return unknown2; + } + + public void setUnknown2(int unknown2) { + this.unknown2 = unknown2; + } + + public int getPercent() { + return percent; + } + + public void setPercent(int percent) { + this.percent = percent; + } + +} diff --git a/src/resources/objects/CurrentServerGCWZonePercent.java b/src/resources/objects/CurrentServerGCWZonePercent.java new file mode 100644 index 00000000..55b64070 --- /dev/null +++ b/src/resources/objects/CurrentServerGCWZonePercent.java @@ -0,0 +1,43 @@ +package resources.objects; + +public class CurrentServerGCWZonePercent { + + private byte unknown = 0; + private String zone = ""; + private int percent = 50; + + public CurrentServerGCWZonePercent(byte unknown, String zone, int percent) { + this.unknown = unknown; + this.zone = zone; + this.percent = percent; + } + + public CurrentServerGCWZonePercent() { + + } + + public byte getUnknown() { + return unknown; + } + + public void setUnknown(byte unknown) { + this.unknown = unknown; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public int getPercent() { + return percent; + } + + public void setPercent(int percent) { + this.percent = percent; + } + +} diff --git a/src/resources/objects/Guild.java b/src/resources/objects/Guild.java new file mode 100644 index 00000000..940ec36c --- /dev/null +++ b/src/resources/objects/Guild.java @@ -0,0 +1,43 @@ +package resources.objects; + +public class Guild { + + private int id; + private String abbreviation; + private String name; + + public Guild(int id, String abbreviation, String name) { + this.id = id; + this.abbreviation = abbreviation; + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getAbbreviation() { + return abbreviation; + } + + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getString() { + return (Integer.toString(id) + ":" + abbreviation); + } + +} diff --git a/src/resources/objects/OtherServerGCWZonePercent.java b/src/resources/objects/OtherServerGCWZonePercent.java new file mode 100644 index 00000000..5a5c1c56 --- /dev/null +++ b/src/resources/objects/OtherServerGCWZonePercent.java @@ -0,0 +1,53 @@ +package resources.objects; + +public class OtherServerGCWZonePercent { + + private byte unknown = 0; + private String server = ""; + private String zone = ""; + private int percent = 50; + + public OtherServerGCWZonePercent(byte unknown, String server, String zone, int percent) { + this.unknown = unknown; + this.server = server; + this.zone = zone; + this.percent = percent; + } + + public OtherServerGCWZonePercent() { + + } + + public byte getUnknown() { + return unknown; + } + + public void setUnknown(byte unknown) { + this.unknown = unknown; + } + + public String getServer() { + return server; + } + + public void setServer(String server) { + this.server = server; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public int getPercent() { + return percent; + } + + public void setPercent(int percent) { + this.percent = percent; + } + +} diff --git a/src/resources/objects/guild/GuildMessageBuilder.java b/src/resources/objects/guild/GuildMessageBuilder.java index b18a86e0..b3c66a39 100644 --- a/src/resources/objects/guild/GuildMessageBuilder.java +++ b/src/resources/objects/guild/GuildMessageBuilder.java @@ -1,26 +1,122 @@ -/******************************************************************************* - * Copyright (c) 2013 - * - * This File is part of NGECore2. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. - * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. - ******************************************************************************/ package resources.objects.guild; -public class GuildMessageBuilder { +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.objects.CurrentServerGCWZoneInfo; +import resources.objects.CurrentServerGCWZonePercent; +import resources.objects.Guild; +import resources.objects.ObjectMessageBuilder; +import resources.objects.OtherServerGCWZonePercent; + +public class GuildMessageBuilder extends ObjectMessageBuilder { + + public GuildMessageBuilder(GuildObject guildObject) { + setObject(guildObject); + } + + public IoBuffer buildBaseline3() { + GuildObject guilds = (GuildObject) object; + + IoBuffer buffer = bufferPool.allocate(((guilds.getGuildList().size() * 10) + 49), false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 5); // Object Count + buffer.putFloat(guilds.getComplexity()); + buffer.put(getAsciiString(guilds.getSTFFile())); + buffer.putInt(guilds.getSTFSpacer()); + buffer.put(getAsciiString(guilds.getSTFName())); + buffer.put(getUnicodeString(guilds.getCustomName())); + buffer.putInt(guilds.getVolume()); + buffer.putInt(guilds.getGuildList().size()); + buffer.putInt(guilds.getGuildListUpdateCounter()); + for (Guild object : guilds.getGuildList()) { + buffer.put(getAsciiString(object.getString())); + } + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("GILD", (byte) 3, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline6() { + GuildObject guilds = (GuildObject) object; + + int capacity = 77; + capacity += (guilds.getCurrentServerGCWZonePercentList().size() * 30); + capacity += (guilds.getCurrentServerGCWTotalPercentList().size() * 14); + capacity += (guilds.getCurrentServerGCWZoneInfoList().size() * 34); + capacity += (guilds.getCurrentServerGCWTotalInfoList().size() * 18); + capacity += (guilds.getOtherServerGCWZonePercentList().size() * 45); + capacity += (guilds.getOtherServerGCWTotalPercentList().size() * 29); + + IoBuffer buffer = bufferPool.allocate(capacity, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 9); // Object Count + buffer.putInt(guilds.getServerId()); + buffer.put(getAsciiString(guilds.getSTFFile())); + buffer.putInt(guilds.getUnknown1()); + buffer.putShort(guilds.getUnknown2()); + buffer.putInt(guilds.getCurrentServerGCWZonePercentList().size()); + buffer.putInt(guilds.getCurrentServerGCWZonePercentListUpdateCounter()); + for (CurrentServerGCWZonePercent object : guilds.getCurrentServerGCWZonePercentList()) { + buffer.put(object.getUnknown()); + buffer.put(getAsciiString(object.getZone())); + buffer.putInt(object.getPercent()); + } + buffer.putInt(guilds.getCurrentServerGCWTotalPercentList().size()); + buffer.putInt(guilds.getCurrentServerGCWTotalPercentListUpdateCounter()); + for (CurrentServerGCWZonePercent object : guilds.getCurrentServerGCWTotalPercentList()) { + buffer.put(object.getUnknown()); + buffer.put(getAsciiString(object.getZone())); + buffer.putInt(object.getPercent()); + } + buffer.putInt(guilds.getCurrentServerGCWZoneInfoList().size()); + buffer.putInt(guilds.getCurrentServerGCWZoneInfoListUpdateCounter()); + for (CurrentServerGCWZoneInfo object : guilds.getCurrentServerGCWZoneInfoList()) { + buffer.put(object.getUnknown1()); + buffer.put(getAsciiString(object.getZone())); + buffer.putInt(object.getUnknown2()); + buffer.putInt(object.getPercent()); + } + buffer.putInt(guilds.getCurrentServerGCWTotalInfoList().size()); + buffer.putInt(guilds.getCurrentServerGCWTotalInfoListUpdateCounter()); + for (CurrentServerGCWZoneInfo object : guilds.getCurrentServerGCWTotalInfoList()) { + buffer.put(object.getUnknown1()); + buffer.put(getAsciiString(object.getZone())); + buffer.putInt(object.getUnknown2()); + buffer.putInt(object.getPercent()); + } + buffer.putInt(guilds.getOtherServerGCWZonePercentList().size()); + buffer.putInt(guilds.getOtherServerGCWZonePercentListUpdateCounter()); + for (OtherServerGCWZonePercent object : guilds.getOtherServerGCWZonePercentList()) { + buffer.put(object.getUnknown()); + buffer.put(getAsciiString(object.getServer())); + buffer.put(getAsciiString(object.getZone())); + buffer.putInt(object.getPercent()); + } + buffer.putInt(guilds.getOtherServerGCWTotalPercentList().size()); + buffer.putInt(guilds.getOtherServerGCWTotalPercentListUpdateCounter()); + for (OtherServerGCWZonePercent object : guilds.getOtherServerGCWTotalPercentList()) { + buffer.put(object.getUnknown()); + buffer.put(getAsciiString(object.getServer())); + buffer.put(getAsciiString(object.getZone())); + buffer.putInt(object.getPercent()); + } + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("GILD", (byte) 6, buffer, size); + + return buffer; + } + + @Override + public void sendBaselines() { + // TODO Auto-generated method stub + + } } diff --git a/src/resources/objects/guild/GuildObject.java b/src/resources/objects/guild/GuildObject.java index 3c80b9dd..9b8785d0 100644 --- a/src/resources/objects/guild/GuildObject.java +++ b/src/resources/objects/guild/GuildObject.java @@ -1,26 +1,292 @@ -/******************************************************************************* - * Copyright (c) 2013 - * - * This File is part of NGECore2. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. - * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. - ******************************************************************************/ package resources.objects.guild; -public class GuildObject { +import java.util.ArrayList; +import java.util.List; +import com.sleepycat.persist.model.NotPersistent; + +import clients.Client; +import resources.objects.CurrentServerGCWZoneInfo; +import resources.objects.CurrentServerGCWZonePercent; +import resources.objects.Guild; +import resources.objects.OtherServerGCWZonePercent; +import resources.objects.SWGObject; + +public class GuildObject extends SWGObject { + + // GILD 3 + private float complexity = 0x803F0F00; + private String STFFile = "string_id_table"; + private int STFSpacer = 0; + private String STFName = ""; + private String customName = ""; + private int volume = 0; + private List guildList = new ArrayList(); + @NotPersistent + private int guildListUpdateCounter = 0; + + // GILD 6 + private int serverId = 0x41000000; + //private String STFName = "string_id_table"; + private int unknown1 = 0; + private short unknown2 = 0; + + private List currentServerGCWZonePercentList = new ArrayList(); + @NotPersistent + private int currentServerGCWZonePercentListUpdateCounter = 0; + + private List currentServerGCWTotalPercentList = new ArrayList(); + @NotPersistent + private int currentServerGCWTotalPercentListUpdateCounter = 0; + + private List currentServerGCWZoneInfoList = new ArrayList(); + @NotPersistent + private int currentServerGCWZoneInfoListUpdateCounter = 0; + + private List currentServerGCWTotalInfoList = new ArrayList(); + @NotPersistent + private int currentServerGCWTotalInfoListUpdateCounter = 0; + + private List otherServerGCWZonePercentList = new ArrayList(); + @NotPersistent + private int otherServerGCWZonePercentListUpdateCounter = 0; + + private List otherServerGCWTotalPercentList = new ArrayList(); + @NotPersistent + private int otherServerGCWTotalPercentListUpdateCounter = 0; + + @NotPersistent + private GuildMessageBuilder messageBuilder; + + public GuildObject() { + super(); + messageBuilder = new GuildMessageBuilder(this); + } + + public float getComplexity() { + synchronized(objectMutex) { + return complexity; + } + } + + public void setComplexity(float complexity) { + synchronized(objectMutex) { + this.complexity = complexity; + } + } + + public String getSTFFile() { + synchronized(objectMutex) { + return STFFile; + } + } + + public void setSTFFile(String STFFile) { + synchronized(objectMutex) { + this.STFFile = STFFile; + } + } + + public int getSTFSpacer() { + synchronized(objectMutex) { + return STFSpacer; + } + } + + public void setSTFSpacer(int STFSpacer) { + synchronized(objectMutex) { + this.STFSpacer = STFSpacer; + } + } + + public String getSTFName() { + synchronized(objectMutex) { + return STFName; + } + } + + public void setSTFName(String STFName) { + synchronized(objectMutex) { + this.STFName = STFName; + } + } + + public String getCustomName() { + synchronized(objectMutex) { + return customName; + } + } + + public void setCustomName(String customName) { + synchronized(objectMutex) { + this.customName = customName; + } + } + + public int getVolume() { + synchronized(objectMutex) { + return volume; + } + } + + public void setVolume(int volume) { + synchronized(objectMutex) { + this.volume = volume; + } + } + + public List getGuildList() { + return guildList; + } + + public int getGuildListUpdateCounter() { + synchronized(objectMutex) { + return guildListUpdateCounter; + } + } + + public void setGuildListUpdateCounter(int guildListUpdateCounter) { + synchronized(objectMutex) { + this.guildListUpdateCounter = guildListUpdateCounter; + } + } + + public int getServerId() { + synchronized(objectMutex) { + return serverId; + } + } + + public void setServerId(int serverId) { + synchronized(objectMutex) { + this.serverId = serverId; + } + } + + public int getUnknown1() { + synchronized(objectMutex) { + return unknown1; + } + } + + public void setUnknown1(int unknown1) { + synchronized(objectMutex) { + this.unknown1 = unknown1; + } + } + + public short getUnknown2() { + synchronized(objectMutex) { + return unknown2; + } + } + + public void setUnknown2(short unknown2) { + synchronized(objectMutex) { + this.unknown2 = unknown2; + } + } + + public List getCurrentServerGCWZonePercentList() { + return currentServerGCWZonePercentList; + } + + public int getCurrentServerGCWZonePercentListUpdateCounter() { + synchronized(objectMutex) { + return currentServerGCWZonePercentListUpdateCounter; + } + } + + public void setCurrentServerGCWZonePercentListUpdateCounter(int currentServerGCWZonePercentListUpdateCounter) { + synchronized(objectMutex) { + this.currentServerGCWZonePercentListUpdateCounter = currentServerGCWZonePercentListUpdateCounter; + } + } + + public List getCurrentServerGCWTotalPercentList() { + return currentServerGCWTotalPercentList; + } + + public int getCurrentServerGCWTotalPercentListUpdateCounter() { + synchronized(objectMutex) { + return currentServerGCWTotalPercentListUpdateCounter; + } + } + + public void setCurrentServerGCWTotalPercentListUpdateCounter(int currentServerGCWTotalPercentListUpdateCounter) { + synchronized(objectMutex) { + this.currentServerGCWTotalPercentListUpdateCounter = currentServerGCWTotalPercentListUpdateCounter; + } + } + + public List getCurrentServerGCWZoneInfoList() { + return currentServerGCWZoneInfoList; + } + + public int getCurrentServerGCWZoneInfoListUpdateCounter() { + synchronized(objectMutex) { + return currentServerGCWZoneInfoListUpdateCounter; + } + } + + public void setCurrentServerGCWZoneInfoListUpdateCounter(int currentServerGCWZoneInfoListUpdateCounter) { + synchronized(objectMutex) { + this.currentServerGCWZoneInfoListUpdateCounter = currentServerGCWZoneInfoListUpdateCounter; + } + } + + public List getCurrentServerGCWTotalInfoList() { + return currentServerGCWTotalInfoList; + } + + public int getCurrentServerGCWTotalInfoListUpdateCounter() { + synchronized(objectMutex) { + return currentServerGCWTotalInfoListUpdateCounter; + } + } + + public void setCurrentServerGCWTotalInfoListUpdateCounter(int currentServerGCWTotalInfoListUpdateCounter) { + synchronized(objectMutex) { + this.currentServerGCWTotalInfoListUpdateCounter = currentServerGCWTotalInfoListUpdateCounter; + } + } + + public List getOtherServerGCWZonePercentList() { + return otherServerGCWZonePercentList; + } + + public int getOtherServerGCWZonePercentListUpdateCounter() { + synchronized(objectMutex) { + return otherServerGCWZonePercentListUpdateCounter; + } + } + + public void setOtherServerGCWZonePercentListUpdateCounter(int otherServerGCWZonePercentListUpdateCounter) { + synchronized(objectMutex) { + this.otherServerGCWZonePercentListUpdateCounter = otherServerGCWZonePercentListUpdateCounter; + } + } + + public List getOtherServerGCWTotalPercentList() { + return otherServerGCWTotalPercentList; + } + + public int getOtherServerGCWTotalPercentListUpdateCounter() { + synchronized(objectMutex) { + return otherServerGCWTotalPercentListUpdateCounter; + } + } + + public void setOtherServerGCWTotalPercentListUpdateCounter(int otherServerGCWTotalPercentListUpdateCounter) { + synchronized(objectMutex) { + this.otherServerGCWTotalPercentListUpdateCounter = otherServerGCWTotalPercentListUpdateCounter; + } + } + + @Override + public void sendBaselines(Client destination) { + destination.getSession().write(messageBuilder.buildBaseline3()); + destination.getSession().write(messageBuilder.buildBaseline6()); + } + }