Skip to content

Commit

Permalink
experimental changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dooly123 committed Dec 28, 2024
1 parent c11d148 commit 03b32f0
Show file tree
Hide file tree
Showing 87 changed files with 3,017 additions and 463 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Basis Server/.vs/BasisNetworkServer/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified Basis Server/.vs/BasisNetworkServer/v17/.futdcache.v2
Binary file not shown.
251 changes: 216 additions & 35 deletions Basis Server/.vs/BasisNetworkServer/v17/DocumentLayout.backup.json

Large diffs are not rendered by default.

252 changes: 217 additions & 35 deletions Basis Server/.vs/BasisNetworkServer/v17/DocumentLayout.json

Large diffs are not rendered by default.

Binary file modified Basis Server/.vs/BasisNetworkServer/v17/HierarchyCache.v1.txt
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LiteNetLib.Utils;
using LiteNetLib.Utils;
namespace Basis.Network.Core.Serializable
{
public static partial class SerializableBasis
Expand Down Expand Up @@ -39,4 +39,4 @@ public void Serialize(NetDataWriter Writer)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ public static partial class SerializableBasis
public struct LocalAvatarSyncMessage
{
public byte[] array;
public const int AvatarSyncSize = 202;
public const int StoredBones = 89;
public void Deserialize(NetDataReader Writer)
{
int Bytes = Writer.AvailableBytes;
if (Bytes >= 386)
if (Bytes >= AvatarSyncSize)
{
if (array == null)
{
array = new byte[386];
}
Writer.GetBytes(array, 386);//360 for muscles, 3*4 for position 12, 4*4 for rotation 16-2
array ??= new byte[AvatarSyncSize];
Writer.GetBytes(array, AvatarSyncSize);
//89 * 2 = 178 + 12 + 14 = 204
//now 178 for muscles, 3*4 for position 12, 4*4 for rotation 16-2 (W is half) = 204
}
else
{
Expand All @@ -27,11 +28,9 @@ public void Dispose()

public void Serialize(NetDataWriter Writer)
{
if (array == null || array.Length != 386)
if (array == null)
{
BNL.LogError("Missing Array in Local Player Data!!");
array = new byte[386];
Writer.Put(array);
BNL.LogError("array was null!!");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LiteNetLib.Utils;
using LiteNetLib.Utils;
using static SerializableBasis;

namespace DarkRift.Basis_Common.Serializable
Expand Down
28 changes: 24 additions & 4 deletions Basis Server/BasisNetworkCore/Serializable/PlayerIdMessage.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
using DarkRift;
using LiteNetLib.Utils;

public static partial class SerializableBasis
{
public struct PlayerIdMessage
{
public ushort playerID;
private ushort data; // Encodes both playerID and additional data.

/// <summary>
/// 0 to 1023
/// </summary>
public ushort playerID// (0-1023)
{
get => (ushort)(data & 0x03FF); // Extract the lower 10 bits for PlayerID
set => data = (ushort)((data & 0xFC00) | (value & 0x03FF)); // Set PlayerID while preserving upper 6 bits
}

/// <summary>
/// 0 to 63
/// </summary>
public byte AdditionalData// (0–63)
{
get => (byte)((data >> 10) & 0x3F); // Extract the upper 6 bits for AdditionalData
set => data = (ushort)((data & 0x03FF) | ((value & 0x3F) << 10)); // Set AdditionalData while preserving lower 10 bits
}

public void Deserialize(NetDataReader Writer)
{
Writer.Get(out playerID);
Writer.Get(out data); // Read the entire ushort value
}

public void Dispose()
{
// No resources to dispose in this structure
}

public void Serialize(NetDataWriter Writer)
{
Writer.Put(playerID);
Writer.Put(data); // Write the entire ushort value
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LiteNetLib.Utils;
using LiteNetLib.Utils;
public static partial class SerializableBasis
{
public struct ServerSideSyncPlayerMessage
Expand Down Expand Up @@ -26,4 +26,4 @@ public void Serialize(NetDataWriter Writer)
avatarSerialization.Serialize(Writer);
}
}
}
}
2 changes: 1 addition & 1 deletion Basis Server/BasisNetworkServer/BasisNetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private static void SendClientListToNewClient(NetPeer authClient)
serverReadyMessage.playerIdMessage = new PlayerIdMessage { playerID = (ushort)client.Id };
serverReadyMessage.localReadyMessage = new ReadyMessage
{
localAvatarSyncMessage = new LocalAvatarSyncMessage() { array = new byte[386] },
localAvatarSyncMessage = new LocalAvatarSyncMessage() { array = new byte[LocalAvatarSyncMessage.AvatarSyncSize] },
clientAvatarChangeMessage = new ClientAvatarChangeMessage() { byteArray = new byte[] { }, },
playerMetaDataMessage = new PlayerMetaDataMessage() { playerDisplayName = "Error", playerUUID = string.Empty },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public static void HandleScene(NetPacketReader Reader, DeliveryMethod DeliveryMe
SceneDataMessage.Deserialize(Reader);
ServerSceneDataMessage serverSceneDataMessage = new ServerSceneDataMessage
{
sceneDataMessage = new RemoteSceneDataMessage() { messageIndex = SceneDataMessage.messageIndex, payload = SceneDataMessage.payload },
sceneDataMessage = new RemoteSceneDataMessage()
{
messageIndex = SceneDataMessage.messageIndex,
payload = SceneDataMessage.payload
},
playerIdMessage = new PlayerIdMessage
{
playerID = (ushort)sender.Id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Concurrent;
using Basis.Network.Core;
using Basis.Network.Core.Compression;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Basis Server/BasisServerConsole/bin/Debug/net9.0/LiteNetLib.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Basis Server/LiteNetLib/LiteNetLib.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>LiteNetLib</AssemblyName>
Expand Down Expand Up @@ -37,7 +37,7 @@
<Authors>Ruslan Pyrch</Authors>
<Copyright>Copyright 2024 Ruslan Pyrch</Copyright>
<Description>Lite reliable UDP library for .NET, Mono, and .NET Core</Description>
<TargetFrameworks>net9.0;net471</TargetFrameworks>
<TargetFrameworks>net9.0;netstandard2.1</TargetFrameworks>
</PropertyGroup>

</Project>
Binary file modified Basis Server/LiteNetLib/bin/Debug/LiteNetLib.1.3.1.nupkg
Binary file not shown.
Binary file modified Basis Server/LiteNetLib/bin/Debug/net471/LiteNetLib.dll
Binary file not shown.
Binary file modified Basis Server/LiteNetLib/bin/Debug/net9.0/LiteNetLib.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Basis/.vs/Basis.Player.csproj.dtbcache.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basis/.vs/Basis.csproj.dtbcache.json

Large diffs are not rendered by default.

Loading

0 comments on commit 03b32f0

Please sign in to comment.