Added networking for object entities

Added networking for object entities
Casted cof component in flatbuffers to ensure they are sign extended properly (0xFF was not becoming 0xFFFFFFFF which is a special value)
Added additional check in CofManager#setComponent to ignore change if redundant
Increased output packet queue to 1024 -- will eventually group all sync packets into a single packet
This commit is contained in:
Collin Smith 2019-12-27 00:47:26 -08:00
parent d3825290ee
commit a49f73f6c4
5 changed files with 8 additions and 8 deletions

View File

@ -219,9 +219,8 @@ public class ClientNetworkReceiver extends IntervalSystem {
case OBJ: {
DS1ObjectWrapperP ds1ObjectWrapper = findTable(sync, SyncData.DS1ObjectWrapperP, new DS1ObjectWrapperP());
if (ds1ObjectWrapper != null) {
// String objectType = Riiablo.files.obj.getType1(ds1ObjectWrapper.act(), ds1ObjectWrapper.id());
// int entityId = factory.createObject(map, null, null, object, 0, 0);
// return entityId;
PositionP position = findTable(sync, SyncData.PositionP, new PositionP());
return factory.createObject(ds1ObjectWrapper.act(), ds1ObjectWrapper.type(), ds1ObjectWrapper.id(), position.x(), position.y());
}
return Engine.INVALID_ENTITY;
@ -232,8 +231,7 @@ public class ClientNetworkReceiver extends IntervalSystem {
PositionP position = findTable(sync, SyncData.PositionP, new PositionP());
String objectType = Riiablo.files.MonPreset.getPlace(ds1ObjectWrapper.act(), ds1ObjectWrapper.id());
MonStats.Entry monstats = Riiablo.files.monstats.get(objectType);
int entityId = factory.createMonster(monstats, position.x(), position.y());
return entityId;
return factory.createMonster(monstats, position.x(), position.y());
}
return Engine.INVALID_ENTITY;
@ -270,7 +268,7 @@ public class ClientNetworkReceiver extends IntervalSystem {
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));
cofs.setComponent(entityId, j, (byte) data.component(j));
}
break;
}

View File

@ -61,6 +61,7 @@ public class CofManager extends BaseEntitySystem {
public int setComponent(int id, int c, int code) {
int[] component = mCofComponents.get(id).component;
if (component[c] == code) return Dirty.NONE;
if (code == CofComponents.COMPONENT_NULL && component[c] == CofComponents.COMPONENT_LIT) return Dirty.NONE;
component[c] = code;
return mCofDirtyComponents.create(id).flags |= (1 << c);
}

View File

@ -151,7 +151,7 @@ public class SerializationManager extends PassiveSystem {
CofComponentsSerializer serializer = (CofComponentsSerializer) serializers.get(clazz);
CofComponentsP table = serializer.getTable(sync, i);
for (int j = 0, s = table.componentLength(); j < s; j++) {
cofs.setComponent(entityId, j, table.component(j));
cofs.setComponent(entityId, j, (byte) table.component(j));
}
// if (DEBUG_DESERIALIZE) Gdx.app.log(TAG, " " + DebugUtils.toByteArray(ArrayUtils.toByteArray(mCofComponents.get(entityId).component)));
break;

View File

@ -133,6 +133,7 @@ public class ServerEntityFactory extends EntityFactory {
}
mSize.create(id); // single size doesn't make any sense in this case because this is a rect
mNetworked.create(id);
return id;
}

View File

@ -150,7 +150,7 @@ public class D2GS extends ApplicationAdapter {
final BlockingQueue<Packet> packets = new ArrayBlockingQueue<>(32);
final Collection<Packet> cache = new ArrayList<>();
final BlockingQueue<Packet> outPackets = new ArrayBlockingQueue<>(32);
final BlockingQueue<Packet> outPackets = new ArrayBlockingQueue<>(1024);
final IntIntMap player = new IntIntMap();
FileHandle home;