From 1c5996eccae520c46e2a2e3919875d57c802bceb Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 28 Sep 2017 22:07:26 +0100 Subject: [PATCH] [server] Add UniqueLineId to DrawnLine & use NCuid for id generation. Also remove ChunkReference.Parse, as we're using JSON now Next ContinuesIn/From need to be updated to use the new property. --- Nibriboard/Nibriboard.csproj | 3 +++ Nibriboard/RippleSpace/ChunkReference.cs | 18 ------------------ Nibriboard/RippleSpace/DrawnLine.cs | 9 ++++++++- Nibriboard/packages.config | 1 + 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Nibriboard/Nibriboard.csproj b/Nibriboard/Nibriboard.csproj index 5257af8..d4415cc 100644 --- a/Nibriboard/Nibriboard.csproj +++ b/Nibriboard/Nibriboard.csproj @@ -56,6 +56,9 @@ ..\packages\SharpCompress.0.18.2\lib\net45\SharpCompress.dll + + ..\packages\NCuid.1.0.0\lib\net40\NCuid.dll + diff --git a/Nibriboard/RippleSpace/ChunkReference.cs b/Nibriboard/RippleSpace/ChunkReference.cs index 0d8080a..5a38596 100644 --- a/Nibriboard/RippleSpace/ChunkReference.cs +++ b/Nibriboard/RippleSpace/ChunkReference.cs @@ -82,24 +82,6 @@ namespace Nibriboard.RippleSpace return $"ChunkReference: {base.ToString()}"; } - public static ChunkReference Parse(Plane plane, string source) - { - if (!source.StartsWith("ChunkReference:")) - throw new InvalidDataException($"Error: That isn't a valid chunk reference. Chunk references start with 'ChunkReference:'."); - - // Trim the extras off the reference - source = source.Substring("ChunkReference:".Length); - source = source.Trim("() \v\t\r\n".ToCharArray()); - - int x = int.Parse(source.Substring(0, source.IndexOf(","))); - int y = int.Parse(source.Substring(source.IndexOf(",") + 1)); - return new ChunkReference( - plane, - x, - y - ); - } - /// /// Returns a clone of this ChunkReference. /// diff --git a/Nibriboard/RippleSpace/DrawnLine.cs b/Nibriboard/RippleSpace/DrawnLine.cs index 9548455..7e1d662 100644 --- a/Nibriboard/RippleSpace/DrawnLine.cs +++ b/Nibriboard/RippleSpace/DrawnLine.cs @@ -14,7 +14,14 @@ namespace Nibriboard.RippleSpace public class DrawnLine { /// - /// The id of line that this is part of. + /// This line (fragment?)'s unique id. Should be globally unique - please blow up + /// if it isn't! + /// + [JsonProperty] + public readonly string UniqueId = NCuid.Cuid.Generate(); + + /// + /// The id of line that this is part of. /// Note that this id may not be unique - several lines that were all /// drawn at once may also have the same id. This is such that a single /// line that was split across multiple chunks can still be referenced and diff --git a/Nibriboard/packages.config b/Nibriboard/packages.config index 2a1187a..fb581fa 100644 --- a/Nibriboard/packages.config +++ b/Nibriboard/packages.config @@ -1,6 +1,7 @@  + \ No newline at end of file