mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-28 13:12:54 -04:00
Refactored PLAY
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<String, Integer> 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<String> 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<String> 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<String> 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<String> 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<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
|
||||
super.buildBaseline3(baselineBuilders, deltaBuilders);
|
||||
@@ -679,10 +46,12 @@ public class PlayerMessageBuilder extends IntangibleMessageBuilder {
|
||||
super.buildBaseline6(baselineBuilders, deltaBuilders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
|
||||
super.buildBaseline8(baselineBuilders, deltaBuilders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
|
||||
super.buildBaseline9(baselineBuilders, deltaBuilders);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,348 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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;
|
||||
|
||||
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;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceConcentration;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class SurveyTool extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private byte toolType=0;
|
||||
private long surveyResourceID;
|
||||
private long userID=0;
|
||||
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;
|
||||
public static byte ChemicalSurveyDevice = 2;
|
||||
public static byte FloraSurveyTool = 3;
|
||||
public static byte GasPocketSurveyDevice = 4;
|
||||
public static byte WaterSurveyDevice = 5;
|
||||
public static byte WindCurrentSurveyingTool = 6;
|
||||
public static byte AmbientSolarEnergySurveyingTool = 7;
|
||||
public static byte CompleteResourceSurveyDevice = 8;
|
||||
|
||||
public SurveyTool() {
|
||||
super();
|
||||
this.exceptionalState = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initAfterDBLoad() {
|
||||
super.init();
|
||||
this.exceptionalState = false;
|
||||
surveyEffectString = "";
|
||||
sampleEffectString = "";
|
||||
defendersList = new Vector<TangibleObject>();
|
||||
}
|
||||
|
||||
public SurveyTool(long objectID, Planet planet, Point3D position, Quaternion orientation, String template) {
|
||||
super(objectID, planet, position, orientation, template);
|
||||
surveyEffectString = "";
|
||||
sampleEffectString = "";
|
||||
this.tanoID = objectID;
|
||||
this.exceptionalState = false;
|
||||
this.recoveryMode = false;
|
||||
switch (template) {
|
||||
case "object/tangible/survey_tool/shared_survey_tool_mineral.iff" :
|
||||
toolType = 1;
|
||||
surveyEffectString = "clienteffect/survey_tool_mineral.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_mineral.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_inorganic.iff" :
|
||||
toolType = 2;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_lumber.iff" :
|
||||
toolType = 3;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_gas.iff" :
|
||||
toolType = 4;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_moisture.iff" :
|
||||
toolType = 5;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_wind.iff" :
|
||||
toolType = 6;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_solar.iff" :
|
||||
toolType = 7;
|
||||
surveyEffectString = "clienteffect/survey_tool_moisture.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_moisture.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_all.iff" :
|
||||
toolType = 8;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
default: toolType = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public SurveyTool(String template, Long tanoID) {
|
||||
super();
|
||||
surveyEffectString = "";
|
||||
sampleEffectString = "";
|
||||
this.tanoID = tanoID;
|
||||
this.exceptionalState = false;
|
||||
switch (template) {
|
||||
case "object/tangible/survey_tool/shared_survey_tool_mineral.iff" :
|
||||
toolType = 1;
|
||||
surveyEffectString = "clienteffect/survey_tool_mineral.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_mineral.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_inorganic.iff" :
|
||||
toolType = 2;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_lumber.iff" :
|
||||
toolType = 3;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_gas.iff" :
|
||||
toolType = 4;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_moisture.iff" :
|
||||
toolType = 5;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_wind.iff" :
|
||||
toolType = 6;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_solar.iff" :
|
||||
toolType = 7;
|
||||
surveyEffectString = "clienteffect/survey_tool_moisture.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_moisture.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_all.iff" :
|
||||
toolType = 8;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
default: toolType = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setToolType(byte toolType) {
|
||||
this.toolType = toolType;
|
||||
}
|
||||
|
||||
public byte getToolType() {
|
||||
return this.toolType;
|
||||
}
|
||||
|
||||
public String getSurveyEffectString() {
|
||||
return surveyEffectString;
|
||||
}
|
||||
|
||||
public String getSampleEffectString() {
|
||||
return sampleEffectString;
|
||||
}
|
||||
|
||||
public void setCurrentlySurveying(boolean toggle){
|
||||
this.currentlySurveying=toggle;
|
||||
}
|
||||
|
||||
public boolean getCurrentlySurveying(){
|
||||
return this.currentlySurveying;
|
||||
}
|
||||
|
||||
public void setCurrentlySampling(boolean toggle){
|
||||
this.currentlySampling=toggle;
|
||||
}
|
||||
|
||||
public boolean getCurrentlySampling(){
|
||||
return this.currentlySampling;
|
||||
}
|
||||
|
||||
public void setLastSurveyTime(Long time){
|
||||
this.lastSurveyTime = time;
|
||||
}
|
||||
|
||||
public Long getLastSurveyTime(){
|
||||
return this.lastSurveyTime;
|
||||
}
|
||||
|
||||
public void setLastSampleTime(Long time){
|
||||
this.lastSampleTime = time;
|
||||
}
|
||||
|
||||
public Long getLastSampleTime(){
|
||||
return this.lastSampleTime;
|
||||
}
|
||||
|
||||
public void setSurveyResourceID(long surveyResourceID){
|
||||
this.surveyResourceID = surveyResourceID;
|
||||
}
|
||||
|
||||
public long getSurveyResourceID(){
|
||||
return this.surveyResourceID;
|
||||
}
|
||||
|
||||
public boolean getCurrentlyCoolingDown() {
|
||||
return currentlyCoolingDown;
|
||||
}
|
||||
|
||||
public void setCurrentlyCoolingDown(boolean currentlyCoolingDown) {
|
||||
this.currentlyCoolingDown = currentlyCoolingDown;
|
||||
}
|
||||
|
||||
public Long getRecoveryTime() {
|
||||
return recoveryTime;
|
||||
}
|
||||
|
||||
public void setRecoveryTime(Long recoveryTime) {
|
||||
this.recoveryTime = recoveryTime;
|
||||
}
|
||||
|
||||
public long getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(long userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public Long getTanoID() {
|
||||
return tanoID;
|
||||
}
|
||||
|
||||
public void setTanoID(Long tanoID) {
|
||||
this.tanoID = tanoID;
|
||||
}
|
||||
|
||||
public boolean isExceptionalState() {
|
||||
return exceptionalState;
|
||||
}
|
||||
|
||||
public void setExceptionalState(boolean exceptionalState) {
|
||||
this.exceptionalState = exceptionalState;
|
||||
}
|
||||
|
||||
public boolean isRecoveryMode() {
|
||||
return this.recoveryMode;
|
||||
}
|
||||
|
||||
public void setRecoveryMode(boolean recoveryMode) {
|
||||
this.recoveryMode = recoveryMode;
|
||||
}
|
||||
|
||||
public byte getSurveyRangeSetting() {
|
||||
return SurveyRangeSetting;
|
||||
}
|
||||
|
||||
public void setSurveyRangeSetting(byte surveyRangeSetting) {
|
||||
SurveyRangeSetting = surveyRangeSetting;
|
||||
}
|
||||
|
||||
public void sendConstructSurveyMapMessage(){
|
||||
float surveyRadius = 64.0f;
|
||||
int surveyToolRangeSetting = this.getSurveyRangeSetting();
|
||||
//surveyToolRangeSetting = 4;
|
||||
int divisor = 0;
|
||||
if (surveyToolRangeSetting==0) {
|
||||
divisor = 2;
|
||||
surveyRadius = 64.0f;
|
||||
} else if (surveyToolRangeSetting==1) {
|
||||
divisor = 3;
|
||||
surveyRadius = 128.0f;
|
||||
} else if (surveyToolRangeSetting==2) {
|
||||
divisor = 3;
|
||||
surveyRadius = 192.0f;
|
||||
} else if (surveyToolRangeSetting==3) {
|
||||
divisor = 4;
|
||||
surveyRadius = 256.0f;
|
||||
} else if (surveyToolRangeSetting==4) {
|
||||
divisor = 4;
|
||||
surveyRadius = 320.0f;
|
||||
} else {
|
||||
divisor = 5;
|
||||
surveyRadius = 3072.0f;
|
||||
}
|
||||
|
||||
float differential = surveyRadius / (float) divisor;
|
||||
GalacticResource resourceToSurvey = (GalacticResource) NGECore.getInstance().objectService.getObject(this.getSurveyResourceID());
|
||||
CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(this.getUserID());
|
||||
if (resourceToSurvey==null || user==null)
|
||||
return;
|
||||
Vector<ResourceConcentration> concentrationMap = resourceToSurvey.buildConcentrationsCollection(user.getPosition(),resourceToSurvey, surveyRadius, differential, user.getPlanetId());
|
||||
resourceToSurvey.constructSurveyMapMessage(user, concentrationMap, surveyRadius);
|
||||
//this.getUser().sendSystemMessage("Distance to nearest Deposit : " + this.getSurveyResource().getHelperMinDist(), (byte) 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user