Fixed more building desync

This commit is contained in:
Anuken
2018-06-29 09:15:07 -04:00
parent 499671a637
commit 0216425209
6 changed files with 14 additions and 7 deletions

View File

@@ -431,6 +431,7 @@ public class NetServer extends Module{
while(remaining > 0){ while(remaining > 0){
int used = Math.min(remaining, maxSnapshotSize); int used = Math.min(remaining, maxSnapshotSize);
byte[] toSend; byte[] toSend;
//re-use sent byte arrays when possible
if(used == maxSnapshotSize){ if(used == maxSnapshotSize){
toSend = reusableSnapArray; toSend = reusableSnapArray;
System.arraycopy(bytes, offset, toSend, 0, Math.min(offset + maxSnapshotSize, bytes.length) - offset); System.arraycopy(bytes, offset, toSend, 0, Math.min(offset + maxSnapshotSize, bytes.length) - offset);

View File

@@ -613,7 +613,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
if(lastShooting != isShooting){ if(lastShooting != isShooting){
CallEntity.setShooting(isShooting); CallEntity.setShooting(isShooting);
} }
}else if(isShooting()){ //desktop shooting, TODO }else if(isShooting()){
Vector2 vec = Graphics.world(Vars.control.input(playerIndex).getMouseX(), Vector2 vec = Graphics.world(Vars.control.input(playerIndex).getMouseX(),
Vars.control.input(playerIndex).getMouseY()); Vars.control.input(playerIndex).getMouseY());
pointerX = vec.x; pointerX = vec.x;

View File

@@ -22,7 +22,6 @@ public class DefaultKeybinds {
"select", Input.MOUSE_LEFT, "select", Input.MOUSE_LEFT,
"break", Input.MOUSE_RIGHT, "break", Input.MOUSE_RIGHT,
"shoot", Input.MOUSE_LEFT, "shoot", Input.MOUSE_LEFT,
"rotate_alt", new Axis(Input.R, Input.E),
"rotate", new Axis(Input.SCROLL), "rotate", new Axis(Input.SCROLL),
"dash", Input.SHIFT_LEFT, "dash", Input.SHIFT_LEFT,
"drop_unit", Input.SHIFT_LEFT, "drop_unit", Input.SHIFT_LEFT,

View File

@@ -102,7 +102,7 @@ public class Build {
Block previous = tile.block(); Block previous = tile.block();
//remote players only //remote players only
if(!player.isLocal){ if(player != null && !player.isLocal){
player.getPlaceQueue().clear(); player.getPlaceQueue().clear();
player.getPlaceQueue().addFirst(new BuildRequest(x, y, rotation, recipe)); player.getPlaceQueue().addFirst(new BuildRequest(x, y, rotation, recipe));
} }

View File

@@ -55,8 +55,7 @@ public class BreakBlock extends Block {
@Override @Override
public void tapped(Tile tile, Player player) { public void tapped(Tile tile, Player player) {
player.clearBuilding(); CallBlocks.onBreakSelect(player, tile);
player.addBuildRequest(new BuildRequest(tile.x, tile.y));
} }
@Override @Override
@@ -147,6 +146,14 @@ public class BreakBlock extends Block {
world.removeBlock(tile); world.removeBlock(tile);
} }
@Remote(called = Loc.both, targets = Loc.both, in = In.blocks, forward = true)
public static void onBreakSelect(Player player, Tile tile){
if(player == null || !(tile.entity instanceof BreakEntity)) return;
player.getPlaceQueue().clear();
player.addBuildRequest(new BuildRequest(tile.x, tile.y));
}
public class BreakEntity extends TileEntity{ public class BreakEntity extends TileEntity{
private double[] accumulator; private double[] accumulator;

View File

@@ -165,13 +165,13 @@ public class BuildBlock extends Block {
} }
} }
@Remote(called = Loc.server, targets = Loc.both, in = In.blocks, forward = true) @Remote(called = Loc.both, targets = Loc.both, in = In.blocks, forward = true)
public static void onBuildSelect(Player player, Tile tile){ public static void onBuildSelect(Player player, Tile tile){
if(player == null || !(tile.entity instanceof BuildEntity)) return; if(player == null || !(tile.entity instanceof BuildEntity)) return;
BuildEntity entity = tile.entity(); BuildEntity entity = tile.entity();
player.clearBuilding(); player.getPlaceQueue().clear();
player.addBuildRequest(new BuildRequest(tile.x, tile.y, tile.getRotation(), entity.recipe)); player.addBuildRequest(new BuildRequest(tile.x, tile.y, tile.getRotation(), entity.recipe));
} }