Fix all of the nullable issues
This commit is contained in:
1 parent
9d97ad0975
commit
30feb15821
13 files changed
+58
-53
No files matched your search
@@ -46,10 +46,10 @@ namespace Mistox {
|
||||
return writer.WrittenSpan.ToArray();
|
||||
}
|
||||
|
||||
public static object Deserialize( DataPacketHeader Header, ReadOnlyMemory<byte> Data ) {
|
||||
public static object? Deserialize( DataPacketHeader Header, ReadOnlyMemory<byte> Data ) {
|
||||
|
||||
// Get the type from the tag
|
||||
if (!NetworkPacketDictionary.PacketLookupTable.TryGetValue(Header.Type, out Type resolvedType)) {
|
||||
if (!NetworkPacketDictionary.PacketLookupTable.TryGetValue(Header.Type, out Type? resolvedType)) {
|
||||
throw new Exception($"Unknown packet type ID: {Header.Type}");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Mistox.Attributes {
|
||||
foreach (Assembly assembly in assemblies) {
|
||||
Type[] allClasses = assembly.GetTypes();
|
||||
foreach( Type cur in allClasses) {
|
||||
mPacket attribute = cur.GetCustomAttribute<mPacket>(false);
|
||||
mPacket? attribute = cur.GetCustomAttribute<mPacket>(false);
|
||||
if (attribute != null) {
|
||||
|
||||
// Generate a deterministic 16-bit ID based on the Type's FullName
|
||||
|
||||
@@ -25,31 +25,31 @@ namespace Mistox.ResevedPackets {
|
||||
|
||||
// Tag to make sure the object on the other side is the same object i want to update here
|
||||
// Need to map these Object ID's to a dictionary to make sure I only send network updates when there is a change
|
||||
public ushort ObjectId { get; set; }
|
||||
public ushort ObjectId { get; set; } = 0;
|
||||
|
||||
// Packet payload data that im matching for in the dictionary
|
||||
public byte[] InnerPayload { get; set; }
|
||||
public byte[] InnerPayload { get; set; } = {};
|
||||
}
|
||||
|
||||
public class UserTableObject {
|
||||
public string UserName { get; set; }
|
||||
public IPAddress IpAddress { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public IPAddress IpAddress { get; set; } = new([]);
|
||||
public Vector3 Position { get; set; } = new();
|
||||
}
|
||||
|
||||
// Not implemented
|
||||
// Packet sent to all clients when a global position update occurrs
|
||||
[mPacket]
|
||||
public class HeartbeatPacket {
|
||||
public Vector3 Position { get; set; }
|
||||
public List<UserTableObject> ServerList { get; set; }
|
||||
public Vector3 Position { get; set; } = new();
|
||||
public List<UserTableObject> ServerList { get; set; } = new();
|
||||
}
|
||||
|
||||
// Not implimented
|
||||
// Packet sent to all clients when a users TCP stream disconnects from the server
|
||||
[mPacket]
|
||||
public class UserDisconnectedPacket {
|
||||
public string UserName { get; set; }
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user