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);
|
Log.warn("Block ID mismatch at @: @ != @. Skipping block snapshot.", tile, tile.build.block.id, block);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tile.build.readAll(Reads.get(input), tile.build.version());
|
tile.build.readSync(Reads.get(input), tile.build.version());
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Log.err(e);
|
Log.err(e);
|
||||||
|
|||||||
@@ -913,7 +913,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
dataStream.writeInt(entity.pos());
|
dataStream.writeInt(entity.pos());
|
||||||
dataStream.writeShort(entity.block.id);
|
dataStream.writeShort(entity.block.id);
|
||||||
entity.writeAll(Writes.get(dataStream));
|
entity.writeSync(Writes.get(dataStream));
|
||||||
|
|
||||||
if(syncStream.size() > maxSnapshotSize){
|
if(syncStream.size() > maxSnapshotSize){
|
||||||
dataStream.close();
|
dataStream.close();
|
||||||
|
|||||||
@@ -261,6 +261,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
read(read, revision);
|
read(read, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeSync(Writes write){
|
||||||
|
writeAll(write);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readSync(Reads read, byte revision){
|
||||||
|
readAll(read, revision);
|
||||||
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void write(Writes write){
|
public void write(Writes write){
|
||||||
//overriden by subclasses!
|
//overriden by subclasses!
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ public class Turret extends ReloadTurret{
|
|||||||
quickRotate = false;
|
quickRotate = false;
|
||||||
outlinedIcon = 1;
|
outlinedIcon = 1;
|
||||||
drawLiquidLight = false;
|
drawLiquidLight = false;
|
||||||
|
sync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -664,6 +665,17 @@ public class Turret extends ReloadTurret{
|
|||||||
public byte version(){
|
public byte version(){
|
||||||
return 1;
|
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{
|
public static class BulletEntry{
|
||||||
|
|||||||
Reference in New Issue
Block a user