Turret ammo sync
This commit is contained in:
@@ -478,7 +478,7 @@ public class NetClient implements ApplicationListener{
|
||||
Log.warn("Block ID mismatch at @: @ != @. Skipping block snapshot.", tile, tile.build.block.id, block);
|
||||
break;
|
||||
}
|
||||
tile.build.readAll(Reads.get(input), tile.build.version());
|
||||
tile.build.readSync(Reads.get(input), tile.build.version());
|
||||
}
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
|
||||
@@ -913,7 +913,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
dataStream.writeInt(entity.pos());
|
||||
dataStream.writeShort(entity.block.id);
|
||||
entity.writeAll(Writes.get(dataStream));
|
||||
entity.writeSync(Writes.get(dataStream));
|
||||
|
||||
if(syncStream.size() > maxSnapshotSize){
|
||||
dataStream.close();
|
||||
|
||||
@@ -261,6 +261,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
read(read, revision);
|
||||
}
|
||||
|
||||
public void writeSync(Writes write){
|
||||
writeAll(write);
|
||||
}
|
||||
|
||||
public void readSync(Reads read, byte revision){
|
||||
readAll(read, revision);
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
public void write(Writes write){
|
||||
//overriden by subclasses!
|
||||
|
||||
@@ -140,6 +140,7 @@ public class Turret extends ReloadTurret{
|
||||
quickRotate = false;
|
||||
outlinedIcon = 1;
|
||||
drawLiquidLight = false;
|
||||
sync = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -664,6 +665,17 @@ public class Turret extends ReloadTurret{
|
||||
public byte version(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSync(Reads read, byte revision){
|
||||
//maintain rotation and reload when syncing so clients don't see turrets snapping around
|
||||
float oldRot = rotation, oldReload = reloadCounter;
|
||||
|
||||
readAll(read, revision);
|
||||
|
||||
rotation = oldRot;
|
||||
reloadCounter = oldReload;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BulletEntry{
|
||||
|
||||
Reference in New Issue
Block a user