Fixed jittery snapshots / Fixed misaligned unit bullets
This commit is contained in:
@@ -19,7 +19,7 @@ public class Interpolator{
|
||||
public void read(float cx, float cy, float x, float y, long sent, float... target1ds){
|
||||
if(lastUpdated != 0) updateSpacing = TimeUtils.timeSinceMillis(lastUpdated);
|
||||
|
||||
lastUpdated = sent;
|
||||
lastUpdated = TimeUtils.millis();
|
||||
|
||||
targets = target1ds;
|
||||
last.set(cx, cy);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import io.anuke.mindustry.net.Net.SendMode;
|
||||
|
||||
public abstract class NetConnection{
|
||||
@@ -10,24 +11,22 @@ public abstract class NetConnection{
|
||||
* The current base snapshot that the client is absolutely confirmed to have recieved.
|
||||
* All sent snapshots should be taking the diff from this base snapshot, if it isn't null.
|
||||
*/
|
||||
public byte[] currentBaseSnapshot;
|
||||
//public byte[] currentBaseSnapshot;
|
||||
/**
|
||||
* ID of the current base snapshot.
|
||||
*/
|
||||
public int currentBaseID = -1;
|
||||
// public int currentBaseID = -1;
|
||||
|
||||
public int lastSentBase = -1;
|
||||
public byte[] lastSentSnapshot;
|
||||
public byte[] lastSentRawSnapshot;
|
||||
//public int lastSentBase = -1;
|
||||
// public byte[] lastSentSnapshot;
|
||||
//public byte[] lastSentRawSnapshot;
|
||||
public int lastRecievedSnapshotID = -1;
|
||||
public int lastSentSnapshotID = -1;
|
||||
public IntMap<byte[]> sent = new IntMap<>();
|
||||
|
||||
/**
|
||||
* ID of last recieved client snapshot.
|
||||
*/
|
||||
/**ID of last recieved client snapshot.*/
|
||||
public int lastRecievedClientSnapshot = -1;
|
||||
/**
|
||||
* Timestamp of last recieved snapshot.
|
||||
*/
|
||||
/**Timestamp of last recieved snapshot.*/
|
||||
public long lastRecievedClientTime;
|
||||
|
||||
public boolean hasConnected = false;
|
||||
|
||||
@@ -155,7 +155,7 @@ public class Packets{
|
||||
//player snapshot data
|
||||
public float x, y, pointerX, pointerY, rotation, baseRotation, xv, yv;
|
||||
public Tile mining;
|
||||
public boolean boosting, shooting;
|
||||
public boolean boosting, shooting, alting;
|
||||
public Array<BuildRequest> requests = new Array<>();
|
||||
|
||||
@Override
|
||||
@@ -172,6 +172,7 @@ public class Packets{
|
||||
buffer.putFloat(player.pointerY);
|
||||
buffer.put(player.isBoosting ? (byte) 1 : 0);
|
||||
buffer.put(player.isShooting ? (byte) 1 : 0);
|
||||
buffer.put(player.isAlt ? (byte) 1 : 0);
|
||||
|
||||
buffer.put((byte) (Mathf.clamp(player.getVelocity().x, -Unit.maxAbsVelocity, Unit.maxAbsVelocity) * Unit.velocityPercision));
|
||||
buffer.put((byte) (Mathf.clamp(player.getVelocity().y, -Unit.maxAbsVelocity, Unit.maxAbsVelocity) * Unit.velocityPercision));
|
||||
@@ -204,6 +205,7 @@ public class Packets{
|
||||
pointerY = buffer.getFloat();
|
||||
boosting = buffer.get() == 1;
|
||||
shooting = buffer.get() == 1;
|
||||
alting = buffer.get() == 1;
|
||||
xv = buffer.get() / Unit.velocityPercision;
|
||||
yv = buffer.get() / Unit.velocityPercision;
|
||||
rotation = buffer.getShort() / 2f;
|
||||
|
||||
Reference in New Issue
Block a user