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); NetConnection connection = Net.getConnection(id);
if(player == null || connection == null || packet.snapid < connection.lastRecievedClientSnapshot) return; 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; if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = TimeUtils.millis() - 16;

View File

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

View File

@@ -283,6 +283,8 @@ public abstract class InputHandler extends InputAdapter{
throw new ValidateException(player, "Player cannot transfer an item."); throw new ValidateException(player, "Player cannot transfer an item.");
} }
if(player == null) return;
player.isTransferring = true; player.isTransferring = true;
ItemStack stack = player.inventory.getItem(); ItemStack stack = player.inventory.getItem();

View File

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

View File

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