diff --git a/Assets/Scripts/Networking/Clientside/SyncHandler.cs b/Assets/Scripts/Networking/Clientside/SyncHandler.cs
index c5775e9..8c87d54 100644
--- a/Assets/Scripts/Networking/Clientside/SyncHandler.cs
+++ b/Assets/Scripts/Networking/Clientside/SyncHandler.cs
@@ -14,6 +14,8 @@ namespace Cyber.Networking.Clientside {
///
public class SyncHandler {
+ public static double LastTimestamp = NetworkHelper.GetCurrentSystemTime();
+
private SyncDB SyncDB;
private int LatestSyncID = -1;
@@ -47,7 +49,11 @@ namespace Cyber.Networking.Clientside {
}
}
- Client.Send(PktType.FailedChecksums, new IntListPkt(FailedSyncBases.ToArray()));
+ if (FailedSyncBases.Count > 0) {
+ Client.Send(PktType.FailedChecksums, new IntListPkt(FailedSyncBases.ToArray()));
+ }
+
+ LastTimestamp = SyncPacket.Timestamp;
}
}
// Otherwise disregard the sync.
diff --git a/Assets/Scripts/Networking/Messages/MoveCreaturePkt.cs b/Assets/Scripts/Networking/Messages/MoveCreaturePkt.cs
index 92298bd..cc17820 100644
--- a/Assets/Scripts/Networking/Messages/MoveCreaturePkt.cs
+++ b/Assets/Scripts/Networking/Messages/MoveCreaturePkt.cs
@@ -19,11 +19,6 @@ namespace Cyber.Networking.Messages {
///
public int SyncBaseID;
- ///
- /// Time when server received this request. Used for compensating ping.
- ///
- public double Timestamp;
-
///
/// Creates a MoveCreaturePkt which contains the direction of desired movement (or (0, 0, 0) for stopping)
///
@@ -48,7 +43,6 @@ namespace Cyber.Networking.Messages {
public override void Deserialize(NetworkReader reader) {
Direction = reader.ReadVector3();
SyncBaseID = reader.ReadInt32();
- Timestamp = reader.ReadDouble();
}
///
@@ -58,7 +52,6 @@ namespace Cyber.Networking.Messages {
public override void Serialize(NetworkWriter writer) {
writer.Write(Direction);
writer.Write(SyncBaseID);
- writer.Write(Timestamp);
}
}
diff --git a/Assets/Scripts/Networking/Messages/SyncPkt.cs b/Assets/Scripts/Networking/Messages/SyncPkt.cs
index 55c05a3..46c3b33 100644
--- a/Assets/Scripts/Networking/Messages/SyncPkt.cs
+++ b/Assets/Scripts/Networking/Messages/SyncPkt.cs
@@ -10,6 +10,11 @@ namespace Cyber.Networking.Messages {
///
public class SyncPkt : MessageBase {
+ ///
+ /// Timestamp of the sync packet when sent from the server.
+ ///
+ public double Timestamp;
+
///
/// The Sync Packet ID of this packet.
///
@@ -40,12 +45,13 @@ namespace Cyber.Networking.Messages {
///
///
/// ID of the sync packet itself.
- public SyncPkt(SyncDB syncDB, int[] syncBases, int[] checksummedSyncBases, int[] checksums, int syncPacketID) {
+ public SyncPkt(SyncDB syncDB, int[] syncBases, int[] checksummedSyncBases, int[] checksums, int syncPacketID, double timestamp) {
SyncPacketID = syncPacketID;
SyncDB = syncDB;
SyncedSyncBases = syncBases;
ChecksummedSyncBases = checksummedSyncBases;
Checksums = checksums;
+ timestamp = Timestamp;
}
///
diff --git a/Assets/Scripts/Networking/Serverside/Server.cs b/Assets/Scripts/Networking/Serverside/Server.cs
index 844ddea..81d0b55 100644
--- a/Assets/Scripts/Networking/Serverside/Server.cs
+++ b/Assets/Scripts/Networking/Serverside/Server.cs
@@ -200,7 +200,6 @@ namespace Cyber.Networking.Serverside {
if (Player.Value.Connection.connectionId == msg.conn.connectionId) {
continue;
}
- MoveCreature.Timestamp = NetworkHelper.GetCurrentSystemTime();
NetworkServer.SendToClient(Player.Value.Connection.connectionId, PktType.MoveCreature, MoveCreature);
}
break;
diff --git a/Assets/Scripts/Networking/Serverside/ServerSyncer.cs b/Assets/Scripts/Networking/Serverside/ServerSyncer.cs
index 77f3e96..4a35393 100644
--- a/Assets/Scripts/Networking/Serverside/ServerSyncer.cs
+++ b/Assets/Scripts/Networking/Serverside/ServerSyncer.cs
@@ -62,7 +62,8 @@ namespace Cyber.Networking.Serverside {
if (QueuedSyncs.Count > 0) {
int[] SyncIDs = QueuedSyncs.ToArray();
- SyncPkt SyncPacket = new SyncPkt(Database, SyncIDs, checksummedIds.ToArray(), checksums.ToArray(), NextSyncID());
+ SyncPkt SyncPacket = new SyncPkt(Database, SyncIDs, checksummedIds.ToArray(),
+ checksums.ToArray(), NextSyncID(), NetworkHelper.GetCurrentSystemTime());
Server.SendToAllByChannel(PktType.Sync, SyncPacket, NetworkChannelID.Unreliable);
QueuedSyncs.Clear();