mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-03-03 22:21:53 +07:00
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:
parent
d3825290ee
commit
a49f73f6c4
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user