mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 14:01:03 -08:00
Turret ammo sync
This commit is contained in:
parent
afc8d5e396
commit
2f1f334d65
4 changed files with 22 additions and 2 deletions
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue