Skip to content

Commit

Permalink
swapped to use default comparision
Browse files Browse the repository at this point in the history
  • Loading branch information
dooly123 committed Jan 9, 2025
1 parent 57fbf5b commit 722f31c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using LiteNetLib.Utils;
public static partial class SerializableBasis
{
public class LocalAvatarSyncMessage
public struct LocalAvatarSyncMessage
{
public byte[] array;
public const int AvatarSyncSize = 202;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public static partial class SerializableBasis
{
public class PlayerMetaDataMessage
public struct PlayerMetaDataMessage
{
public string playerUUID;
public string playerDisplayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Serialize(NetDataWriter Writer)
}
}

public class VoiceReceiversMessage
public struct VoiceReceiversMessage
{
public ushort[] users;
public void Deserialize(NetDataReader Writer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Serialize(NetDataWriter Writer)
clientAvatarChangeMessage.Serialize(Writer);
}
}
public class ClientAvatarChangeMessage
public struct ClientAvatarChangeMessage
{
// Downloading - attempts to download from a URL, make sure a hash also exists.
// BuiltIn - loads as an addressable in Unity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public static class BasisSavedState
public static void RemovePlayer(NetPeer client)
{
int id = client.Id;
avatarSyncStates.SetPulse(id, null);
avatarChangeStates.SetPulse(id, null);
playerMetaDataMessages.SetPulse(id, null);
voiceReceiversMessages.SetPulse(id, null);
avatarSyncStates.SetPulse(id, default);
avatarChangeStates.SetPulse(id, default);
playerMetaDataMessages.SetPulse(id, default);
voiceReceiversMessages.SetPulse(id, default);
}

/// <summary>
Expand Down Expand Up @@ -67,7 +67,7 @@ public static void AddLastData(NetPeer client, ClientAvatarChangeMessage avatarC
public static bool GetLastAvatarSyncState(NetPeer client, out LocalAvatarSyncMessage message)
{
message = avatarSyncStates.GetPulse(client.Id);
return message != null;
return !message.Equals(default);
}

/// <summary>
Expand All @@ -76,7 +76,7 @@ public static bool GetLastAvatarSyncState(NetPeer client, out LocalAvatarSyncMes
public static bool GetLastAvatarChangeState(NetPeer client, out ClientAvatarChangeMessage message)
{
message = avatarChangeStates.GetPulse(client.Id);
return message != null;
return !message.Equals(default);
}

/// <summary>
Expand All @@ -85,7 +85,7 @@ public static bool GetLastAvatarChangeState(NetPeer client, out ClientAvatarChan
public static bool GetLastPlayerMetaData(NetPeer client, out PlayerMetaDataMessage message)
{
message = playerMetaDataMessages.GetPulse(client.Id);
return message != null;
return !message.Equals(default);
}

/// <summary>
Expand All @@ -94,12 +94,12 @@ public static bool GetLastPlayerMetaData(NetPeer client, out PlayerMetaDataMessa
public static bool GetLastVoiceReceivers(NetPeer client, out VoiceReceiversMessage message)
{
message = voiceReceiversMessages.GetPulse(client.Id);
return message != null;
return !message.Equals(default);
}
}

// Generic implementation of ChunkedSyncedToPlayerPulseArray
public class ChunkedSyncedToPlayerPulseArray<T> where T : class
public class ChunkedSyncedToPlayerPulseArray<T> where T : struct
{
private readonly object[] _chunkLocks;
private readonly T[][] _chunks;
Expand Down

0 comments on commit 722f31c

Please sign in to comment.