You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 14:46:29 +09:00
Re-added ReadTime()
This commit is contained in:
@@ -601,6 +601,20 @@ namespace Lidgren.Network
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value, in local time comparable to NetTime.Now, written using WriteTime() for the connection supplied
|
||||
/// </summary>
|
||||
public double ReadTime(NetConnection connection, bool highPrecision)
|
||||
{
|
||||
double remoteTime = (highPrecision ? ReadDouble() : (double)ReadSingle());
|
||||
|
||||
if (connection == null)
|
||||
throw new NetException("Cannot call ReadTime() on message without a connected sender (ie. unconnected messages)");
|
||||
|
||||
// lets bypass NetConnection.GetLocalTime for speed
|
||||
return remoteTime - connection.m_remoteTimeOffset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a stored IPv4 endpoint description
|
||||
/// </summary>
|
||||
|
||||
@@ -547,7 +547,19 @@ namespace Lidgren.Network
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the local time to a message; readable (and convertable to local time) by the remote host using ReadTime()
|
||||
/// Writes the current local time to a message; readable (and convertable to local time) by the remote host using ReadTime()
|
||||
/// </summary>
|
||||
public void WriteTime(bool highPrecision)
|
||||
{
|
||||
double localTime = NetTime.Now;
|
||||
if (highPrecision)
|
||||
Write(localTime);
|
||||
else
|
||||
Write((float)localTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a local timestamp to a message; readable (and convertable to local time) by the remote host using ReadTime()
|
||||
/// </summary>
|
||||
public void WriteTime(double localTime, bool highPrecision)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetBuffer
|
||||
{
|
||||
// @TODO Add ReadTime() to incomingmessage class
|
||||
private const int c_overAllocateAmount = 4;
|
||||
|
||||
private static readonly Dictionary<Type, MethodInfo> s_readMethods;
|
||||
|
||||
@@ -95,6 +95,15 @@ namespace Lidgren.Network
|
||||
return encryption.Decrypt(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value, in local time comparable to NetTime.Now, written using WriteTime()
|
||||
/// Must have a connected sender
|
||||
/// </summary>
|
||||
public double ReadTime(bool highPrecision)
|
||||
{
|
||||
return ReadTime(m_senderConnection, highPrecision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents this object
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user