Various net crashes fixed

This commit is contained in:
Anuken 2018-07-03 13:13:02 -04:00
parent 3597860074
commit 4a626bc920
5 changed files with 12 additions and 4 deletions

View file

@ -169,7 +169,7 @@ public class NetServer extends Module{
NetConnection connection = Net.getConnection(id);
if(player == null || connection == null || packet.snapid < connection.lastRecievedClientSnapshot) return;
boolean verifyPosition = !player.isDead() && !debug && headless && !player.isMobile;
boolean verifyPosition = !player.isDead() && !debug && headless && !player.mech.flying;
if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = TimeUtils.millis() - 16;

View file

@ -99,7 +99,9 @@ public interface BuilderTrait {
/**Return the build requests currently active, or the one at the top of the queue.
* May return null.*/
default BuildRequest getCurrentRequest(){
return getPlaceQueue().size == 0 ? null : getPlaceQueue().first();
synchronized (getPlaceQueue()) {
return getPlaceQueue().size == 0 ? null : getPlaceQueue().first();
}
}
/**Update building mechanism for this unit.

View file

@ -279,10 +279,12 @@ public abstract class InputHandler extends InputAdapter{
@Remote(targets = Loc.both, forward = true, called = Loc.server, in = In.blocks)
public static void transferInventory(Player player, Tile tile){
if(Net.server() && (!player.inventory.hasItem() || player.isTransferring)){
if(Net.server() && (!player.inventory.hasItem() || player.isTransferring)) {
throw new ValidateException(player, "Player cannot transfer an item.");
}
if(player == null) return;
player.isTransferring = true;
ItemStack stack = player.inventory.getItem();

View file

@ -163,6 +163,8 @@ public class Weapon extends Upgrade {
AmmoType type = shooter.getInventory().getAmmo();
if(type == null) return;
weapon.tr.trns(rotation + 180f, type.recoil);
shooter.getVelocity().add(weapon.tr);

View file

@ -151,7 +151,7 @@ public class BuildBlock extends Block {
@Remote(called = Loc.server, in = In.blocks)
public static void onBuildFinish(Tile tile, Player lastBuilder){
if(tile.entity == null) return;
if(tile.entity == null || !(tile.entity instanceof BuildEntity)) return;
BuildEntity entity = tile.entity();
Team team = tile.getTeam();
@ -179,6 +179,8 @@ public class BuildBlock extends Block {
@Remote(called = Loc.server, targets = Loc.both, in = In.blocks, forward = true)
public static void onBuildDeselect(Player player){
if(player == null) return;
player.getPlaceQueue().clear();
}