diff --git a/ClientMsg.cs.meta b/ClientMsg.cs.meta new file mode 100644 index 0000000..a491f9d --- /dev/null +++ b/ClientMsg.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f73ac1131d4d7bd4a8f5b62500069867 \ No newline at end of file diff --git a/DoxyGen/DoxyWarnLogfile.txt.meta b/ControlCore.csproj.meta similarity index 62% rename from DoxyGen/DoxyWarnLogfile.txt.meta rename to ControlCore.csproj.meta index 5134f07..1b43085 100644 --- a/DoxyGen/DoxyWarnLogfile.txt.meta +++ b/ControlCore.csproj.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 7dcc9ff4cd6aac7448a2772858e1a501 -TextScriptImporter: +guid: 7f964f406734cf74097d61697e5cafc9 +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/LinearAlgebra/Angle.cs b/LinearAlgebra/Angle.cs index 6b65a0b..71c44a6 100644 --- a/LinearAlgebra/Angle.cs +++ b/LinearAlgebra/Angle.cs @@ -1,3 +1,5 @@ +using System; + class Angle { public static float Rad2Deg = 360.0f / ((float)Math.PI * 2); diff --git a/LinearAlgebra/Angle.cs.meta b/LinearAlgebra/Angle.cs.meta new file mode 100644 index 0000000..2b65666 --- /dev/null +++ b/LinearAlgebra/Angle.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ee99a6777ed47f743be8068c6ede98c8 \ No newline at end of file diff --git a/LinearAlgebra/Quat32.cs b/LinearAlgebra/Quat32.cs index 9680eb0..b839b0e 100644 --- a/LinearAlgebra/Quat32.cs +++ b/LinearAlgebra/Quat32.cs @@ -1,3 +1,5 @@ +using System; + namespace Passer.LinearAlgebra { public class Quat32 diff --git a/ModelUrlMsg.cs b/ModelUrlMsg.cs index aae6301..a3c02ba 100644 --- a/ModelUrlMsg.cs +++ b/ModelUrlMsg.cs @@ -1,3 +1,5 @@ +#nullable enable + namespace Passer.Control.Core { public class ModelUrlMsg : IMessage { @@ -27,12 +29,15 @@ namespace Passer.Control.Core { } public override byte Serialize(ref byte[] buffer) { + if (this.url == null) + return 0; + byte ix = 0; buffer[ix++] = ModelUrlMsg.Id; buffer[ix++] = this.networkId; buffer[ix++] = this.thingId; // Thing Id - buffer[ix++] = (byte)url.Length; + buffer[ix++] = (byte)this.url.Length; for (int urlIx = 0; urlIx < this.url.Length; urlIx++) buffer[ix++] = (byte)url[urlIx]; return ix; diff --git a/ModelUrlMsg.cs.meta b/ModelUrlMsg.cs.meta new file mode 100644 index 0000000..7f9b6b8 --- /dev/null +++ b/ModelUrlMsg.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 711bdb0248c9f6848a6b4da15cc05db5 \ No newline at end of file diff --git a/NameMsg.cs b/NameMsg.cs index 04802aa..3d99f18 100644 --- a/NameMsg.cs +++ b/NameMsg.cs @@ -1,3 +1,5 @@ +#nullable enable + namespace Passer.Control.Core { public class NameMsg : IMessage { @@ -27,14 +29,15 @@ namespace Passer.Control.Core { } public override byte Serialize(ref byte[] buffer) { + if (this.name == null) + return 0; + byte ix = 0; buffer[ix++] = NameMsg.Id; buffer[ix++] = this.networkId; buffer[ix++] = this.thingId; - int nameLength = 0; - if (this.name != null) - nameLength = this.name.Length; + int nameLength = this.name.Length; buffer[ix++] = (byte)nameLength; for (int nameIx = 0; nameIx < nameLength; nameIx++) diff --git a/NameMsg.cs.meta b/NameMsg.cs.meta new file mode 100644 index 0000000..1c4a0f5 --- /dev/null +++ b/NameMsg.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 462c645008baabe46b81f5d0ab83e26e \ No newline at end of file diff --git a/NetworkIdMsg.cs.meta b/NetworkIdMsg.cs.meta new file mode 100644 index 0000000..afedff4 --- /dev/null +++ b/NetworkIdMsg.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c51dae79b8c6f5a428349e1f4d34982c \ No newline at end of file diff --git a/Participant.cs b/Participant.cs index ae99883..cb78ec6 100644 --- a/Participant.cs +++ b/Participant.cs @@ -1,9 +1,10 @@ +#nullable enable + +using System; using System.Collections.Generic; using System.Collections.Concurrent; using System.Net; using System.Net.Sockets; -using System.IO; -using System.Threading.Tasks; namespace Passer.Control.Core { @@ -75,7 +76,7 @@ namespace Passer.Control.Core { byte[] data = udpClient.EndReceive(result, ref this.endPoint); // This does not yet take multi-packet messages into account! - Participant remoteParticipant = this.GetParticipant(endPoint.Address.ToString(), endPoint.Port); + Participant? remoteParticipant = this.GetParticipant(endPoint.Address.ToString(), endPoint.Port); if (remoteParticipant == null) { remoteParticipant = this.AddParticipant(endPoint.Address.ToString(), endPoint.Port); } diff --git a/SiteServer.cs b/SiteServer.cs index d4d4e19..4dde48e 100644 --- a/SiteServer.cs +++ b/SiteServer.cs @@ -1,3 +1,4 @@ +using System; using System.Net; using System.Net.Sockets; diff --git a/ThingMsg.cs.meta b/ThingMsg.cs.meta new file mode 100644 index 0000000..0c7dce0 --- /dev/null +++ b/ThingMsg.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 718e148be3eeb65498334ed008747482 \ No newline at end of file diff --git a/float16.cs b/float16.cs index 579cb97..b934651 100644 --- a/float16.cs +++ b/float16.cs @@ -1,3 +1,5 @@ +using System; + namespace Passer.LinearAlgebra { @@ -261,9 +263,10 @@ namespace Passer.LinearAlgebra exp <<= 10; man++; man >>= 1; + ushort uexp = (ushort)exp; if (sgn) - return (ushort)(0x8000 | exp | man); - return (ushort)(exp | man); + return (ushort)(0x8000 | uexp | man); + return (ushort)(uexp | man); } // -- END OF FILE -- diff --git a/float16.cs.meta b/float16.cs.meta new file mode 100644 index 0000000..a22c5ad --- /dev/null +++ b/float16.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 620fef383ba64a44995a234a71b2f189 \ No newline at end of file diff --git a/test.meta b/test.meta new file mode 100644 index 0000000..89fd01d --- /dev/null +++ b/test.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 239400f5314a5aa4bac98db5861f77a7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/test.sln.meta b/test.sln.meta new file mode 100644 index 0000000..606fb16 --- /dev/null +++ b/test.sln.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d5d87461365fd8a4da528aa84a49e62c +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/test/UnitTest1.cs b/test/UnitTest1.cs index 1051a4f..d41d268 100644 --- a/test/UnitTest1.cs +++ b/test/UnitTest1.cs @@ -1,84 +1,85 @@ -using System; +using System; +using System.Threading; using NUnit.Framework; using Passer.Control.Core; -namespace ControlCore.test; - -public class Tests { - [SetUp] - public void Setup() { - } - - [Test] - public void Test_Participant() { - Participant participant = new("127.0.0.1", 7681); - - long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - long startTime = milliseconds; - while (milliseconds < startTime + 7000) { - participant.Update(milliseconds); - - Thread.Sleep(100); - milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); +namespace ControlCore.test { + public class Tests { + [SetUp] + public void Setup() { } - Assert.Pass(); - } + [Test] + public void Test_Participant() { + Participant participant = new("127.0.0.1", 7681); - [Test] - public void Test_SiteServer() { - SiteServer siteServer = new(7681); + long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + long startTime = milliseconds; + while (milliseconds < startTime + 7000) { + participant.Update(milliseconds); - long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - long startTime = milliseconds; - while (milliseconds < startTime + 7000) { - siteServer.Update(milliseconds); + Thread.Sleep(100); + milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + } - Thread.Sleep(100); - milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + Assert.Pass(); } - Assert.Pass(); - } + [Test] + public void Test_SiteServer() { + SiteServer siteServer = new(7681); - [Test] - public void Test_SiteParticipant() { - SiteServer siteServer = new(7681); - Participant participant = new("127.0.0.1", 7681); + long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + long startTime = milliseconds; + while (milliseconds < startTime + 7000) { + siteServer.Update(milliseconds); - long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - long startTime = milliseconds; - while (milliseconds < startTime + 1000) { - siteServer.Update(milliseconds); - participant.Update(milliseconds); + Thread.Sleep(100); + milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + } - Thread.Sleep(100); - milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + Assert.Pass(); } - Assert.That(participant.networkId, Is.EqualTo(1)); - } + [Test] + public void Test_SiteParticipant() { + SiteServer siteServer = new(7681); + Participant participant = new("127.0.0.1", 7681); - [Test] - public void Test_ThingMsg() { - SiteServer siteServer = new(); - Participant participant = new("127.0.0.1"); - Thing thing = new() { - name = "First Thing", - modelUrl = "https://passer.life/extras/ant.jpg" - }; + long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + long startTime = milliseconds; + while (milliseconds < startTime + 1000) { + siteServer.Update(milliseconds); + participant.Update(milliseconds); - long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - long startTime = milliseconds; - while (milliseconds < startTime + 7000) { - siteServer.Update(milliseconds); - participant.Update(milliseconds); + Thread.Sleep(100); + milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + } - Thread.Sleep(100); - milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + Assert.That(participant.networkId, Is.EqualTo(1)); } - Assert.That(participant.networkId, Is.EqualTo(1)); + [Test] + public void Test_ThingMsg() { + SiteServer siteServer = new(); + Participant participant = new("127.0.0.1"); + Thing thing = new() { + name = "First Thing", + modelUrl = "https://passer.life/extras/ant.jpg" + }; + + long milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + long startTime = milliseconds; + while (milliseconds < startTime + 7000) { + siteServer.Update(milliseconds); + participant.Update(milliseconds); + + Thread.Sleep(100); + milliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + } + + Assert.That(participant.networkId, Is.EqualTo(1)); + } } } diff --git a/test/UnitTest1.cs.meta b/test/UnitTest1.cs.meta new file mode 100644 index 0000000..8ee19d8 --- /dev/null +++ b/test/UnitTest1.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 743b128a79ef8414fa29d7bb3b9e2ac8 \ No newline at end of file diff --git a/test/test.csproj.meta b/test/test.csproj.meta new file mode 100644 index 0000000..1040180 --- /dev/null +++ b/test/test.csproj.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 92729868a8379c04197dcb80d0276a63 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: