diff --git a/src/resources/datatables/Citizenship.java b/src/resources/datatables/Citizenship.java new file mode 100644 index 00000000..ced0f364 --- /dev/null +++ b/src/resources/datatables/Citizenship.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.datatables; + +public class Citizenship { + + public static final byte Homeless = 0; + public static final byte Citizen = 1; + public static final byte Militia = 2; + public static final byte Mayor = 3; + +} diff --git a/src/resources/gcw/RegionDefender.java b/src/resources/gcw/RegionDefender.java new file mode 100644 index 00000000..e72d1877 --- /dev/null +++ b/src/resources/gcw/RegionDefender.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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.gcw; + +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.common.AString; +import engine.resources.objects.Baseline; +import engine.resources.objects.Delta; + +public class RegionDefender extends Delta { + + private static final long serialVersionUID = 1L; + + private AString region; + private byte byte1 = 0; + private byte byte2 = 0; + + public RegionDefender(String region, byte byte1, byte byte2) { + this.region = new AString(region); + this.byte1 = byte1; + this.byte2 = byte2; + } + + public RegionDefender(String region) { + this.region = new AString(region); + } + + public RegionDefender() { + this.region = new AString(); + } + + public String getRegion() { + synchronized(objectMutex) { + return region.get(); + } + } + + public void setRegion(String region) { + synchronized(objectMutex) { + this.region = new AString(region); + } + } + + public byte getByte1() { + synchronized(objectMutex) { + return byte1; + } + } + + public void setByte1(byte byte1) { + synchronized(objectMutex) { + this.byte1 = byte1; + } + } + + public byte getByte2() { + synchronized(objectMutex) { + return byte2; + } + } + + public void setByte2(byte byte2) { + synchronized(objectMutex) { + this.byte2 = byte2; + } + } + + public byte[] getBytes() { + synchronized(objectMutex) { + IoBuffer buffer = Baseline.createBuffer(region.getBytes().length + 2); + buffer.put(region.getBytes()); + buffer.put(byte1); + buffer.put(byte2); + return buffer.array(); + } + } + +} diff --git a/src/resources/objects/tool/SurveyTool.java b/src/resources/harvest/SurveyTool.java similarity index 97% rename from src/resources/objects/tool/SurveyTool.java rename to src/resources/harvest/SurveyTool.java index 464c8534..f23be1d2 100644 --- a/src/resources/objects/tool/SurveyTool.java +++ b/src/resources/harvest/SurveyTool.java @@ -19,16 +19,13 @@ * 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.tool; +package resources.harvest; import java.io.Serializable; import java.util.Vector; import main.NGECore; -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -40,8 +37,6 @@ import resources.objects.tangible.TangibleObject; /** * @author Charon */ - -@Persistent(version=0) public class SurveyTool extends TangibleObject implements Serializable { private static final long serialVersionUID = 1L; @@ -51,25 +46,15 @@ public class SurveyTool extends TangibleObject implements Serializable { private Long tanoID=0L; private byte SurveyRangeSetting=0; - @NotPersistent private transient String surveyEffectString=""; - @NotPersistent private transient String sampleEffectString=""; - @NotPersistent private transient boolean currentlySurveying=false; - @NotPersistent private transient boolean currentlySampling=false; - @NotPersistent private transient boolean currentlyCoolingDown=false; - @NotPersistent private transient boolean exceptionalState=false; - @NotPersistent private transient boolean recoveryMode=false; - @NotPersistent private transient Long lastSurveyTime=0L; - @NotPersistent private transient Long lastSampleTime=0L; - @NotPersistent private transient Long recoveryTime=10L; public static byte MineralSurveyDevice = 1; diff --git a/src/resources/objects/guild/GuildObject.java b/src/resources/objects/guild/GuildObject.java index b3723937..e87d3210 100644 --- a/src/resources/objects/guild/GuildObject.java +++ b/src/resources/objects/guild/GuildObject.java @@ -34,7 +34,6 @@ import resources.gcw.CurrentServerGCWZonePercent; import resources.gcw.OtherServerGCWZonePercent; import resources.guild.Guild; import resources.objects.ObjectMessageBuilder; -import resources.objects.SWGList; import resources.objects.SWGMap; import resources.objects.SWGMultiMap; import resources.objects.SWGSet; diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index a1a19436..adc62e2b 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -21,16 +21,10 @@ ******************************************************************************/ package resources.objects.player; -import java.nio.ByteOrder; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; - -import org.apache.mina.core.buffer.IoBuffer; import engine.resources.objects.Builder; import resources.objects.intangible.IntangibleMessageBuilder; -import resources.objects.waypoint.WaypointObject; public class PlayerMessageBuilder extends IntangibleMessageBuilder { @@ -42,633 +36,6 @@ public class PlayerMessageBuilder extends IntangibleMessageBuilder { super(); } - public IoBuffer buildBaseline3() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - buffer.putShort((short) 0x14); - buffer.putFloat(1); - buffer.put(getAsciiString("string_id_table")); - buffer.putInt(0); // spacer - buffer.putShort((short) 0); - buffer.putInt(0); // custom name - buffer.putInt(0); // volume - buffer.putInt(0); // generic int - - buffer.putInt(4); // flag bitmask list size - buffer.putInt(player.getFlagBitmask()); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(4); // profile bitmask list size - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - if(player.getTitle() == null || player.getTitle().length() < 1) - buffer.putShort((short) 0); - else - buffer.put(getAsciiString(player.getTitle())); - - buffer.putInt(0); // born date - Needs to be in yyymmdd format - Stored as epoch time of character create - - buffer.putInt(player.getTotalPlayTime()); // total play time? - - buffer.putInt(player.getProfessionIcon()); - - buffer.put(getAsciiString(player.getProfession())); - buffer.putInt(0); // GCW - buffer.putInt(0); // PvP Kills - buffer.putLong(0); // Lifetime GCW - buffer.putInt(0); // Lifetime PvP Kills - buffer.putInt(player.getCollections().length); - buffer.putInt(player.getHighestSetBit()); - buffer.put(player.getCollections()); - buffer.putInt(0); // Unknown, part of one delta, maybe a list - buffer.putInt(0); // Unknown, part of one delta, maybe a list - buffer.put((byte) ((player.isShowBackpack()) ? 1 : 0)); - buffer.put((byte) ((player.isShowHelmet()) ? 1 : 0)); - - int size = buffer.position(); - - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 3, buffer, size); - - return buffer; - - } - - public IoBuffer buildBaseline6() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - buffer.putShort((short) 0x11); - buffer.putInt((short) 0x43); - buffer.put(getAsciiString("string_id_table")); - buffer.putInt(0); // probably stringId - buffer.putShort((short) 0); // detailedDescription - buffer.put(player.getGodLevel()); - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - if(player.getHome() == null || player.getHome().length() < 1) { - buffer.putShort((short) 0); - } else { - buffer.put(getAsciiString(player.getHome())); - } - buffer.putInt(0); // unk - buffer.put((byte) 0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - - int size = buffer.position(); - - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 6, buffer, size); - - return buffer; - - } - - public IoBuffer buildBaseline8() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - buffer.putShort((short) 0x09); - - if(player.getXpList().isEmpty()) { - buffer.putInt(0); - buffer.putInt(player.getXpListUpdateCounter()); - } else { - buffer.putInt(player.getXpList().size()); - buffer.putInt(player.getXpListUpdateCounter()); - - // no need for locking here, concurrent hash map iterator wont throw concurrency exceptions and multiple thread access at zone in is unlikely to occur for the PlayerObject - for(Entry entry : player.getXpList().entrySet()) { - - buffer.put((byte) 0); - buffer.put(getAsciiString(entry.getKey())); - buffer.putInt(entry.getValue()); - - } - - } - - if(player.getWaypoints().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(player.getWaypoints().size()); - buffer.putInt(0); - - synchronized(player.getWaypoints()) { - - for(WaypointObject waypoint : player.getWaypoints()) { - - buffer.put((byte) 0); - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - buffer.putLong(waypoint.getLocationNetworkId()); - buffer.putInt(waypoint.getPlanetCRC()); - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - buffer.put(waypoint.getColor()); - buffer.put((byte) (waypoint.isActive() ? 1 : 0)); - - } - - } - } - - buffer.putInt(0); // Current force power ? - buffer.putInt(0); // Max force power ? - buffer.putInt(0); // Current FS Quest List size ? - buffer.putInt(0); // Current FS Quest List update counter ? - - buffer.putInt(0); // Completed FS Quest List size ? - buffer.putInt(0); // Completed FS Quest List update counter ? - - buffer.putInt(0); // Quest Journal List size ? - buffer.putInt(0); // Quest Journal List update counter ? - - buffer.putInt(0); // unk - - buffer.put(getAsciiString(player.getProfessionWheelPosition())); - int size = buffer.position(); - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 8, buffer, size); - - return buffer; - -} - - public IoBuffer buildBaseline9() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - - buffer.putShort((short) 0x1F); - - buffer.putInt(0); // ExperimentationFlag? - buffer.putInt(0); // CraftingStage? - - buffer.putLong(0); // Nearest Crafting Station id ? - - - buffer.putInt(0); // Draft Schematic List Size - buffer.putInt(0); // Draft Schematic List update counter - - buffer.putInt(0); // ExperimentationPoints? - buffer.putInt(0); // CraftingStage? - - buffer.putInt(8); // unk - - buffer.putInt(0); // unk - - if(player.getFriendList().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(player.getFriendList().size()); - buffer.putInt(player.getFriendListUpdateCounter()); - - synchronized(player.getFriendList()) { - - for(String friend : player.getFriendList()) { - buffer.put(getAsciiString(friend)); - } - } - } - - if(player.getIgnoreList().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(player.getIgnoreList().size()); - buffer.putInt(player.getIgnoreListUpdateCounter()); - - synchronized(player.getIgnoreList()) { - - for(String ignored : player.getIgnoreList()) { - buffer.put(getAsciiString(ignored)); - } - - } - } - - buffer.putInt(1); - buffer.putInt(0); // Current stomach unused in NGE - buffer.putInt(0x64); // Max stomach unused in NGE - buffer.putInt(0); // Current drink unused in NGE - buffer.putInt(0x64); // Max drink unused in NGE - buffer.putInt(0); // Current consumable unused in NGE - buffer.putInt(0x64); // Max consumable unused in NGE - - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); // jedi state??? - buffer.putShort((short) 0); - int size = buffer.position(); - - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 9, buffer, size); - - return buffer; - - } - - public IoBuffer buildTitleDelta(String title) { - IoBuffer buffer = bufferPool.allocate(4 + getAsciiString(title).length, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(title)); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x07, buffer, size + 4); - return buffer; - - } - - public IoBuffer buildProfessionIconDelta(int professionIcon) { - IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(professionIcon); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x0A, buffer, size + 4); - return buffer; - } - - public IoBuffer buildCollectionsDelta(byte[] collections, int highestSetBit) { - IoBuffer buffer = bufferPool.allocate(8 + collections.length, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(collections.length); - buffer.putInt(highestSetBit); - for (byte collection : collections) buffer.put(collection); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 16, buffer, size + 4); - return buffer; - } - - public IoBuffer buildXPListDelta(String type, int amount, boolean alreadyExists) { - PlayerObject player = (PlayerObject) object; - player.setXpListUpdateCounter(player.getXpListUpdateCounter() + 1); - - IoBuffer result = bufferPool.allocate(15 + type.length(), false).order(ByteOrder.LITTLE_ENDIAN); - - result.putInt(1); - result.putInt(player.getXpListUpdateCounter()); - result.put((byte) ((alreadyExists) ? 2 : 0)); - result.put(getAsciiString(type)); - result.putInt(amount); - - int size = result.position(); - result.flip(); - result = createDelta("PLAY", (byte) 8, (short) 1, (short) 0, result, size + 4); - return result; - } - - public IoBuffer buildProfessionWheelPositionDelta(String professionWheelPosition) { - IoBuffer buffer = bufferPool.allocate(2 + professionWheelPosition.length(), false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put(getAsciiString(professionWheelPosition)); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 8, buffer, size + 4); - return buffer; - - } - - public IoBuffer buildWaypointAddDelta(WaypointObject waypoint) { - - PlayerObject player = (PlayerObject) object; - IoBuffer buffer = bufferPool.allocate(59 + waypoint.getName().length() * 2, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - - int nextCounter = player.getWaypointListUpdateCounter() + 1; - player.setWaypointListUpdateCounter(nextCounter); - buffer.putInt(1); - buffer.putInt(player.getWaypointListUpdateCounter()); - - buffer.put((byte) 0); // updateType (SubType) - - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - - buffer.putLong(0); // networklocationId - buffer.putInt(waypoint.getPlanetCRC()); - - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - - buffer.put((byte) waypoint.getColor()); - - if (waypoint.isActive()) { buffer.put((byte) 1); } - else { buffer.put((byte) 0); } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 1, buffer, size + 4); - //System.out.println("WaypointAdd: " + buffer.getHexDump()); - return buffer; - - } - - public IoBuffer buildWaypointRemoveDelta(WaypointObject waypoint) { - - IoBuffer buffer = bufferPool.allocate(59 + waypoint.getName().length() * 2, false).order(ByteOrder.LITTLE_ENDIAN); - PlayerObject player = (PlayerObject) object; - - int nextCounter = player.getWaypointListUpdateCounter() + 1; - player.setWaypointListUpdateCounter(nextCounter); - - buffer.putInt(1); - buffer.putInt(player.getWaypointListUpdateCounter()); - - buffer.put((byte) 1); // updateType (SubType) - - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - - buffer.putLong(0); // networklocationId - buffer.putInt(waypoint.getPlanetCRC()); - - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - - buffer.put((byte) waypoint.getColor()); - - if (waypoint.isActive()) { buffer.put((byte) 1); } - else { buffer.put((byte) 0); } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 1, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildWaypointUpdateDelta(WaypointObject waypoint) { - - IoBuffer buffer = bufferPool.allocate(59 + waypoint.getName().length() * 2, false).order(ByteOrder.LITTLE_ENDIAN); - PlayerObject player = (PlayerObject) object; - - int nextCounter = player.getWaypointListUpdateCounter() + 1; - player.setWaypointListUpdateCounter(nextCounter); - - buffer.putInt(1); - buffer.putInt(player.getWaypointListUpdateCounter()); - - buffer.put((byte) 2); // updateType (SubType) - - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - - buffer.putLong(0); // networklocationId << cluster system I guess? - buffer.putInt(waypoint.getPlanetCRC()); - - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - - buffer.put((byte) waypoint.getColor()); - - if (waypoint.isActive()) { buffer.put((byte) 1); } - else { buffer.put((byte) 0); } // isActive. Activates automatically when created. - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 1, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildTotalPlayTimeDelta(int totalPlayTime) { - - IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(totalPlayTime); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x09, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildFriendAddDelta(List friends) { - - IoBuffer buffer = bufferPool.allocate(13 + (friends.size() * 2), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getFriendListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) (player.getFriendList().size())); - for (String f : friends) { - buffer.put(getAsciiString(f)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 7, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildFriendRemoveDelta(List friends) { - - IoBuffer buffer = bufferPool.allocate(13 + (friends.size() * 2), false).order(ByteOrder.LITTLE_ENDIAN); - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getFriendListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) friends.size()); - for (String f : friends) { - buffer.put(getAsciiString(f)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 7, buffer, size + 4); - - return buffer; - } - - - public IoBuffer buildIgnoreAddDelta(List ignoreList) { - IoBuffer buffer = bufferPool.allocate(13 + (ignoreList.size() * 2) , false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getIgnoreListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) ignoreList.size()); - for (String ignore : ignoreList) { - buffer.put(getAsciiString(ignore)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 8, buffer, size + 4); - - return buffer; - } - - public IoBuffer buildIgnoreRemoveDelta(List ignoreList) { - IoBuffer buffer = bufferPool.allocate(13 + (ignoreList.size() * 2) , false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getIgnoreListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) ignoreList.size()); - for (String ignore : ignoreList) { - buffer.put(getAsciiString(ignore)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 8, buffer, size + 4); - - return buffer; - } - - public IoBuffer buildFlagBitmask(int bitmask) { - IoBuffer buffer = bufferPool.allocate(20, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(4); - buffer.putInt(bitmask); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 5, buffer, size + 4); - return buffer; - } - - public IoBuffer buildShowBackpackDelta(boolean showBackpack) { - IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put((byte) (showBackpack ? 1 : 0)); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 18, buffer, size + 4); - return buffer; - } - - public IoBuffer buildShowHelmetDelta(boolean showHelmet) { - IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put((byte) (showHelmet ? 1 : 0)); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 19, buffer, size + 4); - return buffer; - } - - public IoBuffer buildGodLevelDelta(byte godLevel) { - IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(godLevel); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 6, (short) 1, (short) 0x02, buffer, size + 4); - return buffer; - - } - @Override public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { super.buildBaseline3(baselineBuilders, deltaBuilders); @@ -679,10 +46,12 @@ public class PlayerMessageBuilder extends IntangibleMessageBuilder { super.buildBaseline6(baselineBuilders, deltaBuilders); } + @Override public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { super.buildBaseline8(baselineBuilders, deltaBuilders); } + @Override public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { super.buildBaseline9(baselineBuilders, deltaBuilders); } diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 436daeef..79f53655 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -22,934 +22,981 @@ package resources.objects.player; import java.io.Serializable; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.BitSet; -import java.util.HashMap; +import java.util.Calendar; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.TreeMap; import java.util.Vector; +import org.apache.mina.core.buffer.IoBuffer; + import resources.craft.DraftSchematic; -import resources.objects.ObjectMessageBuilder; +import resources.datatables.Professions; +import resources.gcw.RegionDefender; +import resources.harvest.SurveyTool; +import resources.objects.SWGList; +import resources.objects.SWGMap; +import resources.objects.SWGSet; import resources.objects.intangible.IntangibleObject; import resources.objects.resource.ResourceContainerObject; -import resources.objects.tool.SurveyTool; import resources.objects.waypoint.WaypointObject; -import resources.objects.creature.CreatureObject; import resources.quest.Quest; - -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - import engine.clients.Client; +import engine.resources.objects.Baseline; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=13) public class PlayerObject extends IntangibleObject implements Serializable { private static final long serialVersionUID = 1L; - // PLAY 3 - private String title; - private String profession; - private int professionIcon; - private List flagsList = new ArrayList(); - private List profileList = new ArrayList(); - private List titleList = new ArrayList(); - private long bornDate = 0; - private int totalPlayTime = 0; - private byte[] collections = new byte[] { }; - private int highestSetBit = 0; - private int flagBitmask = 0; - private boolean showHelmet = true; - private boolean showBackpack = true; - - // PLAY 6 - - private String home; // Player City Name - - // PLAY 8 - - private Map xpList = new HashMap(); - @NotPersistent - private transient int xpListUpdateCounter = 0; - - private List waypoints = new ArrayList(); - @NotPersistent - private transient int waypointListUpdateCounter = 0; - - private int currentForcePower = 0; // unused in NGE - private int maxForcePower = 0; // unused in NGE - - private List currentFSQuestList = new ArrayList(); // unused in NGE - private List completedFSQuestList = new ArrayList(); // unused in NGE - - private List questJournal = new ArrayList(); - @NotPersistent - private transient int questJournalUpdateCounter = 0; - - private String professionWheelPosition; - - // PLAY 9 - - private int experimentationFlag = 0; - private int craftingStage = 0; - private long nearestCraftingStation = 0; - - private List draftSchematicList = new ArrayList(); - @NotPersistent - private transient int draftSchematicListUpdateCounter = 0; - - private int experimentationPoints = 0; - private int accomplishmentCounter = 0; - - private List friendList = new ArrayList(); - @NotPersistent - private transient int friendListUpdateCounter = 0; - private List ignoreList = new ArrayList(); - @NotPersistent - private transient int ignoreListUpdateCounter = 0; - - private int languageId = 0; // unused in NGE - private int currentStomach = 0; // unused in NGE - private int maxStomach = 0; // unused in NGE - private int currentDrink = 0; // unused in NGE - private int maxDrink = 0; // unused in NGE - private int currentConsumable = 0; // unused - private int maxConsumable = 0; // unused - - // TODO: research new NGE vars between maxConsumable and jediState - - private int jediState = 0; // unused in NGE - - private String biography = ""; - private String spouse; - private String holoEmote; - private int holoEmoteUses; - - private int lotsRemaining = 10; - - @NotPersistent private transient PlayerMessageBuilder messageBuilder; - @NotPersistent private transient long lastPlayTimeUpdate = System.currentTimeMillis(); - private Map factionStandingMap = new TreeMap(); + private transient WaypointObject lastSurveyWaypoint; + private transient SurveyTool lastUsedSurveyTool; + private transient ResourceContainerObject recentContainer; - private WaypointObject lastSurveyWaypoint; - private SurveyTool lastUsedSurveyTool; - private ResourceContainerObject recentContainer; - - private byte godLevel = 0; - - private List chatChannels = new ArrayList(); - - @NotPersistent private transient boolean callingCompanion = false; - - private long bountyMissionId; - private Vector ownedVendors = new Vector(); - private long bindLocation; - - public PlayerObject() { - super(); - messageBuilder = new PlayerMessageBuilder(this); - } + private long bountyMissionId; // Bad because you could have 2 missions public PlayerObject(long objectID, Planet planet) { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/player/shared_player.iff"); - messageBuilder = new PlayerMessageBuilder(this); + } + + public PlayerObject() { + super(); } @Override public void initAfterDBLoad() { super.init(); lastPlayTimeUpdate = System.currentTimeMillis(); - messageBuilder = new PlayerMessageBuilder(this); - waypoints.forEach(WaypointObject::initAfterDBLoad); - } - - public String getTitle() { - synchronized(objectMutex) { - return title; - } - } - - public void setTitle(String title) { - synchronized(objectMutex) { - if(!getTitleList().isEmpty() && getTitleList().contains(title)) { - this.title = title; - } - - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildTitleDelta(title), true); - } - } - - public String getProfession() { - synchronized(objectMutex) { - return profession; - } - } - - public void setProfession(String profession) { - synchronized(objectMutex) { - this.profession = profession; - } - } - - public List getFlagsList() { - return flagsList; - } - - public List getProfileList() { - return profileList; - } - - public long getBornDate() { - synchronized(objectMutex) { - return bornDate; - } - } - - public void setBornDate(long bornDate) { - synchronized(objectMutex) { - this.bornDate = bornDate; - } - } - - public int getTotalPlayTime() { - synchronized(objectMutex) { - return totalPlayTime; - } - } - - public void setTotalPlayTime(int totalPlayTime) { - synchronized(objectMutex) { - this.totalPlayTime = totalPlayTime; - } - //notifyObservers(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime), true); - getContainer().getClient().getSession().write(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime)); - } - - public String getHome() { - synchronized(objectMutex) { - return home; - } - } - - public void setHome(String home) { - synchronized(objectMutex) { - this.home = home; - } - } - - public Map getXpList() { - return xpList; - } - - public int getXp(String type) { - synchronized(objectMutex) { - return ((!xpList.containsKey(type)) ? 0 : xpList.get(type)); - } - } - - // Temporary - public void setXp(String type, int amount) { - boolean xpExists; - - synchronized(objectMutex) { - xpExists = xpList.containsKey(type); - xpList.put(type, amount); - //Console.println("Put " + type + " exp of " + amount + " in the map."); - //Console.println("Map is now: " + xpList.get(type).intValue()); - } - - if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildXPListDelta(type, amount, xpExists)); - ((CreatureObject) getContainer()).setXpBarValue(amount); - } - - } - - public int getXpListUpdateCounter() { - synchronized(objectMutex) { - return xpListUpdateCounter; - } - } - - public void setXpListUpdateCounter(int xpListUpdateCounter) { - synchronized(objectMutex) { - this.xpListUpdateCounter = xpListUpdateCounter; - } - } - - public List getWaypoints() { - return waypoints; - } - - public int getWaypointListUpdateCounter() { - synchronized(objectMutex) { - return waypointListUpdateCounter; - } - } - - public void setWaypointListUpdateCounter(int count) { - synchronized(objectMutex){ - this.waypointListUpdateCounter = count; - } - } - - public void waypointUpdate(WaypointObject waypoint) { - synchronized(objectMutex) { - getContainer().getClient().getSession().write(messageBuilder.buildWaypointUpdateDelta(waypoint)); - } - } - - public void waypointRemove(WaypointObject waypoint) { - synchronized(objectMutex) { - getContainer().getClient().getSession().write(messageBuilder.buildWaypointRemoveDelta(waypoint)); - getWaypoints().remove(waypoint); - } - } - - public void waypointAdd(WaypointObject waypoint) { - synchronized(objectMutex) { - getContainer().getClient().getSession().write(messageBuilder.buildWaypointAddDelta(waypoint)); - getWaypoints().add(waypoint); - } - } - - public WaypointObject getWaypointFromList(WaypointObject waypoint) { - if (waypoint == null) - return null; - - synchronized(objectMutex) { - for(WaypointObject wp : waypoints) { - if(wp.getObjectID() == waypoint.getObjectID()) - return wp; - } - } - return null; - } - - public int getCurrentForcePower() { - synchronized(objectMutex) { - return currentForcePower; - } - } - - public void setCurrentForcePower(int currentForcePower) { - synchronized(objectMutex) { - this.currentForcePower = currentForcePower; - } - } - - public int getMaxForcePower() { - synchronized(objectMutex) { - return maxForcePower; - } - } - - public void setMaxForcePower(int maxForcePower) { - synchronized(objectMutex) { - this.maxForcePower = maxForcePower; - } - } - - public List getCurrentFSQuestList() { - return currentFSQuestList; - } - - public List getCompletedFSQuestList() { - return completedFSQuestList; - } - - public List getQuestJournal() { - return questJournal; - } - - public String getProfessionWheelPosition() { - synchronized(objectMutex) { - return professionWheelPosition; - } - } - - public void setProfessionWheelPosition(String professionWheelPosition) { - synchronized(objectMutex) { - this.professionWheelPosition = professionWheelPosition; - } - if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildProfessionWheelPositionDelta(professionWheelPosition)); - } - } - - public int getExperimentationFlag() { - synchronized(objectMutex) { - return experimentationFlag; - } - } - - public void setExperimentationFlag(int experimentationFlag) { - synchronized(objectMutex) { - this.experimentationFlag = experimentationFlag; - } - } - - public int getCraftingStage() { - synchronized(objectMutex) { - return craftingStage; - } - } - - public void setCraftingStage(int craftingStage) { - synchronized(objectMutex) { - this.craftingStage = craftingStage; - } - } - - public long getNearestCraftingStation() { - synchronized(objectMutex) { - return nearestCraftingStation; - } - } - - public void setNearestCraftingStation(long nearestCraftingStation) { - synchronized(objectMutex) { - this.nearestCraftingStation = nearestCraftingStation; - } - } - - public List getDraftSchematicList() { - return draftSchematicList; - } - - public int getExperimentationPoints() { - synchronized(objectMutex) { - return experimentationPoints; - } - } - - public void setExperimentationPoints(int experimentationPoints) { - synchronized(objectMutex) { - this.experimentationPoints = experimentationPoints; - } - } - - public int getAccomplishmentCounter() { - synchronized(objectMutex) { - return accomplishmentCounter; - } - } - - public void setAccomplishmentCounter(int accomplishmentCounter) { - synchronized(objectMutex) { - this.accomplishmentCounter = accomplishmentCounter; - } - } - - public List getFriendList() { - return friendList; - } - - public int getFriendListUpdateCounter() { - synchronized(objectMutex) { - return friendListUpdateCounter; - } - } - - public void setFriendListUpdateCounter(int friendListUpdateCounter) { - synchronized(objectMutex) { - this.friendListUpdateCounter = friendListUpdateCounter; - } - } - - public void friendAdd(String friend) { - synchronized(objectMutex) { - setFriendListUpdateCounter(getFriendListUpdateCounter() + 1); - friendList.add(friend); - getContainer().getClient().getSession().write(messageBuilder.buildFriendAddDelta(getFriendList())); - } - } - - public void friendRemove(String friend) { - synchronized(objectMutex) { - setFriendListUpdateCounter(getFriendListUpdateCounter() + 1); - friendList.remove(friend); - getContainer().getClient().getSession().write(messageBuilder.buildFriendRemoveDelta(getFriendList())); - } - } - - public List getIgnoreList() { - return ignoreList; - } - - public int getIgnoreListUpdateCounter() { - synchronized(objectMutex) { - return ignoreListUpdateCounter; - } - } - - public void ignoreAdd(String ignoreName) { - synchronized(objectMutex) { - setIgnoreListUpdateCounter(getIgnoreListUpdateCounter() + 1); - ignoreList.add(ignoreName); - getContainer().getClient().getSession().write(messageBuilder.buildIgnoreAddDelta(getIgnoreList())); - } - } - - public void ignoreRemove(String removeName) { - synchronized(objectMutex) { - setIgnoreListUpdateCounter(getIgnoreListUpdateCounter() + 1); - ignoreList.remove(removeName); - getContainer().getClient().getSession().write(messageBuilder.buildIgnoreRemoveDelta(getIgnoreList())); - } - } - - public void setIgnoreListUpdateCounter(int ignoreListUpdateCounter) { - synchronized(objectMutex) { - this.ignoreListUpdateCounter = ignoreListUpdateCounter; - } - } - - - public int getLanguageId() { - synchronized(objectMutex) { - return languageId; - } - } - - public void setLanguageId(int languageId) { - synchronized(objectMutex) { - this.languageId = languageId; - } - } - - public int getCurrentStomach() { - synchronized(objectMutex) { - return currentStomach; - } - } - - public void setCurrentStomach(int currentStomach) { - synchronized(objectMutex) { - this.currentStomach = currentStomach; - } - } - - public int getMaxStomach() { - synchronized(objectMutex) { - return maxStomach; - } - } - - public void setMaxStomach(int maxStomach) { - synchronized(objectMutex) { - this.maxStomach = maxStomach; - } - } - - public int getCurrentDrink() { - synchronized(objectMutex) { - return currentDrink; - } - } - - public void setCurrentDrink(int currentDrink) { - synchronized(objectMutex) { - this.currentDrink = currentDrink; - } - } - - public int getMaxDrink() { - synchronized(objectMutex) { - return maxDrink; - } - } - - public void setMaxDrink(int maxDrink) { - synchronized(objectMutex) { - this.maxDrink = maxDrink; - } - } - - public int getCurrentConsumable() { - synchronized(objectMutex) { - return currentConsumable; - } - } - - public void setCurrentConsumable(int currentConsumable) { - synchronized(objectMutex) { - this.currentConsumable = currentConsumable; - } - } - - public int getMaxConsumable() { - synchronized(objectMutex) { - return maxConsumable; - } - } - - public void setMaxConsumable(int maxConsumable) { - synchronized(objectMutex) { - this.maxConsumable = maxConsumable; - } - } - - public int getJediState() { - synchronized(objectMutex) { - return jediState; - } - } - - public void setJediState(int jediState) { - synchronized(objectMutex) { - this.jediState = jediState; - } - } - - public Map getFactionStandingMap() { - return factionStandingMap; - } - - public void setFactionStanding(String faction, int factionStanding) { - synchronized(objectMutex) { - factionStandingMap.put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); - } - } - - public void modifyFactionStanding(String faction, int modifier) { - synchronized(objectMutex) { - int factionStanding = (((factionStandingMap.containsKey(faction)) ? factionStandingMap.get(faction) : 0) + modifier); - factionStandingMap.put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); - } - } - - public int getFactionStanding(String faction) { - synchronized(objectMutex) { - return ((factionStandingMap.containsKey(faction)) ? factionStandingMap.get(faction) : 0); - } } @Override - public void sendBaselines(Client destination) { - - if(destination == null || destination.getSession() == null) - return; - destination.getSession().write(messageBuilder.buildBaseline3()); - destination.getSession().write(messageBuilder.buildBaseline6()); - if(destination.getParent().getObjectID() == getParentId()) { // only send to self - destination.getSession().write(messageBuilder.buildBaseline8()); - destination.getSession().write(messageBuilder.buildBaseline9()); - } - - - } - - public long getLastPlayTimeUpdate() { - synchronized(objectMutex) { - return lastPlayTimeUpdate; - } - } - - public void setLastPlayTimeUpdate(long lastPlayTimeUpdate) { - synchronized(objectMutex) { - this.lastPlayTimeUpdate = lastPlayTimeUpdate; - } - } - - public List getTitleList() { - return titleList; + public Baseline getOtherVariables() { + Baseline baseline = super.getOtherVariables(); + baseline.put("ownedVendors", new Vector()); + baseline.put("chatChannels", new ArrayList()); + baseline.put("factionStandingMap", new TreeMap()); + baseline.put("biography", ""); + baseline.put("titleList", new ArrayList()); + baseline.put("spouse", ""); + baseline.put("bindLocation", (long) 0); + baseline.put("lotsRemaining", 10); + baseline.put("holoEmote", ""); + baseline.put("holoEmoteUses", 0); + return baseline; } - public void setTitleList(List titleList) { - this.titleList = titleList; + @Override + public Baseline getBaseline3() { + Baseline baseline = super.getBaseline3(); + List flagsList = new ArrayList(); + flagsList.add(0); + flagsList.add(0); + flagsList.add(0); + flagsList.add(0); + baseline.put("flagsList", flagsList); + List profileFlagsList = new ArrayList(); + profileFlagsList.add(0); + profileFlagsList.add(0); + profileFlagsList.add(0); + profileFlagsList.add(0); + baseline.put("profileFlagsList", profileFlagsList); + baseline.put("title", ""); + baseline.put("bornDate", Integer.parseInt(new SimpleDateFormat("yyyymmdd", Locale.ENGLISH).format(Calendar.getInstance().getTime()))); + baseline.put("totalPlayTime", 0); + baseline.put("professionIcon", 0); + baseline.put("profession", "trader_1a"); + baseline.put("gcwPoints", 0); + baseline.put("pvpKills", 0); + baseline.put("lifetimeGcwPoints", (long) 0); + baseline.put("lifetimePvpKills", 0); + baseline.put("collections", new BitSet()); + baseline.put("17", new SWGList(this, 3, 17, false)); // Misc ints (2 ints in tutorial, 5 bytes other times...) + baseline.put("showHelmet", true); + baseline.put("showBackpack", true); + return baseline; } - public void setCollections(byte[] collections) { - synchronized(objectMutex) { - this.collections = collections; - this.highestSetBit = BitSet.valueOf(collections).length(); - } - - notifyObservers(messageBuilder.buildCollectionsDelta(collections, getHighestSetBit()), true); + @Override + public Baseline getBaseline6() { + Baseline baseline = super.getBaseline6(); + baseline.put("godLevel", (byte) 0); + baseline.put("currentRank", 0); + baseline.put("rankProgress", (float) 0); + baseline.put("highestRebelRank", 0); + baseline.put("highestImperialRank", 0); + baseline.put("nextUpdateTime", 0); + baseline.put("home", ""); + baseline.put("citizenship", (byte) 0); // See datatables.Citizenship + baseline.put("cityRegionDefender", new RegionDefender()); + baseline.put("guildRegionDefender", new RegionDefender()); + baseline.put("12", 0); // General? + baseline.put("13", 0); // Guild Rank Title? + baseline.put("14", 0); // Citizen Rank Title? + baseline.put("15", 0); // All random guesses, always seem to be 0 + baseline.put("16", 0); + return baseline; } - public byte[] getCollections() { - synchronized(objectMutex) { - return collections; - } + @Override + public Baseline getBaseline8() { + Baseline baseline = super.getBaseline8(); + baseline.put("xpList", new SWGMap(this, 8, 0, true)); + baseline.put("waypoints", new SWGMap(this, 8, 1, true)); + baseline.put("currentForcePower", 100); + baseline.put("maxForcePower", 100); + baseline.put("currentFSQuestList", new SWGList(this, 8, 4, false)); + baseline.put("completedFSQuestList", new SWGList(this, 8, 5, false)); + baseline.put("questJournal", new SWGList(this, 8, 6, false)); + baseline.put("7", 0); + baseline.put("professionWheelPosition", ""); + return baseline; } - public int getHighestSetBit() { - synchronized(objectMutex) { - return highestSetBit; - } + @Override + public Baseline getBaseline9() { + Baseline baseline = super.getBaseline9(); + baseline.put("experimentationFlag", 0); + baseline.put("craftingStage", 0); + baseline.put("nearestCraftingStation", (long) 0); + baseline.put("draftSchematicList", new SWGList(this, 9, 3, true)); + baseline.put("4", new SWGList(this, 9, 4, false)); // Might or might not be a list, but at the very least it's two 0 ints that are part of the same delta. + baseline.put("experimentationPoints", 0); + baseline.put("accomplishmentCounter", 0); + baseline.put("friendList", new SWGList(this, 9, 7, false)); + baseline.put("ignoreList", new SWGList(this, 9, 8, false)); + baseline.put("languageId", 0); + baseline.put("currentStomach", 0); + baseline.put("maxStomach", 100); + baseline.put("currentDrink", 0); + baseline.put("maxDrink", 100); + baseline.put("currentConsumable", 0); + baseline.put("maxConsumable", 100); + baseline.put("waypointList", new SWGMap(this, 9, 16, false)); + baseline.put("defendersList", new SWGSet(this, 9, 17, false)); + baseline.put("kills", 0); + baseline.put("19", 0); + baseline.put("pet", (long) 0); + baseline.put("petAbilities", new SWGSet(this, 9, 15, false)); + baseline.put("22", (long) 0); // Unknown type currently + baseline.put("23", (byte) 0); // Seen as 1 or 2 sometimes // Gets set to 0x02 sometimes + baseline.put("24", 0); // Seen as 4 + baseline.put("25", (long) 0); // Bitmask starts with 0x20 ends with 0x40 + baseline.put("26", (long) 0); // Changed from 6 bytes to 9 + baseline.put("27", (byte) 0); // Changed from 6 bytes to 9 + baseline.put("28", (long) 0); // Seen as 856 + baseline.put("29", (long) 0); // Seen as 8559 + baseline.put("residenceTime", 0); // Date format of some sort. Seen as Saturday 28th May 2011 + return baseline; } - public int getProfessionIcon() { - synchronized(objectMutex) { - return professionIcon; - } + @SuppressWarnings("unchecked") + public List getFlagsList() { + return (List) getBaseline(3).get("flagsList"); } - public void setProfessionIcon(int professionIcon) { - synchronized(objectMutex) { - this.professionIcon = professionIcon; - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildProfessionIconDelta(professionIcon), true); - } + public void setFlagsList(int flag1, int flag2, int flag3, int flag4) { + List flagsList = getFlagsList(); + flagsList.set(0, flag1); + flagsList.set(1, flag2); + flagsList.set(2, flag3); + flagsList.set(3, flag4); + notifyClients(getBaseline(3).set("flagsList", flagsList), true); } - public String getBiography() { - return biography; - } - - public void setBiography(String biography) { - synchronized(objectMutex) { - this.biography = biography; - } - } - - public String getSpouseName() { - synchronized(objectMutex) { - return spouse; - } - } - - public void setSpouseName(String spouse) { - synchronized(objectMutex) { - this.spouse = spouse; - } - } - public int getFlagBitmask() { - synchronized(objectMutex) { - return flagBitmask; - } + return getFlagsList().get(0); } - + public void setFlagBitmask(int flagBitmask) { - synchronized(objectMutex) { - this.flagBitmask |= flagBitmask; - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildFlagBitmask(this.flagBitmask), true); - } + getFlagsList().set(0, getFlagsList().get(0) | flagBitmask); + notifyClients(getBaseline(3).set("flagsList", getFlagsList()), true); } + public void clearFlagBitmask(int flagBitmask) { - synchronized(objectMutex) { - // set flag bitmask to 0 - this.flagBitmask &= ~flagBitmask; - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildFlagBitmask(this.flagBitmask), true); - } + getFlagsList().set(0, (getFlagsList().get(0) & ~flagBitmask)); + notifyClients(getBaseline(3).set("flagsList", getFlagsList()), true); + } + + public boolean isSet(int flags) { + return ((getFlagsList().get(0) & flags) == flags); } public void toggleFlag(int flag) { - if ((this.flagBitmask & flag) == flag) { + if ((getFlagsList().get(0) & flag) == flag) { clearFlagBitmask(flag); } else { setFlagBitmask(flag); } } - /* - * @return True if specified flag(s) are enabled - */ - public boolean isSet(int flags) { - synchronized(objectMutex) { - return ((flagBitmask & flags) == flags); + @SuppressWarnings("unchecked") + public List getProfileFlagsList() { + return (List) getBaseline(3).get("profileFlagsList"); + } + + @Deprecated + public List getProfileList() { + return getProfileFlagsList(); + } + + public void setProfileFlagsList(int flag1, int flag2, int flag3, int flag4) { + List profileFlagsList = getProfileFlagsList(); + profileFlagsList.set(0, flag1); + profileFlagsList.set(1, flag2); + profileFlagsList.set(2, flag3); + profileFlagsList.set(3, flag4); + notifyClients(getBaseline(3).set("profileFlagsList", profileFlagsList), true); + } + + public String getBiography() { + return (String) otherVariables.get("biography"); + } + + public void setBiography(String biography) { + otherVariables.set("biography", biography); + } + + public String getTitle() { + return (String) getBaseline(3).get("title"); + } + + public void setTitle(String title) { + if (!getTitleList().isEmpty() && getTitleList().contains(title)) { + notifyClients(getBaseline(3).set("title", title), true); } } - - public String getHoloEmote() { - return holoEmote; + + @SuppressWarnings("unchecked") + public List getTitleList() { + return (List) otherVariables.get("titleList"); } - - public void setHoloEmote(String holoEmote) { - this.holoEmote = holoEmote; + + public void setTitleList(List titleList) { + otherVariables.set("titleList", titleList); } - - public int getHoloEmoteUses() { - return holoEmoteUses; + + public int getBornDate() { + return (int) getBaseline(3).get("bornDate"); } - - public void setHoloEmoteUses(int holoEmoteUses) { - this.holoEmoteUses = holoEmoteUses; + + public void setBornDate(int bornDate) { + getBaseline(3).set("bornDate", bornDate); } - - public boolean isShowHelmet() { - return showHelmet; + + public long getLastPlayTimeUpdate() { + synchronized(objectMutex) { + return lastPlayTimeUpdate; + } } - + + public void setLastPlayTimeUpdate(long lastPlayTimeUpdate) { + synchronized(objectMutex) { + this.lastPlayTimeUpdate = lastPlayTimeUpdate; + } + } + + public int getTotalPlayTime() { + return (int) getBaseline(3).get("totalPlayTime"); + } + + public void setTotalPlayTime(int totalPlayTime) { + if (getContainer() != null && getContainer().getClient() != null) { + getContainer().getClient().getSession().write(getBaseline(3).set("totalPlayTime", totalPlayTime)); + } + } + + public int getProfessionIcon() { + return (int) getBaseline(3).get("professionIcon"); + } + + public void setProfessionIcon(int professionIcon) { + notifyClients(getBaseline(3).set("professionIcon", professionIcon), true); + } + + public String getProfession() { + return (String) getBaseline(3).get("profession"); + } + + public void setProfession(String profession) { + notifyClients(getBaseline(3).set("profession", profession), true); + setProfessionIcon(Professions.get(profession)); + } + + public int getGcwPoints() { + return (int) getBaseline(3).get("gcwPoints"); + } + + public void setGcwPoints(int gcwPoints) { + notifyClients(getBaseline(3).set("gcwPoints", gcwPoints), true); + } + + public void resetGcwPoints() { + notifyClients(getBaseline(3).set("gcwPoints", 0), true); + } + + public int getPvpKills() { + return (int) getBaseline(3).get("pvpKills"); + } + + public void addPvpKill() { + IoBuffer buffer; + + synchronized(objectMutex) { + buffer = getBaseline(3).set("pvpKills", (((int) getBaseline(3).get("pvpKills")) + 1)); + } + + notifyClients(buffer, true); + } + + public void resetPvpKills() { + notifyClients(getBaseline(3).set("pvpKills", 0), true); + } + + public long getLifetimeGcwPoints() { + return (long) getBaseline(3).get("lifetimeGcwPoints"); + } + + public void addLifetimeGcwPoints(long gcwPoints) { + IoBuffer buffer; + + synchronized(objectMutex) { + buffer = getBaseline(3).set("lifetimeGcwPoints", (((long) getBaseline(3).get("lifetimeGcwPoints")) + gcwPoints)); + } + + notifyClients(buffer, true); + } + + public int getLifetimePvpKills() { + return (int) getBaseline(3).get("lifetimePvpKills"); + } + + public void addLifetimePvpKills(int pvpKills) { + IoBuffer buffer; + + synchronized(objectMutex) { + buffer = getBaseline(3).set("lifetimePvpKills", (((int) getBaseline(3).get("lifetimePvpKills")) + pvpKills)); + } + + notifyClients(buffer, true); + } + + public byte[] getCollections() { + return ((BitSet) getBaseline(3).get("collections")).toByteArray(); + } + + public void setCollections(byte[] collections) { + getBaseline(3).set("collections", BitSet.valueOf(collections)); + } + + public int getHighestSetBit() { + synchronized(objectMutex) { + return ((BitSet) getBaseline(3).get("collections")).length(); + } + } + + public boolean isShowingHelmet() { + return (boolean) getBaseline(3).get("showHelmet"); + } + public void setShowHelmet(boolean showHelmet) { - synchronized(objectMutex) { - this.showHelmet = showHelmet; - } - - if (getContainer() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildShowHelmetDelta(showHelmet)); - } + notifyClients(getBaseline(3).set("showHelmet", showHelmet), true); } - - public boolean isShowBackpack() { - return showBackpack; + + public boolean isShowingBackpack() { + return (boolean) getBaseline(3).get("showBackpack"); } - + public void setShowBackpack(boolean showBackpack) { + notifyClients(getBaseline(3).set("showBackpack", showBackpack), true); + } + + public byte getGodLevel() { + return (byte) getBaseline(6).get("godLevel"); + } + + public void setGodLevel(int godLevel) { + notifyClients(getBaseline(6).set("godLevel", (byte) godLevel), true); + } + + public int getCurrentRank() { synchronized(objectMutex) { - this.showBackpack = showBackpack; + return (int) getBaseline(6).get("currentRank"); + } + } + + public void setCurrentRank(int currentRank) { + notifyClients(getBaseline(6).set("currentRank", currentRank), true); + } + + public float getRankProgress() { + return (float) getBaseline(6).get("rankProgress"); + } + + public void setRankProgress(float rankProgress) { + notifyClients(getBaseline(6).set("rankProgress", rankProgress), true); + } + + public int getHighestRebelRank() { + return (int) getBaseline(6).get("highestRebelRank"); + } + + public void setHighestRebelRank(int highestRebelRank) { + notifyClients(getBaseline(6).set("highestRebelRank", highestRebelRank), true); + } + + public int getHighestImperialRank() { + return (int) getBaseline(6).get("highestImperialRank"); + } + + public void setHighestImperialRank(int highestImperialRank) { + notifyClients(getBaseline(6).set("highestImperialRank", highestImperialRank), true); + } + + public int getNextUpdateTime() { + return (int) getBaseline(6).get("nextUpdateTime"); + } + + public void setNextUpdateTime(int nextUpdateTime) { + notifyClients(getBaseline(6).set("nextUpdateTime", nextUpdateTime), true); + } + + public String getHome() { + return (String) getBaseline(6).get("home"); + } + + public void setHome(String home) { + notifyClients(getBaseline(6).set("home", home), true); + } + + public byte getCitizenship() { + return (byte) getBaseline(6).get("citizenship"); + } + + public void setCitizenship(byte citizenship) { + notifyClients(getBaseline(6).set("citizenship", citizenship), true); + } + + public RegionDefender getCityRegionDefender() { + return (RegionDefender) getBaseline(6).get("cityRegionDefender"); + } + + public void setCityRegionDefender(RegionDefender cityRegionDefender) { + notifyClients(getBaseline(6).set("cityRegionDefender", cityRegionDefender), true); + } + + public RegionDefender getGuildRegionDefender() { + return (RegionDefender) getBaseline(6).get("guildRegionDefender"); + } + + public void setGuildRegionDefender(RegionDefender guildRegionDefender) { + notifyClients(getBaseline(6).set("guildRegionDefender", guildRegionDefender), true); + } + + @SuppressWarnings("unchecked") + public SWGMap getXpList() { + return (SWGMap) getBaseline(8).get("xpList"); + } + + public int getXp(String type) { + return ((!getXpList().containsKey(type)) ? 0 : getXpList().get(type)); + } + + public void setXp(String type, int amount) { + getXpList().put(type, amount); + } + + @SuppressWarnings("unchecked") + public SWGMap getWaypoints() { + return (SWGMap) getBaseline(8).get("waypoints"); + } + + public void waypointUpdate(WaypointObject waypoint) { + getWaypoints().put(waypoint.getObjectID(), waypoint); + } + + public void waypointRemove(WaypointObject waypoint) { + getWaypoints().remove(waypoint.getObjectID()); + } + + public void waypointAdd(WaypointObject waypoint) { + getWaypoints().put(waypoint.getObjectID(), waypoint); + } + + public WaypointObject getWaypointFromList(WaypointObject waypoint) { + synchronized(objectMutex) { + if (getWaypoints().containsKey(waypoint.getObjectID())) { + return getWaypoints().get(waypoint.getObjectID()); + } } - if (getContainer() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildShowBackpackDelta(showBackpack)); + return null; + } + + public int getCurrentForcePower() { + return (int) getBaseline(8).get("currentForcePower"); + } + + public void setCurrentForcePower(int currentForcePower) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(8).set("currentForcePower", currentForcePower)); } } + public int getMaxForcePower() { + return (int) getBaseline(8).get("maxForcePower"); + } + + public void setMaxForcePower(int maxForcePower) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(8).set("maxForcePower", maxForcePower)); + } + } + + @SuppressWarnings("unchecked") + public SWGList getCurrentFSQuestList() { + return (SWGList) getBaseline(8).get("currentFSQuestList"); + } + + @SuppressWarnings("unchecked") + public SWGList getCompletedFSQuestList() { + return (SWGList) getBaseline(8).get("completedFSQuestList"); + } + + @SuppressWarnings("unchecked") + public SWGList getQuestJournal() { + return (SWGList) getBaseline(8).get("questJournal"); + } + + public String getProfessionWheelPosition() { + return (String) getBaseline(8).get("professionWheelPosition"); + } + + public void setProfessionWheelPosition(String professionWheelPosition) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(8).set("professionWheelPosition", professionWheelPosition)); + } + } + + public int getExperimentationFlag() { + return (int) getBaseline(9).get("experimentationFlag"); + } + + public void setExperimentationFlag(int experimentationFlag) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("experimentationFlag", experimentationFlag)); + } + } + + public int getCraftingStage() { + return (int) getBaseline(9).get("craftingStage"); + } + + public void setCraftingStage(int craftingStage) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("craftingStage", craftingStage)); + } + } + + public long getNearestCraftingStation() { + return (long) getBaseline(9).get("nearestCraftingStation"); + } + + public void setNearestCraftingStation(long nearestCraftingStation) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("nearestCraftingStation", nearestCraftingStation)); + } + } + + @SuppressWarnings("unchecked") + public SWGList getDraftSchematicList() { + return (SWGList) getBaseline(9).get("draftSchematicList"); + } + + public int getExperimentationPoints() { + return (int) getBaseline(9).get("experimentationPoints"); + } + + public void setExperimentationPoints(int experimentationPoints) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("experimentationPoints", experimentationPoints)); + } + } + + public int getAccomplishmentCounter() { + return (int) getBaseline(9).get("accomplishmentCounter"); + } + + public void setAccomplishmentCounter(int accomplishmentCounter) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("accomplishmentCounter", accomplishmentCounter)); + } + } + + @SuppressWarnings("unchecked") + public SWGList getFriendList() { + return (SWGList) getBaseline(9).get("friendList"); + } + + public void friendAdd(String friend) { + getFriendList().add(friend); + } + + public void friendRemove(String friend) { + getFriendList().remove(friend); + } + + @SuppressWarnings("unchecked") + public SWGList getIgnoreList() { + return (SWGList) getBaseline(9).get("ignoreList"); + } + + public void ignoreAdd(String name) { + getIgnoreList().add(name); + } + + public void ignoreRemove(String name) { + getIgnoreList().remove(name); + } + + public int getLanguageId() { + return (int) getBaseline(9).get("languageId"); + } + + public void setLanguageId(int languageId) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("languageId", languageId)); + } + } + + public int getCurrentStomach() { + return (int) getBaseline(9).get("currentStomach"); + } + + public void setCurrentStomach(int currentStomach) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("currentStomach", currentStomach)); + } + } + + public int getMaxStomach() { + return (int) getBaseline(9).get("maxStomach"); + } + + public void setMaxStomach(int maxStomach) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("maxStomach", maxStomach)); + } + } + + public int getCurrentDrink() { + return (int) getBaseline(9).get("currentDrink"); + } + + public void setCurrentDrink(int currentDrink) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("currentDrink", currentDrink)); + } + } + + public int getMaxDrink() { + return (int) getBaseline(9).get("maxDrink"); + } + + public void setMaxDrink(int maxDrink) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("maxDrink", maxDrink)); + } + } + + public int getCurrentConsumable() { + return (int) getBaseline(9).get("currentConsumable"); + } + + public void setCurrentConsumable(int currentConsumable) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("currentConsumable", currentConsumable)); + } + } + + public int getMaxConsumable() { + return (int) getBaseline(9).get("maxConsumable"); + } + + public void setMaxConsumable(int maxConsumable) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("maxConsumable", maxConsumable)); + } + } + + @SuppressWarnings("unchecked") + public SWGSet getDefendersList() { + return (SWGSet) getBaseline(8).get("defendersList"); + } + + public int getKills() { + return (int) getBaseline(9).get("kills"); + } + + public void setKills(int kills) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("kills", kills)); + } + } + + public void addKills(int kills) { + setKills(getKills() + kills); + } + + public long getPet() { + return (long) getBaseline(9).get("pet"); + } + + public void setPet(long pet) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("pet", pet)); + } + } + + @SuppressWarnings("unchecked") + public SWGSet getPetAbilities() { + return (SWGSet) getBaseline(8).get("petAbilities"); + } + + public int getJediState() { + return 0; + } + + public void setJediState(int jediState) { + + } + + @SuppressWarnings("unchecked") + public Map getFactionStandingMap() { + return (Map) otherVariables.get("factionStandingMap"); + } + + public int getFactionStanding(String faction) { + synchronized(objectMutex) { + return ((getFactionStandingMap().containsKey(faction)) ? getFactionStandingMap().get(faction) : 0); + } + } + + public void setFactionStanding(String faction, int factionStanding) { + synchronized(objectMutex) { + getFactionStandingMap().put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); + } + } + + public void modifyFactionStanding(String faction, int modifier) { + synchronized(objectMutex) { + int factionStanding = (((getFactionStandingMap().containsKey(faction)) ? getFactionStandingMap().get(faction) : 0) + modifier); + getFactionStandingMap().put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); + } + } + + public String getSpouseName() { + return (String) otherVariables.get("spouse"); + } + + public void setSpouseName(String spouse) { + otherVariables.set("spouse", spouse); + } + + public long getBindLocation() { + return (long) otherVariables.get("bindLocation"); + } + + public void setBindLocation(long bindLocation) { + otherVariables.set("bindLocation", bindLocation); + } + + public int getLotsRemaining() { + return (int) otherVariables.get("lotsRemaining"); + } + + public void setLotsRemaining(int lotsRemaining) { + otherVariables.set("lotsRemaining", lotsRemaining); + } + + public boolean addLots(int lots) { + otherVariables.set("lotsRemaining", getLotsRemaining() + lots); + return true; + } + + public boolean deductLots(int lots) { + if (getLotsRemaining() - lots >= 0) { + setLotsRemaining(getLotsRemaining() - lots); + return true; + } + + return false; + } + + public String getHoloEmote() { + return (String) otherVariables.get("holoEmote"); + } + + public void setHoloEmote(String holoEmote) { + otherVariables.set("holoEmote", holoEmote); + } + + public int getHoloEmoteUses() { + return (int) otherVariables.get("holoEmoteUses"); + } + + public void setHoloEmoteUses(int holoEmoteUses) { + otherVariables.set("holoEmoteUses", holoEmoteUses); + } + public WaypointObject getLastSurveyWaypoint() { return lastSurveyWaypoint; } - + public void setLastSurveyWaypoint(WaypointObject lastSurveyWaypoint) { this.lastSurveyWaypoint = lastSurveyWaypoint; } public SurveyTool getLastUsedSurveyTool() { synchronized(objectMutex) { - return this.lastUsedSurveyTool; + return lastUsedSurveyTool; } } - public void setLastUsedSurveyTool(SurveyTool surveyTool) { + public void setLastUsedSurveyTool(SurveyTool lastUsedSurveyTool) { synchronized(objectMutex) { - this.lastUsedSurveyTool = surveyTool; + this.lastUsedSurveyTool = lastUsedSurveyTool; } } - + public ResourceContainerObject getRecentContainer() { - return recentContainer; + synchronized(objectMutex) { + return recentContainer; + } } - + public void setRecentContainer(ResourceContainerObject recentContainer) { - this.recentContainer = recentContainer; - } - - public void setLotsRemaining(int amount) - { - this.lotsRemaining = amount; - } - - public boolean addLots(int amount) - { - this.lotsRemaining += amount; - return true; - } - - public boolean deductLots(int amount) - { - if(this.lotsRemaining - amount >= 0) - { - this.lotsRemaining -= amount; - return true; - } - return false; - } - - public int getLotsRemaining() - { - return this.lotsRemaining; - } - - public byte getGodLevel() { - return godLevel; - } - - public void setGodLevel(int godLevel) { - this.godLevel = (byte) godLevel; - - if (getContainer() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildGodLevelDelta((byte) godLevel)); + synchronized(objectMutex) { + this.recentContainer = recentContainer; } } + @SuppressWarnings("unchecked") public List getJoinedChatChannels() { - return chatChannels; + return (List) otherVariables.get("chatChannels"); } public void addChannel(int roomId) { - chatChannels.add(roomId); + getJoinedChatChannels().add(roomId); } public void removeChannel(int roomId) { - if (chatChannels.contains(roomId)) - chatChannels.remove(roomId); + if (getJoinedChatChannels().contains(roomId)) { + getJoinedChatChannels().remove(roomId); + } } public boolean isMemberOfChannel(int roomId) { - if (chatChannels.contains(roomId)) { + if (getJoinedChatChannels().contains(roomId)) { return true; } + return false; } public boolean isCallingCompanion() { - return callingCompanion; + synchronized(objectMutex) { + return callingCompanion; + } } public void setCallingCompanion(boolean callingCompanion) { - this.callingCompanion = callingCompanion; + synchronized(objectMutex) { + this.callingCompanion = callingCompanion; + } } public long getBountyMissionId() { - return bountyMissionId; + synchronized(objectMutex) { + return bountyMissionId; + } } - + public void setBountyMissionId(long bountyMissionId) { - this.bountyMissionId = bountyMissionId; + synchronized(objectMutex) { + this.bountyMissionId = bountyMissionId; + } } - - public ObjectMessageBuilder getMessageBuilder() { - return messageBuilder; - } - + + @SuppressWarnings("unchecked") public Vector getOwnedVendors() { - return ownedVendors; + return (Vector) otherVariables.get("ownedVendors"); } - + public void addVendor(long vendorId) { - ownedVendors.add(vendorId); + getOwnedVendors().add(vendorId); } public void removeVendor(long vendorId) { - ownedVendors.remove(vendorId); + getOwnedVendors().remove(vendorId); } public int getAmountOfVendors() { - return ownedVendors.size(); + return getOwnedVendors().size(); } - - public long getBindLocation() { - synchronized(objectMutex) { - return bindLocation; + + @Override + public void notifyClients(IoBuffer buffer, boolean notifySelf) { + if (getContainer() != null) { + getContainer().notifyObservers(buffer, notifySelf); } } - - public void setBindLocation(long bindLocation) { + + @Override + public PlayerMessageBuilder getMessageBuilder() { synchronized(objectMutex) { - this.bindLocation = bindLocation; + if (messageBuilder == null) { + messageBuilder = new PlayerMessageBuilder(this); + } + + return messageBuilder; + } + } + + @Override + public void sendBaselines(Client destination) { + if (destination != null && destination.getSession() != null) { + destination.getSession().write(getBaseline(3).getBaseline()); + destination.getSession().write(getBaseline(6).getBaseline()); + if (destination.getParent().getObjectID() == getContainer().getObjectID()) { + destination.getSession().write(getBaseline(8).getBaseline()); + destination.getSession().write(getBaseline(9).getBaseline()); + } + } + } + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + switch (viewType) { + case 3: + case 6: + if (getContainer() != null) { + getContainer().notifyObservers(getBaseline(viewType).createDelta(updateType, buffer.array()), true); + } + default: + if (getContainer() != null && getContainer().getClient() != null) { + getContainer().getClient().getSession().write(getBaseline(viewType).createDelta(updateType, buffer.array())); + } } } diff --git a/src/services/DevService.java b/src/services/DevService.java index 68c616a7..10887e91 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -36,11 +36,11 @@ import resources.common.FileUtilities; import resources.common.Opcodes; import resources.common.SpawnPoint; import resources.datatables.WeaponType; +import resources.harvest.SurveyTool; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import resources.objects.weapon.WeaponObject; import services.sui.SUIWindow; import services.sui.SUIService.ListBoxType; diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 4eda23aa..0e839581 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -924,6 +924,7 @@ public class PlayerService implements INetworkDispatch { } player.setXp(xpType, experience); + creature.setXpBarValue(experience); // 2. See if they need to level up. for (int i = 0; i < experienceTable.getRowCount(); i++) { diff --git a/src/services/SurveyService.java b/src/services/SurveyService.java index fddea8b1..1088c505 100644 --- a/src/services/SurveyService.java +++ b/src/services/SurveyService.java @@ -31,13 +31,13 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import protocol.swg.PlayClientEffectLocMessage; +import resources.harvest.SurveyTool; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import services.sui.SUIWindow; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; diff --git a/src/services/bazaar/BazaarService.java b/src/services/bazaar/BazaarService.java index 75f3e3f4..7e1bef59 100644 --- a/src/services/bazaar/BazaarService.java +++ b/src/services/bazaar/BazaarService.java @@ -38,7 +38,6 @@ import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.common.Opcodes; import resources.common.OutOfBand; -import resources.common.ProsePackage; import resources.datatables.DisplayType; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; diff --git a/src/services/gcw/PvPZone.java b/src/services/gcw/PvPZone.java index 8f14000d..b272f6bf 100644 --- a/src/services/gcw/PvPZone.java +++ b/src/services/gcw/PvPZone.java @@ -29,7 +29,6 @@ import resources.common.collidables.AbstractCollidable.ExitEvent; import resources.datatables.FactionStatus; import resources.datatables.PvpStatus; import resources.objects.creature.CreatureObject; -import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index c1566e45..5fecc24d 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -48,6 +48,7 @@ import java.util.concurrent.atomic.AtomicLong; import resources.common.*; import resources.datatables.Options; import resources.datatables.PlayerFlags; +import resources.harvest.SurveyTool; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; @@ -118,7 +119,6 @@ import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; import resources.objects.staticobject.StaticObject; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import resources.objects.waypoint.WaypointObject; import resources.objects.weapon.WeaponObject; import services.ai.AIActor;