More multiplayer fixes

This commit is contained in:
Anuken
2020-06-24 10:07:05 -04:00
parent d5c758c18a
commit b204074690
65 changed files with 75 additions and 7 deletions

View File

@@ -600,6 +600,8 @@ public class NetServer implements ApplicationListener{
if(!player.dead()){
Unitc unit = player.unit();
unit.vel().set(xVelocity, yVelocity).limit(unit.type().speed);
long elapsed = Time.timeSinceMillis(connection.lastRecievedClientTime);
float maxSpeed = player.dead() ? Float.MAX_VALUE : player.unit().type().speed;
float maxMove = elapsed / 1000f * 60f * maxSpeed * 1.1f;
@@ -652,10 +654,6 @@ public class NetServer implements ApplicationListener{
//read sync data so it can be used for interpolation for the server
unit.readSyncManual(fbuffer);
//TODO clients shouldn't care about velocities, so should it always just get set to 0? why even save it?
//[[ignore sent velocity values, set it to the delta movement vector instead]]
//unit.vel().set(vector);
}else{
player.x(x);
player.y(y);

View File

@@ -1,6 +1,7 @@
package mindustry.entities.comp;
import arc.func.*;
import arc.math.*;
import arc.math.geom.QuadTree.*;
import arc.math.geom.*;
import mindustry.annotations.Annotations.*;
@@ -48,6 +49,14 @@ abstract class HitboxComp implements Posc, QuadTreeObject{
return y - lastY;
}
float deltaLen(){
return Mathf.len(deltaX(), deltaY());
}
float deltaAngle(){
return Mathf.angle(deltaX(), deltaY());
}
boolean collides(Hitboxc other){
return true;
}

View File

@@ -12,8 +12,8 @@ abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, Elevati
@Override
public void update(){
float len = vel().len();
baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
float len = deltaLen();
baseRotation = Angles.moveToward(baseRotation, deltaAngle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
walkTime += Time.delta()*len;
}
}