mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-01-17 00:06:00 -05:00
Merged Engine into the Core! Woooo open source
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Engine3"/>
|
||||
<classpathentry kind="lib" path="lib/jdbc-postgresql.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jython-standalone-2.5.4-rc1.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
46
src/intents/CloseConnectionIntent.java
Normal file
46
src/intents/CloseConnectionIntent.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package intents;
|
||||
|
||||
import network.packets.soe.Disconnect.DisconnectReason;
|
||||
import resources.control.Intent;
|
||||
|
||||
|
||||
public class CloseConnectionIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "CloseConnectionIntent";
|
||||
|
||||
private int connId;
|
||||
private long networkId;
|
||||
private DisconnectReason reason;
|
||||
|
||||
public CloseConnectionIntent(int connId, long networkId, DisconnectReason reason) {
|
||||
super(TYPE);
|
||||
setConnectionId(connId);
|
||||
setNetworkId(networkId);
|
||||
setReason(reason);
|
||||
}
|
||||
|
||||
public void setConnectionId(int connId) {
|
||||
this.connId = connId;
|
||||
}
|
||||
|
||||
public void setNetworkId(long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public void setReason(DisconnectReason reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public int getConnectionId() {
|
||||
return connId;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public DisconnectReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
}
|
||||
46
src/intents/InboundPacketIntent.java
Normal file
46
src/intents/InboundPacketIntent.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package intents;
|
||||
|
||||
import network.packets.Packet;
|
||||
import resources.control.Intent;
|
||||
import resources.network.ServerType;
|
||||
|
||||
public class InboundPacketIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "InboundPacketIntent";
|
||||
|
||||
private Packet packet;
|
||||
private ServerType type;
|
||||
private long networkId;
|
||||
|
||||
public InboundPacketIntent(ServerType type, Packet p, long networkId) {
|
||||
super(TYPE);
|
||||
setPacket(p);
|
||||
setServerType(type);
|
||||
setNetworkId(networkId);
|
||||
}
|
||||
|
||||
public void setPacket(Packet p) {
|
||||
this.packet = p;
|
||||
}
|
||||
|
||||
public void setServerType(ServerType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setNetworkId(long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public Packet getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public ServerType getServerType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
}
|
||||
36
src/intents/InboundUdpPacketIntent.java
Normal file
36
src/intents/InboundUdpPacketIntent.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package intents;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.network.ServerType;
|
||||
import resources.network.UDPServer.UDPPacket;
|
||||
|
||||
public class InboundUdpPacketIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "InboundUdpPacketIntent";
|
||||
|
||||
private UDPPacket packet;
|
||||
private ServerType type;
|
||||
|
||||
public InboundUdpPacketIntent(ServerType type, UDPPacket p) {
|
||||
super(TYPE);
|
||||
setPacket(p);
|
||||
setServerType(type);
|
||||
}
|
||||
|
||||
public void setPacket(UDPPacket p) {
|
||||
this.packet = p;
|
||||
}
|
||||
|
||||
public void setServerType(ServerType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public UDPPacket getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public ServerType getServerType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
42
src/intents/LoginEventIntent.java
Normal file
42
src/intents/LoginEventIntent.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package intents;
|
||||
|
||||
import resources.control.Intent;
|
||||
|
||||
public class LoginEventIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "LoginEventIntent";
|
||||
|
||||
private LoginEvent event;
|
||||
private long networkId;
|
||||
|
||||
public LoginEventIntent(long networkId, LoginEvent event) {
|
||||
super(TYPE);
|
||||
setNetworkId(networkId);
|
||||
setEvent(event);
|
||||
}
|
||||
|
||||
public void setNetworkId(long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public void setEvent(LoginEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public LoginEvent getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public enum LoginEvent {
|
||||
LOGIN_FAIL_INVALID_VERSION_CODE,
|
||||
LOGIN_FAIL_INVALID_USER_PASS,
|
||||
LOGIN_FAIL_SERVER_ERROR,
|
||||
LOGIN_FAIL_BANNED,
|
||||
LOGIN_SUCCESS
|
||||
}
|
||||
|
||||
}
|
||||
35
src/intents/OutboundPacketIntent.java
Normal file
35
src/intents/OutboundPacketIntent.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package intents;
|
||||
|
||||
import network.packets.Packet;
|
||||
import resources.control.Intent;
|
||||
|
||||
public class OutboundPacketIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "OutboundPacketIntent";
|
||||
|
||||
private Packet packet;
|
||||
private long networkId;
|
||||
|
||||
public OutboundPacketIntent(Packet p, long networkId) {
|
||||
super(TYPE);
|
||||
setPacket(p);
|
||||
setNetworkId(networkId);
|
||||
}
|
||||
|
||||
public void setPacket(Packet p) {
|
||||
this.packet = p;
|
||||
}
|
||||
|
||||
public void setNetworkId(long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public Packet getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
}
|
||||
36
src/intents/OutboundUdpPacketIntent.java
Normal file
36
src/intents/OutboundUdpPacketIntent.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package intents;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.network.ServerType;
|
||||
import resources.network.UDPServer.UDPPacket;
|
||||
|
||||
public class OutboundUdpPacketIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "OutboundUdpPacketIntent";
|
||||
|
||||
private UDPPacket packet;
|
||||
private ServerType type;
|
||||
|
||||
public OutboundUdpPacketIntent(ServerType type, UDPPacket p) {
|
||||
super(TYPE);
|
||||
setPacket(p);
|
||||
setServerType(type);
|
||||
}
|
||||
|
||||
public void setPacket(UDPPacket p) {
|
||||
this.packet = p;
|
||||
}
|
||||
|
||||
public void setServerType(ServerType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public UDPPacket getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public ServerType getServerType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
13
src/intents/PingIntent.java
Normal file
13
src/intents/PingIntent.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package intents;
|
||||
|
||||
import resources.control.Intent;
|
||||
|
||||
public class PingIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "PingIntent";
|
||||
|
||||
public PingIntent() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
}
|
||||
44
src/intents/ServerStatusIntent.java
Normal file
44
src/intents/ServerStatusIntent.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package intents;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.control.ServerStatus;
|
||||
|
||||
public class ServerStatusIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "ServerStatusIntent";
|
||||
|
||||
private ServerStatus status;
|
||||
private long time;
|
||||
|
||||
public ServerStatusIntent() {
|
||||
super(TYPE);
|
||||
setStatus(null);
|
||||
}
|
||||
|
||||
public ServerStatusIntent(ServerStatus status) {
|
||||
super(TYPE);
|
||||
setStatus(status);
|
||||
}
|
||||
|
||||
public ServerStatusIntent(ServerStatus status, long time) {
|
||||
this(status);
|
||||
setTime(time);
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setStatus(ServerStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public ServerStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
}
|
||||
39
src/intents/swgobject_events/SWGObjectEventIntent.java
Normal file
39
src/intents/swgobject_events/SWGObjectEventIntent.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package intents.swgobject_events;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.objects.SWGObject;
|
||||
|
||||
public class SWGObjectEventIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "SWGObjectEventType";
|
||||
|
||||
private SWGObject obj;
|
||||
private Event event;
|
||||
|
||||
public SWGObjectEventIntent(SWGObject obj, Event e) {
|
||||
super(TYPE);
|
||||
setObject(obj);
|
||||
setEvent(e);
|
||||
}
|
||||
|
||||
public void setObject(SWGObject obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
public void setEvent(Event e) {
|
||||
this.event = e;
|
||||
}
|
||||
|
||||
public SWGObject getObject() {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public Event getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public enum Event {
|
||||
SOE_UPDATE_LOCATION
|
||||
}
|
||||
|
||||
}
|
||||
23
src/intents/swgobject_events/SWGObjectMovedIntent.java
Normal file
23
src/intents/swgobject_events/SWGObjectMovedIntent.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package intents.swgobject_events;
|
||||
|
||||
import resources.Location;
|
||||
import resources.objects.SWGObject;
|
||||
|
||||
public class SWGObjectMovedIntent extends SWGObjectEventIntent {
|
||||
|
||||
private Location oldLocation;
|
||||
|
||||
public SWGObjectMovedIntent(SWGObject object, Location oldLocation) {
|
||||
super(object, SWGObjectEventIntent.Event.SOE_UPDATE_LOCATION);
|
||||
this.oldLocation = oldLocation;
|
||||
}
|
||||
|
||||
public Location getOldLocation() {
|
||||
return oldLocation;
|
||||
}
|
||||
|
||||
public Location getNewLocation() {
|
||||
return getObject().getLocation();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package main;
|
||||
|
||||
import intents.ServerStatusIntent;
|
||||
import intents.ServerStatusIntent.ServerStatus;
|
||||
import resources.Galaxy.GalaxyStatus;
|
||||
import resources.control.ServerStatus;
|
||||
import services.CoreManager;
|
||||
|
||||
public class ProjectSWG {
|
||||
|
||||
83
src/network/FragmentedHandler.java
Normal file
83
src/network/FragmentedHandler.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package network;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import network.packets.soe.Fragmented;
|
||||
import resources.SortedLinkedList;
|
||||
|
||||
public class FragmentedHandler {
|
||||
|
||||
private SortedLinkedList<Fragmented> fragPackets;
|
||||
private int fragSize;
|
||||
|
||||
public FragmentedHandler() {
|
||||
fragPackets = new SortedLinkedList<Fragmented>();
|
||||
fragSize = 0;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
fragPackets.clear();
|
||||
fragSize = 0;
|
||||
}
|
||||
|
||||
public byte [] onReceived(Fragmented f) {
|
||||
synchronized (fragPackets) {
|
||||
if (insertIfNew(f) && getBufferedSize() == fragSize) {
|
||||
byte [] data = new byte[fragSize];
|
||||
int offset = 0;
|
||||
while (fragPackets.size() > 0 && offset < fragSize) {
|
||||
offset = spliceFragmentedIntoBuffer(fragPackets.removeFirst(), data, offset);
|
||||
}
|
||||
updateMetadata();
|
||||
return data;
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
private boolean insertIfNew(Fragmented f) {
|
||||
synchronized (fragPackets) {
|
||||
if (!fragPackets.contains(f)) {
|
||||
fragPackets.add(f);
|
||||
updateMetadata();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int spliceFragmentedIntoBuffer(Fragmented f, byte [] data, int offset) {
|
||||
byte [] fData = f.encode().array();
|
||||
int header = offset==0?8:4;
|
||||
System.arraycopy(fData, header, data, offset, fData.length-header);
|
||||
return offset + fData.length-header;
|
||||
}
|
||||
|
||||
private void updateMetadata() {
|
||||
synchronized (fragPackets) {
|
||||
if (fragPackets.isEmpty())
|
||||
fragSize = 0;
|
||||
else
|
||||
fragSize = fragPackets.getFirst().encode().order(ByteOrder.BIG_ENDIAN).getInt(4);
|
||||
}
|
||||
}
|
||||
|
||||
private int getBufferedSize() {
|
||||
int curSize = 0;
|
||||
int i = 0;
|
||||
short prevSeq = (short) (fragPackets.getFirst().getSequence()-1);
|
||||
for (Fragmented frag : fragPackets) {
|
||||
// Update previous sequence and verify all in-order
|
||||
if (prevSeq+1 != frag.getSequence())
|
||||
break;
|
||||
prevSeq = frag.getSequence();
|
||||
// Update current size
|
||||
curSize += (i == 0) ? frag.encode().array().length-8 : frag.encode().array().length-4;
|
||||
i++;
|
||||
if (curSize >= fragSize)
|
||||
break;
|
||||
}
|
||||
return curSize;
|
||||
}
|
||||
|
||||
}
|
||||
166
src/network/InboundNetworkHandler.java
Normal file
166
src/network/InboundNetworkHandler.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import network.encryption.Encryption;
|
||||
import network.packets.Packet;
|
||||
import network.packets.soe.Acknowledge;
|
||||
import network.packets.soe.ClientNetworkStatusUpdate;
|
||||
import network.packets.soe.DataChannelA;
|
||||
import network.packets.soe.Disconnect;
|
||||
import network.packets.soe.Fragmented;
|
||||
import network.packets.soe.MultiPacket;
|
||||
import network.packets.soe.OutOfOrder;
|
||||
import network.packets.soe.SessionRequest;
|
||||
import network.packets.soe.SessionResponse;
|
||||
import network.packets.swg.SWGPacket;
|
||||
import network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
public class InboundNetworkHandler {
|
||||
|
||||
private final Queue <Packet> inboundQueue;
|
||||
private final FragmentedHandler fragStream;
|
||||
private final InboundEventCallback eventCallback;
|
||||
private short recvSequence;
|
||||
private int crc;
|
||||
|
||||
public InboundNetworkHandler(InboundEventCallback eventCallback) {
|
||||
this.inboundQueue = new LinkedList<Packet>();
|
||||
this.fragStream = new FragmentedHandler();
|
||||
this.eventCallback = eventCallback;
|
||||
recvSequence = -1;
|
||||
crc = 0;
|
||||
}
|
||||
|
||||
public synchronized void reset() {
|
||||
fragStream.reset();
|
||||
recvSequence = -1;
|
||||
crc = 0;
|
||||
}
|
||||
|
||||
public synchronized void setCrc(int crc) {
|
||||
this.crc = crc;
|
||||
}
|
||||
|
||||
public synchronized int getCrc() {
|
||||
return crc;
|
||||
}
|
||||
|
||||
public synchronized short getReceivedSequence() {
|
||||
return recvSequence;
|
||||
}
|
||||
|
||||
public synchronized boolean hasInbound() {
|
||||
synchronized (inboundQueue) {
|
||||
return !inboundQueue.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Packet pollInbound() {
|
||||
synchronized (inboundQueue) {
|
||||
return inboundQueue.poll();
|
||||
}
|
||||
}
|
||||
|
||||
private void pushPacket(Packet packet) {
|
||||
synchronized (inboundQueue) {
|
||||
inboundQueue.add(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int onReceive(byte [] data) {
|
||||
if (data.length < 2)
|
||||
return 0;
|
||||
if (data[1] == 1 || data[1] == 2)
|
||||
return processPacket(data);
|
||||
else
|
||||
return processPacket(Encryption.decode(data, crc));
|
||||
}
|
||||
|
||||
private int processPacket(byte [] data) {
|
||||
if (data.length < 2)
|
||||
return 0;
|
||||
ByteBuffer bb = ByteBuffer.wrap(data);
|
||||
int packets = 0;
|
||||
switch (data[1]) {
|
||||
case 0x00:
|
||||
if (data[0] > 0)
|
||||
packets += processSwgPacket(data);
|
||||
break;
|
||||
case 0x01: ++packets; pushPacket(new SessionRequest(bb)); break;
|
||||
case 0x02: ++packets; pushPacket(new SessionResponse(bb)); break;
|
||||
case 0x03: packets += processMulti(new MultiPacket(bb)); break;
|
||||
case 0x05: ++packets; pushPacket(new Disconnect(bb)); break;
|
||||
case 0x07: ++packets; pushPacket(new ClientNetworkStatusUpdate(bb)); break;
|
||||
case 0x09: packets += processData(new DataChannelA(bb)); break;
|
||||
case 0x0D: packets += processFrag(new Fragmented(bb)); break;
|
||||
case 0x11: ++packets; pushPacket(new OutOfOrder(bb)); break;
|
||||
case 0x15: ++packets; pushPacket(new Acknowledge(bb)); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
private int processMulti(MultiPacket packet) {
|
||||
int packets = 0;
|
||||
for (Packet p : packet.getPackets())
|
||||
packets += processPacket(p.getData().array());
|
||||
return packets;
|
||||
}
|
||||
|
||||
private int processData(DataChannelA packet) {
|
||||
if (packet.getSequence() != (short) (recvSequence+1)) {
|
||||
if (packet.getSequence() > recvSequence)
|
||||
eventCallback.sendOutOfOrder(packet.getSequence());
|
||||
return 0;
|
||||
}
|
||||
recvSequence = packet.getSequence();
|
||||
eventCallback.sendAcknowledge(recvSequence);
|
||||
int packets = 0;
|
||||
for (SWGPacket p : packet.getPackets()) {
|
||||
processSwgPacket(p.getData().array());
|
||||
++packets;
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
private int processFrag(Fragmented packet) {
|
||||
if (packet.getSequence() != (short) (recvSequence+1)) {
|
||||
if (packet.getSequence() > recvSequence)
|
||||
eventCallback.sendOutOfOrder(packet.getSequence());
|
||||
return 0;
|
||||
}
|
||||
recvSequence = packet.getSequence();
|
||||
eventCallback.sendAcknowledge(recvSequence);
|
||||
return processPacket(fragStream.onReceived(packet));
|
||||
}
|
||||
|
||||
private int processSwgPacket(byte [] data) {
|
||||
if (data.length < 6)
|
||||
return 0;
|
||||
ByteBuffer bb = ByteBuffer.wrap(data);
|
||||
int crc = bb.order(ByteOrder.LITTLE_ENDIAN).getInt(2);
|
||||
SWGPacket packet;
|
||||
if (crc == ObjectController.CRC)
|
||||
packet = ObjectController.decodeController(bb);
|
||||
else {
|
||||
packet = PacketType.getForCrc(crc);
|
||||
if (packet != null)
|
||||
packet.decode(bb);
|
||||
}
|
||||
if (packet == null)
|
||||
return 0;
|
||||
pushPacket(packet);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public interface InboundEventCallback {
|
||||
public void sendAcknowledge(short sequence);
|
||||
public void sendOutOfOrder(short sequence);
|
||||
}
|
||||
|
||||
}
|
||||
100
src/network/NetworkClient.java
Normal file
100
src/network/NetworkClient.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package network;
|
||||
|
||||
import intents.InboundPacketIntent;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.network.ServerType;
|
||||
import network.packets.Packet;
|
||||
|
||||
public class NetworkClient {
|
||||
|
||||
private final Object prevPacketIntentMutex = new Object();
|
||||
private final long networkId;
|
||||
private final ServerType serverType;
|
||||
private final NetworkProtocol protocol;
|
||||
private InetAddress address;
|
||||
private Intent prevPacketIntent;
|
||||
private int port;
|
||||
private int connId;
|
||||
|
||||
public NetworkClient(ServerType type, InetAddress addr, int port, long networkId) {
|
||||
this.serverType = type;
|
||||
this.networkId = networkId;
|
||||
protocol = new NetworkProtocol(type, addr, port);
|
||||
prevPacketIntent = null;
|
||||
connId = 0;
|
||||
updateNetworkInfo(addr, port);
|
||||
}
|
||||
|
||||
public void updateNetworkInfo(InetAddress addr, int port) {
|
||||
protocol.updateNetworkInfo(addr, port);
|
||||
this.address = addr;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void resetNetwork() {
|
||||
protocol.resetNetwork();
|
||||
connId = 0;
|
||||
}
|
||||
|
||||
public void setCrc(int crc) {
|
||||
protocol.setCrc(crc);
|
||||
}
|
||||
|
||||
public void setConnectionId(int id) {
|
||||
connId = id;
|
||||
}
|
||||
|
||||
public InetAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public int getCrc() {
|
||||
return protocol.getCrc();
|
||||
}
|
||||
|
||||
public int getConnectionId() {
|
||||
return connId;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public void sendPacket(Packet p) {
|
||||
protocol.sendPacket(p);
|
||||
}
|
||||
|
||||
public boolean processPacket(ServerType type, byte [] data) {
|
||||
if (type != serverType || type == ServerType.UNKNOWN)
|
||||
return false;
|
||||
if (type == ServerType.PING)
|
||||
return true;
|
||||
List <Packet> packets = protocol.process(data);
|
||||
for (Packet p : packets) {
|
||||
p.setAddress(address);
|
||||
p.setPort(port);
|
||||
synchronized (prevPacketIntentMutex) {
|
||||
InboundPacketIntent i = new InboundPacketIntent(type, p, networkId);
|
||||
if (prevPacketIntent == null)
|
||||
i.broadcast();
|
||||
else
|
||||
i.broadcastAfterIntent(prevPacketIntent);
|
||||
prevPacketIntent = i;
|
||||
}
|
||||
}
|
||||
return packets.size() > 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "NetworkClient[ConnId=" + connId + " " + address + ":" + port + "]";
|
||||
}
|
||||
|
||||
}
|
||||
128
src/network/NetworkProtocol.java
Normal file
128
src/network/NetworkProtocol.java
Normal file
@@ -0,0 +1,128 @@
|
||||
package network;
|
||||
|
||||
import intents.OutboundUdpPacketIntent;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.network.ServerType;
|
||||
import resources.network.UDPServer.UDPPacket;
|
||||
import network.InboundNetworkHandler.InboundEventCallback;
|
||||
import network.packets.Packet;
|
||||
import network.packets.soe.Acknowledge;
|
||||
import network.packets.soe.ClientNetworkStatusUpdate;
|
||||
import network.packets.soe.OutOfOrder;
|
||||
import network.packets.soe.ServerNetworkStatusUpdate;
|
||||
|
||||
public class NetworkProtocol implements InboundEventCallback {
|
||||
|
||||
private final Object prevOutboundIntentMutex = new Object();
|
||||
private final InboundNetworkHandler inbound;
|
||||
private final OutboundNetworkHandler outbound;
|
||||
private final ServerType serverType;
|
||||
|
||||
private Intent prevOutboundIntent;
|
||||
private InetAddress address;
|
||||
private int port;
|
||||
private int crc;
|
||||
|
||||
public NetworkProtocol(ServerType type, InetAddress address, int port) {
|
||||
this.inbound = new InboundNetworkHandler(this);
|
||||
this.outbound = new OutboundNetworkHandler();
|
||||
this.serverType = type;
|
||||
prevOutboundIntent = null;
|
||||
crc = 0;
|
||||
updateNetworkInfo(address, port);
|
||||
}
|
||||
|
||||
public void setCrc(int crc) {
|
||||
this.crc = crc;
|
||||
inbound.setCrc(crc);
|
||||
outbound.setCrc(crc);
|
||||
}
|
||||
|
||||
public int getCrc() {
|
||||
return crc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAcknowledge(short sequence) {
|
||||
sendPacket(new Acknowledge(sequence));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendOutOfOrder(short sequence) {
|
||||
sendPacket(new OutOfOrder(sequence));
|
||||
}
|
||||
|
||||
public void updateNetworkInfo(InetAddress addr, int port) {
|
||||
this.address = addr;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void resetNetwork() {
|
||||
inbound.reset();
|
||||
outbound.reset();
|
||||
prevOutboundIntent = null;
|
||||
}
|
||||
|
||||
public List <Packet> process(byte [] data) {
|
||||
inbound.onReceive(data);
|
||||
List <Packet> packets = new LinkedList<Packet>();
|
||||
while (inbound.hasInbound())
|
||||
process(packets, inbound.pollInbound());
|
||||
return packets;
|
||||
}
|
||||
|
||||
private void process(List <Packet> packets, Packet packet) {
|
||||
if (packet == null)
|
||||
return;
|
||||
packets.add(packet);
|
||||
if (packet instanceof Acknowledge)
|
||||
outbound.onAcknowledge(((Acknowledge) packet).getSequence());
|
||||
else if (packet instanceof OutOfOrder)
|
||||
outbound.onOutOfOrder(((OutOfOrder) packet).getSequence());
|
||||
else if (packet instanceof ClientNetworkStatusUpdate)
|
||||
processClientNetworkUpdate((ClientNetworkStatusUpdate) packet);
|
||||
flushAssembled();
|
||||
}
|
||||
|
||||
public void sendPacket(Packet packet) {
|
||||
if (address == null)
|
||||
return;
|
||||
outbound.assemble(packet);
|
||||
flushAssembled();
|
||||
}
|
||||
|
||||
private void send(byte [] data) {
|
||||
if (data == null)
|
||||
return;
|
||||
UDPPacket packet = new UDPPacket(address, port, data);
|
||||
OutboundUdpPacketIntent intent = new OutboundUdpPacketIntent(serverType, packet);
|
||||
synchronized (prevOutboundIntentMutex) {
|
||||
intent.broadcastAfterIntent(prevOutboundIntent);
|
||||
prevOutboundIntent = intent;
|
||||
}
|
||||
}
|
||||
|
||||
private void processClientNetworkUpdate(ClientNetworkStatusUpdate update) {
|
||||
ServerNetworkStatusUpdate serverNet = new ServerNetworkStatusUpdate();
|
||||
serverNet.setClientTickCount((short) update.getTick());
|
||||
serverNet.setServerSyncStampLong(0);
|
||||
int recv = inbound.getReceivedSequence() < 0 ? 0 : inbound.getReceivedSequence();
|
||||
int send = outbound.getSentSequence();
|
||||
serverNet.setClientPacketsSent(recv);
|
||||
serverNet.setClientPacketsRecv(send);
|
||||
serverNet.setServerPacketsSent(send);
|
||||
serverNet.setServerPacketsRecv(recv);
|
||||
sendPacket(serverNet);
|
||||
}
|
||||
|
||||
private void flushAssembled() {
|
||||
while (outbound.hasAssembled())
|
||||
send(outbound.pollAssembled());
|
||||
}
|
||||
|
||||
}
|
||||
232
src/network/OutboundNetworkHandler.java
Normal file
232
src/network/OutboundNetworkHandler.java
Normal file
@@ -0,0 +1,232 @@
|
||||
package network;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import resources.SortedLinkedList;
|
||||
import network.encryption.Encryption;
|
||||
import network.packets.Packet;
|
||||
import network.packets.soe.DataChannelA;
|
||||
import network.packets.soe.Fragmented;
|
||||
import network.packets.soe.MultiPacket;
|
||||
import network.packets.soe.SessionRequest;
|
||||
import network.packets.soe.SessionResponse;
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class OutboundNetworkHandler {
|
||||
|
||||
private final Queue <byte []> assembleQueue;
|
||||
private final SortedLinkedList <SequencedPacket> sequenced;
|
||||
private short sendSequence;
|
||||
private int crc;
|
||||
|
||||
public OutboundNetworkHandler() {
|
||||
assembleQueue = new LinkedList<byte []>();
|
||||
sequenced = new SortedLinkedList<SequencedPacket>();
|
||||
sendSequence = 0;
|
||||
crc = 0;
|
||||
}
|
||||
|
||||
public synchronized void reset() {
|
||||
sendSequence = 0;
|
||||
crc = 0;
|
||||
}
|
||||
|
||||
public synchronized void setCrc(int crc) {
|
||||
this.crc = crc;
|
||||
}
|
||||
|
||||
public synchronized int getCrc() {
|
||||
return crc;
|
||||
}
|
||||
|
||||
public synchronized short getSentSequence() {
|
||||
return sendSequence;
|
||||
}
|
||||
|
||||
public synchronized void onAcknowledge(short sequence) {
|
||||
synchronized (sequenced) {
|
||||
Iterator <SequencedPacket> it = sequenced.iterator();
|
||||
while (it.hasNext()) {
|
||||
SequencedPacket sp = it.next();
|
||||
if (sp.getSequence() <= sequence)
|
||||
it.remove();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onOutOfOrder(short sequence) {
|
||||
synchronized (sequenced) {
|
||||
Iterator <SequencedPacket> it = sequenced.iterator();
|
||||
while (it.hasNext()) {
|
||||
SequencedPacket sp = it.next();
|
||||
if (sp.getSequence() <= sequence)
|
||||
pushAssembledEncrypted(sp.getPacket());
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean hasAssembled() {
|
||||
synchronized (assembleQueue) {
|
||||
return !assembleQueue.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized byte [] pollAssembled() {
|
||||
synchronized (assembleQueue) {
|
||||
return assembleQueue.poll();
|
||||
}
|
||||
}
|
||||
|
||||
private void pushAssembledEncrypted(byte [] data) {
|
||||
data = Encryption.encode(data, crc);
|
||||
synchronized (assembleQueue) {
|
||||
assembleQueue.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void pushAssembledUnencrypted(byte [] data) {
|
||||
synchronized (assembleQueue) {
|
||||
assembleQueue.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void pushSequencedPacket(short sequence, byte [] packet) {
|
||||
synchronized (sequenced) {
|
||||
sequenced.add(new SequencedPacket(sequence, packet));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int assemble(Packet packet) {
|
||||
if (packet instanceof SessionRequest || packet instanceof SessionResponse) {
|
||||
pushAssembledUnencrypted(packet.encode().array());
|
||||
return 1;
|
||||
} else
|
||||
return assembleUnencrypted(packet);
|
||||
}
|
||||
|
||||
private int assembleUnencrypted(Packet packet) {
|
||||
if (packet instanceof SWGPacket)
|
||||
return assembleSwg((SWGPacket) packet);
|
||||
else
|
||||
return assembleSoe(packet);
|
||||
}
|
||||
|
||||
private int assembleSoe(Packet packet) {
|
||||
if (packet instanceof DataChannelA)
|
||||
return assembleDataChannelA((DataChannelA) packet);
|
||||
if (packet instanceof MultiPacket)
|
||||
return assembleMultiPacket((MultiPacket) packet);
|
||||
pushAssembledEncrypted(packet.encode().array());
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int assembleSwg(SWGPacket packet) {
|
||||
return assembleDataChannelA(new DataChannelA(packet));
|
||||
}
|
||||
|
||||
private int assembleMultiPacket(MultiPacket m) {
|
||||
int len = m.getLength();
|
||||
if (len >= 493) {
|
||||
int count = getFragmentedPacketCount(len);
|
||||
int lastSeq = updateSequencesMulti((short)(sendSequence+count), m);
|
||||
for (Fragmented f : Fragmented.encode(m.encode(), sendSequence)) {
|
||||
byte [] encoded = f.encode().array();
|
||||
pushSequencedPacket(f.getSequence(), encoded);
|
||||
pushAssembledEncrypted(encoded);
|
||||
}
|
||||
sendSequence = (short) (lastSeq + 1);
|
||||
return count;
|
||||
} else {
|
||||
sendSequence = updateSequencesMulti(sendSequence, m);
|
||||
pushAssembledEncrypted(m.encode().array());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int assembleDataChannelA(DataChannelA d) {
|
||||
int len = d.getLength();
|
||||
if (len >= 493) {
|
||||
int count = getFragmentedPacketCount(len);
|
||||
int lastSeq = updateSequenceData((short)(sendSequence+count), d);
|
||||
for (Fragmented f : Fragmented.encode(d.encode(), sendSequence)) {
|
||||
byte [] encoded = f.encode().array();
|
||||
pushSequencedPacket(f.getSequence(), encoded);
|
||||
pushAssembledEncrypted(encoded);
|
||||
}
|
||||
sendSequence = (short) lastSeq;
|
||||
return count;
|
||||
} else {
|
||||
d.setSequence(sendSequence++);
|
||||
byte [] encoded = d.encode().array();
|
||||
pushSequencedPacket(d.getSequence(), encoded);
|
||||
pushAssembledEncrypted(encoded);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private short updateSequencesMulti(short seq, MultiPacket m) {
|
||||
for (Packet p : m.getPackets()) {
|
||||
if (p instanceof DataChannelA)
|
||||
seq = updateSequenceData(seq, (DataChannelA) p);
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
|
||||
private short updateSequenceData(short seq, DataChannelA d) {
|
||||
d.setSequence(seq++);
|
||||
return seq;
|
||||
}
|
||||
|
||||
private int getFragmentedPacketCount(int length) {
|
||||
return (int) Math.ceil((length+4)/489.0);
|
||||
}
|
||||
|
||||
private static class SequencedPacket implements Comparable <SequencedPacket> {
|
||||
private final short sequence;
|
||||
private final byte [] packet;
|
||||
|
||||
public SequencedPacket(short sequence, byte [] packet) {
|
||||
this.sequence = sequence;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public short getSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public byte [] getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(SequencedPacket sp) {
|
||||
if (sequence < sp.getSequence())
|
||||
return -1;
|
||||
if (sequence == sp.getSequence())
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null)
|
||||
return false;
|
||||
if (o instanceof SequencedPacket)
|
||||
return ((SequencedPacket) o).getSequence() == sequence;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
163
src/network/OutboundPacketService.java
Normal file
163
src/network/OutboundPacketService.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package network;
|
||||
|
||||
import intents.CloseConnectionIntent;
|
||||
import intents.OutboundPacketIntent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import resources.control.Intent;
|
||||
import resources.control.Service;
|
||||
import network.packets.Packet;
|
||||
import network.packets.soe.DataChannelA;
|
||||
import network.packets.soe.MultiPacket;
|
||||
import network.packets.soe.SessionResponse;
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class OutboundPacketService {
|
||||
|
||||
private final Map <Long, OutboundPacketSender> outboundPackets = new HashMap<Long, OutboundPacketSender>();
|
||||
|
||||
public OutboundPacketService() {
|
||||
new Service() {
|
||||
public void onIntentReceived(Intent i) {
|
||||
if (i instanceof CloseConnectionIntent)
|
||||
closeConnection(((CloseConnectionIntent)i).getNetworkId());
|
||||
}
|
||||
}.registerForIntent(CloseConnectionIntent.TYPE);
|
||||
}
|
||||
|
||||
public void sendPacket(long networkId, Packet ... packets) {
|
||||
getSender(networkId).add(packets);
|
||||
}
|
||||
|
||||
public void sendPacket(long networkId, Packet packet) {
|
||||
getSender(networkId).add(packet);
|
||||
}
|
||||
|
||||
public int flushPackets() {
|
||||
int count = 0;
|
||||
synchronized (outboundPackets) {
|
||||
for (OutboundPacketSender sender : outboundPackets.values())
|
||||
count += sender.sendPackets();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private void closeConnection(long networkId) {
|
||||
synchronized (outboundPackets) {
|
||||
outboundPackets.remove(networkId);
|
||||
}
|
||||
}
|
||||
|
||||
private OutboundPacketSender getSender(long networkId) {
|
||||
synchronized (outboundPackets) {
|
||||
OutboundPacketSender outbound = outboundPackets.get(networkId);
|
||||
if (outbound == null) {
|
||||
outbound = new OutboundPacketSender(networkId);
|
||||
outboundPackets.put(networkId, outbound);
|
||||
}
|
||||
return outbound;
|
||||
}
|
||||
}
|
||||
|
||||
private static class OutboundPacketSender {
|
||||
|
||||
private final List <Packet> outbound;
|
||||
private final long networkId;
|
||||
private Intent prevOutbound;
|
||||
private boolean hasSoe;
|
||||
private boolean hasSwg;
|
||||
|
||||
public OutboundPacketSender(long networkId) {
|
||||
outbound = new LinkedList<Packet>();
|
||||
this.networkId = networkId;
|
||||
prevOutbound = null;
|
||||
hasSoe = false;
|
||||
hasSwg = false;
|
||||
}
|
||||
|
||||
public synchronized void add(Packet ... packets) {
|
||||
for (Packet p : packets)
|
||||
add(p);
|
||||
}
|
||||
|
||||
public synchronized void add(Packet p) {
|
||||
if (p instanceof SessionResponse) {
|
||||
send(p);
|
||||
} else {
|
||||
if (p instanceof SWGPacket)
|
||||
hasSwg = true;
|
||||
else
|
||||
hasSoe = true;
|
||||
outbound.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int sendPackets() {
|
||||
if (outbound.isEmpty())
|
||||
return 0;
|
||||
int size = outbound.size();
|
||||
packageAndSendPackets();
|
||||
return size;
|
||||
}
|
||||
|
||||
private synchronized void send(Packet p) {
|
||||
Intent out = new OutboundPacketIntent(p, networkId);
|
||||
out.broadcastAfterIntent(prevOutbound);
|
||||
prevOutbound = out;
|
||||
}
|
||||
|
||||
private synchronized void clear() {
|
||||
hasSoe = false;
|
||||
hasSwg = false;
|
||||
outbound.clear();
|
||||
}
|
||||
|
||||
private synchronized void packageAndSendPackets() {
|
||||
if (hasSwg) {
|
||||
if (hasSoe)
|
||||
packageMix();
|
||||
else
|
||||
packageSwg();
|
||||
} else {
|
||||
if (hasSoe)
|
||||
packageSoe();
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
private synchronized void packageSoe() {
|
||||
send(new MultiPacket(new LinkedList<Packet>(outbound)));
|
||||
}
|
||||
|
||||
private synchronized void packageSwg() {
|
||||
send(new DataChannelA(outbound.toArray(new SWGPacket[outbound.size()])));
|
||||
}
|
||||
|
||||
private synchronized void packageMix() {
|
||||
MultiPacket multi = new MultiPacket();
|
||||
DataChannelA data = null;
|
||||
for (Packet p : outbound) {
|
||||
if (p instanceof SWGPacket) {
|
||||
if (data == null)
|
||||
data = new DataChannelA();
|
||||
data.addPacket((SWGPacket) p);
|
||||
} else {
|
||||
if (data != null) {
|
||||
multi.addPacket(data);
|
||||
data = null;
|
||||
}
|
||||
multi.addPacket(p);
|
||||
}
|
||||
}
|
||||
if (data != null)
|
||||
multi.addPacket(data);
|
||||
send(multi);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
182
src/network/PacketType.java
Normal file
182
src/network/PacketType.java
Normal file
@@ -0,0 +1,182 @@
|
||||
package network;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import network.packets.swg.*;
|
||||
import network.packets.swg.login.*;
|
||||
import network.packets.swg.login.creation.*;
|
||||
import network.packets.swg.zone.*;
|
||||
import network.packets.swg.zone.auction.*;
|
||||
import network.packets.swg.zone.baselines.*;
|
||||
import network.packets.swg.zone.building.*;
|
||||
import network.packets.swg.zone.chat.*;
|
||||
import network.packets.swg.zone.combat.*;
|
||||
import network.packets.swg.zone.deltas.*;
|
||||
import network.packets.swg.zone.insertion.*;
|
||||
import network.packets.swg.zone.object_controller.*;
|
||||
import network.packets.swg.zone.server_ui.*;
|
||||
import network.packets.swg.zone.spatial.*;
|
||||
|
||||
public enum PacketType {
|
||||
|
||||
// Both
|
||||
SERVER_UNIX_EPOCH_TIME (0x24b73893, ServerUnixEpochTime.class),
|
||||
SERVER_ID (0x58c07f21, ServerId.class),
|
||||
SERVER_STRING (0x0e20d7e9, ServerString.class),
|
||||
|
||||
// Login
|
||||
CLIENT_ID_MSG (0xd5899226, ClientIdMsg.class),
|
||||
ERROR_MESSAGE (0xb5abf91a, ErrorMessage.class),
|
||||
ACCOUNT_FEATURE_BITS (0x979f0279, AccountFeatureBits.class),
|
||||
CLIENT_PERMISSIONS_MESSAGE (0xe00730e5, ClientPermissionsMessage.class),
|
||||
REQUEST_EXTENDED_CLUSTERS (0x8e33ed05, RequestExtendedClusters.class),
|
||||
OFFLINE_SERVERS_MESSAGE (0xF41A5265, OfflineServersMessage.class),
|
||||
|
||||
// Post-Login
|
||||
LOGIN_CLIENT_ID (0x41131F96, LoginClientId.class),
|
||||
LOGIN_INCORRECT_CLIENT_ID (0x20E7E510, LoginIncorrectClientId.class),
|
||||
LOGIN_CLIENT_TOKEN (0xaab296c6, LoginClientToken.class),
|
||||
LOGIN_ENUM_CLUSTER (0xc11c63b9, LoginEnumCluster.class),
|
||||
LOGIN_CLUSTER_STATUS (0x3436aeb6, LoginClusterStatus.class),
|
||||
ENUMERATE_CHARACTER_ID (0x65ea4574, EnumerateCharacterId.class),
|
||||
STATION_ID_HAS_JEDI_SLOT (0xcc9fccf8, StationIdHasJediSlot.class),
|
||||
CHARACTER_CREATION_DISABLED (0xf4a15265, CharacterCreationDisabled.class),
|
||||
|
||||
// Character Creation
|
||||
CLIENT_CREATE_CHARACTER (0xb97f3074, ClientCreateCharacter.class),
|
||||
CREATE_CHARACTER_SUCCESS (0x1db575cc, CreateCharacterSuccess.class),
|
||||
CREATE_CHARACTER_FAILURE (0xdf333c6e, CreateCharacterFailure.class),
|
||||
APPROVE_NAME_REQUEST (0x9eb04b9f, ClientVerifyAndLockNameRequest.class),
|
||||
APPROVE_NAME_RESPONSE (0x9b2c6ba7, ClientVerifyAndLockNameResponse.class),
|
||||
RANDOM_NAME_REQUEST (0xd6d1b6d1, RandomNameRequest.class),
|
||||
RANDOM_NAME_RESPONSE (0xe85fb868, RandomNameResponse.class),
|
||||
|
||||
// Character Deletion
|
||||
DELETE_CHARACTER_RESPONSE (0x8268989b, DeleteCharacterResponse.class),
|
||||
DELETE_CHARACTER_REQUEST (0xe87ad031, DeleteCharacterRequest.class),
|
||||
|
||||
// Zone
|
||||
COMMAND_QUEUE_ENQUEUE (0x00000116, CommandQueueEnqueue.class),
|
||||
SELECT_CHARACTER (0xb5098d76, SelectCharacter.class),
|
||||
CMD_SCENE_READY (0x43fd1c22, CmdSceneReady.class),
|
||||
CMD_START_SCENE (0x3ae6dfae, CmdStartScene.class),
|
||||
HEART_BEAT_MESSAGE (0xa16cf9af, HeartBeatMessage.class),
|
||||
OBJECT_CONTROLLER (0x80ce5e46, ObjectController.class),
|
||||
BASELINE (0x68a75f0c, Baseline.class),
|
||||
DATA_TRANSFORM (0x00000071, DataTransform.class),
|
||||
CONNECT_PLAYER_MESSAGE (0x2e365218, ConnectPlayerMessage.class),
|
||||
CONNECT_PLAYER_RESPONSE_MESSAGE (0x6137556F, ConnectPlayerResponseMessage.class),
|
||||
GALAXY_LOOP_TIMES_REQUEST (0x7d842d68, GalaxyLoopTimesRequest.class),
|
||||
GALAXY_LOOP_TIMES_RESPONSE (0x4e428088, GalaxyLoopTimesResponse.class),
|
||||
PARAMETERS_MESSAGE (0x487652DA, ParametersMessage.class),
|
||||
DELTA (0x12862153, DeltasMessage.class),
|
||||
SERVER_TIME_MESSAGE (0x2EBC3BD9, ServerTimeMessage.class),
|
||||
SET_WAYPOINT_COLOR (0x90C59FDE, SetWaypointColor.class),
|
||||
|
||||
// Chat
|
||||
CHAT_FRIENDS_LIST_UPDATE (0x6CD2FCD8, ChatFriendsListUpdate.class),
|
||||
CHAT_IGNORE_LIST (0xF8C275B0, ChatIgnoreList.class),
|
||||
CHAT_INSTANT_MESSAGE_TO_CLIENT (0x3C565CED, ChatInstantMessageToClient.class),
|
||||
CHAT_INSTANT_MESSAGE_TO_CHARACTER (0x84BB21F7, ChatInstantMessageToCharacter.class),
|
||||
CHAT_ON_CONNECT_AVATAR (0xD72FE9BE, ChatOnConnectAvatar.class),
|
||||
CHAT_ON_DESTROY_ROOM (0xE8EC5877, ChatOnDestroyRoom.class),
|
||||
CHAT_ON_ENTERED_ROOM (0xE69BDC0A, ChatOnEnteredRoom.class),
|
||||
CHAT_ON_LEAVE_ROOM (0x60B5098B, ChatOnLeaveRoom.class),
|
||||
CHAT_ON_RECEIVE_ROOM_INVITATION (0xC17EB06D, ChatOnReceiveRoomInvitation.class),
|
||||
CHAT_ON_SEND_INSTANT_MESSAGE (0x88DBB381, ChatOnSendInstantMessage.class),
|
||||
CHAT_ON_SEND_ROOM_MESSAGE (0xE7B61633, ChatOnSendRoomMessage.class),
|
||||
CHAT_PERSISTENT_MESSAGE_TO_CLIENT (0x08485E17, ChatPersistentMessageToClient.class),
|
||||
CHAT_PERSISTENT_MESSAGE_TO_SERVER (0x25A29FA6, ChatPersistentMessageToServer.class),
|
||||
CHAT_DELETE_PERSISTENT_MESSAGE (0x8F251641, ChatDeletePersistentMessage.class),
|
||||
CHAT_REQUEST_PERSISTENT_MESSAGE (0x07E3559F, ChatRequestPersistentMessage.class),
|
||||
CHAT_REQUEST_ROOM_LIST (0x4C3d2CfA, ChatRequestRoomList.class),
|
||||
CHAT_ROOM_LIST (0x70DEB197, ChatRoomList.class),
|
||||
CHAT_ROOM_MESSAGE (0xCD4CE444, ChatRoomMessage.class),
|
||||
CHAT_SERVER_STATUS (0x7102B15F, ChatServerStatus.class),
|
||||
CHAT_SYSTEM_MESSAGE (0x6D2A6413, ChatSystemMessage.class),
|
||||
CON_GENERIC_MESSAGE (0x08C5FC76, ConGenericMessage.class),
|
||||
VOICE_CHAT_STATUS (0x9E601905, VoiceChatStatus.class),
|
||||
|
||||
// Scene
|
||||
SCENE_END_BASELINES (0x2C436037, SceneEndBaselines.class),
|
||||
SCENE_CREATE_OBJECT_BY_CRC (0xFE89DDEA, SceneCreateObjectByCrc.class),
|
||||
SCENE_DESTROY_OBJECT (0x4D45D504, SceneDestroyObject.class),
|
||||
UPDATE_CONTAINMENT_MESSAGE (0x56CBDE9E, UpdateContainmentMessage.class),
|
||||
UPDATE_CELL_PERMISSIONS_MESSAGE (0xF612499C, UpdateCellPermissionMessage.class),
|
||||
GET_MAP_LOCATIONS_MESSAGE (0x1A7AB839, GetMapLocationsMessage.class),
|
||||
GET_MAP_LOCATIONS_RESPONSE_MESSAGE (0x9F80464C, GetMapLocationsResponseMessage.class),
|
||||
|
||||
// Spatial
|
||||
UPDATE_POSTURE_MESSAGE (0x0bde6b41, UpdatePostureMessage.class),
|
||||
UPDATE_TRANSFORMS_MESSAGE (0x1B24F808, UpdateTransformsMessage.class),
|
||||
SPATIAL_CHAT (0x000000f4, SpatialChat.class),
|
||||
NEW_TICKET_ACTIVITY_RESPONSE_MESSAGE (0x6EA42D80, NewTicketActivityResponseMessage.class),
|
||||
ATTRIBUTE_LIST_MESSAGE (0xF3F12F2A, AttributeListMessage.class),
|
||||
STOP_CLIENT_EFFECT_OBJECT_BY_LABEL (0xAD6F6B26, StopClientEffectObjectByLabelMessage.class),
|
||||
OPENED_CONTAINER_MESSAGE (0x2E11E4AB, OpenedContainerMessage.class),
|
||||
|
||||
// Combat
|
||||
UPDATE_PVP_STATUS_MESSAGE (0x08a1c126, UpdatePvpStatusMessage.class),
|
||||
GRANT_COMMAND_MESSAGE (0xE67E3875, GrantCommandMessage.class),
|
||||
|
||||
// Server UI
|
||||
OBJECT_MENU_REQUEST (0x00000146, ObjectMenuRequest.class),
|
||||
OBJECT_MENU_RESPONSE (0x00000147, ObjectMenuResponse.class),
|
||||
SUI_CREATE_PAGE_MESSAGE (0xD44B7259, SuiCreatePageMessage.class),
|
||||
SUI_EVENT_NOTIFICATION (0x092D3564, SuiEventNotification.class),
|
||||
|
||||
// Auction
|
||||
IS_VENDOR_OWNER_RESPONSE_MESSAGE (0xCE04173E, IsVendorOwnerResponseMessage.class),
|
||||
AUCTION_QUERY_HEADERS_MESSAGE (0x679E0D00, AuctionQueryHeadersMessage.class),
|
||||
GET_AUCTION_DETAILS (0xD36EFAE4, GetAuctionDetails.class),
|
||||
GET_AUCTION_DETAILS_RESPONSE (0xFE0E644B, GetAuctionDetailsResponse.class),
|
||||
CANCEL_LIVE_AUCTION_MESSAGE (0x3687A4D2, CancelLiveAuctionMessage.class),
|
||||
CANCEL_LIVE_AUCTION_RESPONSE_MESSAGE (0x7DA2246C, CancelLiveAuctionResponseMessage.class),
|
||||
AUCTION_QUERY_HEADERS_RESPONSE_MESSAGE (0xFA500E52, AuctionQueryHeadersResponseMessage.class),
|
||||
RETRIEVE_AUCTION_ITEM_MESSAGE (0x12B0D449, RetrieveAuctionItemMessage.class),
|
||||
RETRIEVE_AUCTION_ITEM_RESPONSE_MESSAGE (0x9499EF8C, RetrieveAuctionItemResponseMessage.class),
|
||||
|
||||
UNKNOWN (0xFFFFFFFF, SWGPacket.class);
|
||||
|
||||
private static final Map <Integer, PacketType> packetMap = new HashMap<Integer, PacketType>();
|
||||
|
||||
static {
|
||||
for (PacketType type : values()) {
|
||||
packetMap.put(type.crc, type);
|
||||
}
|
||||
}
|
||||
|
||||
private int crc;
|
||||
private Class <? extends SWGPacket> c;
|
||||
|
||||
PacketType(int crc, Class <? extends SWGPacket> c) {
|
||||
this.crc = crc;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public int getCrc() {
|
||||
return crc;
|
||||
}
|
||||
|
||||
public static final PacketType fromCrc(int crc) {
|
||||
PacketType type = packetMap.get(crc);
|
||||
if (type == null)
|
||||
return UNKNOWN;
|
||||
return type;
|
||||
}
|
||||
|
||||
public static final SWGPacket getForCrc(int crc) {
|
||||
PacketType type = packetMap.get(crc);
|
||||
if (type == null)
|
||||
return null;
|
||||
Class <? extends SWGPacket> c = type.c;
|
||||
try {
|
||||
return c.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
116
src/network/encryption/Encryption.java
Normal file
116
src/network/encryption/Encryption.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package network.encryption;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class Encryption {
|
||||
|
||||
public static String md5(String plaintext) {
|
||||
return MD5.digest(plaintext);
|
||||
}
|
||||
|
||||
public static byte [] encode(byte [] input, int crc) {
|
||||
return assembleMessage(input, crc);
|
||||
}
|
||||
|
||||
public static byte [] decode(byte [] input, int crc) {
|
||||
return disassemble(input, crc);
|
||||
}
|
||||
|
||||
private static byte [] disassemble(byte [] data, int crcSeed) {
|
||||
return decompress(encrypt(EncryptionCRC.validate(data, crcSeed), crcSeed, false));
|
||||
}
|
||||
|
||||
private static byte [] assembleMessage(byte [] data, int crc) {
|
||||
if (data.length < 2)
|
||||
return data;
|
||||
return EncryptionCRC.append(encrypt(compress(data), crc, true), crc);
|
||||
}
|
||||
|
||||
public static byte [] encrypt(byte [] data, int iCrc, boolean encrypt) {
|
||||
if (data.length < 2)
|
||||
return data;
|
||||
byte [] encrypted = new byte[data.length];
|
||||
int start = 2;
|
||||
encrypted[0] = data[0];
|
||||
if (data[0] != 0)
|
||||
start = 1;
|
||||
else
|
||||
encrypted[1] = data[1];
|
||||
if (data.length < 6) {
|
||||
for (int i = start; i < data.length; i++)
|
||||
encrypted[i] = (byte) (data[i] ^ iCrc);
|
||||
return encrypted;
|
||||
}
|
||||
int lastBytes = start+(int)((data.length-start)/4)*4;
|
||||
byte [] crc = new byte[] {(byte)(iCrc), (byte)(iCrc >>> 8),(byte)(iCrc >>> 16), (byte)(iCrc >>> 24)};
|
||||
for (int i = start; i < lastBytes; i++) {
|
||||
encrypted[i] = (byte) (data[i] ^ crc[(i-start)%4]);
|
||||
crc[(i-start)%4] = encrypt ? encrypted[i] : data[i];
|
||||
}
|
||||
if (lastBytes >= 4) { // Avoids an Index Out of Bounds Exception
|
||||
for (int i = lastBytes; i < data.length; i++) { // Remaining 0-3 bytes that won't fit w/ the crc
|
||||
byte lastCrc = encrypt ? encrypted[lastBytes-4] : data[lastBytes-4];
|
||||
encrypted[i] = (byte) (data[i] ^ lastCrc);
|
||||
}
|
||||
}
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public static byte [] compress(byte [] data) {
|
||||
if (data.length >= 200) {
|
||||
byte [] result = new byte[512];
|
||||
Deflater compressor = new Deflater();
|
||||
compressor.setInput(data, 2, data.length - 2);
|
||||
compressor.finish();
|
||||
int length = compressor.deflate(result);
|
||||
if (length < data.length) {
|
||||
ByteBuffer bb = ByteBuffer.allocate(length+3);
|
||||
bb.put(data[0]).put(data[1]);
|
||||
bb.put(result, 0, length);
|
||||
bb.put((byte) 1);
|
||||
return bb.array();
|
||||
}
|
||||
}
|
||||
return ByteBuffer.allocate(data.length+1).put(data).put((byte) 0).array();
|
||||
}
|
||||
|
||||
private static byte [] decompress(byte [] data) {
|
||||
if (data.length == 0)
|
||||
return data;
|
||||
else if (data[data.length - 1] == 0)
|
||||
return ByteBuffer.allocate(data.length - 1).put(data, 0, data.length - 1).array();
|
||||
else if (data[data.length - 1] != 1)
|
||||
return new byte[0];
|
||||
|
||||
int startingIndex = data[0] > 0 ? 1 : 2;
|
||||
byte [] result = new byte[512];
|
||||
int length = inflate(startingIndex, data, result);
|
||||
if (length == -1)
|
||||
return data;
|
||||
|
||||
byte [] ret = new byte[length+startingIndex];
|
||||
ret[0] = data[0];
|
||||
if (startingIndex > 1)
|
||||
System.arraycopy(data, 1, ret, 1, startingIndex-1);
|
||||
System.arraycopy(result, 0, ret, startingIndex, length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static int inflate(int startingIndex, byte [] data, byte [] result) {
|
||||
Inflater decompressor = new Inflater();
|
||||
decompressor.setInput(data, startingIndex, data.length - startingIndex);
|
||||
|
||||
try {
|
||||
int length = decompressor.inflate(result);
|
||||
decompressor.end();
|
||||
return length;
|
||||
} catch (DataFormatException e) {
|
||||
System.err.println("Failed to decompress packet. "+e.getClass().getSimpleName()+" Message: " + e.getMessage());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
76
src/network/encryption/EncryptionCRC.java
Normal file
76
src/network/encryption/EncryptionCRC.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package network.encryption;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
class EncryptionCRC {
|
||||
|
||||
private static int [] crcTable = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
||||
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
||||
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
||||
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
||||
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
||||
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
||||
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
||||
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
||||
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
||||
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
||||
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
||||
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
||||
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
||||
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
|
||||
|
||||
public static short generate(byte [] data, int crcSeed) {
|
||||
return generate(data, 0, data.length, crcSeed);
|
||||
}
|
||||
|
||||
public static short generate(byte [] data, int off, int len, int crcSeed) {
|
||||
int crc = crcTable[(~crcSeed) & 0xFF];
|
||||
int index;
|
||||
|
||||
if (data.length <= 4) return 0;
|
||||
|
||||
crc ^= 0x00FFFFFF;
|
||||
|
||||
for (int i = 1; i < 4; i++, crc = ((crc >> 8) & 0x00FFFFFF) ^ crcTable[index & 0xFF])
|
||||
index = (crcSeed >> (8 * i) ^ crc);
|
||||
for (int i = off; i < off+len; i++, crc = ((crc >> 8) & 0x00FFFFFF) ^ crcTable[index & 0xFF])
|
||||
index = (data[i]) ^ crc;
|
||||
|
||||
return (short)~crc;
|
||||
}
|
||||
|
||||
private static boolean isValid(byte[] data, int crcSeed) {
|
||||
try {
|
||||
short gen = generate(data, 0, data.length-2, crcSeed);
|
||||
short crc = (short)((data[data.length-2] << 8) + (data[data.length-1] & 0xff));
|
||||
return crc == gen;
|
||||
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static byte[] append(byte[] data, int crcSeed) {
|
||||
return ByteBuffer.allocate(data.length + 2).put(data).putShort(generate(data, crcSeed)).array();
|
||||
}
|
||||
|
||||
public static byte[] validate(byte[] data, int crcSeed) {
|
||||
if (isValid(data, crcSeed))
|
||||
return ByteBuffer.allocate(data.length - 2).put(data, 0, data.length-2).array();
|
||||
return new byte[] { };
|
||||
}
|
||||
|
||||
}
|
||||
30
src/network/encryption/MD5.java
Normal file
30
src/network/encryption/MD5.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package network.encryption;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class MD5 {
|
||||
|
||||
public static String digest(String text) {
|
||||
String result = text;
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(text.getBytes("iso-8859-1"), 0, text.length());
|
||||
result = convertToHex(md.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String convertToHex(byte[] b) {
|
||||
StringBuilder result = new StringBuilder(32);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
result.append(Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 ));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
185
src/network/packets/Packet.java
Normal file
185
src/network/packets/Packet.java
Normal file
@@ -0,0 +1,185 @@
|
||||
package network.packets;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
|
||||
public class Packet {
|
||||
public static Charset ascii = Charset.forName("UTF-8");
|
||||
public static Charset unicode = Charset.forName("UTF-16LE");
|
||||
private InetAddress address;
|
||||
private ByteBuffer data;
|
||||
private int port = 0;
|
||||
private int opcode;
|
||||
|
||||
public Packet() {
|
||||
data = ByteBuffer.allocate(2);
|
||||
}
|
||||
|
||||
public Packet(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void setAddress(InetAddress address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public InetAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setOpcode(int opcode) {
|
||||
this.opcode = opcode;
|
||||
}
|
||||
|
||||
public int getOpcode() {
|
||||
return opcode;
|
||||
}
|
||||
|
||||
public static void addBoolean(ByteBuffer bb, boolean b) {
|
||||
bb.put(b ? (byte)1 : (byte)0);
|
||||
}
|
||||
|
||||
public static void addAscii(ByteBuffer bb, String s) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
bb.putShort((short)s.length());
|
||||
bb.put(s.getBytes(ascii));
|
||||
}
|
||||
|
||||
public static void addUnicode(ByteBuffer bb, String s) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
bb.putInt(s.length());
|
||||
bb.put(s.getBytes(unicode));
|
||||
}
|
||||
|
||||
public static void addLong(ByteBuffer bb, long l) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN).putLong(l);
|
||||
}
|
||||
|
||||
public static void addInt(ByteBuffer bb, int i) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN).putInt(i);
|
||||
}
|
||||
|
||||
public static void addFloat(ByteBuffer bb, float f) {
|
||||
bb.putFloat(f);
|
||||
}
|
||||
|
||||
public static void addShort(ByteBuffer bb, int i) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN).putShort((short)i);
|
||||
}
|
||||
|
||||
public static void addNetLong(ByteBuffer bb, long l) {
|
||||
bb.order(ByteOrder.BIG_ENDIAN).putLong(l);
|
||||
}
|
||||
|
||||
public static void addNetInt(ByteBuffer bb, int i) {
|
||||
bb.order(ByteOrder.BIG_ENDIAN).putInt(i);
|
||||
}
|
||||
|
||||
public static void addNetShort(ByteBuffer bb, int i) {
|
||||
bb.order(ByteOrder.BIG_ENDIAN).putShort((short)i);
|
||||
}
|
||||
|
||||
public static void addByte(ByteBuffer bb, int b) {
|
||||
bb.put((byte)b);
|
||||
}
|
||||
|
||||
public static void addArray(ByteBuffer bb, byte [] b) {
|
||||
addShort(bb, b.length);
|
||||
bb.put(b);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(ByteBuffer bb) {
|
||||
return getByte(bb) == 1 ? true : false;
|
||||
}
|
||||
|
||||
public static String getAscii(ByteBuffer bb) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
short length = bb.getShort();
|
||||
if (length > bb.remaining())
|
||||
return "";
|
||||
byte [] str = new byte[length];
|
||||
bb.get(str);
|
||||
return new String(str, ascii);
|
||||
}
|
||||
|
||||
public static String getUnicode(ByteBuffer bb) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int length = bb.getInt() * 2;
|
||||
if (length > bb.remaining())
|
||||
return "";
|
||||
byte [] str = new byte[length];
|
||||
bb.get(str);
|
||||
return new String(str, unicode);
|
||||
}
|
||||
|
||||
public static byte getByte(ByteBuffer bb) {
|
||||
return bb.get();
|
||||
}
|
||||
|
||||
public static short getShort(ByteBuffer bb) {
|
||||
return bb.order(ByteOrder.LITTLE_ENDIAN).getShort();
|
||||
}
|
||||
|
||||
public static int getInt(ByteBuffer bb) {
|
||||
return bb.order(ByteOrder.LITTLE_ENDIAN).getInt();
|
||||
}
|
||||
|
||||
public static float getFloat(ByteBuffer bb) {
|
||||
return bb.getFloat();
|
||||
}
|
||||
|
||||
public static long getLong(ByteBuffer bb) {
|
||||
return bb.order(ByteOrder.LITTLE_ENDIAN).getLong();
|
||||
}
|
||||
|
||||
public static short getNetShort(ByteBuffer bb) {
|
||||
return bb.order(ByteOrder.BIG_ENDIAN).getShort();
|
||||
}
|
||||
|
||||
public static int getNetInt(ByteBuffer bb) {
|
||||
return bb.order(ByteOrder.BIG_ENDIAN).getInt();
|
||||
}
|
||||
|
||||
public static long getNetLong(ByteBuffer bb) {
|
||||
return bb.order(ByteOrder.BIG_ENDIAN).getLong();
|
||||
}
|
||||
|
||||
public static byte [] getArray(ByteBuffer bb) {
|
||||
byte [] data = new byte[getShort(bb)];
|
||||
bb.get(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte [] getArray(ByteBuffer bb, int length) {
|
||||
byte [] data = new byte[length];
|
||||
bb.get(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(0);
|
||||
this.data = data;
|
||||
opcode = getNetShort(data);
|
||||
data.position(0);
|
||||
}
|
||||
|
||||
public ByteBuffer getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/network/packets/soe/Acknowledge.java
Normal file
41
src/network/packets/soe/Acknowledge.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
public class Acknowledge extends Packet {
|
||||
|
||||
private short sequence;
|
||||
|
||||
public Acknowledge() {
|
||||
sequence = 0;
|
||||
}
|
||||
|
||||
public Acknowledge(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public Acknowledge(short sequence) {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (data.array().length < 4)
|
||||
return;
|
||||
data.position(2);
|
||||
sequence = getNetShort(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(4);
|
||||
addNetShort(data, 21);
|
||||
addNetShort(data, sequence);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setSequence(short sequence) { this.sequence = sequence; }
|
||||
|
||||
public short getSequence() { return sequence; }
|
||||
|
||||
}
|
||||
80
src/network/packets/soe/ClientNetworkStatusUpdate.java
Normal file
80
src/network/packets/soe/ClientNetworkStatusUpdate.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class ClientNetworkStatusUpdate extends Packet {
|
||||
|
||||
private int clientTickCount;
|
||||
private int lastUpdate;
|
||||
private int avgUpdate;
|
||||
private int shortUpdate;
|
||||
private int longUpdate;
|
||||
private int lastServerUpdate;
|
||||
private long packetSent;
|
||||
private long packetRecv;
|
||||
|
||||
public ClientNetworkStatusUpdate() {
|
||||
|
||||
}
|
||||
|
||||
public ClientNetworkStatusUpdate(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public ClientNetworkStatusUpdate(int clientTickCount, int lastUpdate, int avgUpdate, int shortUpdate, int longUpdate, int lastServerUpdate, long packetsSent, long packetsRecv) {
|
||||
this.clientTickCount = clientTickCount;
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.avgUpdate = avgUpdate;
|
||||
this.shortUpdate = shortUpdate;
|
||||
this.longUpdate = longUpdate;
|
||||
this.lastServerUpdate = lastServerUpdate;
|
||||
this.packetSent = packetsSent;
|
||||
this.packetRecv = packetsRecv;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(2);
|
||||
clientTickCount = getNetShort(data);
|
||||
lastUpdate = getNetInt(data);
|
||||
avgUpdate = getNetInt(data);
|
||||
shortUpdate = getNetInt(data);
|
||||
longUpdate = getNetInt(data);
|
||||
lastServerUpdate = getNetInt(data);
|
||||
packetSent = getNetLong(data);
|
||||
packetRecv = getNetLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(40);
|
||||
addNetShort(data, 7);
|
||||
addNetShort(data, clientTickCount);
|
||||
addNetInt( data, lastUpdate);
|
||||
addNetInt( data, avgUpdate);
|
||||
addNetInt( data, shortUpdate);
|
||||
addNetInt( data, longUpdate);
|
||||
addNetInt( data, lastServerUpdate);
|
||||
addNetLong( data, packetSent);
|
||||
addNetLong( data, packetRecv);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getTick() { return clientTickCount; }
|
||||
public int getLastUpdate() { return lastUpdate; }
|
||||
public int getAverageUpdate() { return avgUpdate; }
|
||||
public int getShortestUpdate() { return shortUpdate; }
|
||||
public int getLongestUpdate() { return longUpdate; }
|
||||
public int getLastServerUpdate() { return lastServerUpdate; }
|
||||
public long getSent() { return packetSent; }
|
||||
public long getRecv() { return packetRecv; }
|
||||
|
||||
public void setTick(int tick) { this.clientTickCount = tick; }
|
||||
public void setLastUpdate(int last) { this.lastUpdate = last; }
|
||||
public void setAverageUpdate(int avg) { this.avgUpdate = avg; }
|
||||
public void setShortestUpdate(int shortest) { this.shortUpdate = shortest; }
|
||||
public void setLongestUpdate(int longest) { this.longUpdate = longest; }
|
||||
public void setLastServerUpdate(int last) { this.lastServerUpdate = last; }
|
||||
public void setPacketsSent(long sent) { this.packetSent = sent; }
|
||||
public void setPacketsRecv(long recv) { this.packetRecv = recv; }
|
||||
}
|
||||
141
src/network/packets/soe/DataChannelA.java
Normal file
141
src/network/packets/soe/DataChannelA.java
Normal file
@@ -0,0 +1,141 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import network.packets.Packet;
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class DataChannelA extends Packet implements Comparable<DataChannelA> {
|
||||
|
||||
private List <SWGPacket> content = new ArrayList<SWGPacket>();
|
||||
private short sequence = 0;
|
||||
private short multiPacket = 0;
|
||||
|
||||
public DataChannelA() {
|
||||
|
||||
}
|
||||
|
||||
public DataChannelA(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public DataChannelA(SWGPacket packet) {
|
||||
content.add(packet);
|
||||
}
|
||||
|
||||
public DataChannelA(List <SWGPacket> packets) {
|
||||
content = packets;
|
||||
}
|
||||
|
||||
public DataChannelA(SWGPacket [] packets) {
|
||||
for (SWGPacket p : packets) {
|
||||
content.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
super.decode(data);
|
||||
if (getOpcode() != 9)
|
||||
return;
|
||||
data.position(2);
|
||||
sequence = getNetShort(data);
|
||||
multiPacket = getNetShort(data);
|
||||
if (multiPacket == 0x19) {
|
||||
int length = 0;
|
||||
while (data.remaining() > 1) {
|
||||
length = getByte(data) & 0xFF;
|
||||
if (length == 0xFF)
|
||||
length = getNetShort(data);
|
||||
if (length > data.remaining()) {
|
||||
data.position(data.position()-1);
|
||||
return;
|
||||
}
|
||||
byte [] pData = new byte[length];
|
||||
data.get(pData);
|
||||
SWGPacket packet = new SWGPacket();
|
||||
packet.decode(ByteBuffer.wrap(pData));
|
||||
content.add(packet);
|
||||
}
|
||||
} else {
|
||||
data.position(data.position()-2);
|
||||
byte [] pData = new byte[data.remaining()];
|
||||
data.get(pData);
|
||||
SWGPacket packet = new SWGPacket();
|
||||
packet.decode(ByteBuffer.wrap(pData));
|
||||
content.add(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
return encode(this.sequence);
|
||||
}
|
||||
|
||||
public ByteBuffer encode(int sequence) {
|
||||
this.sequence = (short) sequence;
|
||||
if (content.size() == 1) {
|
||||
byte [] pData = content.get(0).encode().array();
|
||||
ByteBuffer data = ByteBuffer.allocate(4 + pData.length);
|
||||
addNetShort(data, 9);
|
||||
addNetShort(data, sequence);
|
||||
data.put(pData);
|
||||
return data;
|
||||
} else if (content.size() > 1) {
|
||||
int length = getLength();
|
||||
ByteBuffer data= ByteBuffer.allocate(length);
|
||||
addNetShort(data, 9);
|
||||
addNetShort(data, sequence);
|
||||
addNetShort(data, 0x19);
|
||||
for (SWGPacket packet : content) {
|
||||
byte [] pData = packet.encode().array();
|
||||
if (pData.length >= 0xFF) {
|
||||
addByte(data, 0xFF);
|
||||
addNetShort(data, pData.length);
|
||||
} else {
|
||||
data.put((byte) pData.length);
|
||||
}
|
||||
data.put(pData);
|
||||
}
|
||||
return data;
|
||||
} else {
|
||||
return ByteBuffer.allocate(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPacket(SWGPacket packet) {
|
||||
content.add(packet);
|
||||
}
|
||||
|
||||
public void clearPackets() {
|
||||
content.clear();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
if (content.size() == 1) {
|
||||
return 4 + content.get(0).encode().array().length;
|
||||
} else {
|
||||
int length = 6;
|
||||
for (SWGPacket packet : content) {
|
||||
int addLength = packet.encode().array().length;
|
||||
length += 1 + addLength + ((addLength >= 0xFF) ? 2 : 0);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(DataChannelA d) {
|
||||
if (sequence < d.sequence)
|
||||
return -1;
|
||||
if (sequence == d.sequence)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void setSequence(short sequence) { this.sequence = sequence; }
|
||||
|
||||
public short getSequence() { return sequence; }
|
||||
public List <SWGPacket> getPackets() { return content; }
|
||||
}
|
||||
78
src/network/packets/soe/Disconnect.java
Normal file
78
src/network/packets/soe/Disconnect.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class Disconnect extends Packet {
|
||||
|
||||
private int connectionId;
|
||||
private DisconnectReason reason;
|
||||
|
||||
public Disconnect() {
|
||||
connectionId = 0;
|
||||
reason = DisconnectReason.NONE;
|
||||
}
|
||||
|
||||
public Disconnect(int connectionId, DisconnectReason reason) {
|
||||
this.connectionId = connectionId;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public Disconnect(ByteBuffer data){
|
||||
this.decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(2);
|
||||
connectionId = getNetInt(data);
|
||||
reason = getReason(getNetShort(data));
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(8);
|
||||
addNetShort(data, 5);
|
||||
addNetInt(data, connectionId);
|
||||
addNetShort(data, reason.getReason());
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getConnectionID() { return connectionId; }
|
||||
public DisconnectReason getReason() { return reason; }
|
||||
|
||||
private DisconnectReason getReason(int reason) {
|
||||
for (DisconnectReason dr : DisconnectReason.values())
|
||||
if (dr.getReason() == reason)
|
||||
return dr;
|
||||
return DisconnectReason.NONE;
|
||||
}
|
||||
|
||||
public enum DisconnectReason {
|
||||
NONE (0x00),
|
||||
ICMP_ERROR (0x01),
|
||||
TIMEOUT (0x02),
|
||||
OTHER_SIDE_TERMINATED (0x03),
|
||||
MANAGER_DELETED (0x04),
|
||||
CONNECT_FAIL (0x05),
|
||||
APPLICATION (0x06),
|
||||
UNREACHABLE_CONNECTION (0x07),
|
||||
UNACKNOWLEDGED_TIMEOUT (0x08),
|
||||
NEW_CONNECTION_ATTEMPT (0x09),
|
||||
CONNECTION_REFUSED (0x0A),
|
||||
MUTUAL_CONNETION_ERROR (0x0B),
|
||||
CONNETING_TO_SELF (0x0C),
|
||||
RELIABLE_OVERFLOW (0x0D),
|
||||
COUNT (0x0E);
|
||||
|
||||
private short reason;
|
||||
|
||||
DisconnectReason(int reason) {
|
||||
this.reason = (short) reason;
|
||||
}
|
||||
|
||||
public short getReason() {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
114
src/network/packets/soe/Fragmented.java
Normal file
114
src/network/packets/soe/Fragmented.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class Fragmented extends Packet implements Comparable<Fragmented> {
|
||||
|
||||
private short sequence;
|
||||
private int length;
|
||||
private ByteBuffer packet;
|
||||
private ByteBuffer data;
|
||||
|
||||
public Fragmented() {
|
||||
this.sequence = 0;
|
||||
this.length = 0;
|
||||
this.packet = null;
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
public Fragmented(ByteBuffer data) {
|
||||
decode(data);
|
||||
length = -1;
|
||||
}
|
||||
|
||||
public Fragmented(ByteBuffer data, int sequence) {
|
||||
this.sequence = (short) sequence;
|
||||
decode(data);
|
||||
length = -1;
|
||||
}
|
||||
|
||||
public void setPacket(ByteBuffer packet) {
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(2);
|
||||
sequence = getNetShort(data);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Fragmented [] encode(int startSequence) {
|
||||
packet.position(0);
|
||||
int ord = 0;
|
||||
Fragmented [] packets = new Fragmented[(int) Math.ceil((packet.remaining()+4)/489.0)];
|
||||
while (packet.remaining() > 0) {
|
||||
packets[ord] = createSegment(startSequence++, ord++, packet);
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Fragmented f) {
|
||||
if (sequence < f.sequence)
|
||||
return -1;
|
||||
if (sequence == f.sequence)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Fragmented)
|
||||
return ((Fragmented) o).sequence == sequence;
|
||||
if (o instanceof Number)
|
||||
return ((Number) o).shortValue() == sequence;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public ByteBuffer getPacketData() { return data; }
|
||||
public short getSequence() { return sequence; }
|
||||
public int getDatLength() { return length; }
|
||||
|
||||
public static final Fragmented [] encode(ByteBuffer data, int startSequence) {
|
||||
data.position(0);
|
||||
int ord = 0;
|
||||
Fragmented [] packets = new Fragmented[(int) Math.ceil((data.remaining()+4)/489.0)];
|
||||
while (data.remaining() > 0) {
|
||||
packets[ord] = createSegment(startSequence++, ord++, data);
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
private static final Fragmented createSegment(int startSequence, int ord, ByteBuffer packet) {
|
||||
int header = (ord == 0) ? 8 : 4;
|
||||
ByteBuffer data = ByteBuffer.allocate(Math.min(packet.remaining()+header, 493));
|
||||
|
||||
addNetShort(data, 0x0D);
|
||||
addNetShort(data, startSequence);
|
||||
if (ord == 0)
|
||||
addNetInt(data, packet.remaining());
|
||||
|
||||
int len = data.remaining();
|
||||
data.put(packet.array(), packet.position(), len);
|
||||
packet.position(packet.position() + len);
|
||||
|
||||
byte [] pData = new byte[data.array().length-header];
|
||||
System.arraycopy(data.array(), header, pData, 0, pData.length);
|
||||
Fragmented f = new Fragmented(data, startSequence);
|
||||
f.packet = ByteBuffer.wrap(pData);
|
||||
return f;
|
||||
}
|
||||
|
||||
}
|
||||
113
src/network/packets/soe/MultiPacket.java
Normal file
113
src/network/packets/soe/MultiPacket.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
public class MultiPacket extends Packet {
|
||||
|
||||
private List <Packet> content = new ArrayList<Packet>();
|
||||
|
||||
public MultiPacket() {
|
||||
this(new ArrayList<Packet>());
|
||||
}
|
||||
|
||||
public MultiPacket(ByteBuffer data) {
|
||||
this(new ArrayList<Packet>());
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public MultiPacket(List <Packet> packets) {
|
||||
this.content = packets;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(2);
|
||||
int length = data.array().length;
|
||||
int pLength = 0;
|
||||
for (int i = 2; i < length; i += pLength) {
|
||||
if (data.remaining() < 1)
|
||||
return;
|
||||
pLength = getByte(data) & 0xFF;
|
||||
if (pLength == 255) {
|
||||
if (data.remaining() < 2)
|
||||
return;
|
||||
pLength = data.order(ByteOrder.LITTLE_ENDIAN).getShort();
|
||||
}
|
||||
if (pLength > data.remaining()) {
|
||||
data.position(data.position()-1);
|
||||
return;
|
||||
}
|
||||
byte [] pData = new byte[pLength];
|
||||
data.get(pData);
|
||||
Packet p = new Packet();
|
||||
p.decode(ByteBuffer.wrap(pData));
|
||||
content.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 2;
|
||||
for (Packet packet : content) {
|
||||
int pLength = packet.encode().array().length;
|
||||
if (pLength >= 255) {
|
||||
length += 3;
|
||||
} else {
|
||||
length += 1;
|
||||
}
|
||||
length += pLength;
|
||||
}
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
data.order(ByteOrder.BIG_ENDIAN).putShort((short)3);
|
||||
for (Packet packet : content) {
|
||||
byte [] pData = packet.encode().array();
|
||||
if (pData.length >= 255) {
|
||||
data.put((byte)255);
|
||||
addShort(data, (short)pData.length);
|
||||
} else {
|
||||
data.put((byte)pData.length);
|
||||
}
|
||||
data.put(pData);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
int length = 2;
|
||||
for (Packet packet : content) {
|
||||
int pLength = getPacketLength(packet);
|
||||
if (pLength >= 255) {
|
||||
length += 3;
|
||||
} else {
|
||||
length += 1;
|
||||
}
|
||||
length += pLength;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
private int getPacketLength(Packet packet) {
|
||||
if (packet instanceof DataChannelA)
|
||||
return ((DataChannelA) packet).getLength();
|
||||
else if (packet instanceof Acknowledge || packet instanceof OutOfOrder)
|
||||
return 4;
|
||||
else if (packet instanceof Disconnect)
|
||||
return 8;
|
||||
return packet.encode().array().length;
|
||||
}
|
||||
|
||||
public void addPacket(Packet packet) {
|
||||
content.add(packet);
|
||||
}
|
||||
|
||||
public void clearPackets() {
|
||||
content.clear();
|
||||
}
|
||||
|
||||
public List <Packet> getPackets() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
37
src/network/packets/soe/OutOfOrder.java
Normal file
37
src/network/packets/soe/OutOfOrder.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class OutOfOrder extends Packet {
|
||||
|
||||
private short sequence;
|
||||
|
||||
public OutOfOrder() {
|
||||
|
||||
}
|
||||
|
||||
public OutOfOrder(short sequence) {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public OutOfOrder(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(2);
|
||||
sequence = getNetShort(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(4);
|
||||
addNetShort(data, 0x11);
|
||||
addNetShort(data, sequence);
|
||||
return data;
|
||||
}
|
||||
|
||||
public short getSequence() { return sequence; }
|
||||
}
|
||||
69
src/network/packets/soe/ServerNetworkStatusUpdate.java
Normal file
69
src/network/packets/soe/ServerNetworkStatusUpdate.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class ServerNetworkStatusUpdate extends Packet {
|
||||
|
||||
private short clientTickCount = 0;
|
||||
private int serverSyncStampLong = 0;
|
||||
private long clientPacketsSent = 0;
|
||||
private long clientPacketsRecv = 0;
|
||||
private long serverPacketsSent = 0;
|
||||
private long serverPacketsRecv = 0;
|
||||
|
||||
public ServerNetworkStatusUpdate() {
|
||||
|
||||
}
|
||||
|
||||
public ServerNetworkStatusUpdate(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public ServerNetworkStatusUpdate(int clientTickCount, long clientSent, long clientRecv, long serverSent, long serverRecv) {
|
||||
this.clientTickCount = (short) clientTickCount;
|
||||
this.serverSyncStampLong = 0;
|
||||
this.clientPacketsSent = clientSent;
|
||||
this.clientPacketsRecv = clientRecv;
|
||||
this.serverPacketsSent = serverSent;
|
||||
this.serverPacketsRecv = serverRecv;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
data.position(2);
|
||||
clientTickCount = getNetShort(data);
|
||||
serverSyncStampLong = getNetInt(data);
|
||||
clientPacketsSent = getNetLong(data);
|
||||
clientPacketsRecv = getNetLong(data);
|
||||
serverPacketsSent = getNetLong(data);
|
||||
serverPacketsRecv = getNetLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(40);
|
||||
addNetShort(data, 8);
|
||||
addNetShort(data, clientTickCount);
|
||||
addNetInt( data, serverSyncStampLong);
|
||||
addNetLong( data, clientPacketsSent);
|
||||
addNetLong( data, clientPacketsRecv);
|
||||
addNetLong( data, serverPacketsSent);
|
||||
addNetLong( data, serverPacketsRecv);
|
||||
return data;
|
||||
}
|
||||
|
||||
public short getClientTickCount() { return clientTickCount; }
|
||||
public int getServerSyncStampLong() { return serverSyncStampLong; }
|
||||
public long getClientPacketsSent() { return clientPacketsSent; }
|
||||
public long getClientPacketsRecv() { return clientPacketsRecv; }
|
||||
public long getServerPacketsSent() { return serverPacketsSent; }
|
||||
public long getServerPacketsRecv() { return serverPacketsRecv; }
|
||||
|
||||
public void setClientTickCount(short tick) { this.clientTickCount = tick; }
|
||||
public void setServerSyncStampLong(int sync) { this.serverSyncStampLong = sync; }
|
||||
public void setClientPacketsSent(int sent) { this.clientPacketsSent = sent; }
|
||||
public void setClientPacketsRecv(int recv) { this.clientPacketsRecv = recv; }
|
||||
public void setServerPacketsSent(int sent) { this.serverPacketsSent = sent; }
|
||||
public void setServerPacketsRecv(int recv) { this.serverPacketsRecv = recv; }
|
||||
}
|
||||
49
src/network/packets/soe/SessionRequest.java
Normal file
49
src/network/packets/soe/SessionRequest.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class SessionRequest extends Packet {
|
||||
|
||||
private int crcLength;
|
||||
private int connectionID;
|
||||
private int udpSize;
|
||||
|
||||
public SessionRequest() {
|
||||
|
||||
}
|
||||
|
||||
public SessionRequest(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public SessionRequest(int crcLength, int connectionID, int udpSize) {
|
||||
this.crcLength = crcLength;
|
||||
this.connectionID = connectionID;
|
||||
this.udpSize = udpSize;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer packet) {
|
||||
super.decode(packet);
|
||||
packet.position(2);
|
||||
crcLength = getNetInt(packet);
|
||||
connectionID = getNetInt(packet);
|
||||
udpSize = getNetInt(packet);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer bb = ByteBuffer.allocate(14).order(ByteOrder.BIG_ENDIAN);
|
||||
addNetShort(bb, 1);
|
||||
addNetInt(bb, crcLength);
|
||||
addNetInt(bb, connectionID);
|
||||
addNetInt(bb, udpSize);
|
||||
return bb;
|
||||
}
|
||||
|
||||
public int getCrcLength() { return crcLength; }
|
||||
public int getConnectionID() { return connectionID; }
|
||||
public int getUdpSize() { return udpSize; }
|
||||
}
|
||||
76
src/network/packets/soe/SessionResponse.java
Normal file
76
src/network/packets/soe/SessionResponse.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package network.packets.soe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class SessionResponse extends Packet {
|
||||
|
||||
private int connectionID;
|
||||
private int crcSeed;
|
||||
private byte crcLength;
|
||||
private byte encryptionFlag;
|
||||
private byte xorLength;
|
||||
private int udpSize;
|
||||
|
||||
public SessionResponse() {
|
||||
|
||||
}
|
||||
|
||||
public SessionResponse(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public SessionResponse(int connectionID,
|
||||
int crcSeed,
|
||||
byte crcLength,
|
||||
byte encryptionFlag,
|
||||
byte xorLength,
|
||||
int udpSize) {
|
||||
this.connectionID = connectionID;
|
||||
this.crcSeed = crcSeed;
|
||||
this.crcLength = crcLength;
|
||||
this.encryptionFlag = encryptionFlag;
|
||||
this.xorLength = xorLength;
|
||||
this.udpSize = udpSize;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
super.decode(data);
|
||||
data.position(2);
|
||||
connectionID = getNetInt(data);
|
||||
crcSeed = getNetInt(data);
|
||||
crcLength = data.get();
|
||||
encryptionFlag = data.get();
|
||||
xorLength = data.get();
|
||||
udpSize = getNetInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer bb = ByteBuffer.allocate(17).order(ByteOrder.BIG_ENDIAN);
|
||||
addNetShort(bb, 2);
|
||||
addNetInt( bb, connectionID);
|
||||
addNetInt( bb, crcSeed);
|
||||
addByte( bb, crcLength);
|
||||
addByte( bb, encryptionFlag);
|
||||
addByte( bb, xorLength);
|
||||
addNetInt( bb, udpSize);
|
||||
return bb;
|
||||
}
|
||||
|
||||
public int getConnectionID() { return connectionID; }
|
||||
public int getCrcSeed() { return crcSeed; }
|
||||
public byte getCrcLength() { return crcLength; }
|
||||
public short getEncryptionFlag() { return encryptionFlag; }
|
||||
public byte getXorLength() { return xorLength; }
|
||||
public int getUdpSize() { return udpSize; }
|
||||
|
||||
public void setConnectionID(int id) { this.connectionID = id; }
|
||||
public void setCrcSeed(int crc) { this.crcSeed = crc; }
|
||||
public void setCrcLength(int length) { this.crcLength = (byte) length; }
|
||||
public void setEncryptionFlag(short flag) { this.encryptionFlag = (byte) flag; }
|
||||
public void setXorLength(byte xorLength) { this.xorLength = xorLength; }
|
||||
public void setUdpSize(int size) { this.udpSize = size; }
|
||||
}
|
||||
40
src/network/packets/swg/ErrorMessage.java
Normal file
40
src/network/packets/swg/ErrorMessage.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package network.packets.swg;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class ErrorMessage extends SWGPacket {
|
||||
public static final int CRC = 0xB5ABF91A;
|
||||
private String type;
|
||||
private String message;
|
||||
private boolean fatal;
|
||||
|
||||
public ErrorMessage() {
|
||||
|
||||
}
|
||||
|
||||
public ErrorMessage(String type, String message, boolean fatal) {
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
this.fatal = fatal;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
type = getAscii(data);
|
||||
message = getAscii(data);
|
||||
fatal = getBoolean(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 11 + type.length() + message.length();
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 3);
|
||||
addInt( data, CRC);
|
||||
addAscii(data, type);
|
||||
addAscii(data, message);
|
||||
addBoolean(data, fatal);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
77
src/network/packets/swg/SWGPacket.java
Normal file
77
src/network/packets/swg/SWGPacket.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package network.packets.swg;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import resources.Location;
|
||||
import network.PacketType;
|
||||
import network.packets.Packet;
|
||||
|
||||
|
||||
public class SWGPacket extends Packet {
|
||||
|
||||
private ByteBuffer data = null;
|
||||
private int opcode = 0;
|
||||
private PacketType type = PacketType.UNKNOWN;
|
||||
|
||||
protected void addLocation(ByteBuffer data, Location l) {
|
||||
addFloat(data, (float) (Double.isNaN(l.getOrientationX()) ? 0 : l.getOrientationX()));
|
||||
addFloat(data, (float) (Double.isNaN(l.getOrientationY()) ? 0 : l.getOrientationY()));
|
||||
addFloat(data, (float) (Double.isNaN(l.getOrientationZ()) ? 0 : l.getOrientationZ()));
|
||||
addFloat(data, (float) (Double.isNaN(l.getOrientationW()) ? 1 : l.getOrientationW()));
|
||||
addFloat(data, (float) (Double.isNaN(l.getX()) ? 0 : l.getX()));
|
||||
addFloat(data, (float) (Double.isNaN(l.getY()) ? 0 : l.getY()));
|
||||
addFloat(data, (float) (Double.isNaN(l.getZ()) ? 0 : l.getZ()));
|
||||
}
|
||||
|
||||
protected Location getLocation(ByteBuffer data) {
|
||||
Location l = new Location();
|
||||
l.setOrientationX(getFloat(data));
|
||||
l.setOrientationY(getFloat(data));
|
||||
l.setOrientationZ(getFloat(data));
|
||||
l.setOrientationW(getFloat(data));
|
||||
l.setX(getFloat(data));
|
||||
l.setY(getFloat(data));
|
||||
l.setZ(getFloat(data));
|
||||
return l;
|
||||
}
|
||||
|
||||
public void setSWGOpcode(int opcode) {
|
||||
this.opcode = opcode;
|
||||
this.type = PacketType.fromCrc(opcode);
|
||||
}
|
||||
|
||||
public int getSWGOpcode() {
|
||||
return opcode;
|
||||
}
|
||||
|
||||
public PacketType getPacketType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean decode(ByteBuffer data, int crc) {
|
||||
this.data = data;
|
||||
super.decode(data);
|
||||
data.position(2);
|
||||
setSWGOpcode(getInt(data));
|
||||
if (getSWGOpcode() != crc)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
this.data = data;
|
||||
if (data.array().length < 6)
|
||||
return;
|
||||
data.position(2);
|
||||
setSWGOpcode(getInt(data));
|
||||
data.position(0);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ByteBuffer getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
36
src/network/packets/swg/ServerUnixEpochTime.java
Normal file
36
src/network/packets/swg/ServerUnixEpochTime.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package network.packets.swg;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class ServerUnixEpochTime extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x24B73893;
|
||||
private int time = 0;
|
||||
|
||||
public ServerUnixEpochTime() {
|
||||
|
||||
}
|
||||
|
||||
public ServerUnixEpochTime(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
time = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, time);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
33
src/network/packets/swg/login/AccountFeatureBits.java
Normal file
33
src/network/packets/swg/login/AccountFeatureBits.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class AccountFeatureBits extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x979F0279;
|
||||
|
||||
public AccountFeatureBits() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
// Not sure how to decode this.. still a mystery
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(22);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, 0x025C8231);
|
||||
addInt( data, 1);
|
||||
addInt( data, 6);
|
||||
addInt( data, 0x4EEAC08A);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
50
src/network/packets/swg/login/CharacterCreationDisabled.java
Normal file
50
src/network/packets/swg/login/CharacterCreationDisabled.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class CharacterCreationDisabled extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xF4A15265;
|
||||
|
||||
private String [] serverNames = new String[0];
|
||||
|
||||
public CharacterCreationDisabled() {
|
||||
this(new String[0]);
|
||||
}
|
||||
|
||||
public CharacterCreationDisabled(String [] serverNames) {
|
||||
this.serverNames = serverNames;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
int listSize = getInt(data);
|
||||
serverNames = new String[listSize];
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
serverNames[i] = getAscii(data);
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 10;
|
||||
for (int i = 0; i < serverNames.length; i++)
|
||||
length += 2 + serverNames[i].length();
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, serverNames.length);
|
||||
for (int i = 0; i < serverNames.length; i++) {
|
||||
addAscii(data, serverNames[i]);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public String [] getServerNames() {
|
||||
return serverNames;
|
||||
}
|
||||
|
||||
}
|
||||
53
src/network/packets/swg/login/ClientIdMsg.java
Normal file
53
src/network/packets/swg/login/ClientIdMsg.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ClientIdMsg extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xD5899226;
|
||||
private int gameBitsToClear;
|
||||
private byte [] sessionToken;
|
||||
private String version;
|
||||
|
||||
public ClientIdMsg() {
|
||||
this(0, new byte[0], "");
|
||||
}
|
||||
|
||||
public ClientIdMsg(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public ClientIdMsg(int gameBitsToClear, byte [] sessionKey, String version) {
|
||||
this.gameBitsToClear = gameBitsToClear;
|
||||
this.sessionToken = sessionKey;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
gameBitsToClear = getInt(data);
|
||||
int sessionKeyLength = getInt(data);
|
||||
sessionToken = new byte[sessionKeyLength];
|
||||
data.get(sessionToken);
|
||||
version = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(16 + sessionToken.length + version.length());
|
||||
addShort(data, 4);
|
||||
addInt( data, CRC);
|
||||
addInt( data, gameBitsToClear);
|
||||
addInt( data, sessionToken.length);
|
||||
data.put(sessionToken);
|
||||
addAscii(data, version);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getGameBitsToClear() { return gameBitsToClear; }
|
||||
public byte [] getSessionToken() { return sessionToken; }
|
||||
public String getVersion() { return version; }
|
||||
}
|
||||
53
src/network/packets/swg/login/ClientPermissionsMessage.java
Normal file
53
src/network/packets/swg/login/ClientPermissionsMessage.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ClientPermissionsMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xE00730E5;
|
||||
|
||||
private boolean canLogin;
|
||||
private boolean canCreateRegularCharacter;
|
||||
private boolean canCreateJediCharacter;
|
||||
private boolean canSkipTutorial;
|
||||
|
||||
public ClientPermissionsMessage() {
|
||||
canLogin = true;
|
||||
canCreateRegularCharacter = true;
|
||||
canCreateJediCharacter = true;
|
||||
canSkipTutorial = true;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
canLogin = getBoolean(data);
|
||||
canCreateRegularCharacter = getBoolean(data);
|
||||
canCreateJediCharacter = getBoolean(data);
|
||||
canSkipTutorial = getBoolean(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort( data, 5);
|
||||
addInt( data, CRC);
|
||||
addBoolean(data, canLogin);
|
||||
addBoolean(data, canCreateRegularCharacter);
|
||||
addBoolean(data, canCreateJediCharacter);
|
||||
addBoolean(data, canSkipTutorial);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setCanLogin(boolean can) { this.canLogin = can; }
|
||||
public void setCanCreateRegularCharacter(boolean can) { this.canCreateRegularCharacter = can; }
|
||||
public void setCanCreateJediCharacter(boolean can) { this.canCreateJediCharacter = can; }
|
||||
public void setCanSkipTutorial(boolean can) { this.canSkipTutorial = can; }
|
||||
|
||||
public boolean canLogin() { return canLogin; }
|
||||
public boolean canCreateRegularCharacter() { return canCreateRegularCharacter; }
|
||||
public boolean canCreateJediCharacter() { return canCreateJediCharacter; }
|
||||
public boolean canSkipTutorial() { return canSkipTutorial; }
|
||||
}
|
||||
109
src/network/packets/swg/login/EnumerateCharacterId.java
Normal file
109
src/network/packets/swg/login/EnumerateCharacterId.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Vector;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class EnumerateCharacterId extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x65EA4574;
|
||||
|
||||
private SWGCharacter [] characters;
|
||||
|
||||
public EnumerateCharacterId() {
|
||||
characters = new SWGCharacter[0];
|
||||
}
|
||||
|
||||
public EnumerateCharacterId(SWGCharacter [] characters) {
|
||||
this.characters = characters;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
int characterLength = getInt(data);
|
||||
Vector <SWGCharacter> _characters = new Vector<SWGCharacter>();
|
||||
for (int i = 0; i < characterLength; i++) {
|
||||
SWGCharacter c = new SWGCharacter();
|
||||
c.decode(data);
|
||||
_characters.add(c);
|
||||
}
|
||||
characters = _characters.toArray(new SWGCharacter[0]);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 10;
|
||||
for (int i = 0; i < characters.length; i++) {
|
||||
length += characters[i].getLength();
|
||||
}
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, characters.length);
|
||||
for (SWGCharacter c : characters) {
|
||||
data.put(c.encode().array());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public SWGCharacter [] getCharacters () {
|
||||
return characters;
|
||||
}
|
||||
|
||||
public static class SWGCharacter extends EnumerateCharacterId {
|
||||
private String name;
|
||||
private int raceCrc;
|
||||
private long id;
|
||||
private int galaxyId;
|
||||
private int type;
|
||||
|
||||
public SWGCharacter() {
|
||||
|
||||
}
|
||||
|
||||
public SWGCharacter(String name, int raceCrc, long id, int galaxyId, int status) {
|
||||
this.name = name;
|
||||
this.raceCrc = raceCrc;
|
||||
this.id = id;
|
||||
this.galaxyId = galaxyId;
|
||||
this.type = status;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return 24 + name.length() * 2;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
name = getUnicode(data);
|
||||
raceCrc = getInt(data);
|
||||
id = getLong(data);
|
||||
galaxyId = getInt(data);
|
||||
type = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(getLength());
|
||||
addUnicode(data, name);
|
||||
addInt( data, raceCrc);
|
||||
addLong( data, id);
|
||||
addInt( data, galaxyId);
|
||||
addInt( data, type);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setId(long id) { this.id = id; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public void setRaceCrc(int crc) { this.raceCrc = crc; }
|
||||
public void setGalaxyId(int id) { this.galaxyId = id; }
|
||||
public void setType(int type) { this.type = type; }
|
||||
|
||||
public long getId() { return id; }
|
||||
public String getName() { return name; }
|
||||
public int getRaceCrc() { return raceCrc; }
|
||||
public int getGalaxyId() { return galaxyId; }
|
||||
public int getType() { return type; }
|
||||
|
||||
}
|
||||
}
|
||||
54
src/network/packets/swg/login/LoginClientId.java
Normal file
54
src/network/packets/swg/login/LoginClientId.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class LoginClientId extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x41131F96;
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
private String version;
|
||||
|
||||
public LoginClientId() {
|
||||
this("", "", "");
|
||||
}
|
||||
|
||||
public LoginClientId(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public LoginClientId(String username, String password, String version) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
username = getAscii(data);
|
||||
password = getAscii(data);
|
||||
version = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 6 + 6 + username.length() * 2 + password.length() * 2 + version.length() * 2;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 4);
|
||||
addInt( data, CRC);
|
||||
addAscii(data, username);
|
||||
addAscii(data, password);
|
||||
addAscii(data, version);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getUsername() { return username; }
|
||||
public void setUsername(String str) { this.username = str; }
|
||||
public String getPassword() { return password; }
|
||||
public void setPassword(String str) { this.password = str; }
|
||||
public String getVersion() { return version; }
|
||||
}
|
||||
65
src/network/packets/swg/login/LoginClientToken.java
Normal file
65
src/network/packets/swg/login/LoginClientToken.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class LoginClientToken extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xAAB296C6;
|
||||
private byte [] sessionKey;
|
||||
private int userId;
|
||||
private String username;
|
||||
|
||||
public LoginClientToken() {
|
||||
|
||||
}
|
||||
|
||||
public LoginClientToken(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public LoginClientToken(byte [] sessionKey, int userId, String username) {
|
||||
this.sessionKey = sessionKey;
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
int sessionKeyLength = getInt(data);
|
||||
if (sessionKeyLength > data.remaining())
|
||||
return;
|
||||
sessionKey = new byte[sessionKeyLength];
|
||||
data.get(sessionKey);
|
||||
userId = getInt(data);
|
||||
username = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 16 + sessionKey.length + username.length();
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 4);
|
||||
addInt( data, CRC);
|
||||
addInt( data, sessionKey.length);
|
||||
data.put(sessionKey);
|
||||
addInt( data, userId);
|
||||
addAscii(data, username);
|
||||
return data;
|
||||
}
|
||||
|
||||
public byte [] getSessionKey() {
|
||||
return sessionKey;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
}
|
||||
92
src/network/packets/swg/login/LoginClusterStatus.java
Normal file
92
src/network/packets/swg/login/LoginClusterStatus.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
import resources.Galaxy;
|
||||
|
||||
|
||||
public class LoginClusterStatus extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x3436AEB6;
|
||||
|
||||
private Vector <Galaxy> galaxies;
|
||||
|
||||
public LoginClusterStatus() {
|
||||
galaxies = new Vector<Galaxy>();
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
int serverCount = getInt(data);
|
||||
for (int i = 0; i < serverCount; i++) {
|
||||
Galaxy g = new Galaxy();
|
||||
g.setId(getInt(data));
|
||||
g.setAddress(getAscii(data));
|
||||
g.setZonePort(getShort(data));
|
||||
g.setPingPort(getShort(data));
|
||||
g.setPopulation(getInt(data));
|
||||
g.setPopulationStatus(getInt(data));
|
||||
g.setMaxCharacters(getInt(data));
|
||||
g.setTimeZone(getInt(data));
|
||||
g.setStatus(getInt(data));
|
||||
g.setRecommended(getBoolean(data));
|
||||
g.setOnlinePlayerLimit(getInt(data));
|
||||
g.setOnlineFreeTrialLimit(getInt(data));
|
||||
galaxies.add(g);
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 10;
|
||||
for (Galaxy g : galaxies)
|
||||
length += 35 + g.getAddress().length() + 8;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, galaxies.size());
|
||||
for (Galaxy g : galaxies) {
|
||||
addInt( data, g.getId());
|
||||
addAscii( data, g.getAddress());
|
||||
addShort( data, g.getZonePort());
|
||||
addShort( data, g.getPingPort());
|
||||
addInt( data, g.getPopulation());
|
||||
addInt( data, getPopulationStatus(g.getPopulation()));
|
||||
addInt( data, g.getMaxCharacters());
|
||||
addInt( data, g.getTimeZone());
|
||||
addInt( data, g.getStatus().getStatus());
|
||||
addBoolean(data, g.isRecommended());
|
||||
addInt( data, g.getOnlinePlayerLimit());
|
||||
addInt( data, g.getOnlineFreeTrialLimit());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public void addGalaxy(Galaxy g) {
|
||||
galaxies.add(g);
|
||||
}
|
||||
|
||||
public List <Galaxy> getGalaxies() {
|
||||
return galaxies;
|
||||
}
|
||||
|
||||
private int getPopulationStatus(int pop) {
|
||||
if (pop < 300)
|
||||
return 0; // Very Light
|
||||
if (pop < 600)
|
||||
return 1; // Light
|
||||
if (pop < 900)
|
||||
return 2; // Medium
|
||||
if (pop < 1200)
|
||||
return 3; // Heavy
|
||||
if (pop < 1500)
|
||||
return 4; // Very Heavy
|
||||
if (pop < 3000)
|
||||
return 5; // Extremely Heavy
|
||||
return 6; // Full
|
||||
}
|
||||
|
||||
}
|
||||
73
src/network/packets/swg/login/LoginEnumCluster.java
Normal file
73
src/network/packets/swg/login/LoginEnumCluster.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
import resources.Galaxy;
|
||||
|
||||
|
||||
public class LoginEnumCluster extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xC11C63B9;
|
||||
|
||||
private Vector <Galaxy> galaxies;
|
||||
private int maxCharacters;
|
||||
|
||||
public LoginEnumCluster() {
|
||||
galaxies = new Vector<Galaxy>();
|
||||
}
|
||||
|
||||
public LoginEnumCluster(int maxCharacters) {
|
||||
galaxies = new Vector<Galaxy>();
|
||||
this.maxCharacters = maxCharacters;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
int serverCount = getInt(data);
|
||||
for (int i = 0; i < serverCount; i++) {
|
||||
Galaxy g = new Galaxy();
|
||||
g.setId(getInt(data));
|
||||
g.setName(getAscii(data));
|
||||
g.setTimeZone(getInt(data));
|
||||
galaxies.add(g);
|
||||
}
|
||||
maxCharacters = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 14;
|
||||
for (Galaxy g : galaxies)
|
||||
length += 10 + g.getName().length();
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 3);
|
||||
addInt( data, CRC);
|
||||
addInt( data, galaxies.size());
|
||||
for (Galaxy g : galaxies) {
|
||||
addInt( data, g.getId());
|
||||
addAscii(data, g.getName());
|
||||
addInt( data, g.getTimeZone());
|
||||
}
|
||||
addInt(data, maxCharacters);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void addGalaxy(Galaxy g) {
|
||||
galaxies.add(g);
|
||||
}
|
||||
|
||||
public void setMaxCharacters(int max) {
|
||||
this.maxCharacters = max;
|
||||
}
|
||||
|
||||
public int getMaxCharacters() {
|
||||
return maxCharacters;
|
||||
}
|
||||
|
||||
public List <Galaxy> getGalaxies() {
|
||||
return galaxies;
|
||||
}
|
||||
}
|
||||
43
src/network/packets/swg/login/LoginIncorrectClientId.java
Normal file
43
src/network/packets/swg/login/LoginIncorrectClientId.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class LoginIncorrectClientId extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x20E7E510;
|
||||
|
||||
private String serverId;
|
||||
private String serverAppVersion;
|
||||
|
||||
public LoginIncorrectClientId() {
|
||||
this("", "");
|
||||
}
|
||||
|
||||
public LoginIncorrectClientId(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public LoginIncorrectClientId(String serverId, String serverAppVersion) {
|
||||
this.serverId = serverId;
|
||||
this.serverAppVersion = serverAppVersion;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
serverId = getAscii(data);
|
||||
serverAppVersion = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10 + serverId.length() + serverAppVersion.length());
|
||||
addShort(data, 4);
|
||||
addInt(data, CRC);
|
||||
addAscii(data, serverId);
|
||||
addAscii(data, serverAppVersion);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
60
src/network/packets/swg/login/OfflineServersMessage.java
Normal file
60
src/network/packets/swg/login/OfflineServersMessage.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class OfflineServersMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xF41A5265;
|
||||
|
||||
private List <String> offlineServers;
|
||||
|
||||
public OfflineServersMessage() {
|
||||
offlineServers = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public OfflineServersMessage(List <String> offline) {
|
||||
this.offlineServers = offline;
|
||||
}
|
||||
|
||||
public OfflineServersMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
int listCount = getInt(data);
|
||||
offlineServers = new ArrayList<String>(listCount);
|
||||
for (int i = 0 ; i < listCount; i++)
|
||||
offlineServers.add(getAscii(data));
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int strLength = 0;
|
||||
for (String str : offlineServers)
|
||||
strLength += 2 + str.length();
|
||||
ByteBuffer data = ByteBuffer.allocate(10 + strLength);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
for (String str : offlineServers)
|
||||
addAscii(data, str);
|
||||
return data;
|
||||
}
|
||||
|
||||
public List <String> getOfflineServers() {
|
||||
return offlineServers;
|
||||
}
|
||||
|
||||
public void setOfflineServers(List <String> offline) {
|
||||
offlineServers = offline;
|
||||
}
|
||||
|
||||
public void addOflineServer(String offline) {
|
||||
offlineServers.add(offline);
|
||||
}
|
||||
|
||||
}
|
||||
28
src/network/packets/swg/login/RequestExtendedClusters.java
Normal file
28
src/network/packets/swg/login/RequestExtendedClusters.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class RequestExtendedClusters extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x8E33ED05;
|
||||
|
||||
public RequestExtendedClusters() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
39
src/network/packets/swg/login/ServerId.java
Normal file
39
src/network/packets/swg/login/ServerId.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ServerId extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x58C07F21;
|
||||
private int serverId = 0;
|
||||
|
||||
public ServerId() {
|
||||
|
||||
}
|
||||
|
||||
public ServerId(int id) {
|
||||
this.serverId = id;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
serverId = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, serverId);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
}
|
||||
39
src/network/packets/swg/login/ServerString.java
Normal file
39
src/network/packets/swg/login/ServerString.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ServerString extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x0E20D7E9;
|
||||
private String serverName = "";
|
||||
|
||||
public ServerString() {
|
||||
|
||||
}
|
||||
|
||||
public ServerString(String name) {
|
||||
this.serverName = name;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
serverName = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(8 + serverName.length());
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addAscii(data, serverName);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getServerString() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
}
|
||||
40
src/network/packets/swg/login/StationIdHasJediSlot.java
Normal file
40
src/network/packets/swg/login/StationIdHasJediSlot.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package network.packets.swg.login;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class StationIdHasJediSlot extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xCC9FCCF8;
|
||||
|
||||
private int jedi;
|
||||
|
||||
public StationIdHasJediSlot() {
|
||||
this.jedi = 1;
|
||||
}
|
||||
|
||||
public StationIdHasJediSlot(int jedi) {
|
||||
this.jedi = jedi;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
jedi = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, jedi);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getJediSlot() {
|
||||
return jedi;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ClientCreateCharacter extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xB97F3074;
|
||||
private byte [] charCustomization = new byte[0];
|
||||
private String name = "";
|
||||
private String race = "";
|
||||
private String start = "";
|
||||
private String hair = "";
|
||||
private byte [] hairCustomization = new byte[0];
|
||||
private String clothes = "";
|
||||
private boolean jedi = false;
|
||||
private float height = 0;
|
||||
private String biography = "";
|
||||
private boolean tutorial = false;
|
||||
private String profession = "";
|
||||
private String startingPhase = "";
|
||||
|
||||
public ClientCreateCharacter() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
charCustomization = getArray(data);
|
||||
name = getUnicode(data);
|
||||
race = getAscii(data);
|
||||
start = getAscii(data);
|
||||
hair = getAscii(data);
|
||||
hairCustomization = getArray(data);
|
||||
clothes = getAscii(data);
|
||||
jedi = getBoolean(data);
|
||||
height = getFloat(data);
|
||||
biography = getUnicode(data);
|
||||
tutorial = getBoolean(data);
|
||||
profession = getAscii(data);
|
||||
startingPhase = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int extraSize = charCustomization.length;
|
||||
extraSize += name.length()*2;
|
||||
extraSize += race.length() + start.length();
|
||||
extraSize += hair.length() + hairCustomization.length;
|
||||
extraSize += clothes.length() + profession.length();
|
||||
extraSize += startingPhase.length();
|
||||
ByteBuffer data = ByteBuffer.allocate(36+extraSize);
|
||||
addShort (data, 2);
|
||||
addInt (data, CRC);
|
||||
addArray (data, charCustomization);
|
||||
addUnicode(data, name);
|
||||
addAscii (data, race);
|
||||
addAscii (data, start);
|
||||
addAscii (data, hair);
|
||||
addArray (data, hairCustomization);
|
||||
addAscii (data, clothes);
|
||||
addBoolean(data, jedi);
|
||||
addFloat (data, height);
|
||||
addUnicode(data, biography);
|
||||
addBoolean(data, tutorial);
|
||||
addAscii (data, profession);
|
||||
addAscii (data, startingPhase);
|
||||
return data;
|
||||
}
|
||||
|
||||
public byte [] getCharCustomization() { return charCustomization; }
|
||||
public String getName() { return name; }
|
||||
public String getRace() { return race; }
|
||||
public String getStartLocation() { return start; }
|
||||
public String getHair() { return hair; }
|
||||
public byte [] getHairCustomization() { return hairCustomization; }
|
||||
public String getClothes() { return clothes; }
|
||||
public float getHeight() { return height; }
|
||||
public boolean isTutorial() { return tutorial; }
|
||||
public String getProfession() { return profession; }
|
||||
public String getStartingPhase() { return startingPhase; }
|
||||
|
||||
public void setCharCustomization(byte [] data) { this.charCustomization = data; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getStart() { return start; }
|
||||
public void setStart(String start) { this.start = start; }
|
||||
public void setRace(String race) { this.race = race; }
|
||||
public void setHair(String hair) { this.hair = hair; }
|
||||
public void setHairCustomization(byte [] hairCustomization) { this.hairCustomization = hairCustomization; }
|
||||
public void setClothes(String clothes) { this.clothes = clothes; }
|
||||
public void setHeight(float height) { this.height = height; }
|
||||
public void setTutorial(boolean tutorial) { this.tutorial = tutorial; }
|
||||
public void setProfession(String profession) { this.profession = profession; }
|
||||
public void setStartingPhase(String startingPhase) { this.startingPhase = startingPhase; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ClientVerifyAndLockNameRequest extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x9EB04B9F;
|
||||
private String race = "";
|
||||
private String name = "";
|
||||
|
||||
public ClientVerifyAndLockNameRequest() {
|
||||
|
||||
}
|
||||
|
||||
public ClientVerifyAndLockNameRequest(String race, String name) {
|
||||
this.race = race;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
race = getAscii(data);
|
||||
name = getUnicode(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10 + race.length() + name.length() * 2);
|
||||
addShort( data, 4);
|
||||
addInt( data, CRC);
|
||||
addAscii( data, race);
|
||||
addUnicode(data, name);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getRace() { return race; }
|
||||
public String getName() { return name; }
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class ClientVerifyAndLockNameResponse extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x9B2C6BA7;
|
||||
|
||||
private String name = "";
|
||||
private ErrorMessage error = ErrorMessage.NAME_APPROVED;
|
||||
|
||||
public ClientVerifyAndLockNameResponse() {
|
||||
|
||||
}
|
||||
|
||||
public ClientVerifyAndLockNameResponse(String name, ErrorMessage error) {
|
||||
this.name = name;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
name = getUnicode(data);
|
||||
error = ErrorMessage.valueOf(getAscii(data).toUpperCase());
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(20 + error.name().length() + name.length() * 2);
|
||||
addShort( data, 9);
|
||||
addInt( data, CRC);
|
||||
addUnicode(data, name);
|
||||
addAscii( data, "ui");
|
||||
addInt( data, 0);
|
||||
addAscii( data, error.name().toLowerCase());
|
||||
return data;
|
||||
}
|
||||
|
||||
public enum ErrorMessage {
|
||||
NAME_APPROVED,
|
||||
NAME_APPROVED_MODIFIED,
|
||||
NAME_DECLINED_SYNTAX,
|
||||
NAME_DECLINED_EMPTY,
|
||||
NAME_DECLINED_RACIALLY_INAPPROPRIATE,
|
||||
NAME_DECLINED_FICTIONALLY_INAPPROPRIATE,
|
||||
NAME_DECLINED_PROFANE,
|
||||
NAME_DECLINED_IN_USE,
|
||||
NAME_DECLINED_RESERVED,
|
||||
NAME_DECLINED_NO_TEMPLATE,
|
||||
NAME_DECLINED_NOT_CREATURE_TEMPLATE,
|
||||
NAME_DECLINED_NO_NAME_GENERATOR,
|
||||
NAME_DECLINED_CANT_CREATE_AVATAR,
|
||||
NAME_DECLINED_INTERNAL_ERROR,
|
||||
NAME_DECLINED_RETRY,
|
||||
NAME_DECLINED_TOO_FAST,
|
||||
NAME_DECLINED_NOT_AUTHORIZED_FOR_SPECIES;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class CreateCharacterFailure extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xDF333C6E;
|
||||
private NameFailureReason reason;
|
||||
|
||||
public CreateCharacterFailure() {
|
||||
reason = NameFailureReason.NAME_RETRY;
|
||||
}
|
||||
|
||||
public CreateCharacterFailure(NameFailureReason reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
String errorString = nameFailureTranslation(reason);
|
||||
ByteBuffer data = ByteBuffer.allocate(20 + errorString.length());
|
||||
addShort( data, 3);
|
||||
addInt( data, CRC);
|
||||
addUnicode(data, "");
|
||||
addAscii( data, "ui");
|
||||
addInt( data, 0);
|
||||
addAscii( data, errorString);
|
||||
return data;
|
||||
}
|
||||
|
||||
private String nameFailureTranslation(NameFailureReason reason) {
|
||||
switch (reason) {
|
||||
case NAME_DECLINED_EMPTY:
|
||||
return "name_declined_empty";
|
||||
case NAME_IN_USE:
|
||||
return "name_declined_in_use";
|
||||
case NAME_RETRY:
|
||||
return "name_declined_retry";
|
||||
case NAME_SYNTAX:
|
||||
return "name_declined_syntax";
|
||||
case NAME_TOO_FAST:
|
||||
return "name_declined_too_fast";
|
||||
}
|
||||
return "name_declined_retry";
|
||||
}
|
||||
|
||||
public enum NameFailureReason {
|
||||
NAME_DECLINED_EMPTY,
|
||||
NAME_TOO_FAST,
|
||||
NAME_RETRY,
|
||||
NAME_SYNTAX,
|
||||
NAME_IN_USE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class CreateCharacterSuccess extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x1DB575CC;
|
||||
private long id = 0;
|
||||
|
||||
public CreateCharacterSuccess() {
|
||||
|
||||
}
|
||||
|
||||
public CreateCharacterSuccess(long charId) {
|
||||
this.id = charId;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
id = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(14);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addLong( data, id);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getId() { return id; }
|
||||
public void setId(long id) { this.id = id; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class DeleteCharacterRequest extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xE87AD031;
|
||||
private int serverId = 0;
|
||||
private long playerId = 0;
|
||||
|
||||
public DeleteCharacterRequest() {
|
||||
|
||||
}
|
||||
|
||||
public DeleteCharacterRequest(int serverId, long playerId) {
|
||||
this.serverId = serverId;
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
serverId = getInt(data);
|
||||
playerId = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(18);
|
||||
addShort(data, 3);
|
||||
addInt( data, CRC);
|
||||
addInt( data, serverId);
|
||||
addLong( data, playerId);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getServerId() { return serverId; }
|
||||
public long getPlayerId() { return playerId; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class DeleteCharacterResponse extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x8268989B;
|
||||
private boolean deleted = true;
|
||||
|
||||
public DeleteCharacterResponse() {
|
||||
|
||||
}
|
||||
|
||||
public DeleteCharacterResponse(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
deleted = getInt(data) == 0;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, deleted ? 0 : 1);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class RandomNameRequest extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xD6D1B6D1;
|
||||
private String raceCrc = "object/creature/player/human_male.iff";
|
||||
|
||||
public RandomNameRequest() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
raceCrc = getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(8 + raceCrc.length());
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addAscii(data, raceCrc);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getRace() { return raceCrc; }
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package network.packets.swg.login.creation;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
|
||||
public class RandomNameResponse extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xE85FB868;
|
||||
|
||||
private String race;
|
||||
private String randomName;
|
||||
|
||||
public RandomNameResponse() {
|
||||
this.race = "object/creature/player/human_male.iff";
|
||||
this.randomName = "";
|
||||
}
|
||||
|
||||
public RandomNameResponse(String race, String randomName) {
|
||||
this.race = race;
|
||||
this.randomName = randomName;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
race = getAscii(data);
|
||||
randomName = getUnicode(data);
|
||||
getAscii(data);
|
||||
getInt(data);
|
||||
getAscii(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 35 + race.length() + randomName.length() * 2;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort( data, 4);
|
||||
addInt( data, CRC);
|
||||
addAscii( data, race);
|
||||
addUnicode(data, randomName);
|
||||
addAscii( data, "ui");
|
||||
addInt( data, 0);
|
||||
addAscii( data, "name_approved");
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setRace(String race) { this.race = race; }
|
||||
public void setRandomName(String randomName) { this.randomName = randomName; }
|
||||
|
||||
public String getRace() { return race; }
|
||||
public String getRandomName() { return randomName; }
|
||||
}
|
||||
27
src/network/packets/swg/zone/ChatRequestRoomList.java
Normal file
27
src/network/packets/swg/zone/ChatRequestRoomList.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatRequestRoomList extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x4C3D2CFA;
|
||||
|
||||
public ChatRequestRoomList() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 6;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 1);
|
||||
addInt( data, CRC);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
27
src/network/packets/swg/zone/CmdSceneReady.java
Normal file
27
src/network/packets/swg/zone/CmdSceneReady.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class CmdSceneReady extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x43FD1C22;
|
||||
|
||||
public CmdSceneReady() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 6;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 1);
|
||||
addInt( data, CRC);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ConnectPlayerResponseMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x6137556F;
|
||||
|
||||
public ConnectPlayerResponseMessage() {
|
||||
|
||||
}
|
||||
|
||||
public ConnectPlayerResponseMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(10);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
addInt (data, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
27
src/network/packets/swg/zone/GalaxyLoopTimesRequest.java
Normal file
27
src/network/packets/swg/zone/GalaxyLoopTimesRequest.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class GalaxyLoopTimesRequest extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x7D842D68;
|
||||
|
||||
public GalaxyLoopTimesRequest() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 6;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 1);
|
||||
addInt( data, CRC);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
34
src/network/packets/swg/zone/GalaxyLoopTimesResponse.java
Normal file
34
src/network/packets/swg/zone/GalaxyLoopTimesResponse.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class GalaxyLoopTimesResponse extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x4E428088;
|
||||
private long time = 0;
|
||||
|
||||
public GalaxyLoopTimesResponse() {
|
||||
|
||||
}
|
||||
|
||||
public GalaxyLoopTimesResponse(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
time = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 14;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 3);
|
||||
addInt( data, CRC);
|
||||
addLong( data, time);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
28
src/network/packets/swg/zone/HeartBeatMessage.java
Normal file
28
src/network/packets/swg/zone/HeartBeatMessage.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class HeartBeatMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xA16CF9AF;
|
||||
|
||||
public HeartBeatMessage() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 10;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 1);
|
||||
addInt( data, CRC);
|
||||
addInt( data, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
43
src/network/packets/swg/zone/OpenedContainerMessage.java
Normal file
43
src/network/packets/swg/zone/OpenedContainerMessage.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class OpenedContainerMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x2E11E4AB;
|
||||
|
||||
private long containerId;
|
||||
|
||||
public OpenedContainerMessage() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public OpenedContainerMessage(long containerId) {
|
||||
this.containerId = 0;
|
||||
}
|
||||
|
||||
public OpenedContainerMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
getInt(data); // 0?
|
||||
containerId = getLong(data);
|
||||
getShort(data); // 0?
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(20);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
addInt (data, 0);
|
||||
addLong (data, containerId);
|
||||
addShort(data, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
29
src/network/packets/swg/zone/ParametersMessage.java
Normal file
29
src/network/packets/swg/zone/ParametersMessage.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ParametersMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x487652DA;
|
||||
|
||||
public ParametersMessage() {
|
||||
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 14;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addInt( data, 900);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
53
src/network/packets/swg/zone/SceneCreateObjectByCrc.java
Normal file
53
src/network/packets/swg/zone/SceneCreateObjectByCrc.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
import resources.Location;
|
||||
|
||||
public class SceneCreateObjectByCrc extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xFE89DDEA;
|
||||
private long objId = 0;
|
||||
private Location l = new Location();
|
||||
private int objCrc = 0;
|
||||
|
||||
public SceneCreateObjectByCrc() {
|
||||
|
||||
}
|
||||
|
||||
public SceneCreateObjectByCrc(long objId, Location l, int objCrc) {
|
||||
this.objId = objId;
|
||||
this.l = l;
|
||||
this.objCrc = objCrc;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objId = getLong(data);
|
||||
l = getLocation();
|
||||
objCrc = getInt(data);
|
||||
getByte(data); // Unknown Byte
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 47;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 5);
|
||||
addInt( data, CRC);
|
||||
addLong( data, objId);
|
||||
addLocation(data, l);
|
||||
addInt( data, objCrc);
|
||||
addByte( data, 0); // Unknown Byte
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setObjectId(long objId) { this.objId = objId; }
|
||||
public void setLocation(Location l) { this.l = l; }
|
||||
public void setObjectCrc(int objCrc) { this.objCrc = objCrc; }
|
||||
|
||||
public long getObjectId() { return objId; }
|
||||
public Location getLocation() { return l; }
|
||||
public int getObjectCrc() { return objCrc; }
|
||||
}
|
||||
44
src/network/packets/swg/zone/SceneDestroyObject.java
Normal file
44
src/network/packets/swg/zone/SceneDestroyObject.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class SceneDestroyObject extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x4D45D504;
|
||||
|
||||
private long objId;
|
||||
|
||||
public SceneDestroyObject() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SceneDestroyObject(long objId) {
|
||||
|
||||
}
|
||||
|
||||
public SceneDestroyObject(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objId = getLong(data);
|
||||
getByte(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(15);
|
||||
addShort(data, 3);
|
||||
addInt (data, CRC);
|
||||
addLong (data, objId);
|
||||
addByte (data, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getObjectId() { return objId; }
|
||||
public void setObjectId(long objId) { this.objId = objId; }
|
||||
|
||||
}
|
||||
37
src/network/packets/swg/zone/SceneEndBaselines.java
Normal file
37
src/network/packets/swg/zone/SceneEndBaselines.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class SceneEndBaselines extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x2C436037;
|
||||
private long objId = 0;
|
||||
|
||||
public SceneEndBaselines() {
|
||||
|
||||
}
|
||||
|
||||
public SceneEndBaselines(long objId) {
|
||||
this.objId = objId;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objId = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 14;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addLong( data, objId);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getObjectId() { return objId; }
|
||||
|
||||
}
|
||||
38
src/network/packets/swg/zone/ServerTimeMessage.java
Normal file
38
src/network/packets/swg/zone/ServerTimeMessage.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ServerTimeMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x2EBC3BD9;
|
||||
|
||||
private long time = 0;
|
||||
|
||||
public ServerTimeMessage() {
|
||||
|
||||
}
|
||||
|
||||
public ServerTimeMessage(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
time = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(14);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addLong( data, time);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
31
src/network/packets/swg/zone/SetWaypointColor.java
Normal file
31
src/network/packets/swg/zone/SetWaypointColor.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class SetWaypointColor extends SWGPacket {
|
||||
public static final int CRC = 0x90C59FDE;
|
||||
|
||||
private long objId;
|
||||
private String color;
|
||||
|
||||
public SetWaypointColor() { }
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
|
||||
objId = getLong(data);
|
||||
color = getAscii(data);
|
||||
}
|
||||
|
||||
public long getObjId() {
|
||||
return objId;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
47
src/network/packets/swg/zone/UpdateContainmentMessage.java
Normal file
47
src/network/packets/swg/zone/UpdateContainmentMessage.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class UpdateContainmentMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x56CBDE9E;
|
||||
|
||||
private long containerId = 0;
|
||||
private long objectId = 0;
|
||||
private int slotIndex = 0;
|
||||
|
||||
public UpdateContainmentMessage() {
|
||||
|
||||
}
|
||||
|
||||
public UpdateContainmentMessage(long objectId, long containerId, int slotIndex) {
|
||||
this.objectId = objectId;
|
||||
this.containerId = containerId;
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objectId = getLong(data);
|
||||
containerId = getLong(data);
|
||||
slotIndex = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 26;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 4);
|
||||
addInt( data, CRC);
|
||||
addLong( data, objectId);
|
||||
addLong( data, containerId);
|
||||
addInt( data, slotIndex);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getObjectId() { return objectId; }
|
||||
public long getContainerId() { return containerId; }
|
||||
public int getSlotIndex() { return slotIndex; }
|
||||
}
|
||||
44
src/network/packets/swg/zone/UpdatePostureMessage.java
Normal file
44
src/network/packets/swg/zone/UpdatePostureMessage.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
import resources.Posture;
|
||||
|
||||
public class UpdatePostureMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x00BDE6B41;
|
||||
private int posture = 0;
|
||||
private long objId = 0;
|
||||
|
||||
public UpdatePostureMessage() {
|
||||
|
||||
}
|
||||
|
||||
public UpdatePostureMessage(Posture posture, long objId) {
|
||||
this.posture = posture.getId();
|
||||
this.objId = objId;
|
||||
}
|
||||
|
||||
public UpdatePostureMessage(int posture, long objId) {
|
||||
this.posture = posture;
|
||||
this.objId = objId;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
posture = getByte(data);
|
||||
objId = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 16;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 3);
|
||||
addInt (data, CRC);
|
||||
addByte (data, posture);
|
||||
addLong (data, objId);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
58
src/network/packets/swg/zone/UpdatePvpStatusMessage.java
Normal file
58
src/network/packets/swg/zone/UpdatePvpStatusMessage.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class UpdatePvpStatusMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x08A1C126;
|
||||
|
||||
public static final int ATTACKABLE = 1;
|
||||
public static final int AGGRESSIVE = 2;
|
||||
public static final int OVERT = 4;
|
||||
public static final int TEF = 8;
|
||||
public static final int PLAYER = 16;
|
||||
public static final int ENEMY = 32;
|
||||
public static final int GOING_OVERT = 64; // purple/blue blink
|
||||
public static final int GOING_COVERT = 128; // green blink
|
||||
public static final int DUEL = 256;
|
||||
|
||||
private int flag = 16;
|
||||
private int playerFaction = 0;
|
||||
private long objId = 0;
|
||||
|
||||
public UpdatePvpStatusMessage() {
|
||||
|
||||
}
|
||||
|
||||
public UpdatePvpStatusMessage(int playerType, int flag, long objId) {
|
||||
this.flag = playerType;
|
||||
this.playerFaction = flag;
|
||||
this.objId = objId;
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
flag = getInt(data);
|
||||
playerFaction = getInt(data);
|
||||
objId = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 22;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 4);
|
||||
addInt( data, CRC);
|
||||
addInt( data, flag);
|
||||
addInt( data, playerFaction);
|
||||
addLong( data, objId);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getObjectId() { return objId; }
|
||||
public int getPlayerFaction() { return playerFaction; }
|
||||
public int getPlayerType() { return flag; }
|
||||
|
||||
}
|
||||
78
src/network/packets/swg/zone/UpdateTransformsMessage.java
Normal file
78
src/network/packets/swg/zone/UpdateTransformsMessage.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package network.packets.swg.zone;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class UpdateTransformsMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x1B24F808;
|
||||
private long objId;
|
||||
private short posX;
|
||||
private short posY;
|
||||
private short posZ;
|
||||
private int updateCounter;
|
||||
private byte direction;
|
||||
private float speed;
|
||||
|
||||
public UpdateTransformsMessage() {
|
||||
this.objId = 0;
|
||||
this.posX = 0;
|
||||
this.posY = 0;
|
||||
this.posZ = 0;
|
||||
this.updateCounter = 0;
|
||||
this.direction = 0;
|
||||
this.speed = 0;
|
||||
}
|
||||
|
||||
public UpdateTransformsMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objId = getLong(data);
|
||||
posX = getShort(data);
|
||||
posY = getShort(data);
|
||||
posZ = getShort(data);
|
||||
updateCounter = getInt(data);
|
||||
speed = getByte(data);
|
||||
direction = getByte(data);
|
||||
getByte(data);
|
||||
getByte(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(28);
|
||||
addShort(data, 10);
|
||||
addInt( data, CRC);
|
||||
addLong( data, objId);
|
||||
addShort(data, posX);
|
||||
addShort(data, posY);
|
||||
addShort(data, posZ);
|
||||
addInt (data, updateCounter);
|
||||
addByte (data, (byte) speed);
|
||||
addByte (data, (byte) direction);
|
||||
addByte (data, (byte) 1); // lookAtYaw
|
||||
addByte (data, (byte) 0); // useLookAtYaw
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setObjectId(long objId) { this.objId = objId; }
|
||||
public void setX(short x) { this.posX = x; }
|
||||
public void setY(short y) { this.posY = y; }
|
||||
public void setZ(short z) { this.posZ = z; }
|
||||
public void setUpdateCounter(int count) { this.updateCounter = count; }
|
||||
public void setDirection(byte d) { this.direction = d; }
|
||||
public void setSpeed(float speed) { this.speed = speed; }
|
||||
|
||||
public long getObjectId() { return objId; }
|
||||
public short getX() { return posX; }
|
||||
public short getY() { return posY; }
|
||||
public short getZ() { return posZ; }
|
||||
public int getUpdateCounter() { return updateCounter; }
|
||||
public byte getDirection() { return direction; }
|
||||
public float getSpeed() { return speed; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class AuctionQueryHeadersMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x679E0D00;
|
||||
|
||||
public AuctionQueryHeadersMessage() {
|
||||
|
||||
}
|
||||
|
||||
public AuctionQueryHeadersMessage(String command) {
|
||||
|
||||
}
|
||||
|
||||
public AuctionQueryHeadersMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class AuctionQueryHeadersResponseMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xFA500E52;
|
||||
|
||||
private int counter;
|
||||
private int screen;
|
||||
private List <AuctionItem> items;
|
||||
|
||||
public AuctionQueryHeadersResponseMessage() {
|
||||
items = new ArrayList<AuctionItem>();
|
||||
}
|
||||
|
||||
public AuctionQueryHeadersResponseMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
counter = getInt(data);
|
||||
screen = getInt(data);
|
||||
String [] locations = new String[getInt(data)];
|
||||
for (int i = 0; i < locations.length; i++)
|
||||
locations[i] = getAscii(data);
|
||||
int itemCount = getInt(data);
|
||||
AuctionItem [] items = new AuctionItem[itemCount];
|
||||
for (int itemI = 0; itemI < itemCount; itemI++) {
|
||||
AuctionItem item = new AuctionItem();
|
||||
item.setItemName(getUnicode(data));
|
||||
items[itemI] = item;
|
||||
}
|
||||
itemCount = getInt(data);
|
||||
if (itemCount != items.length)
|
||||
throw new IllegalStateException("I WAS LIED TO!");
|
||||
for (int itemI = 0; itemI < itemCount; itemI++) {
|
||||
AuctionItem item = items[itemI];
|
||||
item.setObjectId(getLong(data));
|
||||
getByte(data);
|
||||
item.setPrice(getInt(data));
|
||||
item.setExpireTime(getInt(data)*1000+System.currentTimeMillis());
|
||||
if (getInt(data) != item.getPrice())
|
||||
throw new IllegalStateException("I WAS LIED TO AT INDEX " + itemI);
|
||||
item.setVuid(locations[getShort(data)]);
|
||||
item.setOwnerId(getLong(data));
|
||||
item.setOwnerName(locations[getShort(data)]);
|
||||
getLong(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
getShort(data);
|
||||
item.setItemType(getInt(data));
|
||||
getInt(data);
|
||||
item.setAuctionOptions(getInt(data));
|
||||
getInt(data);
|
||||
}
|
||||
getShort(data);
|
||||
getByte(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 8);
|
||||
addInt (data, CRC);
|
||||
addInt (data, counter);
|
||||
addInt (data, screen);
|
||||
|
||||
Set <String> locations = new LinkedHashSet<String>();
|
||||
for (AuctionItem item : items) {
|
||||
locations.add(item.getVuid());
|
||||
locations.add(item.getOwnerName());
|
||||
}
|
||||
addInt(data, items.size());
|
||||
for (String item : locations) {
|
||||
addAscii(data, item);
|
||||
}
|
||||
|
||||
addInt (data, items.size());
|
||||
for (AuctionItem item : items)
|
||||
addUnicode(data, item.getItemName());
|
||||
|
||||
addInt (data, items.size());
|
||||
|
||||
int i = 0;
|
||||
for(AuctionItem item : items) {
|
||||
addLong(data, item.getObjectId());
|
||||
addByte(data, i);
|
||||
addInt(data, item.getPrice());
|
||||
addInt(data, (int) ((item.getExpireTime() - System.currentTimeMillis()) / 1000));
|
||||
addInt(data, item.getPrice()); // if != price then auction instead of instant sale
|
||||
//addInt(data, 0);
|
||||
addShort(data, getString(locations, item.getVuid()));
|
||||
addLong(data, item.getOwnerId());
|
||||
addShort(data, getString(locations, item.getOwnerName()));
|
||||
addLong(data, 0);
|
||||
addInt(data, 0); // unk seen as 2 mostly, doesnt seem to have any effect
|
||||
addInt(data, 0);
|
||||
addShort(data, (short) 0);
|
||||
addInt(data, item.getItemType()); // gameObjectType/category bitmask
|
||||
|
||||
addInt(data, 0);
|
||||
int options = 0;
|
||||
|
||||
if (item.getStatus() == AuctionState.OFFERED || item.getStatus() == AuctionState.FORSALE)
|
||||
options |= 0x800;
|
||||
|
||||
addInt(data, item.getAuctionOptions() | options);
|
||||
addInt(data, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
addShort(data, 0);
|
||||
|
||||
addByte(data, (byte) 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
private int getString(Set <String> strings, String str) {
|
||||
int index = 0;
|
||||
for (String s : strings) {
|
||||
if (s.equals(str))
|
||||
return index;
|
||||
index++;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public static enum AuctionState {
|
||||
PREMIUM (0x400),
|
||||
WITHDRAW (0x800),
|
||||
FORSALE (1),
|
||||
SOLD (2),
|
||||
EXPIRED (4),
|
||||
OFFERED (5),
|
||||
RETRIEVED (6);
|
||||
|
||||
private int id;
|
||||
|
||||
AuctionState(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() { return id; }
|
||||
}
|
||||
|
||||
public static class AuctionItem {
|
||||
private long objectId;
|
||||
private long ownerId;
|
||||
private long vendorId;
|
||||
private long buyerId;
|
||||
private long offerToId;
|
||||
private int itemType;
|
||||
private int itemTypeCRC;
|
||||
private String ownerName;
|
||||
private String bidderName;
|
||||
private String itemName;
|
||||
private String itemDescription;
|
||||
private String planet;
|
||||
private String location;
|
||||
private int price;
|
||||
private int proxyBid;
|
||||
private boolean auction;
|
||||
private String vuid;
|
||||
private boolean onBazaar = false;
|
||||
private long expireTime;
|
||||
private int auctionOptions;
|
||||
private AuctionState state;
|
||||
|
||||
public long getObjectId() { return objectId; }
|
||||
public long getOwnerId() { return ownerId; }
|
||||
public long getVendorId() { return vendorId; }
|
||||
public long getBuyerId() { return buyerId; }
|
||||
public long getOfferToId() { return offerToId; }
|
||||
public int getItemType() { return itemType; }
|
||||
public String getOwnerName() { return ownerName; }
|
||||
public String getBidderName() { return bidderName; }
|
||||
public String getItemName() { return itemName; }
|
||||
public String getLocation() { return location; }
|
||||
public int getPrice() { return price; }
|
||||
public int getProxyBid() { return proxyBid; }
|
||||
public boolean isAuction() { return auction; }
|
||||
public String getVuid() { return vuid; }
|
||||
public AuctionState getStatus() { return state; }
|
||||
public boolean isOnBazaar() { return onBazaar; }
|
||||
public int getAuctionOptions() { return auctionOptions; }
|
||||
public String getPlanet() { return planet; }
|
||||
public int getItemTypeCRC() { return itemTypeCRC; }
|
||||
|
||||
public String getItemDescription() { return itemDescription; }
|
||||
public void setObjectId(long objectId) { this.objectId = objectId; }
|
||||
public void setOwnerId(long ownerId) { this.ownerId = ownerId; }
|
||||
public void setVendorId(long vendorId) { this.vendorId = vendorId; }
|
||||
public void setBuyerId(long buyerId) { this.buyerId = buyerId; }
|
||||
public void setOfferToId(long offerToId) { this.offerToId = offerToId; }
|
||||
public void setItemType(int itemType) { this.itemType = itemType; }
|
||||
public void setOwnerName(String ownerName) { this.ownerName = ownerName; }
|
||||
public void setBidderName(String bidderName) { this.bidderName = bidderName; }
|
||||
public void setItemName(String itemName) { this.itemName = itemName; }
|
||||
public void setLocation(String location) { this.location = location; }
|
||||
public void setItemDescription(String itemDescription) { this.itemDescription = itemDescription; }
|
||||
public void setPrice(int price) { this.price = price; }
|
||||
public void setProxyBid(int proxyBid) { this.proxyBid = proxyBid; }
|
||||
public void setAuction(boolean auction) { this.auction = auction; }
|
||||
public void setVuid(String vuid) { this.vuid = vuid; }
|
||||
public void setStatus(AuctionState state) { this.state = state; }
|
||||
public void setOnBazaar(boolean onBazaar) { this.onBazaar = onBazaar; }
|
||||
public long getExpireTime() { return expireTime; }
|
||||
public void setExpireTime(long expireTime) { this.expireTime = expireTime; }
|
||||
public void setAuctionOptions(int auctionOptions) { this.auctionOptions = auctionOptions; }
|
||||
public void setPlanet(String planet) { this.planet = planet; }
|
||||
public void setItemTypeCRC(int itemTypeCRC) { this.itemTypeCRC = itemTypeCRC; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class CancelLiveAuctionMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x3687A4D2;
|
||||
|
||||
public CancelLiveAuctionMessage() {
|
||||
|
||||
}
|
||||
|
||||
public CancelLiveAuctionMessage(String command) {
|
||||
|
||||
}
|
||||
|
||||
public CancelLiveAuctionMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class CancelLiveAuctionResponseMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x7DA2246C;
|
||||
|
||||
public CancelLiveAuctionResponseMessage() {
|
||||
|
||||
}
|
||||
|
||||
public CancelLiveAuctionResponseMessage(String command) {
|
||||
|
||||
}
|
||||
|
||||
public CancelLiveAuctionResponseMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
39
src/network/packets/swg/zone/auction/GetAuctionDetails.java
Normal file
39
src/network/packets/swg/zone/auction/GetAuctionDetails.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class GetAuctionDetails extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xD36EFAE4;
|
||||
|
||||
private long auctionId;
|
||||
|
||||
public GetAuctionDetails() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public GetAuctionDetails(long auctionId) {
|
||||
this.auctionId = auctionId;
|
||||
}
|
||||
|
||||
public GetAuctionDetails(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
auctionId = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(14);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
addLong (data, auctionId);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class GetAuctionDetailsResponse extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xFE0E644B;
|
||||
|
||||
private long itemId;
|
||||
private Map <String, String> properties;
|
||||
private String itemName;
|
||||
|
||||
public GetAuctionDetailsResponse() {
|
||||
this(0, new HashMap<String, String>(), "");
|
||||
}
|
||||
|
||||
public GetAuctionDetailsResponse(long itemId, Map <String, String> properties, String itemName) {
|
||||
this.itemId = itemId;
|
||||
this.properties = properties;
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public GetAuctionDetailsResponse(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
itemId = getLong(data);
|
||||
getInt(data);
|
||||
int count = getInt(data);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String key = getAscii(data);
|
||||
String val = getUnicode(data);
|
||||
properties.put(key, val);
|
||||
}
|
||||
itemName = getAscii(data);
|
||||
getShort(data); // 0
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int strSize = 0;
|
||||
for (Entry <String, String> e : properties.entrySet())
|
||||
strSize += 6 + e.getKey().length() + e.getValue().length()*2;
|
||||
ByteBuffer data = ByteBuffer.allocate(18 + strSize);
|
||||
addShort(data, 9);
|
||||
addInt (data, CRC);
|
||||
addLong (data, itemId);
|
||||
addInt (data, properties.size());
|
||||
for (Entry <String, String> e : properties.entrySet()) {
|
||||
addAscii(data, e.getKey());
|
||||
addUnicode(data, e.getValue());
|
||||
}
|
||||
addAscii(data, itemName);
|
||||
addShort(data, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class IsVendorOwnerResponseMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xCE04173E;
|
||||
|
||||
public IsVendorOwnerResponseMessage() {
|
||||
|
||||
}
|
||||
|
||||
public IsVendorOwnerResponseMessage(String command) {
|
||||
|
||||
}
|
||||
|
||||
public IsVendorOwnerResponseMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class RetrieveAuctionItemMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x12B0D449;
|
||||
|
||||
public RetrieveAuctionItemMessage() {
|
||||
|
||||
}
|
||||
|
||||
public RetrieveAuctionItemMessage(String command) {
|
||||
|
||||
}
|
||||
|
||||
public RetrieveAuctionItemMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.auction;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class RetrieveAuctionItemResponseMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x9499EF8C;
|
||||
|
||||
public RetrieveAuctionItemResponseMessage() {
|
||||
|
||||
}
|
||||
|
||||
public RetrieveAuctionItemResponseMessage(String command) {
|
||||
|
||||
}
|
||||
|
||||
public RetrieveAuctionItemResponseMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
77
src/network/packets/swg/zone/baselines/Baseline.java
Normal file
77
src/network/packets/swg/zone/baselines/Baseline.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package network.packets.swg.zone.baselines;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class Baseline extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x68A75F0C;
|
||||
private BaselineType type;
|
||||
private int num;
|
||||
private short opCount;
|
||||
private long objId;
|
||||
private byte [] baseData;
|
||||
|
||||
public Baseline() {
|
||||
|
||||
}
|
||||
|
||||
public Baseline(long objId, Baseline subData) {
|
||||
this.objId = objId;
|
||||
type = subData.getType();
|
||||
num = subData.getNum();
|
||||
baseData = subData.encodeBaseline().array();
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objId = getLong(data);
|
||||
byte [] str = new byte[4]; data.get(str);
|
||||
String strType = new StringBuffer(new String(str, ascii)).reverse().toString();
|
||||
for (BaselineType baseType : BaselineType.values())
|
||||
if (baseType.toString().equals(strType))
|
||||
type = baseType;
|
||||
num = getByte(data);
|
||||
baseData = new byte[getInt(data)];
|
||||
data.get(baseData);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(25 + baseData.length);
|
||||
addShort(data, 5);
|
||||
addInt( data, CRC);
|
||||
addLong( data, objId);
|
||||
data.put(new StringBuffer(type.toString()).reverse().toString().getBytes(ascii));
|
||||
addByte( data, num);
|
||||
addInt( data, baseData.length + 2);
|
||||
addShort( data, (opCount == 0 ? 5 : opCount));
|
||||
data.put(baseData);
|
||||
// TODO: It seems that baselines are being called to encode 3 times, might be possible they're also being sent 3 times as well...
|
||||
return data;
|
||||
}
|
||||
|
||||
public ByteBuffer encodeBaseline() { return ByteBuffer.allocate(0); }
|
||||
|
||||
public long getObjectId() { return objId; }
|
||||
|
||||
public void setType(BaselineType type) { this.type = type; }
|
||||
public void setNum(int num) { this.num = num; }
|
||||
public void setId(long id) { this.objId = id; }
|
||||
public void setBaselineData(byte [] data) { this.baseData = data; }
|
||||
public void setOperandCount(int count) { this.opCount = (short) count;}
|
||||
|
||||
public BaselineType getType() { return type; }
|
||||
public int getNum() { return num; }
|
||||
public long getId() { return objId; }
|
||||
public byte [] getBaselineData() { return baseData; }
|
||||
|
||||
public enum BaselineType {
|
||||
BMRK, BUIO, CREO, FCYT,
|
||||
GILD, GRUP, HINO, INSO,
|
||||
ITNO, MINO, MISO, MSCO,
|
||||
PLAY, RCNO, SCLT, STAO,
|
||||
SHIP, TANO, WAYP, WEAO
|
||||
}
|
||||
}
|
||||
81
src/network/packets/swg/zone/baselines/CREO3.java
Normal file
81
src/network/packets/swg/zone/baselines/CREO3.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package network.packets.swg.zone.baselines;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class CREO3 extends Baseline {
|
||||
|
||||
private String dName = "";
|
||||
private String cName = "";
|
||||
private byte [] customization = new byte[0];
|
||||
private int posture = 1;
|
||||
private float height = 0;
|
||||
private int fatigue = 0;
|
||||
|
||||
public CREO3() {
|
||||
|
||||
}
|
||||
|
||||
public CREO3(String dName, String cName, byte [] customization, int posture, float height, int fatigue) {
|
||||
this.dName = dName;
|
||||
this.cName = cName;
|
||||
this.customization = customization;
|
||||
this.posture = posture;
|
||||
this.height = height;
|
||||
this.fatigue = fatigue;
|
||||
}
|
||||
|
||||
public void decodeBaseline(ByteBuffer data) {
|
||||
getInt(data);
|
||||
getShort(data);
|
||||
getAscii(data);
|
||||
getInt(data);
|
||||
dName = getAscii(data);
|
||||
cName = getUnicode(data);
|
||||
getInt(data);
|
||||
getLong(data);
|
||||
customization = getArray(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
getInt(data);
|
||||
posture = getShort(data);
|
||||
getByte(data);
|
||||
getLong(data);
|
||||
height = getFloat(data);
|
||||
fatigue = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encodeBaseline() {
|
||||
int length = 91 + "species".length() + dName.length() + cName.length() * 2 + customization.length;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addInt( data, 0x13); // Object Count?
|
||||
addShort( data, 0x3F80); // Scale?
|
||||
addAscii( data, "species"); // Unknown..
|
||||
addInt( data, 0); // Spacer
|
||||
addAscii( data, dName); // Default Name
|
||||
addUnicode(data, cName); // Custom Name
|
||||
addInt( data, 0x000F4240); // Unknown
|
||||
addLong( data, 0); // Unknown
|
||||
addArray( data, customization); // Object Customization Data
|
||||
addInt( data, 1); // Unknown
|
||||
addInt( data, 0); // Unknown
|
||||
addInt( data, 0); // Unknown
|
||||
addInt( data, 0x80); // Unknown
|
||||
addInt( data, 0); // Unknown
|
||||
addInt( data, 0); // Unknown
|
||||
addInt( data, 0x00003A98); // Unknown
|
||||
addShort( data, posture); // Posture for Object
|
||||
addByte( data, 1); // Unknown
|
||||
addLong( data, 0); // Target Object Id
|
||||
addFloat( data, height); // Height of Object
|
||||
addInt( data, fatigue); // Battle Fatigue
|
||||
addLong( data, 0); // State?
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getDefaultName() { return dName; }
|
||||
public String getCustomName() { return cName; }
|
||||
}
|
||||
106
src/network/packets/swg/zone/baselines/CREO6.java
Normal file
106
src/network/packets/swg/zone/baselines/CREO6.java
Normal file
File diff suppressed because one or more lines are too long
22
src/network/packets/swg/zone/baselines/CREO8.java
Normal file
22
src/network/packets/swg/zone/baselines/CREO8.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package network.packets.swg.zone.baselines;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class CREO8 extends Baseline {
|
||||
|
||||
public CREO8() {
|
||||
|
||||
}
|
||||
|
||||
public void decodeBaseline(ByteBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer encodeBaseline() {
|
||||
int length = 2;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
22
src/network/packets/swg/zone/baselines/CREO9.java
Normal file
22
src/network/packets/swg/zone/baselines/CREO9.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package network.packets.swg.zone.baselines;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class CREO9 extends Baseline {
|
||||
|
||||
public CREO9() {
|
||||
|
||||
}
|
||||
|
||||
public void decodeBaseline(ByteBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer encodeBaseline() {
|
||||
int length = 2;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
28
src/network/packets/swg/zone/baselines/PLAY6.java
Normal file
28
src/network/packets/swg/zone/baselines/PLAY6.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package network.packets.swg.zone.baselines;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class PLAY6 extends Baseline {
|
||||
|
||||
public void decodeBaseline(ByteBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer encodeBaseline() {
|
||||
int length = 81;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addShort(data, 17);
|
||||
addInt( data, 0x4C);
|
||||
addAscii(data, "string_id_table");
|
||||
addLong( data, 0);
|
||||
addLong( data, 0);
|
||||
addLong( data, 0);
|
||||
addLong( data, 0);
|
||||
addLong( data, 0);
|
||||
addLong( data, 0);
|
||||
addLong( data, 0);
|
||||
addShort(data, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
86
src/network/packets/swg/zone/baselines/PLAY9.java
Normal file
86
src/network/packets/swg/zone/baselines/PLAY9.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package network.packets.swg.zone.baselines;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class PLAY9 extends Baseline {
|
||||
|
||||
public void decodeBaseline(ByteBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer encodeBaseline() {
|
||||
int length = 0x0143;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
addInt( data, 0x1F);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addShort(data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 3);
|
||||
addInt( data, 3);
|
||||
addByte( data, 0);
|
||||
addInt( data, 0x30254293);
|
||||
addInt( data, 0xD805AB60);
|
||||
addInt( data, 1);
|
||||
addByte( data, 0);
|
||||
addInt( data, 0x4BB23CAE);
|
||||
addInt( data, 0x6C750908);
|
||||
addInt( data, 1);
|
||||
addByte( data, 0);
|
||||
addInt( data, 0x83AADF10);
|
||||
addInt( data, 0x757A3F17);
|
||||
addInt( data, 1);
|
||||
addByte( data, 0);
|
||||
addByte( data, 0);
|
||||
addShort(data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 8);
|
||||
addInt( data, 0);
|
||||
addInt( data, 10);
|
||||
addInt( data, 0x21);
|
||||
addAscii(data, "atima");
|
||||
addAscii(data, "brokovo");
|
||||
addAscii(data, "daymian");
|
||||
addAscii(data, "dow-jones");
|
||||
addAscii(data, "eclipse.pandoren");
|
||||
addAscii(data, "eclipse.rabivesk");
|
||||
addAscii(data, "kenpachie");
|
||||
addAscii(data, "melony");
|
||||
addAscii(data, "omatchi'");
|
||||
addAscii(data, "sobli");
|
||||
addInt( data, 0);
|
||||
addInt( data, 3);
|
||||
addInt( data, 1);
|
||||
addInt( data, 0);
|
||||
addInt( data, 100);
|
||||
addInt( data, 0);
|
||||
addInt( data, 100);
|
||||
addInt( data, 0);
|
||||
addInt( data, 100);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 3);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 2);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addInt( data, 0);
|
||||
addShort( data, 0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package network.packets.swg.zone.building;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class UpdateCellPermissionMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xF612499C;
|
||||
|
||||
private byte permissionFlag;
|
||||
private long cellId;
|
||||
|
||||
public UpdateCellPermissionMessage() {
|
||||
permissionFlag = 0;
|
||||
cellId = 0;
|
||||
}
|
||||
|
||||
public UpdateCellPermissionMessage(byte permissionFlag, long cellId) {
|
||||
this.permissionFlag = permissionFlag;
|
||||
this.cellId = cellId;
|
||||
}
|
||||
|
||||
public UpdateCellPermissionMessage(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
permissionFlag = getByte(data);
|
||||
cellId = getLong(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(15);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addByte( data, permissionFlag);
|
||||
addLong( data, cellId);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getCellId() { return cellId; }
|
||||
public byte getPermissions() { return permissionFlag; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatDeletePersistentMessage extends SWGPacket {
|
||||
public static final int CRC = 0x8F251641;
|
||||
|
||||
private int mailId;
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
|
||||
mailId = getInt(data);
|
||||
}
|
||||
|
||||
public int getMailId() { return mailId; }
|
||||
}
|
||||
47
src/network/packets/swg/zone/chat/ChatFriendsListUpdate.java
Normal file
47
src/network/packets/swg/zone/chat/ChatFriendsListUpdate.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatFriendsListUpdate extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x6CD2FCD8;
|
||||
|
||||
private String galaxy;
|
||||
private String friendName;
|
||||
private boolean online;
|
||||
|
||||
public ChatFriendsListUpdate() {
|
||||
|
||||
}
|
||||
|
||||
public ChatFriendsListUpdate(String command) {
|
||||
|
||||
}
|
||||
|
||||
public ChatFriendsListUpdate(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
getAscii(data); // SWG
|
||||
galaxy = getAscii(data);
|
||||
friendName = getAscii(data);
|
||||
online = getBoolean(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort (data, 3);
|
||||
addInt (data, CRC);
|
||||
addAscii (data, "SWG");
|
||||
addAscii (data, galaxy);
|
||||
addAscii (data, friendName);
|
||||
addBoolean(data, online);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
86
src/network/packets/swg/zone/chat/ChatIgnoreList.java
Normal file
86
src/network/packets/swg/zone/chat/ChatIgnoreList.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatIgnoreList extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xF8C275B0;
|
||||
|
||||
private long objectId;
|
||||
private List <IgnoreListItem> ignoreList;
|
||||
|
||||
public ChatIgnoreList() {
|
||||
objectId = 0;
|
||||
ignoreList = new ArrayList<IgnoreListItem>();
|
||||
}
|
||||
|
||||
public ChatIgnoreList(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void addName(String game, String galaxy, String name) {
|
||||
addName(new IgnoreListItem(game, galaxy, name));
|
||||
}
|
||||
|
||||
public void addName(IgnoreListItem name) {
|
||||
ignoreList.add(name);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
objectId = getLong(data);
|
||||
int listCount = getInt(data);
|
||||
for (int i = 0; i < listCount; i++) {
|
||||
String game = getAscii(data);
|
||||
String galaxy = getAscii(data);
|
||||
String name = getAscii(data);
|
||||
addName(game, galaxy, name);
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int extraSize = 0;
|
||||
for (IgnoreListItem item : ignoreList)
|
||||
extraSize += 6 + item.getGame().length() + item.getGalaxy().length() + item.getName().length();
|
||||
ByteBuffer data = ByteBuffer.allocate(18 + extraSize);
|
||||
addShort (data, 3);
|
||||
addInt (data, CRC);
|
||||
addLong (data, objectId);
|
||||
addInt (data, ignoreList.size());
|
||||
for (IgnoreListItem item : ignoreList) {
|
||||
addAscii(data, item.getGame());
|
||||
addAscii(data, item.getGalaxy());
|
||||
addAscii(data, item.getName());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static class IgnoreListItem {
|
||||
private String game;
|
||||
private String galaxy;
|
||||
private String name;
|
||||
|
||||
public IgnoreListItem() {
|
||||
this("SWG", "", "");
|
||||
}
|
||||
|
||||
public IgnoreListItem(String game, String galaxy, String name) {
|
||||
this.game = game;
|
||||
this.galaxy = galaxy;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGame() { return game; }
|
||||
public String getGalaxy() { return galaxy; }
|
||||
public String getName() { return name; }
|
||||
public void setGame(String game) { this.game = game; }
|
||||
public void setGalaxy(String galaxy) { this.galaxy = galaxy; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatInstantMessageToCharacter extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x84BB21F7;
|
||||
|
||||
private String galaxy;
|
||||
private String character;
|
||||
private String message;
|
||||
private String outOfBand;
|
||||
private int sequence;
|
||||
|
||||
public ChatInstantMessageToCharacter() {
|
||||
this("", "", "", "", 0);
|
||||
}
|
||||
|
||||
public ChatInstantMessageToCharacter(String galaxy, String character, String message, int sequence) {
|
||||
this(galaxy, character, message, "", sequence);
|
||||
}
|
||||
|
||||
public ChatInstantMessageToCharacter(String galaxy, String character, String message, String outOfBand, int sequence) {
|
||||
this.galaxy = galaxy;
|
||||
this.character = character;
|
||||
this.message = message;
|
||||
this.outOfBand = outOfBand;
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public ChatInstantMessageToCharacter(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
getAscii(data);
|
||||
galaxy = getAscii(data);
|
||||
character = getAscii(data);
|
||||
message = getUnicode(data);
|
||||
outOfBand = getUnicode(data);
|
||||
sequence = getInt(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(27 + galaxy.length() + character.length() + message.length()*2);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addAscii(data, "SWG");
|
||||
addAscii(data, galaxy);
|
||||
addAscii(data, character);
|
||||
addUnicode(data, message);
|
||||
addUnicode(data, outOfBand);
|
||||
addInt (data, sequence);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getGalaxy() { return galaxy; }
|
||||
public String getCharacter() { return character; }
|
||||
public String getMessage() { return message; }
|
||||
public String getOutOfBand() { return outOfBand; }
|
||||
public int getSequence() { return sequence; }
|
||||
|
||||
public void setGalaxy(String galaxy) { this.galaxy = galaxy; }
|
||||
public void setCharacter(String character) { this.character = character; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
public void setOutOfBand(String outOfBand) { this.outOfBand = outOfBand; }
|
||||
public void setSequence(int sequence) { this.sequence = sequence; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatInstantMessageToClient extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x3C565CED;
|
||||
|
||||
private String galaxy;
|
||||
private String character;
|
||||
private String message;
|
||||
private String outOfBand;
|
||||
|
||||
public ChatInstantMessageToClient() {
|
||||
this("", "", "", "");
|
||||
}
|
||||
|
||||
public ChatInstantMessageToClient(String galaxy, String character, String message) {
|
||||
this(galaxy, character, message, "");
|
||||
}
|
||||
|
||||
public ChatInstantMessageToClient(String galaxy, String character, String message, String outOfBand) {
|
||||
this.galaxy = galaxy;
|
||||
this.character = character;
|
||||
this.message = message;
|
||||
this.outOfBand = outOfBand;
|
||||
}
|
||||
|
||||
public ChatInstantMessageToClient(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
getAscii(data); // "SWG"
|
||||
galaxy = getAscii(data);
|
||||
character = getAscii(data);
|
||||
message = getUnicode(data);
|
||||
outOfBand = getUnicode(data);
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(23 + galaxy.length() + character.length() + message.length()*2 + outOfBand.length()*2);
|
||||
addShort(data, 2);
|
||||
addInt( data, CRC);
|
||||
addAscii(data, "SWG");
|
||||
addAscii(data, galaxy);
|
||||
addAscii(data, character);
|
||||
addUnicode(data, message);
|
||||
addUnicode(data, outOfBand);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getGalaxy() { return galaxy; }
|
||||
public String getCharacter() { return character; }
|
||||
public String getMessage() { return message; }
|
||||
public String getOutOfBand() { return outOfBand; }
|
||||
|
||||
public void setGalaxy(String galaxy) { this.galaxy = galaxy; }
|
||||
public void setCharacter(String character) { this.character = character; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
public void setOutOfBand(String outOfBand) { this.outOfBand = outOfBand; }
|
||||
|
||||
}
|
||||
35
src/network/packets/swg/zone/chat/ChatOnConnectAvatar.java
Normal file
35
src/network/packets/swg/zone/chat/ChatOnConnectAvatar.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package network.packets.swg.zone.chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import network.packets.swg.SWGPacket;
|
||||
|
||||
public class ChatOnConnectAvatar extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0xD72FE9BE;
|
||||
|
||||
public ChatOnConnectAvatar() {
|
||||
|
||||
}
|
||||
|
||||
public ChatOnConnectAvatar(String command) {
|
||||
|
||||
}
|
||||
|
||||
public ChatOnConnectAvatar(ByteBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public void decode(ByteBuffer data) {
|
||||
if (!super.decode(data, CRC))
|
||||
return;
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
ByteBuffer data = ByteBuffer.allocate(6);
|
||||
addShort(data, 2);
|
||||
addInt (data, CRC);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user