Appended P to sync component tables to remove need to fully qualify packet tables against components

This commit is contained in:
Collin Smith 2019-12-22 00:32:45 -08:00
parent 3860283e61
commit cbec965eb1
13 changed files with 240 additions and 191 deletions

View File

@ -8,28 +8,28 @@ import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Velocity extends Table {
public static Velocity getRootAsVelocity(ByteBuffer _bb) { return getRootAsVelocity(_bb, new Velocity()); }
public static Velocity getRootAsVelocity(ByteBuffer _bb, Velocity obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class AngleP extends Table {
public static AngleP getRootAsAngleP(ByteBuffer _bb) { return getRootAsAngleP(_bb, new AngleP()); }
public static AngleP getRootAsAngleP(ByteBuffer _bb, AngleP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public Velocity __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public AngleP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public float x() { int o = __offset(4); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
public float y() { int o = __offset(6); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
public static int createVelocity(FlatBufferBuilder builder,
public static int createAngleP(FlatBufferBuilder builder,
float x,
float y) {
builder.startObject(2);
Velocity.addY(builder, y);
Velocity.addX(builder, x);
return Velocity.endVelocity(builder);
AngleP.addY(builder, y);
AngleP.addX(builder, x);
return AngleP.endAngleP(builder);
}
public static void startVelocity(FlatBufferBuilder builder) { builder.startObject(2); }
public static void startAngleP(FlatBufferBuilder builder) { builder.startObject(2); }
public static void addX(FlatBufferBuilder builder, float x) { builder.addFloat(0, x, 0.0f); }
public static void addY(FlatBufferBuilder builder, float y) { builder.addFloat(1, y, 0.0f); }
public static int endVelocity(FlatBufferBuilder builder) {
public static int endAngleP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -9,24 +9,24 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Class extends Table {
public static Class getRootAsClass(ByteBuffer _bb) { return getRootAsClass(_bb, new Class()); }
public static Class getRootAsClass(ByteBuffer _bb, Class obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class ClassP extends Table {
public static ClassP getRootAsClassP(ByteBuffer _bb) { return getRootAsClassP(_bb, new ClassP()); }
public static ClassP getRootAsClassP(ByteBuffer _bb, ClassP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public Class __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public ClassP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int type() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; }
public static int createClass(FlatBufferBuilder builder,
public static int createClassP(FlatBufferBuilder builder,
int type) {
builder.startObject(1);
Class.addType(builder, type);
return Class.endClass(builder);
ClassP.addType(builder, type);
return ClassP.endClassP(builder);
}
public static void startClass(FlatBufferBuilder builder) { builder.startObject(1); }
public static void startClassP(FlatBufferBuilder builder) { builder.startObject(1); }
public static void addType(FlatBufferBuilder builder, int type) { builder.addByte(0, (byte)type, (byte)0); }
public static int endClass(FlatBufferBuilder builder) {
public static int endClassP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -8,29 +8,29 @@ import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class CofAlphas extends Table {
public static CofAlphas getRootAsCofAlphas(ByteBuffer _bb) { return getRootAsCofAlphas(_bb, new CofAlphas()); }
public static CofAlphas getRootAsCofAlphas(ByteBuffer _bb, CofAlphas obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class CofAlphasP extends Table {
public static CofAlphasP getRootAsCofAlphasP(ByteBuffer _bb) { return getRootAsCofAlphasP(_bb, new CofAlphasP()); }
public static CofAlphasP getRootAsCofAlphasP(ByteBuffer _bb, CofAlphasP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public CofAlphas __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public CofAlphasP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public float alpha(int j) { int o = __offset(4); return o != 0 ? bb.getFloat(__vector(o) + j * 4) : 0; }
public int alphaLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
public ByteBuffer alphaAsByteBuffer() { return __vector_as_bytebuffer(4, 4); }
public ByteBuffer alphaInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 4); }
public static int createCofAlphas(FlatBufferBuilder builder,
public static int createCofAlphasP(FlatBufferBuilder builder,
int alphaOffset) {
builder.startObject(1);
CofAlphas.addAlpha(builder, alphaOffset);
return CofAlphas.endCofAlphas(builder);
CofAlphasP.addAlpha(builder, alphaOffset);
return CofAlphasP.endCofAlphasP(builder);
}
public static void startCofAlphas(FlatBufferBuilder builder) { builder.startObject(1); }
public static void startCofAlphasP(FlatBufferBuilder builder) { builder.startObject(1); }
public static void addAlpha(FlatBufferBuilder builder, int alphaOffset) { builder.addOffset(0, alphaOffset, 0); }
public static int createAlphaVector(FlatBufferBuilder builder, float[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addFloat(data[i]); return builder.endVector(); }
public static void startAlphaVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
public static int endCofAlphas(FlatBufferBuilder builder) {
public static int endCofAlphasP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -8,29 +8,29 @@ import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class CofComponents extends Table {
public static CofComponents getRootAsCofComponents(ByteBuffer _bb) { return getRootAsCofComponents(_bb, new CofComponents()); }
public static CofComponents getRootAsCofComponents(ByteBuffer _bb, CofComponents obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class CofComponentsP extends Table {
public static CofComponentsP getRootAsCofComponentsP(ByteBuffer _bb) { return getRootAsCofComponentsP(_bb, new CofComponentsP()); }
public static CofComponentsP getRootAsCofComponentsP(ByteBuffer _bb, CofComponentsP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public CofComponents __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public CofComponentsP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int component(int j) { int o = __offset(4); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int componentLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
public ByteBuffer componentAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
public ByteBuffer componentInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
public static int createCofComponents(FlatBufferBuilder builder,
public static int createCofComponentsP(FlatBufferBuilder builder,
int componentOffset) {
builder.startObject(1);
CofComponents.addComponent(builder, componentOffset);
return CofComponents.endCofComponents(builder);
CofComponentsP.addComponent(builder, componentOffset);
return CofComponentsP.endCofComponentsP(builder);
}
public static void startCofComponents(FlatBufferBuilder builder) { builder.startObject(1); }
public static void startCofComponentsP(FlatBufferBuilder builder) { builder.startObject(1); }
public static void addComponent(FlatBufferBuilder builder, int componentOffset) { builder.addOffset(0, componentOffset, 0); }
public static int createComponentVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); }
public static void startComponentVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
public static int endCofComponents(FlatBufferBuilder builder) {
public static int endCofComponentsP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -8,29 +8,29 @@ import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class CofTransforms extends Table {
public static CofTransforms getRootAsCofTransforms(ByteBuffer _bb) { return getRootAsCofTransforms(_bb, new CofTransforms()); }
public static CofTransforms getRootAsCofTransforms(ByteBuffer _bb, CofTransforms obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class CofTransformsP extends Table {
public static CofTransformsP getRootAsCofTransformsP(ByteBuffer _bb) { return getRootAsCofTransformsP(_bb, new CofTransformsP()); }
public static CofTransformsP getRootAsCofTransformsP(ByteBuffer _bb, CofTransformsP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public CofTransforms __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public CofTransformsP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int transform(int j) { int o = __offset(4); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int transformLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
public ByteBuffer transformAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
public ByteBuffer transformInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
public static int createCofTransforms(FlatBufferBuilder builder,
public static int createCofTransformsP(FlatBufferBuilder builder,
int transformOffset) {
builder.startObject(1);
CofTransforms.addTransform(builder, transformOffset);
return CofTransforms.endCofTransforms(builder);
CofTransformsP.addTransform(builder, transformOffset);
return CofTransformsP.endCofTransformsP(builder);
}
public static void startCofTransforms(FlatBufferBuilder builder) { builder.startObject(1); }
public static void startCofTransformsP(FlatBufferBuilder builder) { builder.startObject(1); }
public static void addTransform(FlatBufferBuilder builder, int transformOffset) { builder.addOffset(0, transformOffset, 0); }
public static int createTransformVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); }
public static void startTransformVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
public static int endCofTransforms(FlatBufferBuilder builder) {
public static int endCofTransformsP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -2,37 +2,36 @@
package com.riiablo.net.packet.d2gs;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Player extends Table {
public static Player getRootAsPlayer(ByteBuffer _bb) { return getRootAsPlayer(_bb, new Player()); }
public static Player getRootAsPlayer(ByteBuffer _bb, Player obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class PlayerP extends Table {
public static PlayerP getRootAsPlayerP(ByteBuffer _bb) { return getRootAsPlayerP(_bb, new PlayerP()); }
public static PlayerP getRootAsPlayerP(ByteBuffer _bb, PlayerP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public Player __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public PlayerP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int charClass() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; }
public String charName() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer charNameAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
public ByteBuffer charNameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
public static int createPlayer(FlatBufferBuilder builder,
public static int createPlayerP(FlatBufferBuilder builder,
int charClass,
int charNameOffset) {
builder.startObject(2);
Player.addCharName(builder, charNameOffset);
Player.addCharClass(builder, charClass);
return Player.endPlayer(builder);
PlayerP.addCharName(builder, charNameOffset);
PlayerP.addCharClass(builder, charClass);
return PlayerP.endPlayerP(builder);
}
public static void startPlayer(FlatBufferBuilder builder) { builder.startObject(2); }
public static void startPlayerP(FlatBufferBuilder builder) { builder.startObject(2); }
public static void addCharClass(FlatBufferBuilder builder, int charClass) { builder.addByte(0, (byte)charClass, (byte)0); }
public static void addCharName(FlatBufferBuilder builder, int charNameOffset) { builder.addOffset(1, charNameOffset, 0); }
public static int endPlayer(FlatBufferBuilder builder) {
public static int endPlayerP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -8,28 +8,28 @@ import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Position extends Table {
public static Position getRootAsPosition(ByteBuffer _bb) { return getRootAsPosition(_bb, new Position()); }
public static Position getRootAsPosition(ByteBuffer _bb, Position obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class PositionP extends Table {
public static PositionP getRootAsPositionP(ByteBuffer _bb) { return getRootAsPositionP(_bb, new PositionP()); }
public static PositionP getRootAsPositionP(ByteBuffer _bb, PositionP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public Position __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public PositionP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public float x() { int o = __offset(4); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
public float y() { int o = __offset(6); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
public static int createPosition(FlatBufferBuilder builder,
public static int createPositionP(FlatBufferBuilder builder,
float x,
float y) {
builder.startObject(2);
Position.addY(builder, y);
Position.addX(builder, x);
return Position.endPosition(builder);
PositionP.addY(builder, y);
PositionP.addX(builder, x);
return PositionP.endPositionP(builder);
}
public static void startPosition(FlatBufferBuilder builder) { builder.startObject(2); }
public static void startPositionP(FlatBufferBuilder builder) { builder.startObject(2); }
public static void addX(FlatBufferBuilder builder, float x) { builder.addFloat(0, x, 0.0f); }
public static void addY(FlatBufferBuilder builder, float y) { builder.addFloat(1, y, 0.0f); }
public static int endPosition(FlatBufferBuilder builder) {
public static int endPositionP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -5,16 +5,16 @@ package com.riiablo.net.packet.d2gs;
public final class SyncData {
private SyncData() { }
public static final byte NONE = 0;
public static final byte Class = 1;
public static final byte CofComponents = 2;
public static final byte CofTransforms = 3;
public static final byte CofAlphas = 4;
public static final byte Position = 5;
public static final byte Velocity = 6;
public static final byte Angle = 7;
public static final byte Player = 8;
public static final byte ClassP = 1;
public static final byte CofComponentsP = 2;
public static final byte CofTransformsP = 3;
public static final byte CofAlphasP = 4;
public static final byte PositionP = 5;
public static final byte VelocityP = 6;
public static final byte AngleP = 7;
public static final byte PlayerP = 8;
public static final String[] names = { "NONE", "Class", "CofComponents", "CofTransforms", "CofAlphas", "Position", "Velocity", "Angle", "Player", };
public static final String[] names = { "NONE", "ClassP", "CofComponentsP", "CofTransformsP", "CofAlphasP", "PositionP", "VelocityP", "AngleP", "PlayerP", };
public static String name(int e) { return names[e]; }
}

View File

@ -9,28 +9,28 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Angle extends Table {
public static Angle getRootAsAngle(ByteBuffer _bb) { return getRootAsAngle(_bb, new Angle()); }
public static Angle getRootAsAngle(ByteBuffer _bb, Angle obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public final class VelocityP extends Table {
public static VelocityP getRootAsVelocityP(ByteBuffer _bb) { return getRootAsVelocityP(_bb, new VelocityP()); }
public static VelocityP getRootAsVelocityP(ByteBuffer _bb, VelocityP obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
public Angle __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public VelocityP __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public float x() { int o = __offset(4); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
public float y() { int o = __offset(6); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
public static int createAngle(FlatBufferBuilder builder,
public static int createVelocityP(FlatBufferBuilder builder,
float x,
float y) {
builder.startObject(2);
Angle.addY(builder, y);
Angle.addX(builder, x);
return Angle.endAngle(builder);
VelocityP.addY(builder, y);
VelocityP.addX(builder, x);
return VelocityP.endVelocityP(builder);
}
public static void startAngle(FlatBufferBuilder builder) { builder.startObject(2); }
public static void startVelocityP(FlatBufferBuilder builder) { builder.startObject(2); }
public static void addX(FlatBufferBuilder builder, float x) { builder.addFloat(0, x, 0.0f); }
public static void addY(FlatBufferBuilder builder, float y) { builder.addFloat(1, y, 0.0f); }
public static int endAngle(FlatBufferBuilder builder) {
public static int endVelocityP(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}

View File

@ -17,6 +17,7 @@ import com.riiablo.engine.EntityFactory;
import com.riiablo.engine.server.CofManager;
import com.riiablo.engine.server.component.Angle;
import com.riiablo.engine.server.component.Box2DBody;
import com.riiablo.engine.server.component.Class;
import com.riiablo.engine.server.component.CofAlphas;
import com.riiablo.engine.server.component.CofComponents;
import com.riiablo.engine.server.component.CofTransforms;
@ -25,12 +26,20 @@ import com.riiablo.engine.server.component.Player;
import com.riiablo.engine.server.component.Position;
import com.riiablo.engine.server.component.Velocity;
import com.riiablo.map.Map;
import com.riiablo.net.packet.d2gs.AngleP;
import com.riiablo.net.packet.d2gs.ClassP;
import com.riiablo.net.packet.d2gs.CofAlphasP;
import com.riiablo.net.packet.d2gs.CofComponentsP;
import com.riiablo.net.packet.d2gs.CofTransformsP;
import com.riiablo.net.packet.d2gs.Connection;
import com.riiablo.net.packet.d2gs.D2GS;
import com.riiablo.net.packet.d2gs.D2GSData;
import com.riiablo.net.packet.d2gs.Disconnect;
import com.riiablo.net.packet.d2gs.PlayerP;
import com.riiablo.net.packet.d2gs.PositionP;
import com.riiablo.net.packet.d2gs.Sync;
import com.riiablo.net.packet.d2gs.SyncData;
import com.riiablo.net.packet.d2gs.VelocityP;
import com.riiablo.util.ArrayUtils;
import com.riiablo.util.DebugUtils;
import com.riiablo.widget.TextArea;
@ -168,34 +177,60 @@ public class ClientNetworkReceiver extends IntervalSystem {
world.delete(entityId);
}
private com.riiablo.net.packet.d2gs.Player findPlayer(Sync s) {
private int findType(Sync s) {
for (int i = 0, len = s.dataTypeLength(); i < len; i++) {
if (s.dataType(i) == SyncData.Player) {
return (com.riiablo.net.packet.d2gs.Player) s.data(new com.riiablo.net.packet.d2gs.Player(), i);
if (s.dataType(i) == SyncData.ClassP) {
return ((ClassP) s.data(new ClassP(), i)).type();
}
}
return -1;
}
private PlayerP findPlayer(Sync s) {
for (int i = 0, len = s.dataTypeLength(); i < len; i++) {
if (s.dataType(i) == SyncData.PlayerP) {
return (PlayerP) s.data(new PlayerP(), i);
}
}
return null;
}
private void createEntity(Sync sync) {
assert syncIds.get(sync.entityId()) == Engine.INVALID_ENTITY;
Class.Type type = Class.Type.valueOf(findType(sync));
switch (type) {
case OBJ:
break;
case MON:
break;
case PLR: {
PlayerP player = findPlayer(sync);
CharData charData = new CharData().createD2S(player.charName(), CharacterClass.get(player.charClass()));
// TODO: assert entity id is player
// TODO: add support for other entity types
Vector2 origin = map.find(Map.ID.TOWN_ENTRY_1);
if (origin == null) origin = map.find(Map.ID.TOWN_ENTRY_2);
if (origin == null) origin = map.find(Map.ID.TP_LOCATION);
Map.Zone zone = map.getZone(origin);
int entityId = factory.createPlayer(map, zone, charData, origin);
syncIds.put(sync.entityId(), entityId);
cofs.setMode(entityId, Engine.Player.MODE_TN);
cofs.setWClass(entityId, Engine.WEAPON_1HS); // TODO...
break;
}
}
}
private void Synchronize(D2GS packet) {
Sync sync = (Sync) packet.data(new Sync());
int entityId = syncIds.get(sync.entityId());
if (entityId == Engine.INVALID_ENTITY) {
com.riiablo.net.packet.d2gs.Player player = findPlayer(sync);
CharData charData = new CharData().createD2S(player.charName(), CharacterClass.get(player.charClass()));
// TODO: assert entity id is player
// TODO: add support for other entity types
Vector2 origin = map.find(Map.ID.TOWN_ENTRY_1);
if (origin == null) origin = map.find(Map.ID.TOWN_ENTRY_2);
if (origin == null) origin = map.find(Map.ID.TP_LOCATION);
Map.Zone zone = map.getZone(origin);
entityId = factory.createPlayer(map, zone, charData, origin);
syncIds.put(sync.entityId(), entityId);
cofs.setMode(entityId, Engine.Player.MODE_TN);
cofs.setWClass(entityId, Engine.WEAPON_1HS); // TODO...
createEntity(sync);
}
int flags1 = Dirty.NONE;
@ -203,33 +238,33 @@ public class ClientNetworkReceiver extends IntervalSystem {
Gdx.app.log(TAG, "syncing " + entityId);
for (int i = 0, len = sync.dataTypeLength(); i < len; i++) {
switch (sync.dataType(i)) {
case SyncData.Class:
case SyncData.Player:
case SyncData.ClassP:
case SyncData.PlayerP:
break;
case SyncData.CofComponents: {
com.riiablo.net.packet.d2gs.CofComponents data = (com.riiablo.net.packet.d2gs.CofComponents) sync.data(new com.riiablo.net.packet.d2gs.CofComponents(), i);
case SyncData.CofComponentsP: {
CofComponentsP data = (CofComponentsP) sync.data(new CofComponentsP(), i);
for (int j = 0, s0 = data.componentLength(); j < s0; j++) {
cofs.setComponent(entityId, j, data.component(j));
}
break;
}
case SyncData.CofTransforms: {
com.riiablo.net.packet.d2gs.CofTransforms data = (com.riiablo.net.packet.d2gs.CofTransforms) sync.data(new com.riiablo.net.packet.d2gs.CofTransforms(), i);
case SyncData.CofTransformsP: {
CofTransformsP data = (CofTransformsP) sync.data(new CofTransformsP(), i);
for (int j = 0, s0 = data.transformLength(); j < s0; j++) {
flags1 |= cofs.setTransform(entityId, j, (byte) data.transform(j));
}
break;
}
case SyncData.CofAlphas: {
com.riiablo.net.packet.d2gs.CofAlphas data = (com.riiablo.net.packet.d2gs.CofAlphas) sync.data(new com.riiablo.net.packet.d2gs.CofAlphas(), i);
case SyncData.CofAlphasP: {
CofAlphasP data = (CofAlphasP) sync.data(new CofAlphasP(), i);
for (int j = 0, s0 = data.alphaLength(); j < s0; j++) {
flags2 |= cofs.setAlpha(entityId, j, data.alpha(j));
}
break;
}
case SyncData.Position: {
case SyncData.PositionP: {
Vector2 position = mPosition.get(entityId).position;
com.riiablo.net.packet.d2gs.Position data = (com.riiablo.net.packet.d2gs.Position) sync.data(new com.riiablo.net.packet.d2gs.Position(), i);
PositionP data = (PositionP) sync.data(new PositionP(), i);
position.x = data.x();
position.y = data.y();
Body body = mBox2DBody.get(entityId).body;
@ -237,17 +272,17 @@ public class ClientNetworkReceiver extends IntervalSystem {
//Gdx.app.log(TAG, " " + position);
break;
}
case SyncData.Velocity: {
case SyncData.VelocityP: {
Vector2 velocity = mVelocity.get(entityId).velocity;
com.riiablo.net.packet.d2gs.Velocity data = (com.riiablo.net.packet.d2gs.Velocity) sync.data(new com.riiablo.net.packet.d2gs.Velocity(), i);
VelocityP data = (VelocityP) sync.data(new VelocityP(), i);
velocity.x = data.x();
velocity.y = data.y();
//Gdx.app.log(TAG, " " + velocity);
break;
}
case SyncData.Angle: {
case SyncData.AngleP: {
Vector2 angle = mAngle.get(entityId).target;
com.riiablo.net.packet.d2gs.Angle data = (com.riiablo.net.packet.d2gs.Angle) sync.data(new com.riiablo.net.packet.d2gs.Angle(), i);
AngleP data = (AngleP) sync.data(new AngleP(), i);
angle.x = data.x();
angle.y = data.y();
//Gdx.app.log(TAG, " " + angle);

View File

@ -18,11 +18,17 @@ import com.riiablo.engine.server.component.CofTransforms;
import com.riiablo.engine.server.component.Networked;
import com.riiablo.engine.server.component.Position;
import com.riiablo.engine.server.component.Velocity;
import com.riiablo.net.packet.d2gs.AngleP;
import com.riiablo.net.packet.d2gs.CofAlphasP;
import com.riiablo.net.packet.d2gs.CofComponentsP;
import com.riiablo.net.packet.d2gs.CofTransformsP;
import com.riiablo.net.packet.d2gs.Connection;
import com.riiablo.net.packet.d2gs.D2GS;
import com.riiablo.net.packet.d2gs.D2GSData;
import com.riiablo.net.packet.d2gs.PositionP;
import com.riiablo.net.packet.d2gs.Sync;
import com.riiablo.net.packet.d2gs.SyncData;
import com.riiablo.net.packet.d2gs.VelocityP;
import java.io.OutputStream;
import java.nio.ByteBuffer;
@ -128,26 +134,26 @@ public class ClientNetworkSyncronizer extends IntervalSystem {
Vector2 velocity = mVelocity.get(entityId).velocity;
Vector2 angle = mAngle.get(entityId).target;
int cofComponents = com.riiablo.net.packet.d2gs.CofComponents.createComponentVector(builder, component);
int cofTransforms = com.riiablo.net.packet.d2gs.CofTransforms.createTransformVector(builder, transform);
int cofAlphas = com.riiablo.net.packet.d2gs.CofAlphas.createAlphaVector(builder, alpha);
int cofComponents = CofComponentsP.createComponentVector(builder, component);
int cofTransforms = CofTransformsP.createTransformVector(builder, transform);
int cofAlphas = CofAlphasP.createAlphaVector(builder, alpha);
byte[] dataTypes = new byte[6];
dataTypes[0] = SyncData.CofComponents;
dataTypes[1] = SyncData.CofTransforms;
dataTypes[2] = SyncData.CofAlphas;
dataTypes[3] = SyncData.Position;
dataTypes[4] = SyncData.Velocity;
dataTypes[5] = SyncData.Angle;
dataTypes[0] = SyncData.CofComponentsP;
dataTypes[1] = SyncData.CofTransformsP;
dataTypes[2] = SyncData.CofAlphasP;
dataTypes[3] = SyncData.PositionP;
dataTypes[4] = SyncData.VelocityP;
dataTypes[5] = SyncData.AngleP;
int dataTypesOffset = Sync.createDataTypeVector(builder, dataTypes);
int[] data = new int[6];
data[0] = com.riiablo.net.packet.d2gs.CofComponents.createCofComponents(builder, cofComponents);
data[1] = com.riiablo.net.packet.d2gs.CofTransforms.createCofTransforms(builder, cofTransforms);
data[2] = com.riiablo.net.packet.d2gs.CofAlphas.createCofAlphas(builder, cofAlphas);
data[3] = com.riiablo.net.packet.d2gs.Position.createPosition(builder, position.x, position.y);
data[4] = com.riiablo.net.packet.d2gs.Velocity.createVelocity(builder, velocity.x, velocity.y);
data[5] = com.riiablo.net.packet.d2gs.Angle.createAngle(builder, angle.x, angle.y);
data[0] = CofComponentsP.createCofComponentsP(builder, cofComponents);
data[1] = CofTransformsP.createCofTransformsP(builder, cofTransforms);
data[2] = CofAlphasP.createCofAlphasP(builder, cofAlphas);
data[3] = PositionP.createPositionP(builder, position.x, position.y);
data[4] = VelocityP.createVelocityP(builder, velocity.x, velocity.y);
data[5] = AngleP.createAngleP(builder, angle.x, angle.y);
int dataOffset = Sync.createDataVector(builder, data);
Sync.startSync(builder);
@ -157,7 +163,7 @@ public class ClientNetworkSyncronizer extends IntervalSystem {
int syncOffset = Sync.endSync(builder);
//int syncOffset = Sync.createSync(builder, entityId, dataTypesOffset, dataOffset);
int root = com.riiablo.net.packet.d2gs.D2GS.createD2GS(builder, D2GSData.Sync, syncOffset);
int root = D2GS.createD2GS(builder, D2GSData.Sync, syncOffset);
builder.finish(root);
try {

View File

@ -1,14 +1,14 @@
namespace com.riiablo.net.packet.d2gs;
union SyncData {
Class,
CofComponents,
CofTransforms,
CofAlphas,
Position,
Velocity,
Angle,
Player,
ClassP,
CofComponentsP,
CofTransformsP,
CofAlphasP,
PositionP,
VelocityP,
AngleP,
PlayerP,
}
table Sync {
@ -16,38 +16,38 @@ table Sync {
data:[SyncData];
}
table Class {
table ClassP {
type:uint8;
}
table CofComponents {
table CofComponentsP {
component:[uint8];
}
table CofTransforms {
table CofTransformsP {
transform:[uint8];
}
table CofAlphas {
table CofAlphasP {
alpha:[float32];
}
table Position {
table PositionP {
x:float32;
y:float32;
}
table Velocity {
table VelocityP {
x:float32;
y:float32;
}
table Angle {
table AngleP {
x:float32;
y:float32;
}
table Player {
table PlayerP {
charClass:uint8;
charName:string;
}

View File

@ -20,9 +20,18 @@ import com.riiablo.engine.server.component.Networked;
import com.riiablo.engine.server.component.Player;
import com.riiablo.engine.server.component.Position;
import com.riiablo.engine.server.component.Velocity;
import com.riiablo.net.packet.d2gs.D2GS;
import com.riiablo.net.packet.d2gs.AngleP;
import com.riiablo.net.packet.d2gs.ClassP;
import com.riiablo.net.packet.d2gs.CofAlphasP;
import com.riiablo.net.packet.d2gs.CofComponentsP;
import com.riiablo.net.packet.d2gs.CofTransformsP;
import com.riiablo.net.packet.d2gs.D2GSData;
import com.riiablo.net.packet.d2gs.PlayerP;
import com.riiablo.net.packet.d2gs.PositionP;
import com.riiablo.net.packet.d2gs.Sync;
import com.riiablo.net.packet.d2gs.SyncData;
import com.riiablo.net.packet.d2gs.VelocityP;
import com.riiablo.util.ArrayUtils;
import com.riiablo.util.DebugUtils;
@ -48,34 +57,34 @@ public class NetworkSynchronizer extends IteratingSystem {
protected BlockingQueue<com.riiablo.server.d2gs.D2GS.Packet> outPackets;
@Wire(name = "player")
protected IntIntMap player;
protected IntIntMap players;
@Override
protected void process(int entityId) {
com.riiablo.net.packet.d2gs.D2GS sync = sync(entityId);
int id = player.findKey(entityId, -1);
D2GS sync = sync(entityId);
int id = players.findKey(entityId, -1);
assert id != -1;
boolean success = outPackets.offer(D2GS.Packet.obtain(~(1 << id), sync));
boolean success = outPackets.offer(com.riiablo.server.d2gs.D2GS.Packet.obtain(~(1 << id), sync));
assert success;
}
public com.riiablo.net.packet.d2gs.D2GS sync(int entityId) {
public D2GS sync(int entityId) {
FlatBufferBuilder builder = new FlatBufferBuilder(0);
int[] component2 = mCofComponents.get(entityId).component;
byte[] component = new byte[16];
for (int i = 0; i < 16; i++) component[i] = (byte) component2[i];
int componentOffset = com.riiablo.net.packet.d2gs.CofComponents.createComponentVector(builder, component);
int cofComponents = com.riiablo.net.packet.d2gs.CofComponents.createCofComponents(builder, componentOffset);
int componentOffset = CofComponentsP.createComponentVector(builder, component);
int cofComponents = CofComponentsP.createCofComponentsP(builder, componentOffset);
byte[] transform = mCofTransforms.get(entityId).transform;
int transformOffset = com.riiablo.net.packet.d2gs.CofTransforms.createTransformVector(builder, transform);
int cofTransforms = com.riiablo.net.packet.d2gs.CofTransforms.createCofTransforms(builder, transformOffset);
int transformOffset = CofTransformsP.createTransformVector(builder, transform);
int cofTransforms = CofTransformsP.createCofTransformsP(builder, transformOffset);
float[] alpha = mCofAlphas.get(entityId).alpha;
int alphaOffset = com.riiablo.net.packet.d2gs.CofAlphas.createAlphaVector(builder, alpha);
int cofAlphas = com.riiablo.net.packet.d2gs.CofAlphas.createCofAlphas(builder, alphaOffset);
int alphaOffset = CofAlphasP.createAlphaVector(builder, alpha);
int cofAlphas = CofAlphasP.createCofAlphasP(builder, alphaOffset);
Vector2 position = mPosition.get(entityId).position;
Vector2 velocity = mVelocity.get(entityId).velocity;
@ -85,25 +94,25 @@ public class NetworkSynchronizer extends IteratingSystem {
int charNameOffset = builder.createString(charData.getD2S().header.name);
byte[] dataTypes = new byte[8];
dataTypes[0] = SyncData.Class;
dataTypes[1] = SyncData.CofComponents;
dataTypes[2] = SyncData.CofTransforms;
dataTypes[3] = SyncData.CofAlphas;
dataTypes[4] = SyncData.Position;
dataTypes[5] = SyncData.Velocity;
dataTypes[6] = SyncData.Angle;
dataTypes[7] = SyncData.Player;
dataTypes[0] = SyncData.ClassP;
dataTypes[1] = SyncData.CofComponentsP;
dataTypes[2] = SyncData.CofTransformsP;
dataTypes[3] = SyncData.CofAlphasP;
dataTypes[4] = SyncData.PositionP;
dataTypes[5] = SyncData.VelocityP;
dataTypes[6] = SyncData.AngleP;
dataTypes[7] = SyncData.PlayerP;
int dataTypesOffset = Sync.createDataTypeVector(builder, dataTypes);
int[] data = new int[8];
data[0] = com.riiablo.net.packet.d2gs.Class.createClass(builder, mClass.get(entityId).type.ordinal());
data[0] = ClassP.createClassP(builder, mClass.get(entityId).type.ordinal());
data[1] = cofComponents;
data[2] = cofTransforms;
data[3] = cofAlphas;
data[4] = com.riiablo.net.packet.d2gs.Position.createPosition(builder, position.x, position.y);
data[5] = com.riiablo.net.packet.d2gs.Velocity.createVelocity(builder, velocity.x, velocity.y);
data[6] = com.riiablo.net.packet.d2gs.Angle.createAngle(builder, angle.x, angle.y);
data[7] = com.riiablo.net.packet.d2gs.Player.createPlayer(builder, charData.getD2S().header.charClass, charNameOffset);
data[4] = PositionP.createPositionP(builder, position.x, position.y);
data[5] = VelocityP.createVelocityP(builder, velocity.x, velocity.y);
data[6] = AngleP.createAngleP(builder, angle.x, angle.y);
data[7] = PlayerP.createPlayerP(builder, charData.getD2S().header.charClass, charNameOffset);
int dataOffset = Sync.createDataVector(builder, data);
Sync.startSync(builder);
@ -111,61 +120,61 @@ public class NetworkSynchronizer extends IteratingSystem {
Sync.addDataType(builder, dataTypesOffset);
Sync.addData(builder, dataOffset);
int syncOffset = Sync.endSync(builder);
int root = com.riiablo.net.packet.d2gs.D2GS.createD2GS(builder, D2GSData.Sync, syncOffset);
int root = D2GS.createD2GS(builder, D2GSData.Sync, syncOffset);
builder.finish(root);
return com.riiablo.net.packet.d2gs.D2GS.getRootAsD2GS(builder.dataBuffer());
return D2GS.getRootAsD2GS(builder.dataBuffer());
}
public void sync(int entityId, Sync sync) {
Gdx.app.log(TAG, "syncing " + entityId);
for (int i = 0, len = sync.dataTypeLength(); i < len; i++) {
switch (sync.dataType(i)) {
case SyncData.CofComponents: {
case SyncData.CofComponentsP: {
int[] component = mCofComponents.get(entityId).component;
com.riiablo.net.packet.d2gs.CofComponents data = (com.riiablo.net.packet.d2gs.CofComponents) sync.data(new com.riiablo.net.packet.d2gs.CofComponents(), i);
CofComponentsP data = (CofComponentsP) sync.data(new CofComponentsP(), i);
for (int j = 0, s = data.componentLength(); j < s; j++) {
component[j] = data.component(j);
}
Gdx.app.log(TAG, " " + DebugUtils.toByteArray(ArrayUtils.toByteArray(component)));
break;
}
case SyncData.CofTransforms: {
case SyncData.CofTransformsP: {
byte[] transform = mCofTransforms.get(entityId).transform;
com.riiablo.net.packet.d2gs.CofTransforms data = (com.riiablo.net.packet.d2gs.CofTransforms) sync.data(new com.riiablo.net.packet.d2gs.CofTransforms(), i);
CofTransformsP data = (CofTransformsP) sync.data(new CofTransformsP(), i);
for (int j = 0, s = data.transformLength(); j < s; j++) {
transform[j] = (byte) data.transform(j);
}
Gdx.app.log(TAG, " " + DebugUtils.toByteArray(transform));
break;
}
case SyncData.CofAlphas: {
case SyncData.CofAlphasP: {
float[] alpha = mCofAlphas.get(entityId).alpha;
com.riiablo.net.packet.d2gs.CofAlphas data = (com.riiablo.net.packet.d2gs.CofAlphas) sync.data(new com.riiablo.net.packet.d2gs.CofAlphas(), i);
CofAlphasP data = (CofAlphasP) sync.data(new CofAlphasP(), i);
for (int j = 0, s = data.alphaLength(); j < s; j++) {
alpha[j] = data.alpha(j);
}
Gdx.app.log(TAG, " " + Arrays.toString(alpha));
break;
}
case SyncData.Position: {
case SyncData.PositionP: {
Vector2 position = mPosition.get(entityId).position;
com.riiablo.net.packet.d2gs.Position data = (com.riiablo.net.packet.d2gs.Position) sync.data(new com.riiablo.net.packet.d2gs.Position(), i);
PositionP data = (PositionP) sync.data(new PositionP(), i);
position.x = data.x();
position.y = data.y();
Gdx.app.log(TAG, " " + position);
break;
}
case SyncData.Velocity: {
case SyncData.VelocityP: {
Vector2 velocity = mVelocity.get(entityId).velocity;
com.riiablo.net.packet.d2gs.Velocity data = (com.riiablo.net.packet.d2gs.Velocity) sync.data(new com.riiablo.net.packet.d2gs.Velocity(), i);
VelocityP data = (VelocityP) sync.data(new VelocityP(), i);
velocity.x = data.x();
velocity.y = data.y();
Gdx.app.log(TAG, " " + velocity);
break;
}
case SyncData.Angle: {
case SyncData.AngleP: {
Vector2 angle = mAngle.get(entityId).target;
com.riiablo.net.packet.d2gs.Angle data = (com.riiablo.net.packet.d2gs.Angle) sync.data(new com.riiablo.net.packet.d2gs.Angle(), i);
AngleP data = (AngleP) sync.data(new AngleP(), i);
angle.x = data.x();
angle.y = data.y();
Gdx.app.log(TAG, " " + angle);