mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-04 15:27:30 +07:00
Moved D2GS.Packet to separate Packet class
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
package com.riiablo.server.d2gs;
|
||||
|
||||
import com.google.flatbuffers.ByteBufferUtil;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
|
||||
import com.artemis.ComponentMapper;
|
||||
@ -531,18 +530,4 @@ public class D2GS extends ApplicationAdapter {
|
||||
Disconnect(id);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Packet {
|
||||
public int id;
|
||||
public ByteBuffer buffer;
|
||||
public com.riiablo.net.packet.d2gs.D2GS data;
|
||||
|
||||
public static Packet obtain(int id, ByteBuffer buffer) {
|
||||
Packet packet = new Packet();
|
||||
packet.id = id;
|
||||
packet.buffer = buffer;
|
||||
packet.data = com.riiablo.net.packet.d2gs.D2GS.getRootAsD2GS(ByteBufferUtil.removeSizePrefix(buffer));
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class NetworkSynchronizer extends IteratingSystem {
|
||||
protected SerializationManager serializer;
|
||||
|
||||
@Wire(name = "outPackets")
|
||||
protected BlockingQueue<com.riiablo.server.d2gs.D2GS.Packet> outPackets;
|
||||
protected BlockingQueue<Packet> outPackets;
|
||||
|
||||
@Wire(name = "player")
|
||||
protected IntIntMap players;
|
||||
@ -36,8 +36,8 @@ public class NetworkSynchronizer extends IteratingSystem {
|
||||
protected void process(int entityId) {
|
||||
ByteBuffer sync = sync(entityId);
|
||||
int id = players.findKey(entityId, -1);
|
||||
boolean success = outPackets.offer(com.riiablo.server.d2gs.D2GS.Packet
|
||||
.obtain(id != -1 ? ~(1 << id) : 0xFFFFFFFF, sync));
|
||||
Packet packet = Packet.obtain(id != -1 ? ~(1 << id) : 0xFFFFFFFF, sync);
|
||||
boolean success = outPackets.offer(packet);
|
||||
assert success;
|
||||
}
|
||||
|
||||
|
21
server/d2gs/src/com/riiablo/server/d2gs/Packet.java
Normal file
21
server/d2gs/src/com/riiablo/server/d2gs/Packet.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.riiablo.server.d2gs;
|
||||
|
||||
import com.google.flatbuffers.ByteBufferUtil;
|
||||
|
||||
import com.riiablo.net.packet.d2gs.D2GS;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class Packet {
|
||||
public int id;
|
||||
public ByteBuffer buffer;
|
||||
public D2GS data;
|
||||
|
||||
public static Packet obtain(int id, ByteBuffer buffer) {
|
||||
Packet packet = new Packet();
|
||||
packet.id = id;
|
||||
packet.buffer = buffer;
|
||||
packet.data = D2GS.getRootAsD2GS(ByteBufferUtil.removeSizePrefix(buffer));
|
||||
return packet;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user