Sync based on system time
This commit is contained in:
@@ -35,8 +35,8 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class NetServer implements ApplicationListener{
|
public class NetServer implements ApplicationListener{
|
||||||
/** note that snapshots are compressed, so the max snapshot size here is above the typical UDP safe limit */
|
/** note that snapshots are compressed, so the max snapshot size here is above the typical UDP safe limit */
|
||||||
private static final int maxSnapshotSize = 800, timerBlockSync = 0;
|
private static final int maxSnapshotSize = 800, timerBlockSync = 0, serverSyncTime = 200;
|
||||||
private static final float serverSyncTime = 12, blockSyncTime = 60 * 6;
|
private static final float blockSyncTime = 60 * 6;
|
||||||
private static final FloatBuffer fbuffer = FloatBuffer.allocate(20);
|
private static final FloatBuffer fbuffer = FloatBuffer.allocate(20);
|
||||||
private static final Vec2 vector = new Vec2();
|
private static final Vec2 vector = new Vec2();
|
||||||
private static final Rect viewport = new Rect();
|
private static final Rect viewport = new Rect();
|
||||||
@@ -967,9 +967,11 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetConnection connection = player.con;
|
var connection = player.con;
|
||||||
|
|
||||||
if(!player.timer(0, serverSyncTime) || !connection.hasConnected) return;
|
if(Time.timeSinceMillis(connection.syncTime) < serverSyncTime || !connection.hasConnected) return;
|
||||||
|
|
||||||
|
connection.syncTime = Time.millis();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
writeEntitySnapshot(player);
|
writeEntitySnapshot(player);
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
pay.payloads().peek() instanceof BuildPayload p2 ? p2.block() : null) : null;
|
pay.payloads().peek() instanceof BuildPayload p2 ? p2.block() : null) : null;
|
||||||
default -> noSensed;
|
default -> noSensed;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public abstract class NetConnection{
|
|||||||
public boolean mobile, modclient;
|
public boolean mobile, modclient;
|
||||||
public @Nullable Player player;
|
public @Nullable Player player;
|
||||||
public boolean kicked = false;
|
public boolean kicked = false;
|
||||||
|
public long syncTime;
|
||||||
|
|
||||||
/** When this connection was established. */
|
/** When this connection was established. */
|
||||||
public long connectTime = Time.millis();
|
public long connectTime = Time.millis();
|
||||||
|
|||||||
Reference in New Issue
Block a user