Fixed server NaN contamination
This commit is contained in:
@@ -527,6 +527,10 @@ public class NetServer implements ApplicationListener{
|
||||
public static void serverPacketUnreliable(Player player, String type, String contents){
|
||||
serverPacketReliable(player, type, contents);
|
||||
}
|
||||
|
||||
private static boolean invalid(float f){
|
||||
return Float.isInfinite(f) || Float.isNaN(f);
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.client, unreliable = true)
|
||||
public static void clientSnapshot(
|
||||
@@ -545,6 +549,16 @@ public class NetServer implements ApplicationListener{
|
||||
NetConnection con = player.con;
|
||||
if(con == null || snapshotID < con.lastReceivedClientSnapshot) return;
|
||||
|
||||
//validate coordinates just in case
|
||||
if(invalid(x)) x = 0f;
|
||||
if(invalid(y)) y = 0f;
|
||||
if(invalid(xVelocity)) xVelocity = 0f;
|
||||
if(invalid(yVelocity)) yVelocity = 0f;
|
||||
if(invalid(pointerX)) pointerX = 0f;
|
||||
if(invalid(pointerY)) pointerY = 0f;
|
||||
if(invalid(rotation)) rotation = 0f;
|
||||
if(invalid(baseRotation)) baseRotation = 0f;
|
||||
|
||||
boolean verifyPosition = !player.dead() && netServer.admins.getStrict() && headless;
|
||||
|
||||
if(con.lastReceivedClientTime == 0) con.lastReceivedClientTime = Time.millis() - 16;
|
||||
|
||||
@@ -587,7 +587,7 @@ public class DesktopInput extends InputHandler{
|
||||
//limit speed to minimum formation speed to preserve formation
|
||||
if(unit instanceof Commanderc && ((Commanderc)unit).isCommanding()){
|
||||
//add a tiny multiplier to let units catch up just in case
|
||||
baseSpeed = ((Commanderc)unit).minFormationSpeed() * 0.98f;
|
||||
baseSpeed = ((Commanderc)unit).minFormationSpeed() * 0.95f;
|
||||
}
|
||||
|
||||
float speed = baseSpeed * Mathf.lerp(1f, unit.type().canBoost ? unit.type().boostMultiplier : 1f, unit.elevation) * strafePenalty;
|
||||
|
||||
Reference in New Issue
Block a user